menu_input_bind_dialog - cleanups

This commit is contained in:
twinaphex 2020-06-23 16:49:08 +02:00
parent d0f57cdd6f
commit f8fecadd88

View File

@ -75,23 +75,24 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb(
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
uint64_t input_bind_hold_us = settings->uints.input_bind_hold * 1000000; uint64_t input_bind_hold_us = settings->uints.input_bind_hold * 1000000;
uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout * 1000000; uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout * 1000000;
struct menu_bind_state *binds = &menu_input_binds;
/* store key in bind */ /* store key in bind */
menu_input_binds.buffer.key = (enum retro_key)code; binds->buffer.key = (enum retro_key)code;
/* write out the bind */ /* write out the bind */
*(menu_input_binds.output) = menu_input_binds.buffer; *(binds->output) = binds->buffer;
/* next bind */ /* next bind */
menu_input_binds.begin++; binds->begin++;
menu_input_binds.output++; binds->output++;
menu_input_binds.buffer =* (menu_input_binds.output); binds->buffer =* (binds->output);
rarch_timer_begin_new_time_us( rarch_timer_begin_new_time_us(
&menu_input_binds.timer_hold, input_bind_hold_us); &binds->timer_hold, input_bind_hold_us);
rarch_timer_begin_new_time_us( rarch_timer_begin_new_time_us(
&menu_input_binds.timer_timeout, input_bind_timeout_us); &binds->timer_timeout, input_bind_timeout_us);
return (menu_input_binds.begin <= menu_input_binds.last); return (binds->begin <= binds->last);
} }
static int menu_input_key_bind_set_mode_common( static int menu_input_key_bind_set_mode_common(
@ -361,6 +362,7 @@ static bool menu_input_key_bind_poll_find_trigger_pad(
return false; return false;
} }
#ifdef ANDROID
static bool menu_input_key_bind_poll_find_hold_pad( static bool menu_input_key_bind_poll_find_hold_pad(
struct menu_bind_state *new_state, struct menu_bind_state *new_state,
struct retro_keybind * output, struct retro_keybind * output,
@ -445,6 +447,7 @@ static bool menu_input_key_bind_poll_find_hold_pad(
return false; return false;
} }
#endif
static bool menu_input_key_bind_poll_find_trigger( static bool menu_input_key_bind_poll_find_trigger(
struct menu_bind_state *state, struct menu_bind_state *state,
@ -504,6 +507,7 @@ bool menu_input_key_bind_set_mode(
* 1000000; * 1000000;
uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout
* 1000000; * 1000000;
struct menu_bind_state *binds = &menu_input_binds;
if (!setting || !menu) if (!setting || !menu)
return false; return false;
@ -511,7 +515,7 @@ bool menu_input_key_bind_set_mode(
return false; return false;
index_offset = setting->index_offset; index_offset = setting->index_offset;
menu_input_binds.port = settings->uints.input_joypad_map[index_offset]; binds->port = settings->uints.input_joypad_map[index_offset];
menu_input_key_bind_poll_bind_get_rested_axes( menu_input_key_bind_poll_bind_get_rested_axes(
&menu_input_binds); &menu_input_binds);
@ -519,9 +523,9 @@ bool menu_input_key_bind_set_mode(
&menu_input_binds, false); &menu_input_binds, false);
rarch_timer_begin_new_time_us( rarch_timer_begin_new_time_us(
&menu_input_binds.timer_hold, input_bind_hold_us); &binds->timer_hold, input_bind_hold_us);
rarch_timer_begin_new_time_us( rarch_timer_begin_new_time_us(
&menu_input_binds.timer_timeout, input_bind_timeout_us); &binds->timer_timeout, input_bind_timeout_us);
keys.userdata = menu; keys.userdata = menu;
keys.cb = menu_input_key_bind_custom_bind_keyboard_cb; keys.cb = menu_input_key_bind_custom_bind_keyboard_cb;
@ -539,11 +543,12 @@ bool menu_input_key_bind_set_mode(
bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim) bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim)
{ {
struct menu_bind_state *binds = &menu_input_binds;
if (!lim) if (!lim)
return false; return false;
menu_input_binds.begin = lim->min; binds->begin = lim->min;
menu_input_binds.last = lim->max; binds->last = lim->max;
return true; return true;
} }