mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
Refactor more mouse input code for the menu
This commit is contained in:
parent
0f83f48cb4
commit
59db6de385
@ -87,8 +87,6 @@ struct menu_bind_state
|
|||||||
|
|
||||||
typedef struct menu_input_mouse
|
typedef struct menu_input_mouse
|
||||||
{
|
{
|
||||||
int16_t x;
|
|
||||||
int16_t y;
|
|
||||||
bool oldleft;
|
bool oldleft;
|
||||||
bool oldright;
|
bool oldright;
|
||||||
bool hwheelup;
|
bool hwheelup;
|
||||||
@ -872,12 +870,6 @@ static int menu_input_mouse(unsigned *action)
|
|||||||
menu_input->mouse.hwheeldown = input_driver_state(
|
menu_input->mouse.hwheeldown = input_driver_state(
|
||||||
NULL, 0, RETRO_DEVICE_MOUSE,
|
NULL, 0, RETRO_DEVICE_MOUSE,
|
||||||
0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN);
|
0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN);
|
||||||
menu_input->mouse.x = input_driver_state(
|
|
||||||
NULL, 0, RARCH_DEVICE_MOUSE_SCREEN,
|
|
||||||
0, RETRO_DEVICE_ID_MOUSE_X);
|
|
||||||
menu_input->mouse.y = input_driver_state(
|
|
||||||
NULL, 0, RARCH_DEVICE_MOUSE_SCREEN,
|
|
||||||
0, RETRO_DEVICE_ID_MOUSE_Y);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -929,8 +921,8 @@ static int menu_input_mouse_frame(
|
|||||||
{
|
{
|
||||||
menu_ctx_pointer_t point;
|
menu_ctx_pointer_t point;
|
||||||
|
|
||||||
point.x = menu_input->mouse.x;
|
point.x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||||
point.y = menu_input->mouse.y;
|
point.y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||||
point.ptr = menu_input->mouse.ptr;
|
point.ptr = menu_input->mouse.ptr;
|
||||||
point.cbs = cbs;
|
point.cbs = cbs;
|
||||||
point.entry = entry;
|
point.entry = entry;
|
||||||
@ -1000,7 +992,8 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
|
|||||||
|
|
||||||
menu_input->mouse.oldleft = true;
|
menu_input->mouse.oldleft = true;
|
||||||
|
|
||||||
if ((unsigned)menu_input->mouse.y < header_height)
|
/* Back button */
|
||||||
|
if ((unsigned)menu_input_mouse_state(MENU_MOUSE_X_AXIS) < header_height)
|
||||||
{
|
{
|
||||||
menu_entries_pop_stack(&selection, 0);
|
menu_entries_pop_stack(&selection, 0);
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
||||||
@ -1071,6 +1064,7 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state)
|
|||||||
{
|
{
|
||||||
menu_input_t *menu = menu_input_get_ptr();
|
menu_input_t *menu = menu_input_get_ptr();
|
||||||
unsigned type = 0;
|
unsigned type = 0;
|
||||||
|
unsigned device = RETRO_DEVICE_MOUSE;
|
||||||
|
|
||||||
if (!menu)
|
if (!menu)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1078,9 +1072,13 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state)
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case MENU_MOUSE_X_AXIS:
|
case MENU_MOUSE_X_AXIS:
|
||||||
return menu->mouse.x;
|
device = RARCH_DEVICE_MOUSE_SCREEN;
|
||||||
|
type = RETRO_DEVICE_ID_MOUSE_X;
|
||||||
|
break;
|
||||||
case MENU_MOUSE_Y_AXIS:
|
case MENU_MOUSE_Y_AXIS:
|
||||||
return menu->mouse.y;
|
device = RARCH_DEVICE_MOUSE_SCREEN;
|
||||||
|
type = RETRO_DEVICE_ID_MOUSE_Y;
|
||||||
|
break;
|
||||||
case MENU_MOUSE_LEFT_BUTTON:
|
case MENU_MOUSE_LEFT_BUTTON:
|
||||||
type = RETRO_DEVICE_ID_MOUSE_LEFT;
|
type = RETRO_DEVICE_ID_MOUSE_LEFT;
|
||||||
break;
|
break;
|
||||||
@ -1097,7 +1095,7 @@ int16_t menu_input_mouse_state(enum menu_input_mouse_state state)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return input_driver_state(NULL, 0, RETRO_DEVICE_MOUSE, 0, type);
|
return input_driver_state(NULL, 0, device, 0, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int menu_input_pointer_post_iterate(
|
static int menu_input_pointer_post_iterate(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user