This commit is contained in:
twinaphex 2020-02-04 03:10:58 +01:00
parent 58457ef16c
commit 110dda6e48
5 changed files with 57 additions and 42 deletions

View File

@ -41,9 +41,7 @@
#include "input/input_remapping.h"
#include "led/led_defines.h"
#include "defaults.h"
#include "core.h"
#include "paths.h"
#include "retroarch.h"
#include "verbosity.h"
#include "lakka.h"
@ -1953,14 +1951,14 @@ static struct config_int_setting *populate_settings_int(settings_t *settings, in
*
* Set 'default' configuration values.
**/
void config_set_defaults(void *data)
void config_set_defaults(void *data, void *settings_data)
{
unsigned i, j;
#ifdef HAVE_MENU
static bool first_initialized = true;
#endif
global_t *global = (global_t*)data;
settings_t *settings = config_get_ptr();
settings_t *settings = (settings_t*)settings_data;
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
@ -2443,9 +2441,8 @@ void config_set_defaults(void *data)
#ifdef HAVE_CONFIGFILE
#if defined(HAVE_MENU) && defined(HAVE_RGUI)
static bool check_menu_driver_compatibility(void)
static bool check_menu_driver_compatibility(settings_t *settings)
{
settings_t *settings = config_get_ptr();
char *video_driver = settings->arrays.video_driver;
char *menu_driver = settings->arrays.menu_driver;
@ -3162,7 +3159,7 @@ static bool config_load_file(global_t *global,
config_read_keybinds_conf(conf);
#if defined(HAVE_MENU) && defined(HAVE_RGUI)
if (!check_menu_driver_compatibility())
if (!check_menu_driver_compatibility(settings))
strlcpy(settings->arrays.menu_driver, "rgui", sizeof(settings->arrays.menu_driver));
#endif
@ -3234,7 +3231,7 @@ end:
* Returns: false if there was an error or no action was performed.
*
*/
bool config_load_override(void *data)
bool config_load_override(void *data, void *settings_data)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *buf = NULL;
@ -3386,7 +3383,8 @@ bool config_load_override(void *data)
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
if (!config_load_file(global_get_ptr(),
path_get(RARCH_PATH_CONFIG), config_get_ptr()))
path_get(RARCH_PATH_CONFIG),
(settings_t*)settings_data))
goto error;
/* Restore the libretro_path we're using
@ -3424,7 +3422,7 @@ error:
*
* Returns: false if there was an error.
*/
bool config_unload_override(void)
bool config_unload_override(void *settings_data)
{
path_clear(RARCH_PATH_CONFIG_APPEND);
@ -3433,7 +3431,8 @@ bool config_unload_override(void)
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
if (!config_load_file(global_get_ptr(),
path_get(RARCH_PATH_CONFIG), config_get_ptr()))
path_get(RARCH_PATH_CONFIG),
(settings_t*)settings_data))
return false;
RARCH_LOG("[Overrides] configuration overrides unloaded, original configuration restored.\n");
@ -3583,9 +3582,10 @@ success:
* Loads a config file and reads all the values into memory.
*
*/
void config_parse_file(void *data)
void config_parse_file(void *data, void *settings_data)
{
global_t *global = (global_t*)data;
if (path_is_empty(RARCH_PATH_CONFIG))
{
RARCH_LOG("[config] Loading default config.\n");
@ -3595,7 +3595,7 @@ void config_parse_file(void *data)
const char *config_path = path_get(RARCH_PATH_CONFIG);
RARCH_LOG("[config] loading config from: %s.\n", config_path);
if (!config_load_file(global, config_path, config_get_ptr()))
if (!config_load_file(global, config_path, (settings_t *)settings_data))
{
RARCH_ERR("[config] couldn't find config at path: \"%s\"\n",
config_path);
@ -3610,12 +3610,12 @@ void config_parse_file(void *data)
* Loads a config file and reads all the values into memory.
*
*/
void config_load(void *data)
void config_load(void *data, void *settings_data)
{
global_t *global = (global_t*)data;
config_set_defaults(global);
config_set_defaults(global, settings_data);
#ifdef HAVE_CONFIGFILE
config_parse_file(global);
config_parse_file(global, settings_data);
#endif
}
@ -3626,7 +3626,8 @@ void config_load(void *data)
* @user : Controller number to save
* Writes a controller autoconf file to disk.
**/
bool config_save_autoconf_profile(const char *path, unsigned user)
bool config_save_autoconf_profile(void *settings_data,
const char *path, unsigned user)
{
static const char* invalid_filename_chars[] = {
/* https://support.microsoft.com/en-us/help/905231/information-about-the-characters-that-you-cannot-use-in-site-names--fo */
@ -3639,7 +3640,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
int32_t pid_user = 0;
int32_t vid_user = 0;
bool ret = false;
settings_t *settings = config_get_ptr();
settings_t *settings = (settings_t*)settings_data;
const char *autoconf_dir = settings->paths.directory_autoconfig;
const char *joypad_ident = settings->arrays.input_joypad_driver;
char *buf = (char*)
@ -3744,7 +3745,8 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_file(const char *path)
bool config_save_file(void *settings_data,
const char *path)
{
float msg_color;
unsigned i = 0;
@ -3757,7 +3759,7 @@ bool config_save_file(const char *path)
struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL;
config_file_t *conf = config_file_new_from_path_to_string(path);
settings_t *settings = config_get_ptr();
settings_t *settings = (settings_t*)settings_data;
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats)/ sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
@ -3965,7 +3967,8 @@ bool config_save_file(const char *path)
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_overrides(enum override_type type, void *data)
bool config_save_overrides(enum override_type type, void *data,
void *settings_data)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
int tmp_i = 0;
@ -3992,7 +3995,7 @@ bool config_save_overrides(enum override_type type, void *data)
char *core_path = NULL;
char *game_path = NULL;
char *content_path = NULL;
settings_t *overrides = config_get_ptr();
settings_t *overrides = (settings_t*)settings_data;
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
@ -4217,7 +4220,8 @@ bool config_save_overrides(enum override_type type, void *data)
/* Replaces currently loaded configuration file with
* another one. Will load a dummy core to flush state
* properly. */
bool config_replace(bool config_replace_save_on_exit, char *path)
bool config_replace(void *settings_data,
bool config_replace_save_on_exit, char *path)
{
content_ctx_info_t content_info = {0};
const char *rarch_path_config = path_get(RARCH_PATH_CONFIG);
@ -4228,7 +4232,7 @@ bool config_replace(bool config_replace_save_on_exit, char *path)
return false;
if (config_replace_save_on_exit && !path_is_empty(RARCH_PATH_CONFIG))
config_save_file(rarch_path_config);
config_save_file(settings_data, rarch_path_config);
path_set(RARCH_PATH_CONFIG, path);

View File

@ -815,7 +815,7 @@ const char *config_get_default_record(void);
* Loads a config file and reads all the values into memory.
*
*/
void config_parse_file(void *data);
void config_parse_file(void *data, void *settings_data);
#ifdef HAVE_CONFIGFILE
/**
@ -828,7 +828,7 @@ void config_parse_file(void *data);
* Returns: false if there was an error or no action was performed.
*
*/
bool config_load_override(void *data);
bool config_load_override(void *data, void *settings_data);
/**
* config_unload_override:
@ -838,7 +838,7 @@ bool config_load_override(void *data);
*
* Returns: false if there was an error.
*/
bool config_unload_override(void);
bool config_unload_override(void *settings_data);
/**
* config_load_remap:
@ -857,7 +857,8 @@ bool config_load_remap(const char *directory_input_remapping,
* @user : Controller number to save
* Writes a controller autoconf file to disk.
**/
bool config_save_autoconf_profile(const char *path, unsigned user);
bool config_save_autoconf_profile(void *settings_data,
const char *path, unsigned user);
/**
* config_save_file:
@ -867,7 +868,8 @@ bool config_save_autoconf_profile(const char *path, unsigned user);
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_file(const char *path);
bool config_save_file(void *settings_data,
const char *path);
/**
* config_save_overrides:
@ -877,17 +879,19 @@ bool config_save_file(const char *path);
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_overrides(enum override_type type, void *data);
bool config_save_overrides(enum override_type type, void *data,
void *settings_data);
/* Replaces currently loaded configuration file with
* another one. Will load a dummy core to flush state
* properly. */
bool config_replace(bool config_save_on_exit, char *path);
bool config_replace(void *settings_data,
bool config_save_on_exit, char *path);
#endif
bool config_overlay_enable_default(void);
void config_set_defaults(void *data);
void config_set_defaults(void *data, void *settings_data);
settings_t *config_get_ptr(void);

View File

@ -1684,7 +1684,8 @@ static int generic_action_ok(const char *path,
menu_display_set_msg_force(true);
if (config_replace(settings->bools.config_save_on_exit, action_path))
if (config_replace(settings,
settings->bools.config_save_on_exit, action_path))
{
bool pending_push = false;
menu_driver_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);

View File

@ -2567,7 +2567,8 @@ static int setting_action_ok_bind_all_save_autoconfig(rarch_setting_t *setting,
index_offset = setting->index_offset;
name = input_config_get_device_name(index_offset);
if(!string_is_empty(name) && config_save_autoconf_profile(name, index_offset))
if(!string_is_empty(name) && config_save_autoconf_profile(config_get_ptr(),
name, index_offset))
runloop_msg_queue_push(
msg_hash_to_str(MSG_AUTOCONFIG_FILE_SAVED_SUCCESSFULLY), 1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);

View File

@ -5513,7 +5513,7 @@ static void command_event_disable_overrides(void)
return;
/* reload the original config */
config_unload_override();
config_unload_override(&configuration_settings);
runloop_overrides_active = false;
}
#endif
@ -5896,7 +5896,8 @@ static bool command_event_init_core(enum rarch_core_type type)
#ifdef HAVE_CONFIGFILE
/* auto overrides: apply overrides */
if (settings->bools.auto_overrides_enable)
runloop_overrides_active = config_load_override(&runloop_system);
runloop_overrides_active = config_load_override(&runloop_system,
settings);
#endif
/* Load auto-shaders on the next occasion */
@ -5993,7 +5994,8 @@ static bool command_event_save_config(
const char *str = path_exists ? config_path :
path_get(RARCH_PATH_CONFIG);
if (path_exists && config_save_file(config_path))
if (path_exists && config_save_file(&configuration_settings,
config_path))
{
snprintf(s, len, "%s \"%s\".",
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
@ -6158,9 +6160,12 @@ static void command_event_save_current_config(enum override_type type)
case OVERRIDE_GAME:
case OVERRIDE_CORE:
case OVERRIDE_CONTENT_DIR:
if (config_save_overrides(type, &runloop_system))
if (config_save_overrides(type,
&runloop_system, &configuration_settings))
{
strlcpy(msg, msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY), sizeof(msg));
strlcpy(msg,
msg_hash_to_str(MSG_OVERRIDES_SAVED_SUCCESSFULLY),
sizeof(msg));
RARCH_LOG("[config] [overrides] %s\n", msg);
/* set overrides to active so the original config can be
@ -7203,7 +7208,7 @@ TODO: Add a setting for these tweaks */
#endif
break;
case CMD_EVENT_MENU_RESET_TO_DEFAULT_CONFIG:
config_set_defaults(&g_extern);
config_set_defaults(&g_extern, &configuration_settings);
break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG:
#ifdef HAVE_CONFIGFILE
@ -24711,9 +24716,9 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
if (!rarch_block_config_read)
#endif
{
config_set_defaults(&g_extern);
config_set_defaults(&g_extern, &configuration_settings);
#ifdef HAVE_CONFIGFILE
config_parse_file(&g_extern);
config_parse_file(&g_extern, &configuration_settings);
#endif
}