Move state from global_t to input_state_t

This commit is contained in:
twinaphex 2021-11-09 06:27:43 +01:00
parent f671ce4f8c
commit f4c5852cfa
3 changed files with 25 additions and 25 deletions

View File

@ -5113,57 +5113,57 @@ const hid_driver_t *input_hid_init_first(void)
void input_remapping_cache_global_config(void)
{
unsigned i;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
for (i = 0; i < MAX_USERS; i++)
{
global->old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i];
global->old_libretro_device[i] = settings->uints.input_libretro_device[i];
input_st->old_analog_dpad_mode[i] = settings->uints.input_analog_dpad_mode[i];
input_st->old_libretro_device[i] = settings->uints.input_libretro_device[i];
}
global->old_analog_dpad_mode_set = true;
global->old_libretro_device_set = true;
input_st->old_analog_dpad_mode_set = true;
input_st->old_libretro_device_set = true;
}
void input_remapping_enable_global_config_restore(void)
{
global_t *global = global_get_ptr();
global->remapping_cache_active = true;
input_driver_state_t *input_st = &input_driver_st;
input_st->remapping_cache_active = true;
}
void input_remapping_restore_global_config(bool clear_cache)
{
unsigned i;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
input_driver_state_t *input_st = &input_driver_st;
if (!global->remapping_cache_active)
if (!input_st->remapping_cache_active)
goto end;
for (i = 0; i < MAX_USERS; i++)
{
if (global->old_analog_dpad_mode_set &&
if (input_st->old_analog_dpad_mode_set &&
(settings->uints.input_analog_dpad_mode[i] !=
global->old_analog_dpad_mode[i]))
input_st->old_analog_dpad_mode[i]))
configuration_set_uint(settings,
settings->uints.input_analog_dpad_mode[i],
global->old_analog_dpad_mode[i]);
input_st->old_analog_dpad_mode[i]);
if (global->old_libretro_device_set &&
if (input_st->old_libretro_device_set &&
(settings->uints.input_libretro_device[i] !=
global->old_libretro_device[i]))
input_st->old_libretro_device[i]))
configuration_set_uint(settings,
settings->uints.input_libretro_device[i],
global->old_libretro_device[i]);
input_st->old_libretro_device[i]);
}
end:
if (clear_cache)
{
global->old_analog_dpad_mode_set = false;
global->old_libretro_device_set = false;
global->remapping_cache_active = false;
input_st->old_analog_dpad_mode_set = false;
input_st->old_libretro_device_set = false;
input_st->remapping_cache_active = false;
}
}

View File

@ -415,6 +415,8 @@ typedef struct
input_mapper_t mapper; /* uint32_t alignment */
input_device_info_t input_device_info[MAX_INPUT_DEVICES]; /* unsigned alignment */
input_mouse_info_t input_mouse_info[MAX_INPUT_DEVICES];
unsigned old_analog_dpad_mode[MAX_USERS];
unsigned old_libretro_device[MAX_USERS];
unsigned osk_last_codepoint;
unsigned osk_last_codepoint_len;
unsigned input_hotkey_block_counter;
@ -437,6 +439,9 @@ typedef struct
bool grab_mouse_state;
bool analog_requested[MAX_USERS];
bool keyboard_mapping_blocked;
bool old_analog_dpad_mode_set;
bool old_libretro_device_set;
bool remapping_cache_active;
retro_bits_512_t keyboard_mapping_bits; /* bool alignment */
input_game_focus_state_t game_focus_state; /* bool alignment */
} input_driver_state_t;

View File

@ -371,11 +371,6 @@ typedef struct global
bool softfilter_enable;
} console;
unsigned old_analog_dpad_mode[MAX_USERS];
unsigned old_libretro_device[MAX_USERS];
bool old_analog_dpad_mode_set;
bool old_libretro_device_set;
bool remapping_cache_active;
/* Settings and/or global states specific to menus */
bool launched_from_cli;
bool cli_load_menu_on_error;