src/video/uikit/SDL_uikitview.m
changeset 8337 4a67a3cca43d
parent 8314 24f2de48557b
parent 6597 d359909f8121
child 8340 e470405f3ae9
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Sun Nov 04 09:02:58 2012 -0500
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Sun Nov 04 09:46:59 2012 -0500
     1.3 @@ -50,7 +50,6 @@
     1.4      [self initializeKeyboard];
     1.5  #endif
     1.6  
     1.7 -#ifdef FIXED_MULTITOUCH
     1.8      self.multipleTouchEnabled = YES;
     1.9  
    1.10      SDL_Touch touch;
    1.11 @@ -69,9 +68,7 @@
    1.12      touch.pressure_max = 1;
    1.13      touch.native_pressureres = touch.pressure_max - touch.pressure_min;
    1.14  
    1.15 -
    1.16      touchId = SDL_AddTouch(&touch, "IPHONE SCREEN");
    1.17 -#endif
    1.18  
    1.19      return self;
    1.20  
    1.21 @@ -102,25 +99,25 @@
    1.22      NSEnumerator *enumerator = [touches objectEnumerator];
    1.23      UITouch *touch = (UITouch*)[enumerator nextObject];
    1.24  
    1.25 -    if (touch) {
    1.26 -        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.27 +    while (touch) {
    1.28 +        if (!leftFingerDown) {
    1.29 +            CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.30  
    1.31 -        /* send moved event */
    1.32 -        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.33 +            /* send moved event */
    1.34 +            SDL_SendMouseMotion(NULL, 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 -    }
    1.39 +            /* send mouse down event */
    1.40 +            SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT);
    1.41  
    1.42 -#ifdef FIXED_MULTITOUCH
    1.43 -    while(touch) {
    1.44 +            leftFingerDown = (SDL_FingerID)touch;
    1.45 +        }
    1.46 +
    1.47          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.48 -
    1.49  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.50 -        //FIXME: TODO: Using touch as the fingerId is potentially dangerous
    1.51 -        //It is also much more efficient than storing the UITouch pointer
    1.52 -        //and comparing it to the incoming event.
    1.53 -        SDL_SendFingerDown(touchId, (long)touch,
    1.54 +        // FIXME: TODO: Using touch as the fingerId is potentially dangerous
    1.55 +        // It is also much more efficient than storing the UITouch pointer
    1.56 +        // and comparing it to the incoming event.
    1.57 +        SDL_SendFingerDown(touchId, (SDL_FingerID)touch,
    1.58                             SDL_TRUE, locationInView.x, locationInView.y,
    1.59                             1);
    1.60  #else
    1.61 @@ -135,10 +132,8 @@
    1.62              }
    1.63          }
    1.64  #endif
    1.65 -
    1.66          touch = (UITouch*)[enumerator nextObject];
    1.67      }
    1.68 -#endif
    1.69  }
    1.70  
    1.71  - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    1.72 @@ -146,15 +141,14 @@
    1.73      NSEnumerator *enumerator = [touches objectEnumerator];
    1.74      UITouch *touch = (UITouch*)[enumerator nextObject];
    1.75  
    1.76 -    if (touch) {
    1.77 -        /* send mouse up */
    1.78 -        SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.79 -    }
    1.80 +    while(touch) {
    1.81 +        if ((SDL_FingerID)touch == leftFingerDown) {
    1.82 +            /* send mouse up */
    1.83 +            SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT);
    1.84 +            leftFingerDown = 0;
    1.85 +        }
    1.86  
    1.87 -#ifdef FIXED_MULTITOUCH
    1.88 -    while(touch) {
    1.89          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.90 -
    1.91  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.92          SDL_SendFingerDown(touchId, (long)touch,
    1.93                             SDL_FALSE, locationInView.x, locationInView.y,
    1.94 @@ -171,10 +165,8 @@
    1.95              }
    1.96          }
    1.97  #endif
    1.98 -
    1.99          touch = (UITouch*)[enumerator nextObject];
   1.100      }
   1.101 -#endif
   1.102  }
   1.103  
   1.104  - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
   1.105 @@ -192,17 +184,15 @@
   1.106      NSEnumerator *enumerator = [touches objectEnumerator];
   1.107      UITouch *touch = (UITouch*)[enumerator nextObject];
   1.108  
   1.109 -    if (touch) {
   1.110 -        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   1.111 +    while (touch) {
   1.112 +        if ((SDL_FingerID)touch == leftFingerDown) {
   1.113 +            CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
   1.114  
   1.115 -        /* send moved event */
   1.116 -        SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   1.117 -    }
   1.118 +            /* send moved event */
   1.119 +            SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
   1.120 +        }
   1.121  
   1.122 -#ifdef FIXED_MULTITOUCH
   1.123 -    while(touch) {
   1.124          CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
   1.125 -
   1.126  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
   1.127          SDL_SendTouchMotion(touchId, (long)touch,
   1.128                              SDL_FALSE, locationInView.x, locationInView.y,
   1.129 @@ -218,10 +208,8 @@
   1.130              }
   1.131          }
   1.132  #endif
   1.133 -
   1.134          touch = (UITouch*)[enumerator nextObject];
   1.135      }
   1.136 -#endif
   1.137  }
   1.138  
   1.139  /*