From 18d67aefc73b43bc88fb4a5a4c1197460e7eb314 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Mon, 30 Mar 2015 02:09:25 +0100 Subject: [PATCH] (menu) improve mouse navigation a bit. --- menu/menu_driver.h | 2 ++ menu/menu_entries_cbs_iterate.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 8fd676eddd..76d5d4c6ec 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -158,6 +158,8 @@ typedef struct int16_t dy; int16_t x; int16_t y; + int16_t screen_x; + int16_t screen_y; bool left; bool right; bool oldleft; diff --git a/menu/menu_entries_cbs_iterate.c b/menu/menu_entries_cbs_iterate.c index 5e54c05f5a..a815f1b20d 100644 --- a/menu/menu_entries_cbs_iterate.c +++ b/menu/menu_entries_cbs_iterate.c @@ -711,6 +711,7 @@ static int mouse_iterate(unsigned *action) menu_handle_t *menu = menu_driver_get_ptr(); runloop_t *runloop = rarch_main_get_ptr(); settings_t *settings = config_get_ptr(); + video_viewport_t vp; if (!menu) return -1; @@ -727,11 +728,16 @@ static int mouse_iterate(unsigned *action) menu->mouse.dy = 0; menu->mouse.x = 0; menu->mouse.y = 0; + menu->mouse.screen_x = 0; + menu->mouse.screen_y = 0; menu->mouse.scrollup = 0; menu->mouse.scrolldown = 0; return 0; } + if (!video_driver_viewport_info(&vp)) + return -1; + if (menu->mouse.hwheeldown) { *action = MENU_ACTION_LEFT; @@ -763,8 +769,11 @@ static int mouse_iterate(unsigned *action) menu->mouse.dy = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); - menu->mouse.x += menu->mouse.dx; - menu->mouse.y += menu->mouse.dy; + menu->mouse.screen_x += menu->mouse.dx; + menu->mouse.screen_y += menu->mouse.dy; + + menu->mouse.x = ((int)menu->mouse.screen_x * (int)menu->frame_buf.width) / (int)vp.width; + menu->mouse.y = ((int)menu->mouse.screen_y * (int)menu->frame_buf.height) / (int)vp.height; if (menu->mouse.x < 5) menu->mouse.x = 5;