From c4c26b83ccfe918da89bc64d7ad4103f78b980d5 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 31 Oct 2015 22:55:22 +0100 Subject: [PATCH] (OSX) Fixed mouse for Retina --- ui/drivers/ui_cocoa.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 5dde6f99e9..1d50516bcd 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -113,11 +113,18 @@ void apple_rarch_exited(void) /* Relative */ apple->mouse_rel_x = event.deltaX; apple->mouse_rel_y = event.deltaY; + +#if MAC_OS_X_VERSION_10_7 + RAScreen *screen = [RAScreen mainScreen]; + CGFloat backing_scale_factor = screen.backingScaleFactor; +#else + CGFloat backing_scale_factor = 1.0f; +#endif /* Absolute */ pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; - apple->touches[0].screen_x = pos.x; - apple->touches[0].screen_y = pos.y; + apple->touches[0].screen_x = pos.x * backing_scale_factor; + apple->touches[0].screen_y = pos.y * backing_scale_factor; //window is a variable containing your window //mouse_pos = [self.window mouseLocationOutsideOfEventStream]; @@ -127,8 +134,8 @@ void apple_rarch_exited(void) //mouse_pos = [event locationInWindow]; //mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:[CocoaView get] ]; mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; - apple->window_pos_x = (int16_t)mouse_pos.x; - apple->window_pos_y = (int16_t)mouse_pos.y; + apple->window_pos_x = (int16_t)mouse_pos.x * backing_scale_factor; + apple->window_pos_y = (int16_t)mouse_pos.y * backing_scale_factor; } break; case NSScrollWheel: