From ef7541261a44b4cb129b573caa9ba5a65d9e1d49 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 16 Sep 2016 16:54:04 +0200 Subject: [PATCH] Move delay struct variables to menu_event as static variables --- menu/menu_event.c | 21 ++++++++++++--------- menu/menu_input.h | 8 -------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/menu/menu_event.c b/menu/menu_event.c index 8e1dbc3e20..3accf3efc7 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -72,17 +72,17 @@ unsigned menu_event(retro_input_t input, { menu_animation_ctx_delta_t delta; float delta_time; + /* Used for key repeat */ + static float delay_timer = 0.0f; + static float delay_count = 0.0f; unsigned ret = MENU_ACTION_NOOP; static bool initial_held = true; static bool first_held = false; bool set_scroll = false; bool mouse_enabled = false; size_t new_scroll_accel = 0; + menu_input_t *menu_input = NULL; settings_t *settings = config_get_ptr(); - menu_input_t *menu_input = menu_input_get_ptr(); - - if (!menu_input) - return 0; if (input.state) { @@ -91,12 +91,12 @@ unsigned menu_event(retro_input_t input, /* don't run anything first frame, only capture held inputs * for old_input_state. */ - first_held = true; - menu_input->delay.timer = initial_held ? 12 : 6; - menu_input->delay.count = 0; + first_held = true; + delay_timer = initial_held ? 12 : 6; + delay_count = 0; } - if (menu_input->delay.count >= menu_input->delay.timer) + if (delay_count >= delay_timer) { retro_input_t input_repeat = {0}; 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; 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()) { @@ -217,6 +217,9 @@ unsigned menu_event(retro_input_t input, && input_overlay_is_alive(NULL)); #endif + if (!(menu_input = menu_input_get_ptr())) + return 0; + if (!mouse_enabled) menu_input->mouse.ptr = 0; diff --git a/menu/menu_input.h b/menu/menu_input.h index 50c03563d5..cb61e9a45d 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -97,14 +97,6 @@ typedef struct menu_input bool back; unsigned ptr; } pointer; - - - /* Used for key repeat */ - struct - { - float timer; - float count; - } delay; } menu_input_t; typedef struct menu_input_ctx_hitbox