mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Merge pull request #1603 from fr500/master
Override and remap improvements #2
This commit is contained in:
commit
4b01483482
@ -1656,7 +1656,7 @@ bool config_load_override(void)
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
//early return in case a library isn't loaded
|
||||
if(!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core"))
|
||||
if (!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core"))
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Game name: %s\n",global->basename);
|
||||
@ -1701,6 +1701,11 @@ bool config_load_override(void)
|
||||
// If a core override exists, add it's location to append_config_path
|
||||
if (new_conf)
|
||||
{
|
||||
if (settings->core_specific_config)
|
||||
{
|
||||
RARCH_LOG("Can't use overrides in conjunction with per-core configs, disabling overrides\n");
|
||||
return false;
|
||||
}
|
||||
RARCH_LOG("Core-specific overrides found at %s. Appending.\n", core_path);
|
||||
strlcpy(global->append_config_path, core_path, sizeof(global->append_config_path));
|
||||
should_append = true;
|
||||
@ -1716,8 +1721,13 @@ bool config_load_override(void)
|
||||
// If a game override exists, add it's location to append_config_path
|
||||
if (new_conf)
|
||||
{
|
||||
if (settings->core_specific_config)
|
||||
{
|
||||
RARCH_LOG("Can't use overrides in conjunction with per-core configs, disabling overrides\n");
|
||||
return false;
|
||||
}
|
||||
RARCH_LOG("Game-specific overrides found at %s. Appending.\n", game_path);
|
||||
if(should_append)
|
||||
if (should_append)
|
||||
{
|
||||
strlcat(global->append_config_path, "|", sizeof(global->append_config_path));
|
||||
strlcat(global->append_config_path, game_path, sizeof(global->append_config_path));
|
||||
@ -1731,10 +1741,13 @@ bool config_load_override(void)
|
||||
RARCH_LOG("No game-specific overrides found at %s.\n", game_path);
|
||||
|
||||
// Re-load the configuration with any overrides that might have been found
|
||||
if(should_append)
|
||||
if (should_append)
|
||||
{
|
||||
if(config_load_file(global->config_path, false))
|
||||
if (config_load_file(global->config_path, false))
|
||||
{
|
||||
rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1788,7 +1801,7 @@ bool config_load_remap(void)
|
||||
settings_t *settings = config_get_ptr(); /* config pointer */
|
||||
|
||||
//early return in case a library isn't loaded or remapping is disabled
|
||||
if(!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core"))
|
||||
if (!global->system.info.library_name || !strcmp(global->system.info.library_name,"No Core"))
|
||||
return false;
|
||||
|
||||
RARCH_LOG("Game name: %s\n",global->basename);
|
||||
@ -1824,10 +1837,13 @@ bool config_load_remap(void)
|
||||
if (new_conf)
|
||||
{
|
||||
RARCH_LOG("Game-specific remap found at %s. Appending.\n", game_path);
|
||||
if(input_remapping_load_file(game_path))
|
||||
if (input_remapping_load_file(game_path))
|
||||
{
|
||||
rarch_main_msg_queue_push("Game remap file loaded", 1, 100, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
RARCH_LOG("No core-specific remap found at %s.\n", core_path);
|
||||
*settings->input.remapping_path= '\0';
|
||||
@ -1843,8 +1859,11 @@ bool config_load_remap(void)
|
||||
if (new_conf)
|
||||
{
|
||||
RARCH_LOG("Core-specific remap found at %s. Loading.\n", core_path);
|
||||
if(input_remapping_load_file(core_path))
|
||||
if (input_remapping_load_file(core_path))
|
||||
{
|
||||
rarch_main_msg_queue_push("Core remap file loaded", 1, 100, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1852,7 +1871,6 @@ bool config_load_remap(void)
|
||||
*settings->input.remapping_path= '\0';
|
||||
input_remapping_set_defaults();
|
||||
}
|
||||
|
||||
|
||||
new_conf = NULL;
|
||||
|
||||
@ -2131,6 +2149,9 @@ bool config_save_file(const char *path)
|
||||
settings->load_dummy_on_core_shutdown);
|
||||
config_set_bool(conf, "fps_show", settings->fps_show);
|
||||
config_set_bool(conf, "ui_menubar_enable", settings->ui.menubar_enable);
|
||||
config_set_path(conf, "libretro_path", settings->libretro);
|
||||
config_set_path(conf, "core_options_path", settings->core_options_path);
|
||||
|
||||
config_set_bool(conf, "suspend_screensaver_enable", settings->ui.suspend_screensaver_enable);
|
||||
config_set_path(conf, "libretro_directory", settings->libretro_directory);
|
||||
config_set_path(conf, "libretro_info_path", settings->libretro_info_path);
|
||||
|
@ -69,9 +69,12 @@ bool input_remapping_load_file(const char *path)
|
||||
* @path : Path to remapping file (relative path).
|
||||
*
|
||||
* Saves remapping values to file.
|
||||
*
|
||||
* Returns: true (1) if successfull, otherwise false (0).
|
||||
**/
|
||||
void input_remapping_save_file(const char *path)
|
||||
bool input_remapping_save_file(const char *path)
|
||||
{
|
||||
bool ret;
|
||||
unsigned i, j;
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
char remap_file[PATH_MAX_LENGTH];
|
||||
@ -86,10 +89,10 @@ void input_remapping_save_file(const char *path)
|
||||
conf = config_file_new(remap_file);
|
||||
|
||||
if (!conf)
|
||||
{
|
||||
conf = config_file_new(NULL);
|
||||
|
||||
if (!conf)
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
{
|
||||
@ -106,8 +109,10 @@ void input_remapping_save_file(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
config_file_write(conf, remap_file);
|
||||
ret = config_file_write(conf, remap_file);
|
||||
config_file_free(conf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void input_remapping_set_defaults(void)
|
||||
|
@ -39,8 +39,10 @@ bool input_remapping_load_file(const char *path);
|
||||
* @path : Path to remapping file (relative path).
|
||||
*
|
||||
* Saves remapping values to file.
|
||||
*
|
||||
* Returns: true (1) if successfull, otherwise false (0).
|
||||
**/
|
||||
void input_remapping_save_file(const char *path);
|
||||
bool input_remapping_save_file(const char *path);
|
||||
|
||||
void input_remapping_set_defaults(void);
|
||||
|
||||
|
@ -127,7 +127,7 @@ static int action_ok_shader_pass(const char *path,
|
||||
|
||||
return menu_list_push_stack_refresh(
|
||||
menu->menu_list,
|
||||
settings->video.shader_dir,
|
||||
settings->video.shader_dir,
|
||||
label,
|
||||
type,
|
||||
idx);
|
||||
@ -183,7 +183,7 @@ static int action_ok_shader_preset(const char *path,
|
||||
|
||||
return menu_list_push_stack_refresh(
|
||||
menu->menu_list,
|
||||
settings->video.shader_dir,
|
||||
settings->video.shader_dir,
|
||||
label, type, idx);
|
||||
}
|
||||
|
||||
@ -528,14 +528,18 @@ static int action_ok_remap_file_save_core(const char *path,
|
||||
|
||||
char directory[PATH_MAX_LENGTH];
|
||||
char file[PATH_MAX_LENGTH];
|
||||
|
||||
|
||||
fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH);
|
||||
fill_pathname_join(file,core_name,core_name,PATH_MAX_LENGTH);
|
||||
|
||||
|
||||
if(!path_file_exists(directory))
|
||||
path_mkdir(directory);
|
||||
|
||||
input_remapping_save_file(file);
|
||||
|
||||
if(input_remapping_save_file(file))
|
||||
rarch_main_msg_queue_push("Remap file saved successfully", 1, 100, true);
|
||||
else
|
||||
rarch_main_msg_queue_push("Error saving remap file", 1, 100, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -547,20 +551,24 @@ static int action_ok_remap_file_save_game(const char *path,
|
||||
|
||||
const char *core_name;
|
||||
core_name = global->system.info.library_name;
|
||||
|
||||
|
||||
const char *game_name;
|
||||
game_name = path_basename(global->basename);
|
||||
|
||||
char directory[PATH_MAX_LENGTH];
|
||||
char file[PATH_MAX_LENGTH];
|
||||
|
||||
|
||||
fill_pathname_join(directory,settings->input_remapping_directory,core_name,PATH_MAX_LENGTH);
|
||||
fill_pathname_join(file,core_name,game_name,PATH_MAX_LENGTH);
|
||||
|
||||
|
||||
if(!path_file_exists(directory))
|
||||
path_mkdir(directory);
|
||||
|
||||
input_remapping_save_file(file);
|
||||
|
||||
if(input_remapping_save_file(file))
|
||||
rarch_main_msg_queue_push("Remap file saved successfully", 1, 100, true);
|
||||
else
|
||||
rarch_main_msg_queue_push("Error saving remap file", 1, 100, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1087,7 +1095,7 @@ static int action_ok_rdb_entry_submenu(const char *path,
|
||||
if (!label)
|
||||
return -1;
|
||||
|
||||
str_list = string_split(label, "|");
|
||||
str_list = string_split(label, "|");
|
||||
|
||||
if (!str_list)
|
||||
return -1;
|
||||
@ -1161,7 +1169,7 @@ static int action_ok_video_resolution(const char *path,
|
||||
{
|
||||
unsigned width = 0, height = 0;
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
|
||||
(void)global;
|
||||
(void)width;
|
||||
(void)height;
|
||||
@ -1324,7 +1332,7 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
|
||||
else if (!strcmp(label, "remap_file_save_core"))
|
||||
cbs->action_ok = action_ok_remap_file_save_core;
|
||||
else if (!strcmp(label, "remap_file_save_game"))
|
||||
cbs->action_ok = action_ok_remap_file_save_game;
|
||||
cbs->action_ok = action_ok_remap_file_save_game;
|
||||
else if (!strcmp(label, "core_list"))
|
||||
cbs->action_ok = action_ok_core_list;
|
||||
else if (!strcmp(label, "disk_image_append"))
|
||||
@ -1391,7 +1399,7 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
|
||||
case MENU_FILE_RDB:
|
||||
if (!strcmp(menu_label, "deferred_database_manager_list"))
|
||||
cbs->action_ok = action_ok_database_manager_list_deferred;
|
||||
else if (!strcmp(menu_label, "database_manager_list")
|
||||
else if (!strcmp(menu_label, "database_manager_list")
|
||||
|| !strcmp(menu_label, "Horizontal Menu"))
|
||||
cbs->action_ok = action_ok_database_manager_list;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user