From 58b0ae530181e892fba64b127c83377d616502e1 Mon Sep 17 00:00:00 2001 From: DavidLudwig Date: Wed, 25 Jul 2012 20:56:42 -0400 Subject: [PATCH] Fix for iOS touch input coordinates being halved on Retina displays --- src/video/uikit/SDL_uikitview.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index b6c4cf867..02e394ae5 100755 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -94,6 +94,12 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event if (touch) { CGPoint locationInView = [touch locationInView: self]; + + /* Make sure UIView points are converted to screen pixels: */ + if ([self respondsToSelector:@selector(contentScaleFactor)]) { + locationInView.x *= self.contentScaleFactor; + locationInView.y *= self.contentScaleFactor; + } /* send moved event */ SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); @@ -184,6 +190,12 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event if (touch) { CGPoint locationInView = [touch locationInView: self]; + + /* Make sure UIView points are converted to screen pixels: */ + if ([self respondsToSelector:@selector(contentScaleFactor)]) { + locationInView.x *= self.contentScaleFactor; + locationInView.y *= self.contentScaleFactor; + } /* send moved event */ SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y);