src/video/uikit/SDL_uikitview.m
changeset 6436 29a35c72905a
parent 6392 fa7eb111f994
child 6439 fbbd640d7867
     1.1 --- a/src/video/uikit/SDL_uikitview.m	Tue Sep 18 00:50:41 2012 -0700
     1.2 +++ b/src/video/uikit/SDL_uikitview.m	Tue Sep 18 01:45:15 2012 -0700
     1.3 @@ -76,14 +76,24 @@
     1.4  
     1.5  }
     1.6  
     1.7 -- (CGPoint)touchLocation:(UITouch *)touch
     1.8 +- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize
     1.9  {
    1.10      CGPoint point = [touch locationInView: self];
    1.11      CGRect frame = [self frame];
    1.12  
    1.13      frame = CGRectApplyAffineTransform(frame, [self transform]);
    1.14 -    point.x /= frame.size.width;
    1.15 -    point.y /= frame.size.height;
    1.16 +
    1.17 +    // Get the display scale and apply that to the input coordinates
    1.18 +    SDL_Window *window = self->viewcontroller.window;
    1.19 +    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    1.20 +    SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    1.21 +    point.x *= displaymodedata->scale;
    1.22 +    point.y *= displaymodedata->scale;
    1.23 +    
    1.24 +    if (normalize) {
    1.25 +        point.x /= frame.size.width;
    1.26 +        point.y /= frame.size.height;
    1.27 +    }
    1.28      return point;
    1.29  }
    1.30  
    1.31 @@ -93,7 +103,7 @@
    1.32      UITouch *touch = (UITouch*)[enumerator nextObject];
    1.33  
    1.34      if (touch) {
    1.35 -        CGPoint locationInView = [touch locationInView: self];
    1.36 +        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.37  
    1.38          /* send moved event */
    1.39          SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.40 @@ -104,7 +114,7 @@
    1.41  
    1.42  #ifdef FIXED_MULTITOUCH
    1.43      while(touch) {
    1.44 -        CGPoint locationInView = [self touchLocation:touch];
    1.45 +        CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.46  
    1.47  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.48          //FIXME: TODO: Using touch as the fingerId is potentially dangerous
    1.49 @@ -143,7 +153,7 @@
    1.50  
    1.51  #ifdef FIXED_MULTITOUCH
    1.52      while(touch) {
    1.53 -        CGPoint locationInView = [self touchLocation:touch];
    1.54 +        CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.55  
    1.56  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.57          SDL_SendFingerDown(touchId, (long)touch,
    1.58 @@ -183,7 +193,7 @@
    1.59      UITouch *touch = (UITouch*)[enumerator nextObject];
    1.60  
    1.61      if (touch) {
    1.62 -        CGPoint locationInView = [touch locationInView: self];
    1.63 +        CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO];
    1.64  
    1.65          /* send moved event */
    1.66          SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);
    1.67 @@ -191,7 +201,7 @@
    1.68  
    1.69  #ifdef FIXED_MULTITOUCH
    1.70      while(touch) {
    1.71 -        CGPoint locationInView = [self touchLocation:touch];
    1.72 +        CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES];
    1.73  
    1.74  #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS
    1.75          SDL_SendTouchMotion(touchId, (long)touch,