From 6a561f64145ab63cc68b798ca00cecb24ab1a0ca Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 11 Sep 2017 22:49:39 -0500 Subject: [PATCH] input remapping cleanups --- command.c | 2 +- configuration.c | 6 +++--- input/input_remapping.c | 8 +++++++- input/input_remapping.h | 2 +- menu/cbs/menu_cbs_ok.c | 15 ++++++++++++--- menu/cbs/menu_cbs_start.c | 8 +------- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/command.c b/command.c index a53ef71d06..e4abf8477f 100644 --- a/command.c +++ b/command.c @@ -1305,7 +1305,7 @@ static void command_event_restore_default_shader_preset(void) static void command_event_restore_remaps(void) { if (rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL)) - input_remapping_set_defaults(); + input_remapping_set_defaults(true); } static bool command_event_save_auto_state(void) diff --git a/configuration.c b/configuration.c index b0cbe90ee8..3f9a0a0abc 100644 --- a/configuration.c +++ b/configuration.c @@ -1586,7 +1586,7 @@ static void config_set_defaults(void) #endif input_config_reset(); - input_remapping_set_defaults(); + input_remapping_set_defaults(true); input_autoconfigure_reset(); /* Verify that binds are in proper order. */ @@ -3009,7 +3009,7 @@ bool config_load_remap(void) else { RARCH_LOG("Remaps: no game-specific remap found at %s.\n", game_path); - input_remapping_set_defaults(); + input_remapping_set_defaults(false); } /* Create a new config file from core_path */ @@ -3029,7 +3029,7 @@ bool config_load_remap(void) else { RARCH_LOG("Remaps: no core-specific remap found at %s.\n", core_path); - input_remapping_set_defaults(); + input_remapping_set_defaults(false); } new_conf = NULL; diff --git a/input/input_remapping.c b/input/input_remapping.c index 5a0f650ac4..718932d110 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -246,10 +246,16 @@ bool input_remapping_remove_file(const char *path) return ret; } -void input_remapping_set_defaults(void) +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; + + global->name.remapfile[0] = '\0'; for (i = 0; i < MAX_USERS; i++) { diff --git a/input/input_remapping.h b/input/input_remapping.h index 147136f1ef..12316e1115 100644 --- a/input/input_remapping.h +++ b/input/input_remapping.h @@ -47,7 +47,7 @@ bool input_remapping_save_file(const char *path); bool input_remapping_remove_file(const char *path); -void input_remapping_set_defaults(void); +void input_remapping_set_defaults(bool deinit); RETRO_END_DECLS diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 844b50ae3d..0a73387e00 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2141,7 +2141,7 @@ static int generic_action_ok_remap_file_operation(const char *path, { if (action_type == ACTION_OK_REMAP_FILE_SAVE_CORE) rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL); - else + else if (action_type == ACTION_OK_REMAP_FILE_SAVE_GAME) rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL); runloop_msg_queue_push( @@ -2157,10 +2157,19 @@ static int generic_action_ok_remap_file_operation(const char *path, { if(input_remapping_remove_file(file)) { - if (action_type == ACTION_OK_REMAP_FILE_REMOVE_CORE) + if (action_type == ACTION_OK_REMAP_FILE_REMOVE_CORE && + rarch_ctl(RARCH_CTL_IS_REMAPS_CORE_ACTIVE, NULL)) + { rarch_ctl(RARCH_CTL_UNSET_REMAPS_CORE_ACTIVE, NULL); - else + input_remapping_set_defaults(true); + } + + else if (action_type == ACTION_OK_REMAP_FILE_REMOVE_GAME && + rarch_ctl(RARCH_CTL_IS_REMAPS_GAME_ACTIVE, NULL)) + { rarch_ctl(RARCH_CTL_UNSET_REMAPS_GAME_ACTIVE, NULL); + input_remapping_set_defaults(true); + } runloop_msg_queue_push( msg_hash_to_str(MSG_REMAP_FILE_REMOVED_SUCCESSFULLY), diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index e6225eec3b..57e988171c 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -48,13 +48,7 @@ static int action_start_remap_file_load(unsigned type, const char *label) { - global_t *global = global_get_ptr(); - - if (!global) - return -1; - - global->name.remapfile[0] = '\0'; - input_remapping_set_defaults(); + input_remapping_set_defaults(true); return 0; }