add remap saving, add new variables

This commit is contained in:
radius 2018-05-13 16:20:51 -05:00
parent 908d9b315b
commit 16c33b4f42
3 changed files with 60 additions and 2 deletions

View File

@ -261,10 +261,12 @@ static bool quick_menu_show_options = true;
static bool quick_menu_show_controls = true; static bool quick_menu_show_controls = true;
static bool quick_menu_show_cheats = true; static bool quick_menu_show_cheats = true;
static bool quick_menu_show_shaders = true; static bool quick_menu_show_shaders = true;
static bool quick_menu_show_save_core_overrides = true;
static bool quick_menu_show_save_game_overrides = true;
static bool quick_menu_show_information = true; static bool quick_menu_show_information = true;
static bool quick_menu_show_save_core_overrides = true;
static bool quick_menu_show_save_game_overrides = true;
static bool quick_menu_show_save_content_dir_overrides = true;
static bool kiosk_mode_enable = false; static bool kiosk_mode_enable = false;
static bool menu_show_online_updater = true; static bool menu_show_online_updater = true;

View File

@ -3171,11 +3171,16 @@ bool config_load_remap(void)
char *remap_directory = NULL; char *remap_directory = NULL;
char *core_path = NULL; char *core_path = NULL;
char *game_path = NULL; char *game_path = NULL;
char *content_path = NULL;
config_file_t *new_conf = NULL; config_file_t *new_conf = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info(); rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ? system->info.library_name : NULL; const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
if (string_is_empty(core_name) || string_is_empty(game_name)) if (string_is_empty(core_name) || string_is_empty(game_name))
return false; return false;
@ -3194,8 +3199,12 @@ bool config_load_remap(void)
/* final path for game-specific configuration (prefix+suffix) */ /* final path for game-specific configuration (prefix+suffix) */
game_path = (char*) game_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char)); malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for content-dir-specific configuration (prefix+suffix) */
content_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
remap_directory[0] = core_path[0] = game_path[0] = '\0'; remap_directory[0] = core_path[0] = game_path[0] = '\0';
strlcpy(remap_directory, strlcpy(remap_directory,
settings->paths.directory_input_remapping, settings->paths.directory_input_remapping,
path_size); path_size);
@ -3208,6 +3217,12 @@ bool config_load_remap(void)
file_path_str(FILE_PATH_REMAP_EXTENSION), file_path_str(FILE_PATH_REMAP_EXTENSION),
path_size); path_size);
fill_pathname_join_special_ext(content_path,
remap_directory, core_name,
content_dir_name,
file_path_str(FILE_PATH_REMAP_EXTENSION),
path_size);
fill_pathname_join_special_ext(game_path, fill_pathname_join_special_ext(game_path,
remap_directory, core_name, remap_directory, core_name,
game_name, game_name,
@ -3235,6 +3250,28 @@ bool config_load_remap(void)
input_remapping_set_defaults(false); input_remapping_set_defaults(false);
} }
/* Create a new config file from content_path */
new_conf = config_file_new(content_path);
/* If a content-dir remap file exists, load it. */
if (new_conf)
{
RARCH_LOG("Remaps: content-dir-specific remap found at %s.\n", content_path);
if (input_remapping_load_file(new_conf, content_path))
{
runloop_msg_queue_push(msg_hash_to_str(
MSG_GAME_REMAP_FILE_LOADED), 1, 100, true);
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
goto success;
}
}
else
{
RARCH_LOG("Remaps: no content-dir-specific remap found at %s.\n", content_path);
input_remapping_set_defaults(false);
}
/* Create a new config file from core_path */ /* Create a new config file from core_path */
new_conf = config_file_new(core_path); new_conf = config_file_new(core_path);
@ -4087,6 +4124,7 @@ bool config_save_overrides(int override_type)
char *override_directory = NULL; char *override_directory = NULL;
char *core_path = NULL; char *core_path = NULL;
char *game_path = NULL; char *game_path = NULL;
char *content_path = NULL;
settings_t *overrides = config_get_ptr(); settings_t *overrides = config_get_ptr();
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder); int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder); int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
@ -4097,6 +4135,10 @@ bool config_save_overrides(int override_type)
rarch_system_info_t *system = runloop_get_system_info(); rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ? system->info.library_name : NULL; const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME)); const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
if (string_is_empty(core_name) || string_is_empty(game_name)) if (string_is_empty(core_name) || string_is_empty(game_name))
return false; return false;
@ -4106,6 +4148,7 @@ bool config_save_overrides(int override_type)
override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
content_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0'; config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0';
@ -4125,6 +4168,12 @@ bool config_save_overrides(int override_type)
file_path_str(FILE_PATH_CONFIG_EXTENSION), file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size); path_size);
fill_pathname_join_special_ext(content_path,
config_directory, core_name,
content_dir_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
fill_pathname_join_special_ext(core_path, fill_pathname_join_special_ext(core_path,
config_directory, core_name, config_directory, core_name,
core_name, core_name,
@ -4288,6 +4337,11 @@ bool config_save_overrides(int override_type)
RARCH_LOG ("[overrides] path %s\n", game_path); RARCH_LOG ("[overrides] path %s\n", game_path);
ret = config_file_write(conf, game_path); ret = config_file_write(conf, game_path);
break; break;
case OVERRIDE_CONTENT_DIR:
/* Create a new config file from content_path */
RARCH_LOG ("[overrides] path %s\n", content_path);
ret = config_file_write(conf, content_path);
break;
default: default:
break; break;
} }

View File

@ -57,6 +57,7 @@ enum override_type
{ {
OVERRIDE_NONE = 0, OVERRIDE_NONE = 0,
OVERRIDE_CORE, OVERRIDE_CORE,
OVERRIDE_CONTENT_DIR,
OVERRIDE_GAME OVERRIDE_GAME
}; };
@ -177,6 +178,7 @@ typedef struct settings
bool quick_menu_show_shaders; bool quick_menu_show_shaders;
bool quick_menu_show_save_core_overrides; bool quick_menu_show_save_core_overrides;
bool quick_menu_show_save_game_overrides; bool quick_menu_show_save_game_overrides;
bool quick_menu_show_save_content_dir_overrides;
bool quick_menu_show_information; bool quick_menu_show_information;
bool kiosk_mode_enable; bool kiosk_mode_enable;