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;
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 */
menu_handle_t *driver_data;
@ -466,6 +472,8 @@ struct menu_state
/* int16_t alignment */
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(),
* the entry with a label matching 'pending_selection' will
* be selected automatically */

View File

@ -727,29 +727,25 @@ static void setting_get_string_representation_uint_as_enum(
static float recalc_step_based_on_length_of_action(rarch_setting_t *setting)
{
float step = setting->step;
global_t *global = global_get_ptr();
if (global)
{
retro_time_t action_press_time = global->menu.action_press_time;
if (action_press_time > _21_SECONDS)
step = setting->step * 1000000.0f;
else if (action_press_time > _18_SECONDS)
step = setting->step * 100000.0f;
else if (action_press_time > _15_SECONDS)
step = setting->step * 10000.0f;
else if (action_press_time > _12_SECONDS)
step = setting->step * 1000.0f;
else if (action_press_time > _9_SECONDS)
step = setting->step * 100.0f;
else if (action_press_time > _6_SECONDS)
step = setting->step * 10.0f;
else if (action_press_time > _3_SECONDS)
step = setting->step * 5.0f;
else
step = setting->step;
}
float step = setting->step;
struct menu_state *menu_st = menu_state_get_ptr();
retro_time_t action_press_time = menu_st->action_press_time;
if (action_press_time > _21_SECONDS)
step = setting->step * 1000000.0f;
else if (action_press_time > _18_SECONDS)
step = setting->step * 100000.0f;
else if (action_press_time > _15_SECONDS)
step = setting->step * 10000.0f;
else if (action_press_time > _12_SECONDS)
step = setting->step * 1000.0f;
else if (action_press_time > _9_SECONDS)
step = setting->step * 100.0f;
else if (action_press_time > _6_SECONDS)
step = setting->step * 10.0f;
else if (action_press_time > _3_SECONDS)
step = setting->step * 5.0f;
else
step = setting->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();
bool focused = false;
input_bits_t trigger_input = current_bits;
global_t *global = global_get_ptr();
unsigned screensaver_timeout = settings->uints.menu_screensaver_timeout;
/* Get current time */
@ -14846,45 +14845,42 @@ static enum runloop_state_enum runloop_check_state(
focused = focused &&
!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)
global->menu.noop_press_time = press_time - global->menu.noop_start_time;
else
global->menu.action_press_time = press_time - global->menu.action_start_time;
}
else
{
if (action == MENU_ACTION_NOOP)
{
global->menu.noop_start_time = current_time;
global->menu.noop_press_time = 0;
if (action == MENU_ACTION_NOOP)
menu_st->noop_press_time = press_time - menu_st->noop_start_time;
else
menu_st->action_press_time = press_time - menu_st->action_start_time;
}
else
{
if (action == MENU_ACTION_NOOP)
{
menu_st->noop_start_time = current_time;
menu_st->noop_press_time = 0;
if (global->menu_prev_action == old_action)
global->menu.action_start_time = global->menu.prev_start_time;
else
global->menu.action_start_time = current_time;
}
else
{
if ( global->menu_prev_action == action &&
global->menu.noop_press_time < 200000) /* 250ms */
{
global->menu.action_start_time = global->menu.prev_start_time;
global->menu.action_press_time = current_time - global->menu.action_start_time;
}
else
{
global->menu.prev_start_time = current_time;
global->menu_prev_action = action;
global->menu.action_press_time = 0;
}
}
}
if (menu_st->prev_action == old_action)
menu_st->action_start_time = menu_st->prev_start_time;
else
menu_st->action_start_time = current_time;
}
else
{
if ( menu_st->prev_action == action &&
menu_st->noop_press_time < 200000) /* 250ms */
{
menu_st->action_start_time = menu_st->prev_start_time;
menu_st->action_press_time = current_time - menu_st->action_start_time;
}
else
{
menu_st->prev_start_time = current_time;
menu_st->prev_action = action;
menu_st->action_press_time = 0;
}
}
}
/* Check whether menu screensaver should be enabled */

View File

@ -332,16 +332,6 @@ typedef struct rarch_resolution
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
{
char *remapfile;
@ -399,9 +389,6 @@ typedef struct global
bool old_libretro_device_set;
bool remapping_cache_active;
/* Settings and/or global states specific to menus */
#ifdef HAVE_MENU
enum menu_action menu_prev_action;
#endif
bool launched_from_cli;
bool cli_load_menu_on_error;
} global_t;