Move delay struct variables to menu_event as static variables

This commit is contained in:
twinaphex 2016-09-16 16:54:04 +02:00
parent 125c4f9529
commit ef7541261a
2 changed files with 12 additions and 17 deletions

View File

@ -72,17 +72,17 @@ unsigned menu_event(retro_input_t input,
{ {
menu_animation_ctx_delta_t delta; menu_animation_ctx_delta_t delta;
float delta_time; float delta_time;
/* Used for key repeat */
static float delay_timer = 0.0f;
static float delay_count = 0.0f;
unsigned ret = MENU_ACTION_NOOP; unsigned ret = MENU_ACTION_NOOP;
static bool initial_held = true; static bool initial_held = true;
static bool first_held = false; static bool first_held = false;
bool set_scroll = false; bool set_scroll = false;
bool mouse_enabled = false; bool mouse_enabled = false;
size_t new_scroll_accel = 0; size_t new_scroll_accel = 0;
menu_input_t *menu_input = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_input_t *menu_input = menu_input_get_ptr();
if (!menu_input)
return 0;
if (input.state) if (input.state)
{ {
@ -92,11 +92,11 @@ unsigned menu_event(retro_input_t input,
* for old_input_state. */ * for old_input_state. */
first_held = true; first_held = true;
menu_input->delay.timer = initial_held ? 12 : 6; delay_timer = initial_held ? 12 : 6;
menu_input->delay.count = 0; delay_count = 0;
} }
if (menu_input->delay.count >= menu_input->delay.timer) if (delay_count >= delay_timer)
{ {
retro_input_t input_repeat = {0}; retro_input_t input_repeat = {0};
BIT32_SET(input_repeat.state, RETRO_DEVICE_ID_JOYPAD_UP); BIT32_SET(input_repeat.state, RETRO_DEVICE_ID_JOYPAD_UP);
@ -136,7 +136,7 @@ unsigned menu_event(retro_input_t input,
delta.current = delta_time; delta.current = delta_time;
if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta)) if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta))
menu_input->delay.count += delta.ideal; delay_count += delta.ideal;
if (menu_input_dialog_get_display_kb()) if (menu_input_dialog_get_display_kb())
{ {
@ -217,6 +217,9 @@ unsigned menu_event(retro_input_t input,
&& input_overlay_is_alive(NULL)); && input_overlay_is_alive(NULL));
#endif #endif
if (!(menu_input = menu_input_get_ptr()))
return 0;
if (!mouse_enabled) if (!mouse_enabled)
menu_input->mouse.ptr = 0; menu_input->mouse.ptr = 0;

View File

@ -97,14 +97,6 @@ typedef struct menu_input
bool back; bool back;
unsigned ptr; unsigned ptr;
} pointer; } pointer;
/* Used for key repeat */
struct
{
float timer;
float count;
} delay;
} menu_input_t; } menu_input_t;
typedef struct menu_input_ctx_hitbox typedef struct menu_input_ctx_hitbox