Use skeleton config as basis for new configs.

This commit is contained in:
Themaister 2013-10-04 15:38:57 +02:00
parent dcde156630
commit 9e67406c40
3 changed files with 20 additions and 5 deletions

View File

@ -93,11 +93,13 @@ Always starts RetroArch in fullscreen. Disregards settings in configuration file
Sets the configuration file path. \fBretroarch\fR will use this path to load the configuration file.
Should this not be defined, \fBretroarch\fR will look in platform specific paths to attempt finding the config file.
/etc/retroarch.cfg (when installed), or retroarch.cfg in the source tarball serves as a skeleton configuration file.
/etc/retroarch.cfg should serve as a skeleton config only, and not used as a config file.
/etc/retroarch.cfg should serve as a skeleton config only.
.IP
Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. If $XDG_CONFIG_HOME is not defined, it is assumed to be $HOME/.config as per specification. Then it will try $HOME/.retroarch.cfg. If both paths fail, RetroArch will try to create a new, default config file in $XDG_CONFIG_HOME/retroarch/retroarch.cfg (or the $HOME/.config default for $XDG_CONFIG_HOME). If no configuration is found at all, default settings will be assumed.
RetroArch will not attempt to load the skeleton config /etc/retroarch.cfg.
Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. If $XDG_CONFIG_HOME is not defined, it is assumed to be $HOME/.config as per specification. Then it will try $HOME/.retroarch.cfg. If both paths fail, RetroArch will try to create a new, default config file in $XDG_CONFIG_HOME/retroarch/retroarch.cfg (or the $HOME/.config default for $XDG_CONFIG_HOME).
If all fails, default settings will be assumed.
If RetroArch creates a new default config file, it will attempt to load the skeleton config file /etc/retroarch.cfg and use that as a basis.
This allows distributions to set up default paths for libretro cores, and similar things.
A configuration file does not need to define every possible option, only those which should be overridden.
If config_save_on_exit = true is set in the config file, RetroArch will overwrite the config file on exit. Settings can be changed from within RGUI.

View File

@ -602,7 +602,10 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig
#ifdef _WIN32
#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe.\n\t\tIf a default config is not found, RetroArch will attempt to create one."
#else
#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg.\n\t\tIf a default config is not found, RetroArch will attempt to create one."
#ifndef GLOBAL_CONFIG_DIR
#define GLOBAL_CONFIG_DIR "/etc"
#endif
#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg.\n\t\tIf a default config is not found, RetroArch will attempt to create one based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg)."
#endif
#include "config.features.h"

View File

@ -455,7 +455,17 @@ static config_file_t *open_default_config_file(void)
if (path_mkdir(basedir))
{
conf = config_file_new(NULL);
#ifndef GLOBAL_CONFIG_DIR
#define GLOBAL_CONFIG_DIR "/etc"
#endif
char skeleton_conf[PATH_MAX];
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, "retroarch.cfg", sizeof(skeleton_conf));
conf = config_file_new(skeleton_conf);
if (conf)
RARCH_WARN("Using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf);
else
conf = config_file_new(NULL);
bool saved = false;
if (conf)
{