Skip to content

Commit 67ade86

Browse files
committed
input remapping: reset in-memory state on every content load (fix d4c8611 incomplete)
Commit d4c8611 ("Fix remapping default reset on close content") added a defaults-reset to config_load_remap, but the new branch fires only when sys_info->info.library_name is empty. In the reproducer reported against the original 9eb083a regression (open content -> unbind ABXY in Quick Menu without saving a remap file -> close content -> reopen same content), the core is reinitialized and runloop_event_init_core() calls retro_get_system_info() at runloop.c:4745 BEFORE the config_load_remap() call at runloop.c:4828. By the time config_load_remap runs, sys_info->info.library_name is already re-populated with the new core's name, so the new guard does not fire, no tier file exists, and the function falls through to 'return false' without ever resetting the per-port input_remap_ids[][] arrays. The unsaved unbinds from the previous session persist into the new one. Move the reset above the early-return guards so it fires on every entry to config_load_remap, regardless of whether a core name is set or a remap directory is configured. This is the load-path counterpart to input_remapping_cache_global_config() in runloop_event_init_core: that function caches global input settings on every content load so they can be restored on unload; this reset clears the per-port remap arrays on every content load so unsaved in-menu edits from a previous session do not bleed through. input_remapping_load_file() already calls input_remapping_set_defaults(false) itself (configuration.c:6986) before applying a tier file's bindings, so the double-reset on the found-file path is harmless - it just clears arrays that are about to be overwritten. The menu remap-file removal sites in menu_cbs_ok.c that 9eb083a was actually targeting are unaffected, since this is the load path, not the delete path.
1 parent 3cbdaa2 commit 67ade86

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

configuration.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5046,15 +5046,25 @@ bool config_load_remap(const char *directory_input_remapping,
50465046
bool notification_show_remap_load = settings->bools.notification_show_remap_load;
50475047
bool sort_remaps_by_controller = settings->bools.input_remap_sort_by_controller_enable;
50485048

5049-
/* Reset defaults if we have no core */
5050-
if (!core_name || !*core_name)
5051-
{
5052-
input_remapping_set_defaults(false);
5053-
return false;
5054-
}
5049+
/* Always reset the in-memory remap state on entry. This is the
5050+
* load-path counterpart to input_remapping_cache_global_config()
5051+
* in runloop.c: when a content load reaches this point, any
5052+
* unsaved per-port edits from a previous session must be
5053+
* cleared before either a tier file is loaded or we fall
5054+
* through with no file (otherwise stale edits persist into
5055+
* the new session, since the unload-paths in runloop /
5056+
* retroarch only call set_defaults when a remap file or
5057+
* REMAPS_*_ACTIVE flag was in effect).
5058+
*
5059+
* If a tier file is found below, input_remapping_load_file()
5060+
* calls input_remapping_set_defaults() itself before applying
5061+
* the file's bindings, so this reset is harmless on the
5062+
* found-file path. */
5063+
input_remapping_set_defaults(false);
50555064

5056-
/* Cannot load remaps if remap directory is unset */
5057-
if (!directory_input_remapping || !*directory_input_remapping)
5065+
/* Cannot load remaps if we have no core or no remap directory */
5066+
if ( (!core_name || !*core_name)
5067+
|| (!directory_input_remapping || !*directory_input_remapping))
50585068
return false;
50595069

50605070
core_path[0] = '\0';

0 commit comments

Comments
 (0)