mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 22:08:34 +00:00
Simplify menu_input_bind_iterate
This commit is contained in:
parent
ec789e0943
commit
3981a621e9
@ -455,26 +455,6 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_iterate_custom_bind(const char *label, unsigned action)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
if (!menu_list)
|
||||
return -1;
|
||||
if (menu_input_bind_iterate())
|
||||
menu_list_pop_stack(menu_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_iterate_custom_bind_keyboard(const char *label, unsigned action)
|
||||
{
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
if (!menu_list)
|
||||
return -1;
|
||||
if (menu_input_bind_iterate_keyboard())
|
||||
menu_list_pop_stack(menu_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_iterate_message(const char *label, unsigned action)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
@ -526,10 +506,12 @@ static int action_iterate_main(const char *label, unsigned action)
|
||||
!strcmp(label, "custom_bind_defaults")
|
||||
)
|
||||
{
|
||||
if (global->menu.bind_mode_keyboard)
|
||||
return action_iterate_custom_bind_keyboard(label, action);
|
||||
else
|
||||
return action_iterate_custom_bind(label, action);
|
||||
menu_list_t *menu_list = menu_list_get_ptr();
|
||||
if (!menu_list)
|
||||
return -1;
|
||||
if (menu_input_bind_iterate())
|
||||
menu_list_pop_stack(menu_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = action_iterate_switch(action);
|
||||
|
@ -454,50 +454,7 @@ int menu_input_set_input_device_bind_mode(void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_input_bind_iterate(void)
|
||||
{
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
struct menu_bind_state binds;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return 1;
|
||||
|
||||
binds = menu->binds;
|
||||
|
||||
menu_driver_render();
|
||||
|
||||
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
|
||||
input_config_bind_map[
|
||||
menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc);
|
||||
|
||||
menu_driver_render_messagebox(msg);
|
||||
|
||||
driver->block_input = true;
|
||||
menu_input_poll_bind_state(&binds);
|
||||
|
||||
if ((binds.skip && !menu->binds.skip) ||
|
||||
menu_input_poll_find_trigger(&menu->binds, &binds))
|
||||
{
|
||||
driver->block_input = false;
|
||||
|
||||
/* Avoid new binds triggering things right away. */
|
||||
driver->flushing_input = true;
|
||||
|
||||
binds.begin++;
|
||||
|
||||
if (binds.begin > binds.last)
|
||||
return 1;
|
||||
|
||||
binds.target++;
|
||||
}
|
||||
menu->binds = binds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_input_bind_iterate_keyboard(void)
|
||||
static int menu_input_bind_iterate_keyboard(void)
|
||||
{
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
int64_t current;
|
||||
@ -548,6 +505,54 @@ int menu_input_bind_iterate_keyboard(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int menu_input_bind_iterate(void)
|
||||
{
|
||||
char msg[PATH_MAX_LENGTH];
|
||||
struct menu_bind_state binds;
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!menu)
|
||||
return 1;
|
||||
|
||||
if (global && global->menu.bind_mode_keyboard)
|
||||
return menu_input_bind_iterate_keyboard();
|
||||
|
||||
binds = menu->binds;
|
||||
|
||||
menu_driver_render();
|
||||
|
||||
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
|
||||
input_config_bind_map[
|
||||
menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc);
|
||||
|
||||
menu_driver_render_messagebox(msg);
|
||||
|
||||
driver->block_input = true;
|
||||
menu_input_poll_bind_state(&binds);
|
||||
|
||||
if ((binds.skip && !menu->binds.skip) ||
|
||||
menu_input_poll_find_trigger(&menu->binds, &binds))
|
||||
{
|
||||
driver->block_input = false;
|
||||
|
||||
/* Avoid new binds triggering things right away. */
|
||||
driver->flushing_input = true;
|
||||
|
||||
binds.begin++;
|
||||
|
||||
if (binds.begin > binds.last)
|
||||
return 1;
|
||||
|
||||
binds.target++;
|
||||
}
|
||||
menu->binds = binds;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int menu_input_mouse(unsigned *action)
|
||||
{
|
||||
const struct retro_keybind *binds[MAX_USERS];
|
||||
|
@ -82,8 +82,6 @@ bool menu_input_poll_find_trigger(struct menu_bind_state *state,
|
||||
|
||||
int menu_input_bind_iterate(void);
|
||||
|
||||
int menu_input_bind_iterate_keyboard(void);
|
||||
|
||||
unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_state);
|
||||
|
||||
void menu_input_post_iterate(int *ret, unsigned action);
|
||||
|
Loading…
Reference in New Issue
Block a user