From 8323d06d3d593b4721df76ac5945837683fa1099 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 15 Jan 2016 22:20:46 +0100 Subject: [PATCH] (Cocoa) No more dependencies on get_chosen_screen or get_backing_scale_factor --- input/drivers/cocoa_input.c | 11 +++++++++-- ui/drivers/ui_cocoa.m | 14 +++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 28b8c78b09..97671207bd 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -141,7 +141,11 @@ static void cocoa_input_poll(void *data) uint32_t i; cocoa_input_data_t *apple = (cocoa_input_data_t*)data; + for (i = 0; i < apple->touch_count; i++) + { + apple->touches[i].screen_x *= backing_scale_factor; + apple->touches[i].screen_y *= backing_scale_factor; input_translate_coord_viewport( apple->touches[i].screen_x, apple->touches[i].screen_y, @@ -149,6 +153,7 @@ static void cocoa_input_poll(void *data) &apple->touches[i].fixed_y, &apple->touches[i].full_x, &apple->touches[i].full_y); + } if (apple->joypad) apple->joypad->poll(); @@ -184,12 +189,14 @@ static int16_t cocoa_mouse_state(cocoa_input_data_t *apple, static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple, unsigned id) { + float backing_scale_factor = get_backing_scale_factor(); + switch (id) { case RETRO_DEVICE_ID_MOUSE_X: - return apple->window_pos_x; + return (apple->window_pos_x * backing_scale_factor); case RETRO_DEVICE_ID_MOUSE_Y: - return apple->window_pos_y; + return (apple->window_pos_y * backing_scale_factor); default: break; } diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index ea22fb82d0..fd1d0ebf15 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -33,9 +33,6 @@ static id apple_platform; -extern void *get_chosen_screen(void); -extern float get_backing_scale_factor(void); - void apple_rarch_exited(void) { [[NSApplication sharedApplication] terminate:nil]; @@ -109,8 +106,7 @@ void apple_rarch_exited(void) NSPoint pos; NSPoint mouse_pos; apple = (cocoa_input_data_t*)input_driver_get_data(); - float backing_scale_factor = get_backing_scale_factor(); - if (!apple || (backing_scale_factor == 0.0)) + if (!apple) return; /* Relative */ @@ -119,12 +115,12 @@ void apple_rarch_exited(void) /* Absolute */ pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; - apple->touches[0].screen_x = pos.x * backing_scale_factor; - apple->touches[0].screen_y = pos.y * backing_scale_factor; + apple->touches[0].screen_x = pos.x; + apple->touches[0].screen_y = pos.y; mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil]; - apple->window_pos_x = (int16_t)mouse_pos.x * backing_scale_factor; - apple->window_pos_y = (int16_t)mouse_pos.y * backing_scale_factor; + apple->window_pos_x = (int16_t)mouse_pos.x; + apple->window_pos_y = (int16_t)mouse_pos.y; } break; case NSScrollWheel: