diff options
Diffstat (limited to 'backends/platform/iphone')
-rw-r--r-- | backends/platform/iphone/iphone_video.h | 1 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.mm | 21 |
2 files changed, 21 insertions, 1 deletions
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 9b26ca9c5a..7dbf3c57ab 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -70,6 +70,7 @@ GLfloat _mouseScaleX, _mouseScaleY; int _scaledShakeOffsetY; + CGFloat _contentScaleFactor; UITouch *_firstTouch; UITouch *_secondTouch; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 3178b38255..5048b57328 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -161,9 +161,23 @@ const char *iPhone_getDocumentsDir() { - (id)initWithFrame:(struct CGRect)frame { self = [super initWithFrame: frame]; + _contentScaleFactor = 1; if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { if ([self respondsToSelector:@selector(setContentScaleFactor:)]) { - [self setContentScaleFactor:[[UIScreen mainScreen] scale]]; + // Horrible and crazy method to get the proper return value of + // scale when the SDK used for building does not know anything + // about the selector scale... + NSMethodSignature *scaleSignature = [UIScreen instanceMethodSignatureForSelector:@selector(scale)]; + NSInvocation *scaleInvocation = [NSInvocation invocationWithMethodSignature:scaleSignature]; + [scaleInvocation setTarget:[UIScreen mainScreen]]; + [scaleInvocation setSelector:@selector(scale)]; + [scaleInvocation invoke]; + + NSInteger returnLength = [[scaleInvocation methodSignature] methodReturnLength]; + if (returnLength == sizeof(CGFloat)) { + [scaleInvocation getReturnValue:&_contentScaleFactor]; + [self setContentScaleFactor:_contentScaleFactor]; + } } } @@ -613,6 +627,11 @@ const char *iPhone_getDocumentsDir() { } - (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y { + // We scale the input according to our scale factor to get actual screen + // cooridnates. + point.x *= _contentScaleFactor; + point.y *= _contentScaleFactor; + if (![self convertToRotatedCoords:point result:&point]) return false; |