@@ -4082,6 +4082,21 @@ void runloop_event_deinit_core(void)
40824082 autosave_deinit ();
40834083#endif
40844084
4085+ /* Remap save and cleanup logic should be placed before
4086+ * core_unload_game(), to ensure that input description data
4087+ * does not become invalid before remaps are saved. */
4088+ if ( (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE )
4089+ || (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE )
4090+ || (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE )
4091+ || (runloop_st -> name .remapfile && * runloop_st -> name .remapfile )
4092+ )
4093+ {
4094+ input_remapping_deinit (settings -> bools .remap_save_on_exit );
4095+ input_remapping_set_defaults (true);
4096+ }
4097+ else
4098+ input_remapping_restore_global_config (true, false);
4099+
40854100 core_unload_game ();
40864101
40874102 /* Reset core sensor tracking — the core is going away */
@@ -4114,18 +4129,6 @@ void runloop_event_deinit_core(void)
41144129 runloop_st -> fastmotion_override .pending = false;
41154130 }
41164131
4117- if ( (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_CORE_ACTIVE )
4118- || (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_CONTENT_DIR_ACTIVE )
4119- || (runloop_st -> flags & RUNLOOP_FLAG_REMAPS_GAME_ACTIVE )
4120- || (runloop_st -> name .remapfile && * runloop_st -> name .remapfile )
4121- )
4122- {
4123- input_remapping_deinit (settings -> bools .remap_save_on_exit );
4124- input_remapping_set_defaults (true);
4125- }
4126- else
4127- input_remapping_restore_global_config (true, false);
4128-
41294132 RARCH_LOG ("[Core] Unloading core symbols...\n" );
41304133 uninit_libretro_symbols (& runloop_st -> current_core );
41314134 runloop_st -> current_core .flags &= ~RETRO_CORE_FLAG_SYMBOLS_INITED ;
0 commit comments