Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fix for iOS touch input coordinates being halved on Retina displays
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Jul 26, 2012
1 parent 08817dd commit 58b0ae5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/video/uikit/SDL_uikitview.m
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 58b0ae5

Please sign in to comment.