From ddf5283ecd6ed32f73b5cebc9cc6244d7a449452 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 11 Feb 2016 00:47:00 +0100 Subject: [PATCH] Cleanups --- menu/menu_driver.c | 23 +++++++++++++---------- menu/menu_driver.h | 18 +++++++++++++----- menu/menu_input.c | 30 ++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index a8fa95f64d..7abc67b133 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -290,16 +290,6 @@ static void menu_driver_toggle(bool latch) } } -int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr, - menu_file_list_cbs_t *cbs, - menu_entry_t *entry, unsigned action) -{ - if (!menu_driver_ctx || !menu_driver_ctx->pointer_tap) - return 0; - return menu_driver_ctx->pointer_tap(menu_userdata, - x, y, ptr, cbs, entry, action); -} - bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { static struct retro_system_info menu_driver_system; @@ -826,6 +816,19 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) } } return false; + case RARCH_MENU_CTL_POINTER_TAP: + { + menu_ctx_pointer_t *point = (menu_ctx_pointer_t*)data; + if (!menu_driver_ctx || !menu_driver_ctx->pointer_tap) + { + point->retcode = 0; + return false; + } + point->retcode = menu_driver_ctx->pointer_tap(menu_userdata, + point->x, point->y, point->ptr, + point->cbs, point->entry, point->action); + } + break; default: case RARCH_MENU_CTL_NONE: break; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 5752e740a1..e6a4cc5edf 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -160,7 +160,8 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_LIST_PUSH, RARCH_MENU_CTL_ITERATE, RARCH_MENU_CTL_ENVIRONMENT, - RARCH_MENU_CTL_DRIVER_DATA_GET + RARCH_MENU_CTL_DRIVER_DATA_GET, + RARCH_MENU_CTL_POINTER_TAP }; typedef enum @@ -371,6 +372,17 @@ typedef struct menu_ctx_environment void *data; } menu_ctx_environment_t; +typedef struct menu_ctx_pointer +{ + unsigned x; + unsigned y; + unsigned ptr; + menu_file_list_cbs_t *cbs; + menu_entry_t *entry; + unsigned action; + int retcode; +} menu_ctx_pointer_t; + /** * menu_driver_find_handle: * @index : index of driver to get handle to. @@ -412,10 +424,6 @@ int menu_driver_bind_init(menu_file_list_cbs_t *cbs, const char *elem0, const char *elem1, uint32_t label_hash, uint32_t menu_label_hash); -int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr, - menu_file_list_cbs_t *cbs, - menu_entry_t *entry, unsigned action); - /* HACK */ extern unsigned int rdb_entry_start_game_selection_ptr; diff --git a/menu/menu_input.c b/menu/menu_input.c index a9f6ecd512..627a57ec09 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -859,8 +859,18 @@ static int menu_input_mouse_frame( if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L)) { - ret = menu_driver_pointer_tap(menu_input->mouse.x, menu_input->mouse.y, - menu_input->mouse.ptr, cbs, entry, action); + menu_ctx_pointer_t point; + + point.x = menu_input->mouse.x; + point.y = menu_input->mouse.y; + point.ptr = menu_input->mouse.ptr; + point.cbs = cbs; + point.entry = entry; + point.action = action; + + menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point); + + ret = point.retcode; } if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R)) @@ -1088,8 +1098,20 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, if (menu_input->pointer.oldpressed[0]) { if (!menu_input->pointer.dragging) - ret = menu_driver_pointer_tap(menu_input->pointer.start_x, - menu_input->pointer.start_y, menu_input->pointer.ptr, cbs, entry, action); + { + menu_ctx_pointer_t point; + + point.x = menu_input->pointer.start_x; + point.y = menu_input->pointer.start_y; + point.ptr = menu_input->pointer.ptr; + point.cbs = cbs; + point.entry = entry; + point.action = action; + + menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point); + + ret = point.retcode; + } menu_input->pointer.oldpressed[0] = false; menu_input->pointer.start_x = 0;