mirror of
https://github.com/libretro/RetroArch
synced 2025-03-16 16:21:15 +00:00
commit
ce58b86a86
@ -449,7 +449,7 @@ static void event_init_controllers(void)
|
||||
{
|
||||
/* If we're trying to connect a completely unknown device,
|
||||
* revert back to JOYPAD. */
|
||||
|
||||
|
||||
if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE)
|
||||
{
|
||||
/* Do not fix settings->input.libretro_device[i],
|
||||
@ -484,18 +484,21 @@ static void event_init_controllers(void)
|
||||
static void event_deinit_core(bool reinit)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
pretro_unload_game();
|
||||
pretro_deinit();
|
||||
|
||||
if (reinit)
|
||||
event_command(EVENT_CMD_DRIVERS_DEINIT);
|
||||
|
||||
|
||||
/* auto overrides: reload the original config */
|
||||
if(global->overrides_active)
|
||||
{
|
||||
config_unload_override();
|
||||
global->overrides_active = false;
|
||||
}
|
||||
|
||||
pretro_set_environment(rarch_environment_cb);
|
||||
uninit_libretro_sym();
|
||||
}
|
||||
@ -530,7 +533,7 @@ static bool event_load_save_files(void)
|
||||
for (i = 0; i < global->savefiles->size; i++)
|
||||
load_ram_file(global->savefiles->elems[i].data,
|
||||
global->savefiles->elems[i].attr.i);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -656,6 +659,11 @@ static bool event_init_core(void)
|
||||
driver_t *driver = driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
/* per-core saves: save the original path */
|
||||
strlcpy(orig_savefile_dir,global->savefile_dir,sizeof(orig_savefile_dir));
|
||||
strlcpy(orig_savestate_dir,global->savestate_dir,sizeof(orig_savestate_dir));
|
||||
|
||||
/* auto overrides: apply overrides */
|
||||
if(settings->auto_overrides_enable)
|
||||
{
|
||||
if (config_load_override())
|
||||
@ -664,11 +672,16 @@ static bool event_init_core(void)
|
||||
global->overrides_active = false;
|
||||
}
|
||||
|
||||
pretro_set_environment(rarch_environment_cb);
|
||||
|
||||
pretro_set_environment(rarch_environment_cb);
|
||||
|
||||
/* auto-remap: apply remap files */
|
||||
if(settings->auto_remaps_enable)
|
||||
config_load_remap();
|
||||
|
||||
/* per-core saves: reset redirection paths */
|
||||
if(settings->sort_savestates_enable || settings->sort_savefiles_enable)
|
||||
set_paths_redirect(global->basename);
|
||||
|
||||
rarch_verify_api_version();
|
||||
pretro_init();
|
||||
|
||||
@ -681,6 +694,12 @@ static bool event_init_core(void)
|
||||
retro_init_libretro_cbs(&driver->retro_ctx);
|
||||
rarch_init_system_av_info();
|
||||
|
||||
/* per-core saves: restore the original path so the config is not affected */
|
||||
if(settings->sort_savefiles_enable)
|
||||
strlcpy(global->savefile_dir,orig_savefile_dir,sizeof(global->savefile_dir));
|
||||
if(settings->sort_savestates_enable)
|
||||
strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -701,7 +720,7 @@ static bool event_save_auto_state(void)
|
||||
ret = save_state(savestate_name_auto);
|
||||
RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ?
|
||||
"succeeded" : "failed");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -494,6 +494,9 @@ static bool default_core_specific_config = false;
|
||||
static bool default_auto_overrides_enable = false;
|
||||
static bool default_auto_remaps_enable = false;
|
||||
|
||||
static bool default_sort_savefiles_enable = false;
|
||||
static bool default_sort_savestates_enable = false;
|
||||
|
||||
static unsigned default_menu_btn_ok = RETRO_DEVICE_ID_JOYPAD_A;
|
||||
static unsigned default_menu_btn_cancel = RETRO_DEVICE_ID_JOYPAD_B;
|
||||
static unsigned default_menu_btn_search = RETRO_DEVICE_ID_JOYPAD_X;
|
||||
|
@ -689,6 +689,9 @@ static void config_set_defaults(void)
|
||||
settings->auto_overrides_enable = default_auto_overrides_enable;
|
||||
settings->auto_remaps_enable = default_auto_remaps_enable;
|
||||
|
||||
settings->sort_savefiles_enable = default_sort_savefiles_enable;
|
||||
settings->sort_savestates_enable = default_sort_savestates_enable;
|
||||
|
||||
settings->menu_ok_btn = default_menu_btn_ok;
|
||||
settings->menu_cancel_btn = default_menu_btn_cancel;
|
||||
settings->menu_search_btn = default_menu_btn_search;
|
||||
@ -1620,6 +1623,9 @@ static bool config_load_file(const char *path, bool set_defaults)
|
||||
CONFIG_GET_BOOL_BASE(conf, settings, auto_overrides_enable, "auto_overrides_enable");
|
||||
CONFIG_GET_BOOL_BASE(conf, settings, auto_remaps_enable, "auto_remaps_enable");
|
||||
|
||||
CONFIG_GET_BOOL_BASE(conf, settings, sort_savefiles_enable, "sort_savefiles_enable");
|
||||
CONFIG_GET_BOOL_BASE(conf, settings, sort_savestates_enable, "sort_savestates_enable");
|
||||
|
||||
CONFIG_GET_INT_BASE(conf, settings, menu_ok_btn, "menu_ok_btn");
|
||||
CONFIG_GET_INT_BASE(conf, settings, menu_cancel_btn, "menu_cancel_btn");
|
||||
CONFIG_GET_INT_BASE(conf, settings, menu_search_btn, "menu_search_btn");
|
||||
@ -1669,6 +1675,11 @@ static void config_load_core_specific(void)
|
||||
|
||||
if (settings->core_specific_config)
|
||||
{
|
||||
|
||||
// Toggle has_save_path to false so it resets
|
||||
global->has_set_save_path = false;
|
||||
global->has_set_state_path = false;
|
||||
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
strlcpy(tmp, settings->libretro, sizeof(tmp));
|
||||
RARCH_LOG("Loading core-specific config from: %s.\n",
|
||||
@ -1683,6 +1694,10 @@ static void config_load_core_specific(void)
|
||||
|
||||
/* This must be true for core specific configs. */
|
||||
settings->core_specific_config = true;
|
||||
|
||||
// Reset save paths
|
||||
global->has_set_save_path = true;
|
||||
global->has_set_state_path = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1808,17 +1823,26 @@ bool config_load_override(void)
|
||||
{
|
||||
RARCH_WARN("Can't use overrides in conjunction with netplay, disabling overrides\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
//Store the libretro_path we're using since it will be overwritten by the override when reloading
|
||||
// Store the libretro_path we're using since it will be overwritten by the override when reloading
|
||||
strlcpy(buf,settings->libretro,sizeof(buf));
|
||||
|
||||
// Toggle has_save_path to false so it resets
|
||||
global->has_set_save_path = false;
|
||||
global->has_set_state_path = false;
|
||||
|
||||
if (config_load_file(global->config_path, false))
|
||||
{
|
||||
//Restore the libretro_path we're using since it will be overwritten by the override when reloading
|
||||
{
|
||||
// Restore the libretro_path we're using since it will be overwritten by the override when reloading
|
||||
strlcpy(settings->libretro,buf,sizeof(settings->libretro));
|
||||
rarch_main_msg_queue_push("Configuration override loaded", 1, 100, true);
|
||||
|
||||
// Reset save paths
|
||||
global->has_set_save_path = true;
|
||||
global->has_set_state_path = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1842,9 +1866,19 @@ bool config_load_override(void)
|
||||
return false;
|
||||
|
||||
*global->append_config_path = '\0';
|
||||
|
||||
// Toggle has_save_path to false so it resets
|
||||
global->has_set_save_path = false;
|
||||
global->has_set_state_path = false;
|
||||
|
||||
if (config_load_file(global->config_path, false))
|
||||
{
|
||||
RARCH_LOG("Configuration overrides unloaded, original configuration reset\n");
|
||||
|
||||
// Reset save paths
|
||||
global->has_set_save_path = true;
|
||||
global->has_set_state_path = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -2507,6 +2541,10 @@ bool config_save_file(const char *path)
|
||||
settings->auto_overrides_enable);
|
||||
config_set_bool(conf, "auto_remaps_enable",
|
||||
settings->auto_remaps_enable);
|
||||
config_set_bool(conf, "sort_savefiles_enable",
|
||||
settings->sort_savefiles_enable);
|
||||
config_set_bool(conf, "sort_savestates_enable",
|
||||
settings->sort_savestates_enable);
|
||||
config_set_int(conf, "libretro_log_level", settings->libretro_log_level);
|
||||
config_set_bool(conf, "log_verbosity", global->verbosity);
|
||||
config_set_bool(conf, "perfcnt_enable", global->perfcnt_enable);
|
||||
|
@ -33,7 +33,7 @@ extern "C" {
|
||||
|
||||
typedef struct settings
|
||||
{
|
||||
struct
|
||||
struct
|
||||
{
|
||||
char driver[32];
|
||||
char context_driver[32];
|
||||
@ -105,7 +105,7 @@ typedef struct settings
|
||||
} ui;
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
struct
|
||||
struct
|
||||
{
|
||||
char driver[32];
|
||||
bool pause_libretro;
|
||||
@ -323,6 +323,9 @@ typedef struct settings
|
||||
bool auto_overrides_enable;
|
||||
bool auto_remaps_enable;
|
||||
|
||||
bool sort_savefiles_enable;
|
||||
bool sort_savestates_enable;
|
||||
|
||||
unsigned menu_ok_btn;
|
||||
unsigned menu_cancel_btn;
|
||||
unsigned menu_search_btn;
|
||||
|
49
retroarch.c
49
retroarch.c
@ -273,7 +273,7 @@ static void set_basename(const char *path)
|
||||
* /file/to/path/comp.7z#folder/game.extension
|
||||
*
|
||||
* The choice I take here is:
|
||||
* /file/to/path/game as basename. We might end up in a writable
|
||||
* /file/to/path/game as basename. We might end up in a writable
|
||||
* directory then and the name of srm and states are meaningful.
|
||||
*
|
||||
*/
|
||||
@ -326,9 +326,40 @@ static void set_special_paths(char **argv, unsigned num_content)
|
||||
sizeof(settings->system_directory));
|
||||
}
|
||||
|
||||
static void set_paths_redirect(const char *path)
|
||||
void set_paths_redirect(const char *path)
|
||||
{
|
||||
global_t *global = global_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
/* per-core saves: append the library_name to the save location */
|
||||
if(global->system.info.library_name && strcmp(global->system.info.library_name,"No Core") && settings->sort_savefiles_enable)
|
||||
{
|
||||
strlcpy(orig_savefile_dir,global->savefile_dir,sizeof(global->savefile_dir));
|
||||
fill_pathname_dir(global->savefile_dir,global->savefile_dir,global->system.info.library_name,sizeof(global->savefile_dir));
|
||||
|
||||
// if path doesn't exist try to create it, if everything fails revert to the original path
|
||||
if(!path_is_directory(global->savefile_dir))
|
||||
if(!path_mkdir(global->savefile_dir))
|
||||
strlcpy(global->savefile_dir,orig_savefile_dir,sizeof(global->savefile_dir));
|
||||
}
|
||||
|
||||
/* per-core states: append the library_name to the save location */
|
||||
if (global->system.info.library_name && strcmp(global->system.info.library_name,"No Core") && settings->sort_savestates_enable)
|
||||
{
|
||||
strlcpy(orig_savestate_dir,global->savestate_dir,sizeof(global->savestate_dir));
|
||||
fill_pathname_dir(global->savestate_dir,global->savestate_dir,global->system.info.library_name,sizeof(global->savestate_dir));
|
||||
|
||||
// if path doesn't exist try to create it, if everything fails revert to the original path
|
||||
if(!path_is_directory(global->savestate_dir))
|
||||
if(!path_mkdir(global->savestate_dir))
|
||||
strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir));
|
||||
}
|
||||
|
||||
if(path_is_directory(global->savefile_dir))
|
||||
strlcpy(global->savefile_name,global->savefile_dir,sizeof(global->savefile_dir));
|
||||
|
||||
if(path_is_directory(global->savestate_dir))
|
||||
strlcpy(global->savestate_name,global->savestate_dir,sizeof(global->savestate_dir));
|
||||
|
||||
if (path_is_directory(global->savefile_name))
|
||||
{
|
||||
@ -382,7 +413,7 @@ void rarch_set_paths(const char *path)
|
||||
/**
|
||||
* parse_input:
|
||||
* @argc : Count of (commandline) arguments.
|
||||
* @argv : (Commandline) arguments.
|
||||
* @argv : (Commandline) arguments.
|
||||
*
|
||||
* Parses (commandline) arguments passed to RetroArch.
|
||||
*
|
||||
@ -417,8 +448,8 @@ static void parse_input(int argc, char *argv[])
|
||||
*global->bps_name = '\0';
|
||||
*global->ips_name = '\0';
|
||||
*global->subsystem = '\0';
|
||||
|
||||
global->overrides_active = false;
|
||||
|
||||
global->overrides_active = false;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
@ -814,7 +845,7 @@ static void rarch_init_savefile_paths(void)
|
||||
/* For subsystems, we know exactly which RAM types are supported. */
|
||||
|
||||
unsigned i, j;
|
||||
const struct retro_subsystem_info *info =
|
||||
const struct retro_subsystem_info *info =
|
||||
libretro_find_subsystem_info(
|
||||
global->system.special, global->system.num_special,
|
||||
global->subsystem);
|
||||
@ -1151,7 +1182,7 @@ int rarch_main_init(int argc, char *argv[])
|
||||
#if defined(GEKKO) && defined(HW_RVL)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
|
||||
if (settings)
|
||||
{
|
||||
event_command(EVENT_CMD_VIDEO_SET_ASPECT_RATIO);
|
||||
@ -1439,7 +1470,7 @@ int rarch_defer_core(core_info_list_t *core_info, const char *dir,
|
||||
else
|
||||
strlcpy(new_core_path, info->path, sizeof(new_core_path));
|
||||
|
||||
/* There are multiple deferred cores and a
|
||||
/* There are multiple deferred cores and a
|
||||
* selection needs to be made from a list, return 0. */
|
||||
if (supported != 1)
|
||||
return 0;
|
||||
@ -1477,7 +1508,7 @@ bool rarch_replace_config(const char *path)
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
/* If config file to be replaced is the same as the
|
||||
/* If config file to be replaced is the same as the
|
||||
* current config file, exit. */
|
||||
if (!strcmp(path, global->config_path))
|
||||
return false;
|
||||
|
@ -167,6 +167,8 @@ void rarch_init_system_av_info(void);
|
||||
|
||||
void rarch_set_paths(const char *path);
|
||||
|
||||
void set_paths_redirect(const char *path);
|
||||
|
||||
/**
|
||||
* rarch_print_compiler:
|
||||
*
|
||||
@ -174,6 +176,9 @@ void rarch_set_paths(const char *path);
|
||||
**/
|
||||
void rarch_print_compiler(char *str, size_t sizeof_str);
|
||||
|
||||
char orig_savestate_dir[PATH_MAX_LENGTH];
|
||||
char orig_savefile_dir[PATH_MAX_LENGTH];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
24
settings.c
24
settings.c
@ -3682,6 +3682,30 @@ static bool setting_append_list_general_options(
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
CONFIG_BOOL(
|
||||
settings->sort_savefiles_enable,
|
||||
"sort_savefiles_enable",
|
||||
"Sort Saves In Folders",
|
||||
default_sort_savefiles_enable,
|
||||
"OFF",
|
||||
"ON",
|
||||
group_info.name,
|
||||
subgroup_info.name,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
CONFIG_BOOL(
|
||||
settings->sort_savestates_enable,
|
||||
"sort_savestates_enable",
|
||||
"Sort Saves States In Folders",
|
||||
default_sort_savestates_enable,
|
||||
"OFF",
|
||||
"ON",
|
||||
group_info.name,
|
||||
subgroup_info.name,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
|
||||
END_SUB_GROUP(list, list_info);
|
||||
|
||||
START_SUB_GROUP(list, list_info, "Logging", group_info.name, subgroup_info);
|
||||
|
Loading…
x
Reference in New Issue
Block a user