From c555b07846900653ac6af303c3247aec9fb98ddd Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Wed, 23 May 2018 15:50:57 -0500 Subject: [PATCH] Translate mouse coordinates correctly in hidpi modes. Hide cursor when SuperScope enabled. --- gtk/src/gtk_control.cpp | 2 +- gtk/src/gtk_s9xwindow.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gtk/src/gtk_control.cpp b/gtk/src/gtk_control.cpp index f2a81065..3e9ef0ca 100644 --- a/gtk/src/gtk_control.cpp +++ b/gtk/src/gtk_control.cpp @@ -141,7 +141,7 @@ S9xIsMousePluggedIn (void) for (int i = 0; i <= 1; i++) { S9xGetController (i, &ctl, &id1, &id2, &id3, &id4); - if (ctl == CTL_MOUSE) + if (ctl == CTL_MOUSE || ctl == CTL_SUPERSCOPE) return true; } diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp index eb6d47d6..4d878019 100644 --- a/gtk/src/gtk_s9xwindow.cpp +++ b/gtk/src/gtk_s9xwindow.cpp @@ -230,12 +230,18 @@ event_motion_notify (GtkWidget *widget, return FALSE; } +#if GTK_CHECK_VERSION(3,10,0) + int scale_factor = gdk_window_get_scale_factor (gtk_widget_get_window (GTK_WIDGET (window->get_window ()))); +#else + int scale_factor = 1; +#endif + window->mouse_loc_x = (uint16) - ((int) (event->x) - window->mouse_region_x) * 256 / + ((int) (event->x * scale_factor) - window->mouse_region_x) * 256 / (window->mouse_region_width <= 0 ? 1 : window->mouse_region_width); window->mouse_loc_y = (uint16) - ((int) (event->y) - window->mouse_region_y) * SNES_HEIGHT_EXTENDED / + ((int) (event->y * scale_factor) - window->mouse_region_y) * (gui_config->overscan ? SNES_HEIGHT_EXTENDED : SNES_HEIGHT) / (window->mouse_region_height <= 0 ? 1 : window->mouse_region_height); if (!window->config->pointer_is_visible)