mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
Move bind_iterate / bind_iterate_keyboard to menu_input_line_cb
This commit is contained in:
parent
90be5e6f93
commit
bf2f55dc60
@ -1578,99 +1578,6 @@ static int menu_viewport_iterate(unsigned action)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int menu_custom_bind_iterate(void *data)
|
|
||||||
{
|
|
||||||
char msg[PATH_MAX];
|
|
||||||
int64_t current;
|
|
||||||
int timeout = 0;
|
|
||||||
menu_handle_t *menu = (menu_handle_t*)data;
|
|
||||||
struct menu_bind_state binds = menu->binds;
|
|
||||||
|
|
||||||
if (driver.video_data && driver.menu_ctx &&
|
|
||||||
driver.menu_ctx->render)
|
|
||||||
driver.menu_ctx->render();
|
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
|
|
||||||
input_config_bind_map[
|
|
||||||
driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc);
|
|
||||||
|
|
||||||
if (driver.video_data && driver.menu_ctx
|
|
||||||
&& driver.menu_ctx->render_messagebox)
|
|
||||||
driver.menu_ctx->render_messagebox(msg);
|
|
||||||
|
|
||||||
menu_poll_bind_state(&binds);
|
|
||||||
|
|
||||||
if ((binds.skip && !menu->binds.skip) ||
|
|
||||||
menu_poll_find_trigger(&menu->binds, &binds))
|
|
||||||
{
|
|
||||||
binds.begin++;
|
|
||||||
if (binds.begin <= binds.last)
|
|
||||||
binds.target++;
|
|
||||||
else
|
|
||||||
menu_entries_pop(driver.menu->menu_stack);
|
|
||||||
|
|
||||||
/* Avoid new binds triggering things right away. */
|
|
||||||
menu->trigger_state = 0;
|
|
||||||
menu->old_input_state = -1ULL;
|
|
||||||
}
|
|
||||||
menu->binds = binds;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int menu_custom_bind_iterate_keyboard(void *data)
|
|
||||||
{
|
|
||||||
char msg[PATH_MAX];
|
|
||||||
int64_t current;
|
|
||||||
int timeout = 0;
|
|
||||||
bool timed_out = false;
|
|
||||||
menu_handle_t *menu = (menu_handle_t*)data;
|
|
||||||
|
|
||||||
if (driver.video_data && driver.menu_ctx &&
|
|
||||||
driver.menu_ctx->render)
|
|
||||||
driver.menu_ctx->render();
|
|
||||||
|
|
||||||
current = rarch_get_time_usec();
|
|
||||||
timeout = (driver.menu->binds.timeout_end - current) / 1000000;
|
|
||||||
snprintf(msg, sizeof(msg), "[%s]\npress keyboard\n(timeout %d seconds)",
|
|
||||||
input_config_bind_map[
|
|
||||||
driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
|
|
||||||
timeout);
|
|
||||||
|
|
||||||
if (driver.video_data && driver.menu_ctx
|
|
||||||
&& driver.menu_ctx->render_messagebox)
|
|
||||||
driver.menu_ctx->render_messagebox(msg);
|
|
||||||
|
|
||||||
if (timeout <= 0)
|
|
||||||
{
|
|
||||||
menu->binds.begin++;
|
|
||||||
|
|
||||||
/* Could be unsafe, but whatever. */
|
|
||||||
menu->binds.target->key = RETROK_UNKNOWN;
|
|
||||||
|
|
||||||
menu->binds.target++;
|
|
||||||
menu->binds.timeout_end = rarch_get_time_usec() +
|
|
||||||
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
|
||||||
timed_out = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* binds.begin is updated in keyboard_press callback. */
|
|
||||||
if (menu->binds.begin > menu->binds.last)
|
|
||||||
{
|
|
||||||
menu_entries_pop(driver.menu->menu_stack);
|
|
||||||
|
|
||||||
/* Avoid new binds triggering things right away. */
|
|
||||||
menu->trigger_state = 0;
|
|
||||||
menu->old_input_state = -1ULL;
|
|
||||||
|
|
||||||
/* We won't be getting any key events, so just cancel early. */
|
|
||||||
if (timed_out)
|
|
||||||
input_keyboard_wait_keys_cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void menu_common_load_content(void)
|
static void menu_common_load_content(void)
|
||||||
{
|
{
|
||||||
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
|
rarch_main_command(RARCH_CMD_LOAD_CONTENT);
|
||||||
@ -2022,9 +1929,17 @@ static int menu_common_iterate(unsigned action)
|
|||||||
)
|
)
|
||||||
return menu_viewport_iterate(action);
|
return menu_viewport_iterate(action);
|
||||||
else if (menu_type == MENU_SETTINGS_CUSTOM_BIND)
|
else if (menu_type == MENU_SETTINGS_CUSTOM_BIND)
|
||||||
return menu_custom_bind_iterate(driver.menu);
|
{
|
||||||
|
if (menu_input_bind_iterate(driver.menu))
|
||||||
|
menu_entries_pop(driver.menu->menu_stack);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if (menu_type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD)
|
else if (menu_type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD)
|
||||||
return menu_custom_bind_iterate_keyboard(driver.menu);
|
{
|
||||||
|
if (menu_input_bind_iterate_keyboard(driver.menu))
|
||||||
|
menu_entries_pop(driver.menu->menu_stack);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE)
|
if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE)
|
||||||
action = MENU_ACTION_NOOP;
|
action = MENU_ACTION_NOOP;
|
||||||
|
@ -352,3 +352,96 @@ uint64_t menu_input(void)
|
|||||||
|
|
||||||
return input_state;
|
return input_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int menu_input_bind_iterate(void *data)
|
||||||
|
{
|
||||||
|
char msg[PATH_MAX];
|
||||||
|
int64_t current;
|
||||||
|
int timeout = 0;
|
||||||
|
menu_handle_t *menu = (menu_handle_t*)data;
|
||||||
|
struct menu_bind_state binds = menu->binds;
|
||||||
|
|
||||||
|
if (driver.video_data && driver.menu_ctx &&
|
||||||
|
driver.menu_ctx->render)
|
||||||
|
driver.menu_ctx->render();
|
||||||
|
|
||||||
|
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
|
||||||
|
input_config_bind_map[
|
||||||
|
driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc);
|
||||||
|
|
||||||
|
if (driver.video_data && driver.menu_ctx
|
||||||
|
&& driver.menu_ctx->render_messagebox)
|
||||||
|
driver.menu_ctx->render_messagebox(msg);
|
||||||
|
|
||||||
|
menu_poll_bind_state(&binds);
|
||||||
|
|
||||||
|
if ((binds.skip && !menu->binds.skip) ||
|
||||||
|
menu_poll_find_trigger(&menu->binds, &binds))
|
||||||
|
{
|
||||||
|
binds.begin++;
|
||||||
|
if (binds.begin <= binds.last)
|
||||||
|
binds.target++;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Avoid new binds triggering things right away. */
|
||||||
|
menu->trigger_state = 0;
|
||||||
|
menu->old_input_state = -1ULL;
|
||||||
|
}
|
||||||
|
menu->binds = binds;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int menu_input_bind_iterate_keyboard(void *data)
|
||||||
|
{
|
||||||
|
char msg[PATH_MAX];
|
||||||
|
int64_t current;
|
||||||
|
int timeout = 0;
|
||||||
|
bool timed_out = false;
|
||||||
|
menu_handle_t *menu = (menu_handle_t*)data;
|
||||||
|
|
||||||
|
if (driver.video_data && driver.menu_ctx &&
|
||||||
|
driver.menu_ctx->render)
|
||||||
|
driver.menu_ctx->render();
|
||||||
|
|
||||||
|
current = rarch_get_time_usec();
|
||||||
|
timeout = (driver.menu->binds.timeout_end - current) / 1000000;
|
||||||
|
snprintf(msg, sizeof(msg), "[%s]\npress keyboard\n(timeout %d seconds)",
|
||||||
|
input_config_bind_map[
|
||||||
|
driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
|
||||||
|
timeout);
|
||||||
|
|
||||||
|
if (driver.video_data && driver.menu_ctx
|
||||||
|
&& driver.menu_ctx->render_messagebox)
|
||||||
|
driver.menu_ctx->render_messagebox(msg);
|
||||||
|
|
||||||
|
if (timeout <= 0)
|
||||||
|
{
|
||||||
|
menu->binds.begin++;
|
||||||
|
|
||||||
|
/* Could be unsafe, but whatever. */
|
||||||
|
menu->binds.target->key = RETROK_UNKNOWN;
|
||||||
|
|
||||||
|
menu->binds.target++;
|
||||||
|
menu->binds.timeout_end = rarch_get_time_usec() +
|
||||||
|
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
|
||||||
|
timed_out = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* binds.begin is updated in keyboard_press callback. */
|
||||||
|
if (menu->binds.begin > menu->binds.last)
|
||||||
|
{
|
||||||
|
/* Avoid new binds triggering things right away. */
|
||||||
|
menu->trigger_state = 0;
|
||||||
|
menu->old_input_state = -1ULL;
|
||||||
|
|
||||||
|
/* We won't be getting any key events, so just cancel early. */
|
||||||
|
if (timed_out)
|
||||||
|
input_keyboard_wait_keys_cancel();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -38,6 +38,10 @@ bool menu_poll_find_trigger(struct menu_bind_state *state,
|
|||||||
|
|
||||||
bool menu_custom_bind_keyboard_cb(void *data, unsigned code);
|
bool menu_custom_bind_keyboard_cb(void *data, unsigned code);
|
||||||
|
|
||||||
|
int menu_input_bind_iterate(void *data);
|
||||||
|
|
||||||
|
int menu_input_bind_iterate_keyboard(void *data);
|
||||||
|
|
||||||
uint64_t menu_input(void);
|
uint64_t menu_input(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user