Skip to content

Commit 7c3d07b

Browse files
authored
Tweaks to how the "Analog to Digital Type" setting is saved (#16187)
1 parent f6502b8 commit 7c3d07b

File tree

4 files changed

+27
-20
lines changed

4 files changed

+27
-20
lines changed

input/input_driver.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6062,7 +6062,7 @@ void input_remapping_cache_global_config(void)
60626062
| INP_FLAG_OLD_LIBRETRO_DEVICE_SET;
60636063
}
60646064

6065-
void input_remapping_restore_global_config(bool clear_cache)
6065+
void input_remapping_restore_global_config(bool clear_cache, bool restore_analog_dpad_mode)
60666066
{
60676067
unsigned i;
60686068
settings_t *settings = config_get_ptr();
@@ -6073,7 +6073,8 @@ void input_remapping_restore_global_config(bool clear_cache)
60736073

60746074
for (i = 0; i < MAX_USERS; i++)
60756075
{
6076-
if ((input_st->flags & INP_FLAG_OLD_ANALOG_DPAD_MODE_SET)
6076+
if ( (input_st->flags & INP_FLAG_OLD_ANALOG_DPAD_MODE_SET)
6077+
&& restore_analog_dpad_mode
60776078
&& (settings->uints.input_analog_dpad_mode[i] !=
60786079
input_st->old_analog_dpad_mode[i]))
60796080
configuration_set_uint(settings,
@@ -6195,7 +6196,7 @@ void input_remapping_set_defaults(bool clear_cache)
61956196
* the last core init
61966197
* > Prevents remap changes from 'bleeding through'
61976198
* into the main config file */
6198-
input_remapping_restore_global_config(clear_cache);
6199+
input_remapping_restore_global_config(clear_cache, true);
61996200
}
62006201

62016202
void input_driver_collect_system_input(input_driver_state_t *input_st,

input/input_remapping.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ void input_remapping_cache_global_config(void);
5858
* init if INP_FLAG_REMAPPING_CACHE_ACTIVE is set.
5959
* Must be called on core deinitialization.
6060
*
61-
* @param clear_cache If true, function becomes a NOOP until the next time
62-
* `input_remapping_cache_global_config()` is called, and
63-
* INP_FLAG_REMAPPING_CACHE_ACTIVE is set.
61+
* @param clear_cache If true, function becomes a NOOP until the next time
62+
* `input_remapping_cache_global_config()` is called, and
63+
* INP_FLAG_REMAPPING_CACHE_ACTIVE is set.
64+
* @param restore_analog_dpad_mode Treat 'Analog to Digital Type' like a regular setting,
65+
* meaning this should be false when we're not using any
66+
* remap file so its value is saved globally on close/quit,
67+
* and it should be true when we're using a remap or if
68+
* we're resetting settings, to restore its global value.
6469
*/
65-
void input_remapping_restore_global_config(bool clear_cache);
70+
void input_remapping_restore_global_config(bool clear_cache, bool restore_analog_dpad_mode);
6671

6772
/**
6873
* Must be called whenever `settings->uints.input_remap_ports` is modified.

retroarch.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,7 +3666,7 @@ bool command_event(enum event_command cmd, void *data)
36663666
input_remapping_set_defaults(true);
36673667
}
36683668
else
3669-
input_remapping_restore_global_config(true);
3669+
input_remapping_restore_global_config(true, false);
36703670

36713671
#ifdef HAVE_CONFIGFILE
36723672
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
@@ -7578,7 +7578,7 @@ bool retroarch_main_init(int argc, char *argv[])
75787578
input_remapping_set_defaults(true);
75797579
}
75807580
else
7581-
input_remapping_restore_global_config(true);
7581+
input_remapping_restore_global_config(true, false);
75827582

75837583
#ifdef HAVE_CONFIGFILE
75847584
/* Reload the original config */
@@ -8155,15 +8155,6 @@ bool retroarch_main_quit(void)
81558155
}
81568156
if (!(runloop_st->flags & RUNLOOP_FLAG_SHUTDOWN_INITIATED))
81578157
{
8158-
/* Save configs before quitting
8159-
* as for UWP depending on `OnSuspending` is not important as we can call it directly here
8160-
* specifically we need to get width,height which requires UI thread and it will not be available on exit
8161-
*/
8162-
#if defined(HAVE_DYNAMIC)
8163-
if (config_save_on_exit)
8164-
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
8165-
#endif
8166-
81678158
if (settings->bools.savestate_auto_save &&
81688159
runloop_st->current_core_type != CORE_TYPE_DUMMY)
81698160
command_event_save_auto_state();
@@ -8183,7 +8174,7 @@ bool retroarch_main_quit(void)
81838174
input_remapping_set_defaults(true);
81848175
}
81858176
else
8186-
input_remapping_restore_global_config(true);
8177+
input_remapping_restore_global_config(true, false);
81878178

81888179
#ifdef HAVE_CONFIGFILE
81898180
if (runloop_st->flags & RUNLOOP_FLAG_OVERRIDES_ACTIVE)
@@ -8192,6 +8183,16 @@ bool retroarch_main_quit(void)
81928183
config_unload_override();
81938184
}
81948185
#endif
8186+
8187+
/* Save configs before quitting
8188+
* as for UWP depending on `OnSuspending` is not important as we can call it directly here
8189+
* specifically we need to get width,height which requires UI thread and it will not be available on exit
8190+
*/
8191+
#if defined(HAVE_DYNAMIC)
8192+
if (config_save_on_exit)
8193+
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
8194+
#endif
8195+
81958196
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
81968197
runloop_st->runtime_shader_preset_path[0] = '\0';
81978198
#endif

runloop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4088,7 +4088,7 @@ void runloop_event_deinit_core(void)
40884088
input_remapping_set_defaults(true);
40894089
}
40904090
else
4091-
input_remapping_restore_global_config(true);
4091+
input_remapping_restore_global_config(true, false);
40924092

40934093
RARCH_LOG("[Core]: Unloading core symbols..\n");
40944094
uninit_libretro_symbols(&runloop_st->current_core);

0 commit comments

Comments
 (0)