From 29a7984e9d96ef87d4761646498664dc372272fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Oct 2014 17:49:46 +0100 Subject: [PATCH] Create separate static functions for mouse code in backend driver - mouse_iterate and mouse_post_iterate --- frontend/menu/backend/menu_common_backend.c | 92 ++++++++++++--------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 301159f249..e061f51fd1 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -574,18 +574,8 @@ static int menu_load_or_open_zip_iterate(unsigned action) return 0; } -static int menu_common_iterate(unsigned action) +static int mouse_iterate(unsigned action) { - int ret = 0; - unsigned type = 0; - const char *label = NULL; - unsigned scroll_speed = 0, fast_scroll_speed = 0; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); - - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type); - const struct retro_keybind *binds[MAX_PLAYERS]; driver.menu->mouse.dx = driver.input->input_state(driver.input_data, @@ -611,6 +601,57 @@ static int menu_common_iterate(unsigned action) driver.menu->mouse.right = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT); + return 0; +} + +static int mouse_post_iterate(menu_file_list_cbs_t *cbs, unsigned action) +{ + if (driver.menu->mouse.dy) + { + unsigned mouse_ptr = driver.menu->mouse.y / 11 - 2; + if (mouse_ptr <= menu_list_get_size(driver.menu->menu_list)) + menu_navigation_set(driver.menu, mouse_ptr); + } + + if (driver.menu->mouse.left) + { + if (!driver.menu->mouse.oldleft) + { + driver.menu->mouse.oldleft = true; + return menu_action_ok(cbs); + } + } + else + driver.menu->mouse.oldleft = false; + + if (driver.menu->mouse.right) + { + if (!driver.menu->mouse.oldright) + { + driver.menu->mouse.oldright = true; + menu_list_pop_stack(driver.menu->menu_list); + } + } + else + driver.menu->mouse.oldright = false; + + return 0; +} + +static int menu_common_iterate(unsigned action) +{ + int ret = 0; + unsigned type = 0; + const char *label = NULL; + unsigned scroll_speed = 0, fast_scroll_speed = 0; + menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) + menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, + driver.menu->selection_ptr); + + menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type); + + mouse_iterate(action); + if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) driver.menu_ctx->set_texture(driver.menu); @@ -718,34 +759,7 @@ static int menu_common_iterate(unsigned action) break; } - if (driver.menu->mouse.dy) - { - unsigned mouse_ptr = driver.menu->mouse.y / 11 - 2; - if (mouse_ptr <= menu_list_get_size(driver.menu->menu_list)) - menu_navigation_set(driver.menu, mouse_ptr); - } - - if (driver.menu->mouse.left) - { - if (!driver.menu->mouse.oldleft) - { - driver.menu->mouse.oldleft = true; - ret = menu_action_ok(cbs); - } - } - else - driver.menu->mouse.oldleft = false; - - if (driver.menu->mouse.right) - { - if (!driver.menu->mouse.oldright) - { - driver.menu->mouse.oldright = true; - menu_list_pop_stack(driver.menu->menu_list); - } - } - else - driver.menu->mouse.oldright = false; + ret = mouse_post_iterate(cbs, action); if (driver.menu_ctx && driver.menu_ctx->iterate) driver.menu_ctx->iterate(driver.menu, action);