Add menu scroll home+end actions

This commit is contained in:
sonninnos 2023-05-08 14:34:27 +03:00 committed by LibretroAdmin
parent 907724b184
commit 47d71646c9
4 changed files with 113 additions and 20 deletions

View File

@ -6157,37 +6157,39 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
unsigned i;
unsigned ids[][2] =
{
{RETROK_SPACE, RETRO_DEVICE_ID_JOYPAD_START },
{RETROK_SLASH, RETRO_DEVICE_ID_JOYPAD_X },
{RETROK_RSHIFT, RETRO_DEVICE_ID_JOYPAD_SELECT },
{RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT },
{RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT },
{RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN },
{RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP },
{RETROK_PAGEUP, RETRO_DEVICE_ID_JOYPAD_L },
{RETROK_PAGEDOWN, RETRO_DEVICE_ID_JOYPAD_R },
{0, RARCH_QUIT_KEY },
{0, RARCH_FULLSCREEN_TOGGLE_KEY },
{RETROK_BACKSPACE, RETRO_DEVICE_ID_JOYPAD_B },
{RETROK_RETURN, RETRO_DEVICE_ID_JOYPAD_A },
{RETROK_BACKSPACE, RETRO_DEVICE_ID_JOYPAD_B },
{RETROK_DELETE, RETRO_DEVICE_ID_JOYPAD_Y },
{RETROK_SLASH, RETRO_DEVICE_ID_JOYPAD_X },
{RETROK_SPACE, RETRO_DEVICE_ID_JOYPAD_START },
{RETROK_RSHIFT, RETRO_DEVICE_ID_JOYPAD_SELECT },
{RETROK_UP, RETRO_DEVICE_ID_JOYPAD_UP },
{RETROK_DOWN, RETRO_DEVICE_ID_JOYPAD_DOWN },
{RETROK_LEFT, RETRO_DEVICE_ID_JOYPAD_LEFT },
{RETROK_RIGHT, RETRO_DEVICE_ID_JOYPAD_RIGHT },
{RETROK_PAGEUP, RETRO_DEVICE_ID_JOYPAD_L },
{RETROK_PAGEDOWN, RETRO_DEVICE_ID_JOYPAD_R },
{RETROK_HOME, RETRO_DEVICE_ID_JOYPAD_L3 },
{RETROK_END, RETRO_DEVICE_ID_JOYPAD_R3 },
{0, RARCH_QUIT_KEY }, /* 14 */
{0, RARCH_FULLSCREEN_TOGGLE_KEY },
{0, RARCH_UI_COMPANION_TOGGLE },
{0, RARCH_FPS_TOGGLE },
{0, RARCH_NETPLAY_HOST_TOGGLE },
{0, RARCH_MENU_TOGGLE },
};
ids[9][0] = input_config_binds[0][RARCH_QUIT_KEY].key;
ids[10][0] = input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY].key;
ids[14][0] = input_config_binds[0][RARCH_UI_COMPANION_TOGGLE].key;
ids[15][0] = input_config_binds[0][RARCH_FPS_TOGGLE].key;
ids[16][0] = input_config_binds[0][RARCH_NETPLAY_HOST_TOGGLE].key;
ids[17][0] = input_config_binds[0][RARCH_MENU_TOGGLE].key;
ids[14][0] = input_config_binds[0][RARCH_QUIT_KEY].key;
ids[15][0] = input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY].key;
ids[16][0] = input_config_binds[0][RARCH_UI_COMPANION_TOGGLE].key;
ids[17][0] = input_config_binds[0][RARCH_FPS_TOGGLE].key;
ids[18][0] = input_config_binds[0][RARCH_NETPLAY_HOST_TOGGLE].key;
ids[19][0] = input_config_binds[0][RARCH_MENU_TOGGLE].key;
if (settings->bools.input_menu_swap_ok_cancel_buttons)
{
ids[11][1] = RETRO_DEVICE_ID_JOYPAD_A;
ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B;
ids[0][1] = RETRO_DEVICE_ID_JOYPAD_B;
ids[1][1] = RETRO_DEVICE_ID_JOYPAD_A;
}
for (i = 0; i < ARRAY_SIZE(ids); i++)

View File

