Move menu global state code from global_t to menu_st

This commit is contained in:
twinaphex 2021-11-08 20:04:55 +01:00
parent bd5295ca76
commit 2886932968
4 changed files with 60 additions and 73 deletions

View File

@ -433,6 +433,12 @@ struct menu_state
retro_time_t input_last_time_us; retro_time_t input_last_time_us;
menu_input_t input_state; /* retro_time_t alignment */ menu_input_t input_state; /* retro_time_t alignment */
retro_time_t prev_start_time;
retro_time_t noop_press_time;
retro_time_t noop_start_time;
retro_time_t action_start_time;
retro_time_t action_press_time;
struct menu_bind_state input_binds; /* uint64_t alignment */ struct menu_bind_state input_binds; /* uint64_t alignment */
menu_handle_t *driver_data; menu_handle_t *driver_data;
@ -466,6 +472,8 @@ struct menu_state
/* int16_t alignment */ /* int16_t alignment */
menu_input_pointer_hw_state_t input_pointer_hw_state; menu_input_pointer_hw_state_t input_pointer_hw_state;
enum menu_action prev_action;
/* When generating a menu list in menu_displaylist_build_list(), /* When generating a menu list in menu_displaylist_build_list(),
* the entry with a label matching 'pending_selection' will * the entry with a label matching 'pending_selection' will
* be selected automatically */ * be selected automatically */

View File

@ -728,11 +728,8 @@ static void setting_get_string_representation_uint_as_enum(
static float recalc_step_based_on_length_of_action(rarch_setting_t *setting) static float recalc_step_based_on_length_of_action(rarch_setting_t *setting)
{ {
float step = setting->step; float step = setting->step;
global_t *global = global_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
retro_time_t action_press_time = menu_st->action_press_time;
if (global)
{
retro_time_t action_press_time = global->menu.action_press_time;
if (action_press_time > _21_SECONDS) if (action_press_time > _21_SECONDS)
step = setting->step * 1000000.0f; step = setting->step * 1000000.0f;
else if (action_press_time > _18_SECONDS) else if (action_press_time > _18_SECONDS)
@ -749,7 +746,6 @@ static float recalc_step_based_on_length_of_action(rarch_setting_t *setting)
step = setting->step * 5.0f; step = setting->step * 5.0f;
else else
step = setting->step; step = setting->step;
}
return step < setting->step ? setting->step : step; return step < setting->step ? setting->step : step;
} }

View File

@ -14829,7 +14829,6 @@ static enum runloop_state_enum runloop_check_state(
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
bool focused = false; bool focused = false;
input_bits_t trigger_input = current_bits; input_bits_t trigger_input = current_bits;
global_t *global = global_get_ptr();
unsigned screensaver_timeout = settings->uints.menu_screensaver_timeout; unsigned screensaver_timeout = settings->uints.menu_screensaver_timeout;
/* Get current time */ /* Get current time */
@ -14846,43 +14845,40 @@ static enum runloop_state_enum runloop_check_state(
focused = focused && focused = focused &&
!p_rarch->main_ui_companion_is_on_foreground; !p_rarch->main_ui_companion_is_on_foreground;
if (global)
{
if (action == old_action) if (action == old_action)
{ {
retro_time_t press_time = current_time; retro_time_t press_time = current_time;
if (action == MENU_ACTION_NOOP) if (action == MENU_ACTION_NOOP)
global->menu.noop_press_time = press_time - global->menu.noop_start_time; menu_st->noop_press_time = press_time - menu_st->noop_start_time;
else else
global->menu.action_press_time = press_time - global->menu.action_start_time; menu_st->action_press_time = press_time - menu_st->action_start_time;
} }
else else
{ {
if (action == MENU_ACTION_NOOP) if (action == MENU_ACTION_NOOP)
{ {
global->menu.noop_start_time = current_time; menu_st->noop_start_time = current_time;
global->menu.noop_press_time = 0; menu_st->noop_press_time = 0;
if (global->menu_prev_action == old_action) if (menu_st->prev_action == old_action)
global->menu.action_start_time = global->menu.prev_start_time; menu_st->action_start_time = menu_st->prev_start_time;
else else
global->menu.action_start_time = current_time; menu_st->action_start_time = current_time;
} }
else else
{ {
if ( global->menu_prev_action == action && if ( menu_st->prev_action == action &&
global->menu.noop_press_time < 200000) /* 250ms */ menu_st->noop_press_time < 200000) /* 250ms */
{ {
global->menu.action_start_time = global->menu.prev_start_time; menu_st->action_start_time = menu_st->prev_start_time;
global->menu.action_press_time = current_time - global->menu.action_start_time; menu_st->action_press_time = current_time - menu_st->action_start_time;
} }
else else
{ {
global->menu.prev_start_time = current_time; menu_st->prev_start_time = current_time;
global->menu_prev_action = action; menu_st->prev_action = action;
global->menu.action_press_time = 0; menu_st->action_press_time = 0;
}
} }
} }
} }

View File

@ -332,16 +332,6 @@ typedef struct rarch_resolution
typedef struct global typedef struct global
{ {
#ifdef HAVE_MENU
struct
{
retro_time_t prev_start_time;
retro_time_t noop_press_time;
retro_time_t noop_start_time;
retro_time_t action_start_time;
retro_time_t action_press_time;
} menu;
#endif
struct struct
{ {
char *remapfile; char *remapfile;
@ -399,9 +389,6 @@ typedef struct global
bool old_libretro_device_set; bool old_libretro_device_set;
bool remapping_cache_active; bool remapping_cache_active;
/* Settings and/or global states specific to menus */ /* Settings and/or global states specific to menus */
#ifdef HAVE_MENU
enum menu_action menu_prev_action;
#endif
bool launched_from_cli; bool launched_from_cli;
bool cli_load_menu_on_error; bool cli_load_menu_on_error;
} global_t; } global_t;