mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Add Mouse Enable option in Menu Options
This commit is contained in:
parent
3826a3d3e9
commit
4918381cfb
@ -187,6 +187,76 @@ static int menu_start_screen_iterate(unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mouse_iterate(unsigned action)
|
||||
{
|
||||
const struct retro_keybind *binds[MAX_PLAYERS];
|
||||
|
||||
if (!driver.menu->mouse.enable)
|
||||
return 0;
|
||||
|
||||
driver.menu->mouse.dx = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
driver.menu->mouse.dy = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||
|
||||
driver.menu->mouse.x += driver.menu->mouse.dx;
|
||||
driver.menu->mouse.y += driver.menu->mouse.dy;
|
||||
|
||||
if (driver.menu->mouse.x < 5)
|
||||
driver.menu->mouse.x = 5;
|
||||
if (driver.menu->mouse.y < 5)
|
||||
driver.menu->mouse.y = 5;
|
||||
if (driver.menu->mouse.x > driver.menu->width - 5)
|
||||
driver.menu->mouse.x = driver.menu->width - 5;
|
||||
if (driver.menu->mouse.y > driver.menu->height - 5)
|
||||
driver.menu->mouse.y = driver.menu->height - 5;
|
||||
|
||||
driver.menu->mouse.left = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
||||
|
||||
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.enable)
|
||||
return 0;
|
||||
|
||||
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_settings_iterate(unsigned action,
|
||||
menu_file_list_cbs_t *cbs)
|
||||
{
|
||||
@ -277,38 +347,7 @@ static int menu_settings_iterate(unsigned action,
|
||||
driver.menu->push_start_screen = false;
|
||||
}
|
||||
|
||||
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;
|
||||
if (cbs && cbs->action_ok)
|
||||
return cbs->action_ok(path, label, type, driver.menu->selection_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
driver.menu->mouse.oldleft = false;
|
||||
|
||||
if (driver.menu->mouse.right)
|
||||
{
|
||||
if (!driver.menu->mouse.oldright)
|
||||
{
|
||||
driver.menu->mouse.oldright = true;
|
||||
apply_deferred_settings();
|
||||
menu_list_pop_stack(driver.menu->menu_list);
|
||||
}
|
||||
}
|
||||
else
|
||||
driver.menu->mouse.oldright = false;
|
||||
|
||||
return 0;
|
||||
return mouse_post_iterate(cbs, action);
|
||||
}
|
||||
|
||||
static int menu_viewport_iterate(unsigned action)
|
||||
@ -574,69 +613,6 @@ static int menu_load_or_open_zip_iterate(unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mouse_iterate(unsigned action)
|
||||
{
|
||||
const struct retro_keybind *binds[MAX_PLAYERS];
|
||||
|
||||
driver.menu->mouse.dx = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
driver.menu->mouse.dy = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||
|
||||
driver.menu->mouse.x += driver.menu->mouse.dx;
|
||||
driver.menu->mouse.y += driver.menu->mouse.dy;
|
||||
|
||||
if (driver.menu->mouse.x < 5)
|
||||
driver.menu->mouse.x = 5;
|
||||
if (driver.menu->mouse.y < 5)
|
||||
driver.menu->mouse.y = 5;
|
||||
if (driver.menu->mouse.x > driver.menu->width - 5)
|
||||
driver.menu->mouse.x = driver.menu->width - 5;
|
||||
if (driver.menu->mouse.y > driver.menu->height - 5)
|
||||
driver.menu->mouse.y = driver.menu->height - 5;
|
||||
|
||||
driver.menu->mouse.left = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -422,7 +422,8 @@ static void rgui_render(void)
|
||||
rgui_render_messagebox(msg);
|
||||
}
|
||||
|
||||
blit_cursor();
|
||||
if (driver.menu->mouse.enable)
|
||||
blit_cursor();
|
||||
}
|
||||
|
||||
static void *rgui_init(void)
|
||||
|
@ -431,6 +431,8 @@ int menu_iterate(retro_input_t input,
|
||||
driver.menu->scroll_accel = 0;
|
||||
}
|
||||
|
||||
driver.menu->mouse.enable = g_settings.menu.mouse_enable;
|
||||
|
||||
driver.menu->delay_count++;
|
||||
|
||||
if (driver.block_input)
|
||||
|
@ -122,6 +122,7 @@ typedef struct
|
||||
int16_t dy;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
bool enable;
|
||||
bool left;
|
||||
bool right;
|
||||
bool oldleft;
|
||||
|
@ -286,6 +286,7 @@ struct settings
|
||||
{
|
||||
char driver[32];
|
||||
bool pause_libretro;
|
||||
bool mouse_enable;
|
||||
} menu;
|
||||
#endif
|
||||
|
||||
|
@ -4862,6 +4862,19 @@ static bool setting_data_append_list_menu_options(
|
||||
general_read_handler);
|
||||
settings_list_current_add_cmd(list, list_info, RARCH_CMD_MENU_PAUSE_LIBRETRO);
|
||||
settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
|
||||
|
||||
CONFIG_BOOL(
|
||||
g_settings.menu.mouse_enable,
|
||||
"menu_mouse_enable",
|
||||
"Mouse Enable",
|
||||
false,
|
||||
"OFF",
|
||||
"ON",
|
||||
group_info.name,
|
||||
subgroup_info.name,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
END_SUB_GROUP(list, list_info);
|
||||
END_GROUP(list, list_info);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user