@ -8455,6 +8455,61 @@ static enum menu_action ozone_parse_menu_entry_action(
ozone->flags &= ~OZONE_FLAG_CURSOR_MODE;
break;
case MENU_ACTION_SCROLL_HOME:
if (ozone->flags & OZONE_FLAG_CURSOR_IN_SIDEBAR)
{
struct menu_state *menu_st = menu_state_get_ptr();
/* If cursor is active, ensure we target
* an on screen category */
size_t tab_selection = (ozone->flags & OZONE_FLAG_CURSOR_MODE)
? ozone_get_onscreen_category_selection(ozone)
: ozone->categories_selection_ptr;
new_selection = 0;
if (tab_selection > ozone->system_tab_end)
new_selection = (int)(ozone->system_tab_end + 1);
if (new_selection != tab_selection)
ozone_sidebar_goto(ozone, new_selection);
new_action = MENU_ACTION_NOOP;
ozone->flags &= ~OZONE_FLAG_CURSOR_MODE;
#ifdef HAVE_AUDIOMIXER
if (new_selection != selection)
audio_driver_mixer_play_scroll_sound(true);
#endif
break;
}
break;
case MENU_ACTION_SCROLL_END:
if (ozone->flags & OZONE_FLAG_CURSOR_IN_SIDEBAR)
{
struct menu_state *menu_st = menu_state_get_ptr();
/* If cursor is active, ensure we target
* an on screen category */
size_t tab_selection = (ozone->flags & OZONE_FLAG_CURSOR_MODE)
? ozone_get_onscreen_category_selection(ozone)
: ozone->categories_selection_ptr;
new_selection = ozone->system_tab_end + horizontal_list_size;
if (new_selection != tab_selection)
ozone_sidebar_goto(ozone, new_selection);
new_action = MENU_ACTION_NOOP;
ozone->flags &= ~OZONE_FLAG_CURSOR_MODE;
#ifdef HAVE_AUDIOMIXER
if (new_selection != selection)
audio_driver_mixer_play_scroll_sound(false);
#endif
break;
}
break;
case MENU_ACTION_INFO:
/* If we currently viewing a playlist with
* dual thumbnails, toggle the content metadata

View File

@ -411,6 +411,8 @@ enum menu_action
MENU_ACTION_START,
MENU_ACTION_SCROLL_DOWN,
MENU_ACTION_SCROLL_UP,
MENU_ACTION_SCROLL_HOME,
MENU_ACTION_SCROLL_END,
MENU_ACTION_TOGGLE,
MENU_ACTION_POINTER_MOVED,
MENU_ACTION_POINTER_PRESSED,

View File

@ -5850,6 +5850,10 @@ unsigned menu_event(
menu_st->scroll.mode = (swap_scroll_btns) ? MENU_SCROLL_PAGE : MENU_SCROLL_START_LETTER;
ret = MENU_ACTION_SCROLL_DOWN;
}
if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L3))
ret = MENU_ACTION_SCROLL_HOME;
else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R3))
ret = MENU_ACTION_SCROLL_END;
else if (ok_trigger)
ret = MENU_ACTION_OK;
else if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn))
@ -7874,6 +7878,36 @@ int generic_menu_entry_action(
}
}
break;
case MENU_ACTION_SCROLL_HOME:
{
#ifdef HAVE_AUDIOMIXER
size_t selection_old = menu_st->selection_ptr;
#endif
menu_st->selection_ptr = 0;
if (menu_st->driver_ctx->navigation_set)
menu_st->driver_ctx->navigation_set(menu_st->userdata, true);
#ifdef HAVE_AUDIOMIXER
if (menu_st->selection_ptr != selection_old)
audio_driver_mixer_play_scroll_sound(true);
#endif
break;
}
case MENU_ACTION_SCROLL_END:
{
#ifdef HAVE_AUDIOMIXER
size_t selection_old = menu_st->selection_ptr;
#endif
menu_st->selection_ptr = (menu_entries_get_size()) ? menu_entries_get_size() - 1 : 0;
if (menu_st->driver_ctx->navigation_set)
menu_st->driver_ctx->navigation_set(menu_st->userdata, true);
#ifdef HAVE_AUDIOMIXER
if (menu_st->selection_ptr != selection_old)
audio_driver_mixer_play_scroll_sound(false);
#endif
break;
}
case MENU_ACTION_CANCEL:
if (cbs && cbs->action_cancel)
ret = cbs->action_cancel(entry->path,