mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Create separate static functions for mouse code in backend driver -
mouse_iterate and mouse_post_iterate
This commit is contained in:
parent
e73cab5b18
commit
29a7984e9d
@ -574,18 +574,8 @@ static int menu_load_or_open_zip_iterate(unsigned action)
|
|||||||
return 0;
|
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];
|
const struct retro_keybind *binds[MAX_PLAYERS];
|
||||||
|
|
||||||
driver.menu->mouse.dx = driver.input->input_state(driver.input_data,
|
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,
|
driver.menu->mouse.right = driver.input->input_state(driver.input_data,
|
||||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
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)
|
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
|
||||||
driver.menu_ctx->set_texture(driver.menu);
|
driver.menu_ctx->set_texture(driver.menu);
|
||||||
|
|
||||||
@ -718,34 +759,7 @@ static int menu_common_iterate(unsigned action)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (driver.menu->mouse.dy)
|
ret = mouse_post_iterate(cbs, action);
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (driver.menu_ctx && driver.menu_ctx->iterate)
|
if (driver.menu_ctx && driver.menu_ctx->iterate)
|
||||||
driver.menu_ctx->iterate(driver.menu, action);
|
driver.menu_ctx->iterate(driver.menu, action);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user