diff --git a/src/video/uikit/SDL_uikitview.h b/src/video/uikit/SDL_uikitview.h index 3532fded6..862855e0d 100644 --- a/src/video/uikit/SDL_uikitview.h +++ b/src/video/uikit/SDL_uikitview.h @@ -50,6 +50,7 @@ @public SDL_uikitviewcontroller *viewcontroller; } +- (CGPoint)touchLocation:(UITouch *)touch; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index 18ff7e954..452c49a0a 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -1,4 +1,4 @@ -/* + /* Simple DirectMedia Layer Copyright (C) 1997-2011 Sam Lantinga @@ -60,10 +60,10 @@ //EventTouchData* data = (EventTouchData*)(touch.driverdata); touch.x_min = 0; - touch.x_max = frame.size.width; + touch.x_max = 1; touch.native_xres = touch.x_max - touch.x_min; touch.y_min = 0; - touch.y_max = frame.size.height; + touch.y_max = 1; touch.native_yres = touch.y_max - touch.y_min; touch.pressure_min = 0; touch.pressure_max = 1; @@ -77,6 +77,17 @@ } +- (CGPoint)touchLocation:(UITouch *)touch +{ + CGPoint point = [touch locationInView: self]; + CGRect frame = [self frame]; + + frame = CGRectApplyAffineTransform(frame, [self transform]); + point.x /= frame.size.width; + point.y /= frame.size.height; + return point; +} + - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSEnumerator *enumerator = [touches objectEnumerator]; @@ -94,7 +105,7 @@ #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS //FIXME: TODO: Using touch as the fingerId is potentially dangerous @@ -133,7 +144,7 @@ #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS SDL_SendFingerDown(touchId, (long)touch, @@ -181,7 +192,7 @@ #ifdef FIXED_MULTITOUCH while(touch) { - CGPoint locationInView = [touch locationInView: self]; + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS SDL_SendTouchMotion(touchId, (long)touch, diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 3c1b95580..4c7dae8ac 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -138,16 +138,8 @@ return; } - if (w == frame.size.width && h == frame.size.height) { - return; - } - - frame.size.width = w; - frame.size.height = h; - frame.origin.x = 0; - frame.origin.y = 0; - [uiwindow setFrame:frame]; + [data->view setFrame:frame]; [data->view updateFrame]; SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); }