Revert "Revert "Revert "(Input) Add timeout for gamepad binds"""

This reverts commit 50dcaf66c6.
This commit is contained in:
twinaphex 2015-04-14 12:40:23 +02:00
parent 50dcaf66c6
commit f5005cac96
2 changed files with 10 additions and 33 deletions

View File

@ -372,50 +372,28 @@ bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code)
int menu_input_bind_iterate(void)
{
char msg[PATH_MAX_LENGTH];
int64_t current;
struct menu_bind_state binds;
int timeout = 0;
bool timed_out = false;
menu_handle_t *menu = menu_driver_get_ptr();
driver_t *driver = driver_get_ptr();
if (!menu)
return 1;
(void)timed_out;
binds = menu->binds;
menu_driver_render();
current = rarch_get_time_usec();
timeout = (menu->binds.timeout_end - current) / 1000000;
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(timeout %d seconds)\n(RETURN to skip)",
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)",
input_config_bind_map[
menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc,
timeout);
menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc);
menu_driver_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;
}
driver->block_input = true;
menu_input_poll_bind_state(&binds);
if ((binds.skip && !menu->binds.skip) ||
menu_input_poll_find_trigger(&menu->binds, &binds) ||
timed_out)
menu_input_poll_find_trigger(&menu->binds, &binds))
{
driver->block_input = false;

View File

@ -875,12 +875,11 @@ static int setting_action_ok_bind_all(void *data, unsigned action)
MENU_SETTINGS_CUSTOM_BIND,
menu->navigation.selection_ptr);
menu->binds.timeout_end =
rarch_get_time_usec() +
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
if (global->menu.bind_mode_keyboard)
{
menu->binds.timeout_end =
rarch_get_time_usec() +
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
input_keyboard_wait_keys(menu,
menu_input_custom_bind_keyboard_cb);
}
@ -894,7 +893,8 @@ static int setting_action_ok_bind_all(void *data, unsigned action)
}
static int setting_action_ok_bind_defaults(void *data, unsigned action)
{ unsigned i;
{
unsigned i;
struct retro_keybind *target = NULL;
const struct retro_keybind *def_binds = NULL;
rarch_setting_t *setting = (rarch_setting_t*)data;
@ -1089,11 +1089,10 @@ static int setting_bind_action_ok(void *data, unsigned action)
MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND,
menu->navigation.selection_ptr);
menu->binds.timeout_end = rarch_get_time_usec() +
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
if (global->menu.bind_mode_keyboard)
{
menu->binds.timeout_end = rarch_get_time_usec() +
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
input_keyboard_wait_keys(menu,
menu_input_custom_bind_keyboard_cb);
}