mirror of
https://github.com/libretro/RetroArch
synced 2025-02-13 21:40:27 +00:00
Cleanups
This commit is contained in:
parent
f1cf5ceb82
commit
3841fecc59
@ -2357,7 +2357,8 @@ void config_set_defaults(void *data)
|
||||
|
||||
input_config_reset();
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
input_remapping_set_defaults(true);
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
#endif
|
||||
|
||||
/* Verify that binds are in proper order. */
|
||||
@ -3771,7 +3772,7 @@ bool config_load_remap(const char *directory_input_remapping,
|
||||
sizeof(game_path));
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
input_remapping_set_defaults(false);
|
||||
input_remapping_set_defaults();
|
||||
#endif
|
||||
|
||||
/* If a game remap file exists, load it. */
|
||||
@ -4533,7 +4534,10 @@ bool input_remapping_load_file(void *data, const char *path)
|
||||
return false;
|
||||
|
||||
if (!string_is_empty(global->name.remapfile))
|
||||
input_remapping_set_defaults(true);
|
||||
{
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
global->name.remapfile = strdup(path);
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
@ -4740,54 +4744,6 @@ bool input_remapping_remove_file(const char *path,
|
||||
|
||||
return filestream_delete(remap_file) == 0 ? true : false;
|
||||
}
|
||||
|
||||
void input_remapping_set_defaults(bool deinit)
|
||||
{
|
||||
unsigned i, j;
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!global)
|
||||
return;
|
||||
|
||||
if (deinit)
|
||||
{
|
||||
if (!string_is_empty(global->name.remapfile))
|
||||
free(global->name.remapfile);
|
||||
global->name.remapfile = NULL;
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL);
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CONTENT_DIR_ACTIVE, NULL);
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 8; j++)
|
||||
{
|
||||
if (j < RARCH_FIRST_CUSTOM_BIND)
|
||||
{
|
||||
const struct retro_keybind *keybind = &input_config_binds[i][j];
|
||||
if (keybind)
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_remap_ids[i][j], keybind->id);
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_keymapper_ids[i][j], RETROK_UNKNOWN);
|
||||
}
|
||||
else
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_remap_ids[i][j], j);
|
||||
}
|
||||
|
||||
if (global->old_analog_dpad_mode[i])
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_analog_dpad_mode[i],
|
||||
global->old_analog_dpad_mode[i]);
|
||||
if (global->old_libretro_device[i])
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_libretro_device[i],
|
||||
global->old_libretro_device[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_DYNAMIC)
|
||||
|
@ -48,7 +48,9 @@ bool input_remapping_save_file(const char *path);
|
||||
bool input_remapping_remove_file(const char *path,
|
||||
const char *dir_input_remapping);
|
||||
|
||||
void input_remapping_set_defaults(bool deinit);
|
||||
void input_remapping_deinit(void);
|
||||
|
||||
void input_remapping_set_defaults(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -3411,22 +3411,22 @@ static int generic_action_ok_remap_file_operation(const char *path,
|
||||
case ACTION_OK_REMAP_FILE_REMOVE_CORE:
|
||||
if (rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL))
|
||||
{
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL);
|
||||
input_remapping_set_defaults(true);
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
break;
|
||||
case ACTION_OK_REMAP_FILE_REMOVE_GAME:
|
||||
if (rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL))
|
||||
{
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE, NULL);
|
||||
input_remapping_set_defaults(true);
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
break;
|
||||
case ACTION_OK_REMAP_FILE_REMOVE_CONTENT_DIR:
|
||||
if (rarch_ctl(RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE, NULL))
|
||||
{
|
||||
rarch_ctl(RARCH_CTL_UNSET_REMAPS_CONTENT_DIR_ACTIVE, NULL);
|
||||
input_remapping_set_defaults(true);
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ static int action_start_remap_file_load(
|
||||
unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
input_remapping_set_defaults(true);
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
76
retroarch.c
76
retroarch.c
@ -12063,6 +12063,46 @@ static void command_event_disable_overrides(struct rarch_state *p_rarch)
|
||||
config_unload_override();
|
||||
p_rarch->runloop_overrides_active = false;
|
||||
}
|
||||
|
||||
void input_remapping_set_defaults(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
settings_t *settings = p_rarch->configuration_settings;
|
||||
global_t *global = &p_rarch->g_extern;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
||||
{
|
||||
const struct retro_keybind *keybind = &input_config_binds[i][j];
|
||||
if (keybind)
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_remap_ids[i][j], keybind->id);
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_keymapper_ids[i][j], RETROK_UNKNOWN);
|
||||
}
|
||||
|
||||
for (j = RARCH_FIRST_CUSTOM_BIND; j < (RARCH_FIRST_CUSTOM_BIND + 8); j++)
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_remap_ids[i][j], j);
|
||||
}
|
||||
|
||||
if (global)
|
||||
{
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
if (global->old_analog_dpad_mode[i])
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_analog_dpad_mode[i],
|
||||
global->old_analog_dpad_mode[i]);
|
||||
if (global->old_libretro_device[i])
|
||||
configuration_set_uint(settings,
|
||||
settings->uints.input_libretro_device[i],
|
||||
global->old_libretro_device[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void command_event_deinit_core(
|
||||
@ -12099,7 +12139,10 @@ static void command_event_deinit_core(
|
||||
|| p_rarch->runloop_remaps_content_dir_active
|
||||
|| p_rarch->runloop_remaps_game_active
|
||||
)
|
||||
input_remapping_set_defaults(true);
|
||||
{
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -13015,6 +13058,18 @@ static bool command_event_resize_windowed_scale(struct rarch_state *p_rarch)
|
||||
return true;
|
||||
}
|
||||
|
||||
void input_remapping_deinit(void)
|
||||
{
|
||||
struct rarch_state *p_rarch = &rarch_st;
|
||||
global_t *global = &p_rarch->g_extern;
|
||||
if (!string_is_empty(global->name.remapfile))
|
||||
free(global->name.remapfile);
|
||||
global->name.remapfile = NULL;
|
||||
p_rarch->runloop_remaps_core_active = false;
|
||||
p_rarch->runloop_remaps_content_dir_active = false;
|
||||
p_rarch->runloop_remaps_game_active = false;
|
||||
}
|
||||
|
||||
static bool input_driver_grab_mouse(struct rarch_state *p_rarch)
|
||||
{
|
||||
if (!p_rarch->current_input || !p_rarch->current_input->grab_mouse)
|
||||
@ -13592,7 +13647,10 @@ bool command_event(enum event_command cmd, void *data)
|
||||
|| p_rarch->runloop_remaps_content_dir_active
|
||||
|| p_rarch->runloop_remaps_game_active
|
||||
)
|
||||
input_remapping_set_defaults(true);
|
||||
{
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (is_inited)
|
||||
@ -35984,25 +36042,16 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||
case RARCH_CTL_SET_REMAPS_CORE_ACTIVE:
|
||||
p_rarch->runloop_remaps_core_active = true;
|
||||
break;
|
||||
case RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE:
|
||||
p_rarch->runloop_remaps_core_active = false;
|
||||
break;
|
||||
case RARCH_CTL_IS_REMAPS_CORE_ACTIVE:
|
||||
return p_rarch->runloop_remaps_core_active;
|
||||
case RARCH_CTL_SET_REMAPS_GAME_ACTIVE:
|
||||
p_rarch->runloop_remaps_game_active = true;
|
||||
break;
|
||||
case RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE:
|
||||
p_rarch->runloop_remaps_game_active = false;
|
||||
break;
|
||||
case RARCH_CTL_IS_REMAPS_GAME_ACTIVE:
|
||||
return p_rarch->runloop_remaps_game_active;
|
||||
case RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE:
|
||||
p_rarch->runloop_remaps_content_dir_active = true;
|
||||
break;
|
||||
case RARCH_CTL_UNSET_REMAPS_CONTENT_DIR_ACTIVE:
|
||||
p_rarch->runloop_remaps_content_dir_active = false;
|
||||
break;
|
||||
case RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE:
|
||||
return p_rarch->runloop_remaps_content_dir_active;
|
||||
#endif
|
||||
@ -36623,7 +36672,10 @@ bool retroarch_main_quit(void)
|
||||
|| p_rarch->runloop_remaps_content_dir_active
|
||||
|| p_rarch->runloop_remaps_game_active
|
||||
)
|
||||
input_remapping_set_defaults(true);
|
||||
{
|
||||
input_remapping_deinit();
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -123,15 +123,12 @@ enum rarch_ctl_state
|
||||
|
||||
RARCH_CTL_IS_REMAPS_CORE_ACTIVE,
|
||||
RARCH_CTL_SET_REMAPS_CORE_ACTIVE,
|
||||
RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE,
|
||||
|
||||
RARCH_CTL_IS_REMAPS_CONTENT_DIR_ACTIVE,
|
||||
RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE,
|
||||
RARCH_CTL_UNSET_REMAPS_CONTENT_DIR_ACTIVE,
|
||||
|
||||
RARCH_CTL_IS_REMAPS_GAME_ACTIVE,
|
||||
RARCH_CTL_SET_REMAPS_GAME_ACTIVE,
|
||||
RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE,
|
||||
#endif
|
||||
|
||||
RARCH_CTL_IS_MISSING_BIOS,
|
||||
|
Loading…
x
Reference in New Issue
Block a user