src/video/uikit/SDL_uikitview.m
changeset 8460 f483e8bdae3c
parent 8439 14d94a8a9fb6
parent 7050 aa1f44908402
child 8477 ad08f0d710f3
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Sat Apr 13 23:03:46 2013 -0400
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Sun Apr 14 11:42:55 2013 -0400
     1.3 @@ -52,23 +52,8 @@
     1.4  
     1.5      self.multipleTouchEnabled = YES;
     1.6  
     1.7 -    SDL_Touch touch;
     1.8 -    touch.id = 0; //TODO: Should be -1?
     1.9 -
    1.10 -    //touch.driverdata = SDL_malloc(sizeof(EventTouchData));
    1.11 -    //EventTouchData* data = (EventTouchData*)(touch.driverdata);
    1.12 -
    1.13 -    touch.x_min = 0;
    1.14 -    touch.x_max = 1;
    1.15 -    touch.native_xres = touch.x_max - touch.x_min;
    1.16 -    touch.y_min = 0;
    1.17 -    touch.y_max = 1;
    1.18 -    touch.native_yres = touch.y_max - touch.y_min;
    1.19 -    touch.pressure_min = 0;
    1.20 -    touch.pressure_max = 1;
    1.21 -    touch.native_pressureres = touch.pressure_max - touch.pressure_min;
    1.22 -
    1.23 -    touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
    1.24 +    touchId = 1;
    1.25 +    SDL_AddTouch(touchId, "");
    1.26  
    1.27      return self;
    1.28  
    1.29 @@ -104,12 +89,12 @@
    1.30              CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.31  
    1.32              /* send moved event */
    1.33 -            SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.34 +            SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
    1.35  
    1.36              /* send mouse down event */
    1.37 -            SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.38 +            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.39  
    1.40 -            leftFingerDown = (SDL_FingerID)touch;
    1.41 +            leftFingerDown = touch;
    1.42          }
    1.43  
    1.44          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.45 @@ -117,17 +102,15 @@
    1.46          // FIXME: TODO: Using touch as the fingerId is potentially dangerous
    1.47          // It is also much more efficient than storing the UITouch pointer
    1.48          // and comparing it to the incoming event.
    1.49 -        SDL_SendFingerDown(touchId, (SDL_FingerID)touch,
    1.50 -                           SDL_TRUE, locationInView.x, locationInView.y,
    1.51 -                           1);
    1.52 +        SDL_SendTouch(touchId, (SDL_FingerID)((size_t)touch),
    1.53 +                      SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
    1.54  #else
    1.55          int i;
    1.56          for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
    1.57              if (finger[i] == NULL) {
    1.58                  finger[i] = touch;
    1.59 -                SDL_SendFingerDown(touchId, i,
    1.60 -                                   SDL_TRUE, locationInView.x, locationInView.y,
    1.61 -                                   1);
    1.62 +                SDL_SendTouch(touchId, i,
    1.63 +                              SDL_TRUE, locationInView.x, locationInView.y, 1.0f);
    1.64                  break;
    1.65              }
    1.66          }
    1.67 @@ -142,24 +125,22 @@
    1.68      UITouch *touch = (UITouch*)[enumerator nextObject];
    1.69  
    1.70      while(touch) {
    1.71 -        if ((SDL_FingerID)touch == leftFingerDown) {
    1.72 +        if (touch == leftFingerDown) {
    1.73              /* send mouse up */
    1.74 -            SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.75 -            leftFingerDown = 0;
    1.76 +            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.77 +            leftFingerDown = nil;
    1.78          }
    1.79  
    1.80          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.81  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.82 -        SDL_SendFingerDown(touchId, (long)touch,
    1.83 -                           SDL_FALSE, locationInView.x, locationInView.y,
    1.84 -                           1);
    1.85 +        SDL_SendTouch(touchId, (long)touch,
    1.86 +                      SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
    1.87  #else
    1.88          int i;
    1.89          for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
    1.90              if (finger[i] == touch) {
    1.91 -                SDL_SendFingerDown(touchId, i,
    1.92 -                                   SDL_FALSE, locationInView.x, locationInView.y,
    1.93 -                                   1);
    1.94 +                SDL_SendTouch(touchId, i,
    1.95 +                              SDL_FALSE, locationInView.x, locationInView.y, 1.0f);
    1.96                  finger[i] = NULL;
    1.97                  break;
    1.98              }
    1.99 @@ -185,25 +166,23 @@
   1.100      UITouch *touch = (UITouch*)[enumerator nextObject];
   1.101  
   1.102      while (touch) {
   1.103 -        if ((SDL_FingerID)touch == leftFingerDown) {
   1.104 +        if (touch == leftFingerDown) {
   1.105              CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   1.106  
   1.107              /* send moved event */
   1.108 -            SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   1.109 +            SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, locationInView.x, locationInView.y);
   1.110          }
   1.111  
   1.112          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   1.113  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   1.114          SDL_SendTouchMotion(touchId, (long)touch,
   1.115 -                            SDL_FALSE, locationInView.x, locationInView.y,
   1.116 -                            1);
   1.117 +                            locationInView.x, locationInView.y, 1.0f);
   1.118  #else
   1.119          int i;
   1.120          for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) {
   1.121              if (finger[i] == touch) {
   1.122                  SDL_SendTouchMotion(touchId, i,
   1.123 -                                    SDL_FALSE, locationInView.x, locationInView.y,
   1.124 -                                    1);
   1.125 +                                    locationInView.x, locationInView.y, 1.0f);
   1.126                  break;
   1.127              }
   1.128          }