RetroArch/configuration.c

3281 lines
114 KiB
C
Raw Normal View History

2012-04-21 21:13:50 +00:00
/* RetroArch - A frontend for libretro.
2014-01-01 00:50:59 +00:00
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
2016-01-10 03:06:50 +00:00
* Copyright (C) 2011-2016 - Daniel De Matteis
*
2012-04-21 21:13:50 +00:00
* RetroArch is free software: you can redistribute it and/or modify it under the terms
2010-12-30 00:50:37 +00:00
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
2012-04-21 21:13:50 +00:00
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
2010-12-30 00:50:37 +00:00
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
2012-04-21 21:31:57 +00:00
* You should have received a copy of the GNU General Public License along with RetroArch.
2010-12-30 00:50:37 +00:00
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
2014-10-22 01:35:04 +00:00
#include <file/config_file.h>
#include <file/file_path.h>
2014-10-21 05:58:58 +00:00
#include <compat/strl.h>
#include <compat/posix_string.h>
2015-09-21 23:45:16 +00:00
#include <retro_stat.h>
2016-02-05 12:51:30 +00:00
#include <retro_assert.h>
2015-12-26 06:19:04 +00:00
#include <string/stdstring.h>
2016-09-08 03:48:43 +00:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2016-05-01 13:07:45 +00:00
#include "file_path_special.h"
2015-11-23 18:40:09 +00:00
#include "audio/audio_driver.h"
2015-12-02 02:16:04 +00:00
#include "configuration.h"
2016-05-27 14:42:20 +00:00
#include "content.h"
2011-01-08 21:15:02 +00:00
#include "config.def.h"
#include "input/input_config.h"
#include "input/input_keymaps.h"
#include "input/input_remapping.h"
2015-12-06 21:48:57 +00:00
#include "defaults.h"
2016-05-08 03:29:10 +00:00
#include "core.h"
2016-09-17 12:49:35 +00:00
#include "dirs.h"
2016-09-17 10:35:29 +00:00
#include "paths.h"
2015-11-30 21:02:54 +00:00
#include "retroarch.h"
2016-09-01 03:36:52 +00:00
#include "runloop.h"
2015-11-23 11:03:38 +00:00
#include "verbosity.h"
#include "lakka.h"
2011-01-07 16:59:53 +00:00
2016-05-27 14:42:20 +00:00
#include "tasks/tasks_internal.h"
2016-09-01 16:53:34 +00:00
/* All config related settings go here. */
2016-09-05 15:16:37 +00:00
struct config_bool_setting
2016-09-01 16:53:34 +00:00
{
const char *ident;
bool *ptr;
bool def_enable;
bool def;
bool handle;
};
2016-09-05 15:16:37 +00:00
struct config_int_setting
2016-09-01 16:53:34 +00:00
{
const char *ident;
unsigned *ptr;
bool def_enable;
unsigned def;
bool handle;
};
2016-09-05 15:16:37 +00:00
struct config_float_setting
2016-09-01 16:53:34 +00:00
{
const char *ident;
float *ptr;
bool def_enable;
float def;
bool handle;
};
2016-09-05 15:16:37 +00:00
struct config_array_setting
2016-09-01 16:53:34 +00:00
{
const char *ident;
char *ptr;
bool def_enable;
const char *def;
bool handle;
};
2016-09-05 15:16:37 +00:00
struct config_path_setting
2016-09-01 16:53:34 +00:00
{
const char *ident;
char *ptr;
bool def_enable;
char *def;
bool handle;
};
2016-09-01 01:51:54 +00:00
#define GENERAL_SETTING(key, configval, default_enable, default_setting, type, handle_setting) \
2016-08-29 17:10:00 +00:00
{ \
if (count == 0) \
2016-08-30 02:05:27 +00:00
tmp = (type*)malloc(sizeof(type) * (count + 1)); \
2016-08-29 17:10:00 +00:00
else \
2016-08-30 02:05:27 +00:00
tmp = (type*)realloc(tmp, sizeof(type) * (count + 1)); \
tmp[count].ident = key; \
tmp[count].ptr = configval; \
tmp[count].def_enable = default_enable; \
if (default_enable) \
tmp[count].def = default_setting; \
2016-09-01 01:51:54 +00:00
tmp[count].handle = handle_setting; \
2016-08-29 17:10:00 +00:00
count++; \
}
2016-09-01 01:51:54 +00:00
#define SETTING_BOOL(key, configval, default_enable, default_setting, handle_setting) \
2016-09-05 15:16:37 +00:00
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_bool_setting, handle_setting)
2016-08-30 02:05:27 +00:00
2016-09-01 01:51:54 +00:00
#define SETTING_FLOAT(key, configval, default_enable, default_setting, handle_setting) \
2016-09-05 15:16:37 +00:00
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_float_setting, handle_setting)
2016-08-29 17:10:00 +00:00
2016-09-01 01:51:54 +00:00
#define SETTING_INT(key, configval, default_enable, default_setting, handle_setting) \
2016-09-05 15:16:37 +00:00
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_int_setting, handle_setting)
2016-08-30 02:05:27 +00:00
2016-09-01 01:51:54 +00:00
#define SETTING_PATH(key, configval, default_enable, default_setting, handle_setting) \
2016-09-05 15:16:37 +00:00
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_path_setting, handle_setting)
2016-08-29 17:10:00 +00:00
#define SETTING_ARRAY(key, configval, default_enable, default_setting, handle_setting) \
2016-09-05 15:16:37 +00:00
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_array_setting, handle_setting)
2016-08-29 17:10:00 +00:00
2014-06-12 16:06:29 +00:00
struct defaults g_defaults;
2016-05-27 03:13:05 +00:00
static settings_t *configuration_settings = NULL;
settings_t *config_get_ptr(void)
{
2016-05-27 03:02:26 +00:00
return configuration_settings;
}
void config_free(void)
{
2016-05-27 03:02:26 +00:00
free(configuration_settings);
configuration_settings = NULL;
}
2016-05-27 03:05:27 +00:00
bool config_init(void)
{
2016-05-27 03:02:26 +00:00
configuration_settings = (settings_t*)calloc(1, sizeof(settings_t));
2016-05-27 03:02:26 +00:00
if (!configuration_settings)
return false;
return true;
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_audio:
*
* Gets default audio driver.
*
* Returns: Default audio driver.
**/
2012-05-07 21:20:13 +00:00
const char *config_get_default_audio(void)
2010-12-29 18:00:21 +00:00
{
2010-12-29 19:50:50 +00:00
switch (AUDIO_DEFAULT_DRIVER)
{
case AUDIO_RSOUND:
2012-05-07 21:20:13 +00:00
return "rsound";
2010-12-29 19:50:50 +00:00
case AUDIO_OSS:
2012-05-07 21:20:13 +00:00
return "oss";
2010-12-29 19:50:50 +00:00
case AUDIO_ALSA:
2012-05-07 21:20:13 +00:00
return "alsa";
case AUDIO_ALSATHREAD:
return "alsathread";
2010-12-29 19:50:50 +00:00
case AUDIO_ROAR:
2012-05-07 21:20:13 +00:00
return "roar";
2011-08-08 15:27:52 +00:00
case AUDIO_COREAUDIO:
2012-05-07 21:20:13 +00:00
return "coreaudio";
2010-12-29 19:50:50 +00:00
case AUDIO_AL:
2012-05-07 21:20:13 +00:00
return "openal";
case AUDIO_SL:
return "opensl";
2011-01-07 16:59:53 +00:00
case AUDIO_SDL:
2012-05-07 21:20:13 +00:00
return "sdl";
case AUDIO_SDL2:
return "sdl2";
case AUDIO_DSOUND:
2012-05-07 21:20:13 +00:00
return "dsound";
case AUDIO_XAUDIO:
2012-05-07 21:20:13 +00:00
return "xaudio";
2011-01-29 00:15:09 +00:00
case AUDIO_PULSE:
2012-05-07 21:20:13 +00:00
return "pulse";
2011-05-14 23:46:11 +00:00
case AUDIO_EXT:
2012-05-07 21:20:13 +00:00
return "ext";
case AUDIO_XENON360:
2012-05-07 21:20:13 +00:00
return "xenon360";
2011-12-14 11:49:13 +00:00
case AUDIO_PS3:
2012-05-07 21:20:13 +00:00
return "ps3";
2011-12-14 11:49:13 +00:00
case AUDIO_WII:
return "gx";
case AUDIO_PSP:
#ifdef VITA
return "vita";
#else
return "psp";
#endif
2015-04-01 21:14:13 +00:00
case AUDIO_CTR:
return "csnd";
case AUDIO_RWEBAUDIO:
return "rwebaudio";
default:
break;
2010-12-29 19:50:50 +00:00
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
2012-05-07 21:20:13 +00:00
}
2010-12-29 19:50:50 +00:00
2015-04-15 11:37:38 +00:00
const char *config_get_default_record(void)
{
switch (RECORD_DEFAULT_DRIVER)
{
case RECORD_FFMPEG:
return "ffmpeg";
default:
break;
}
return "null";
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_audio_resampler:
*
* Gets default audio resampler driver.
*
* Returns: Default audio resampler driver.
**/
const char *config_get_default_audio_resampler(void)
{
switch (AUDIO_DEFAULT_RESAMPLER_DRIVER)
{
case AUDIO_RESAMPLER_CC:
return "cc";
case AUDIO_RESAMPLER_SINC:
return "sinc";
2014-10-03 11:34:55 +00:00
case AUDIO_RESAMPLER_NEAREST:
return "nearest";
default:
break;
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_video:
*
* Gets default video driver.
*
* Returns: Default video driver.
**/
2012-05-07 21:20:13 +00:00
const char *config_get_default_video(void)
{
switch (VIDEO_DEFAULT_DRIVER)
{
case VIDEO_GL:
return "gl";
case VIDEO_VULKAN:
return "vulkan";
2016-07-03 08:37:07 +00:00
case VIDEO_DRM:
return "drm";
2012-05-07 21:20:13 +00:00
case VIDEO_WII:
return "gx";
2012-05-07 21:20:13 +00:00
case VIDEO_XENON360:
return "xenon360";
2012-07-07 17:15:06 +00:00
case VIDEO_XDK_D3D:
2012-10-26 19:09:30 +00:00
case VIDEO_D3D9:
2014-01-01 00:09:31 +00:00
return "d3d";
case VIDEO_PSP1:
return "psp1";
case VIDEO_VITA2D:
return "vita2d";
2015-04-01 21:14:13 +00:00
case VIDEO_CTR:
return "ctr";
2012-05-07 21:20:13 +00:00
case VIDEO_XVIDEO:
return "xvideo";
case VIDEO_SDL:
return "sdl";
case VIDEO_SDL2:
return "sdl2";
2012-05-07 21:20:13 +00:00
case VIDEO_EXT:
return "ext";
case VIDEO_VG:
return "vg";
case VIDEO_OMAP:
return "omap";
case VIDEO_EXYNOS:
return "exynos";
case VIDEO_DISPMANX:
return "dispmanx";
case VIDEO_SUNXI:
return "sunxi";
default:
break;
2012-05-07 21:20:13 +00:00
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
2012-05-07 21:20:13 +00:00
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_input:
*
* Gets default input driver.
*
* Returns: Default input driver.
**/
2012-05-07 21:20:13 +00:00
const char *config_get_default_input(void)
{
switch (INPUT_DEFAULT_DRIVER)
{
case INPUT_ANDROID:
return "android";
case INPUT_PS3:
2012-05-07 21:20:13 +00:00
return "ps3";
case INPUT_PSP:
#ifdef VITA
return "vita";
#else
return "psp";
#endif
2015-04-01 21:14:13 +00:00
case INPUT_CTR:
return "ctr";
case INPUT_SDL:
2012-05-07 21:20:13 +00:00
return "sdl";
case INPUT_SDL2:
return "sdl2";
2012-09-30 09:26:26 +00:00
case INPUT_DINPUT:
return "dinput";
2011-03-13 03:51:09 +00:00
case INPUT_X:
2012-05-07 21:20:13 +00:00
return "x";
case INPUT_WAYLAND:
return "wayland";
case INPUT_XENON360:
2012-05-07 21:20:13 +00:00
return "xenon360";
case INPUT_XINPUT:
return "xinput";
2011-12-14 12:20:22 +00:00
case INPUT_WII:
return "gx";
case INPUT_LINUXRAW:
return "linuxraw";
case INPUT_UDEV:
return "udev";
case INPUT_COCOA:
return "cocoa";
case INPUT_QNX:
return "qnx_input";
case INPUT_RWEBINPUT:
return "rwebinput";
default:
break;
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
2012-05-07 21:20:13 +00:00
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_joypad:
*
* Gets default input joypad driver.
*
* Returns: Default input joypad driver.
**/
const char *config_get_default_joypad(void)
{
switch (JOYPAD_DEFAULT_DRIVER)
{
case JOYPAD_PS3:
return "ps3";
case JOYPAD_XINPUT:
return "xinput";
case JOYPAD_GX:
return "gx";
case JOYPAD_XDK:
return "xdk";
case JOYPAD_PSP:
#ifdef VITA
return "vita";
#else
return "psp";
#endif
2015-04-01 21:14:13 +00:00
case JOYPAD_CTR:
return "ctr";
case JOYPAD_DINPUT:
return "dinput";
case JOYPAD_UDEV:
return "udev";
case JOYPAD_LINUXRAW:
return "linuxraw";
case JOYPAD_ANDROID:
return "android";
case JOYPAD_SDL:
#ifdef HAVE_SDL2
return "sdl2";
#else
return "sdl";
#endif
case JOYPAD_HID:
return "hid";
case JOYPAD_QNX:
return "qnx";
default:
break;
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_camera:
*
* Gets default camera driver.
*
* Returns: Default camera driver.
**/
const char *config_get_default_camera(void)
{
switch (CAMERA_DEFAULT_DRIVER)
{
case CAMERA_V4L2:
return "video4linux2";
case CAMERA_RWEBCAM:
return "rwebcam";
2013-11-17 18:47:37 +00:00
case CAMERA_ANDROID:
return "android";
2015-04-19 18:46:49 +00:00
case CAMERA_AVFOUNDATION:
return "avfoundation";
default:
break;
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
}
/**
* config_get_default_wifi:
*
* Gets default wifi driver.
*
* Returns: Default wifi driver.
**/
const char *config_get_default_wifi(void)
{
switch (WIFI_DEFAULT_DRIVER)
{
case WIFI_CONNMANCTL:
return "connmanctl";
default:
break;
}
return "null";
}
2015-01-11 04:29:32 +00:00
/**
* config_get_default_location:
*
* Gets default location driver.
*
* Returns: Default location driver.
**/
const char *config_get_default_location(void)
{
switch (LOCATION_DEFAULT_DRIVER)
{
case LOCATION_ANDROID:
return "android";
case LOCATION_CORELOCATION:
return "corelocation";
default:
break;
}
2014-10-03 15:07:51 +00:00
2015-01-09 00:08:54 +00:00
return "null";
}
2016-09-16 23:40:11 +00:00
#ifdef HAVE_MENU
/**
* config_get_default_menu:
*
* Gets default menu driver.
*
* Returns: Default menu driver.
**/
const char *config_get_default_menu(void)
2016-08-01 12:14:21 +00:00
{
2016-09-16 23:40:11 +00:00
if (!string_is_empty(g_defaults.settings.menu))
return g_defaults.settings.menu;
switch (MENU_DEFAULT_DRIVER)
{
case MENU_RGUI:
return "rgui";
case MENU_XUI:
return "xui";
case MENU_MATERIALUI:
return "glui";
case MENU_XMB:
return "xmb";
case MENU_NUKLEAR:
return "nuklear";
default:
break;
}
return "null";
2016-08-01 12:14:21 +00:00
}
static unsigned config_menu_btn_ok_default(void)
{
if (g_defaults.menu.controls.set)
return g_defaults.menu.controls.menu_btn_ok;
return default_menu_btn_ok;
}
static unsigned config_menu_btn_cancel_default(void)
{
if (g_defaults.menu.controls.set)
return g_defaults.menu.controls.menu_btn_cancel;
return default_menu_btn_cancel;
}
#endif
2016-09-16 23:40:11 +00:00
bool config_overlay_enable_default(void)
{
if (g_defaults.overlay.set)
return g_defaults.overlay.enable;
return true;
}
2016-09-05 15:16:37 +00:00
static int populate_settings_array(settings_t *settings, struct config_array_setting **out)
2012-05-07 21:20:13 +00:00
{
2016-08-29 17:10:00 +00:00
unsigned count = 0;
2016-09-05 15:16:37 +00:00
struct config_array_setting *tmp = NULL;
2016-09-01 01:01:04 +00:00
2016-09-01 00:46:09 +00:00
/* Arrays */
SETTING_ARRAY("playlist_names", settings->playlist_names, false, NULL, true);
SETTING_ARRAY("playlist_cores", settings->playlist_cores, false, NULL, true);
SETTING_ARRAY("video_driver", settings->video.driver, false, NULL, true);
SETTING_ARRAY("record_driver", settings->record.driver, false, NULL, true);
SETTING_ARRAY("camera_driver", settings->camera.driver, false, NULL, true);
SETTING_ARRAY("wifi_driver", settings->wifi.driver, false, NULL, true);
SETTING_ARRAY("location_driver", settings->location.driver,false, NULL, true);
#ifdef HAVE_MENU
SETTING_ARRAY("menu_driver", settings->menu.driver, false, NULL, true);
2016-07-09 11:05:58 +00:00
#endif
SETTING_ARRAY("audio_device", settings->audio.device, false, NULL, true);
SETTING_ARRAY("camera_device", settings->camera.device, false, NULL, true);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_CHEEVOS
SETTING_ARRAY("cheevos_username", settings->cheevos.username, false, NULL, true);
SETTING_ARRAY("cheevos_password", settings->cheevos.password, false, NULL, true);
#endif
SETTING_ARRAY("video_context_driver", settings->video.context_driver, false, NULL, true);
SETTING_ARRAY("audio_driver", settings->audio.driver, false, NULL, true);
SETTING_ARRAY("audio_resampler", settings->audio.resampler, false, NULL, true);
SETTING_ARRAY("input_driver", settings->input.driver, false, NULL, true);
SETTING_ARRAY("input_joypad_driver", settings->input.joypad_driver, false, NULL, true);
SETTING_ARRAY("input_keyboard_layout", settings->input.keyboard_layout, false, NULL, true);
SETTING_ARRAY("bundle_assets_src_path", settings->path.bundle_assets_src, false, NULL, true);
SETTING_ARRAY("bundle_assets_dst_path", settings->path.bundle_assets_dst, false, NULL, true);
SETTING_ARRAY("bundle_assets_dst_path_subdir", settings->path.bundle_assets_dst_subdir, false, NULL, true);
2010-12-29 19:50:50 +00:00
2016-08-29 17:10:00 +00:00
*out =
2016-09-05 15:16:37 +00:00
(struct config_array_setting*) malloc(count * sizeof(struct config_array_setting));
memcpy(*out, tmp, sizeof(struct config_array_setting) * count);
2016-08-29 17:10:00 +00:00
free(tmp);
return count;
}
2016-09-05 15:16:37 +00:00
static int populate_settings_path(settings_t *settings, struct config_path_setting **out)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
2016-09-05 15:16:37 +00:00
struct config_path_setting *tmp = NULL;
2016-08-29 17:10:00 +00:00
global_t *global = global_get_ptr();
2016-09-01 01:00:27 +00:00
/* Paths */
2016-09-01 02:37:22 +00:00
#ifdef HAVE_XMB
SETTING_PATH("xmb_font", settings->menu.xmb.font, false, NULL, true);
#endif
2016-09-03 06:12:40 +00:00
SETTING_PATH("netplay_nickname", settings->username, false, NULL, true);
2016-09-01 02:37:22 +00:00
SETTING_PATH("video_filter", settings->path.softfilter_plugin, false, NULL, true);
SETTING_PATH("audio_dsp_plugin", settings->path.audio_dsp_plugin, false, NULL, true);
SETTING_PATH("core_updater_buildbot_url", settings->network.buildbot_url, false, NULL, true);
SETTING_PATH("core_updater_buildbot_assets_url", settings->network.buildbot_assets_url, false, NULL, true);
2016-09-01 01:00:27 +00:00
#ifdef HAVE_NETPLAY
2016-09-03 06:12:40 +00:00
SETTING_PATH("netplay_ip_address", global->netplay.server, false, NULL, true);
2016-09-01 01:41:10 +00:00
#endif
SETTING_PATH("recording_output_directory",
2016-09-01 02:37:22 +00:00
global->record.output_dir, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("recording_config_directory",
2016-09-01 02:37:22 +00:00
global->record.config_dir, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("libretro_directory",
2016-09-01 01:51:54 +00:00
settings->directory.libretro, false, NULL, false);
2016-09-01 01:41:10 +00:00
SETTING_PATH("core_options_path",
2016-09-01 02:37:22 +00:00
settings->path.core_options, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("libretro_info_path",
2016-09-01 02:37:22 +00:00
settings->path.libretro_info, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_shader",
2016-09-01 02:37:22 +00:00
settings->path.shader, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_database_path",
2016-09-01 02:37:22 +00:00
settings->path.content_database, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cheat_database_path",
2016-09-01 02:37:22 +00:00
settings->path.cheat_database, false, NULL, true);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
2016-09-01 01:41:10 +00:00
SETTING_PATH("menu_wallpaper",
2016-09-01 02:37:22 +00:00
settings->path.menu_wallpaper, false, NULL, true);
2016-09-01 01:41:10 +00:00
#endif
SETTING_PATH("content_history_path",
2016-09-01 02:37:22 +00:00
settings->path.content_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_music_history_path",
2016-09-01 02:37:22 +00:00
settings->path.content_music_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_video_history_path",
2016-09-01 02:37:22 +00:00
settings->path.content_video_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_image_history_path",
2016-09-01 02:37:22 +00:00
settings->path.content_image_history, false, NULL, true);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_OVERLAY
2016-09-01 01:41:10 +00:00
SETTING_PATH("input_overlay",
2016-09-01 02:37:22 +00:00
settings->path.overlay, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("input_osk_overlay",
2016-09-01 02:37:22 +00:00
settings->path.osk_overlay, false, NULL, true);
2016-09-01 01:41:10 +00:00
#endif
SETTING_PATH("video_font_path",
2016-09-01 02:37:22 +00:00
settings->path.font, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cursor_directory",
2016-09-01 02:37:22 +00:00
settings->directory.cursor, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_history_dir",
2016-09-01 02:37:22 +00:00
settings->directory.content_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("screenshot_directory",
2016-09-01 02:37:22 +00:00
settings->directory.screenshot, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("system_directory",
2016-09-01 02:37:22 +00:00
settings->directory.system, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cache_directory",
2016-09-01 02:37:22 +00:00
settings->directory.cache, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("input_remapping_directory",
2016-09-01 02:37:22 +00:00
settings->directory.input_remapping, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("resampler_directory",
2016-09-01 02:37:22 +00:00
settings->directory.resampler, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_shader_dir",
2016-09-01 02:37:22 +00:00
settings->directory.video_shader, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_filter_dir",
2016-09-01 02:37:22 +00:00
settings->directory.video_filter, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("core_assets_directory",
2016-09-01 02:37:22 +00:00
settings->directory.core_assets, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("assets_directory",
2016-09-01 02:37:22 +00:00
settings->directory.assets, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("dynamic_wallpapers_directory",
2016-09-01 02:37:22 +00:00
settings->directory.dynamic_wallpapers, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("thumbnails_directory",
2016-09-01 02:37:22 +00:00
settings->directory.thumbnails, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("playlist_directory",
2016-09-01 02:37:22 +00:00
settings->directory.playlist, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("joypad_autoconfig_dir",
2016-09-01 02:37:22 +00:00
settings->directory.autoconfig, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("audio_filter_dir",
2016-09-01 02:37:22 +00:00
settings->directory.audio_filter, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("savefile_directory",
2016-09-17 12:53:30 +00:00
dir_get_savefile_ptr(), true, NULL, false);
2016-09-01 01:41:10 +00:00
SETTING_PATH("savestate_directory",
2016-09-17 12:53:30 +00:00
dir_get_savestate_ptr(), true, NULL, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
2016-09-01 01:41:10 +00:00
SETTING_PATH("rgui_browser_directory",
2016-09-01 02:37:22 +00:00
settings->directory.menu_content, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("rgui_config_directory",
2016-09-01 02:37:22 +00:00
settings->directory.menu_config, true, NULL, true);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_OVERLAY
2016-09-01 01:41:10 +00:00
SETTING_PATH("overlay_directory",
2016-09-01 02:37:22 +00:00
settings->directory.overlay, true, NULL, true);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_OVERLAY
2016-09-01 01:41:10 +00:00
SETTING_PATH("osk_overlay_directory",
2016-09-17 14:28:46 +00:00
dir_get_osk_overlay_ptr(), true, NULL, true);
2016-08-29 17:10:00 +00:00
#endif
#ifndef HAVE_DYNAMIC
2016-09-01 01:41:10 +00:00
SETTING_PATH("libretro_path",
2016-09-17 10:51:44 +00:00
path_get_core_ptr(), false, NULL, false);
2016-08-29 17:10:00 +00:00
#endif
SETTING_PATH(
2016-09-01 01:41:10 +00:00
"screenshot_directory",
2016-09-01 01:51:54 +00:00
settings->directory.screenshot, true, NULL, false);
2016-08-29 17:10:00 +00:00
*out =
2016-09-05 15:16:37 +00:00
(struct config_path_setting*) malloc(count * sizeof(struct config_path_setting));
memcpy(*out, tmp, sizeof(struct config_path_setting) * count);
2016-08-29 17:10:00 +00:00
free(tmp);
return count;
}
2016-09-05 15:16:37 +00:00
static int populate_settings_bool(settings_t *settings, struct config_bool_setting **out)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
global_t *global = global_get_ptr();
2016-09-05 15:16:37 +00:00
struct config_bool_setting *tmp = NULL;
2016-08-29 17:10:00 +00:00
2016-09-01 01:51:54 +00:00
SETTING_BOOL("ui_companion_start_on_boot", &settings->ui.companion_start_on_boot, true, ui_companion_start_on_boot, false);
SETTING_BOOL("ui_companion_enable", &settings->ui.companion_enable, true, ui_companion_enable, false);
SETTING_BOOL("video_gpu_record", &settings->video.gpu_record, true, gpu_record, false);
SETTING_BOOL("input_remap_binds_enable", &settings->input.remap_binds_enable, true, true, false);
SETTING_BOOL("back_as_menu_toggle_enable", &settings->input.back_as_menu_toggle_enable, true, true, false);
SETTING_BOOL("all_users_control_menu", &settings->input.all_users_control_menu, true, all_users_control_menu, false);
2016-09-01 01:51:54 +00:00
SETTING_BOOL("netplay_client_swap_input", &settings->input.netplay_client_swap_input, true, netplay_client_swap_input, false);
SETTING_BOOL("input_descriptor_label_show", &settings->input.input_descriptor_label_show, true, input_descriptor_label_show, false);
SETTING_BOOL("input_descriptor_hide_unbound", &settings->input.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false);
SETTING_BOOL("load_dummy_on_core_shutdown", &settings->load_dummy_on_core_shutdown, true, load_dummy_on_core_shutdown, false);
SETTING_BOOL("builtin_mediaplayer_enable", &settings->multimedia.builtin_mediaplayer_enable, false, false /* TODO */, false);
SETTING_BOOL("builtin_imageviewer_enable", &settings->multimedia.builtin_imageviewer_enable, true, true, false);
SETTING_BOOL("fps_show", &settings->fps_show, true, false, false);
SETTING_BOOL("ui_menubar_enable", &settings->ui.menubar_enable, true, true, false);
SETTING_BOOL("suspend_screensaver_enable", &settings->ui.suspend_screensaver_enable, true, true, false);
SETTING_BOOL("rewind_enable", &settings->rewind_enable, true, rewind_enable, false);
SETTING_BOOL("audio_sync", &settings->audio.sync, true, audio_sync, false);
SETTING_BOOL("video_shader_enable", &settings->video.shader_enable, true, shader_enable, false);
2016-08-29 19:03:01 +00:00
/* Let implementation decide if automatic, or 1:1 PAR. */
2016-09-01 01:51:54 +00:00
SETTING_BOOL("video_aspect_ratio_auto", &settings->video.aspect_ratio_auto, true, aspect_ratio_auto, false);
SETTING_BOOL("video_allow_rotate", &settings->video.allow_rotate, true, allow_rotate, false);
SETTING_BOOL("video_windowed_fullscreen", &settings->video.windowed_fullscreen, true, windowed_fullscreen, false);
SETTING_BOOL("video_crop_overscan", &settings->video.crop_overscan, true, crop_overscan, false);
SETTING_BOOL("video_scale_integer", &settings->video.scale_integer, true, scale_integer, false);
SETTING_BOOL("video_smooth", &settings->video.smooth, true, video_smooth, false);
SETTING_BOOL("video_force_aspect", &settings->video.force_aspect, true, force_aspect, false);
SETTING_BOOL("video_threaded", &settings->video.threaded, true, video_threaded, false);
SETTING_BOOL("video_shared_context", &settings->video.shared_context, true, video_shared_context, false);
SETTING_BOOL("custom_bgm_enable", &global->console.sound.system_bgm_enable, true, false, false);
SETTING_BOOL("auto_screenshot_filename", &settings->auto_screenshot_filename, true, auto_screenshot_filename, false);
SETTING_BOOL("video_force_srgb_disable", &settings->video.force_srgb_disable, true, false, false);
SETTING_BOOL("video_fullscreen", &settings->video.fullscreen, true, fullscreen, false);
SETTING_BOOL("bundle_assets_extract_enable", &settings->bundle_assets_extract_enable, true, bundle_assets_extract_enable, false);
SETTING_BOOL("video_vsync", &settings->video.vsync, true, vsync, false);
SETTING_BOOL("video_hard_sync", &settings->video.hard_sync, true, hard_sync, false);
SETTING_BOOL("video_black_frame_insertion", &settings->video.black_frame_insertion, true, black_frame_insertion, false);
SETTING_BOOL("video_disable_composition", &settings->video.disable_composition, true, disable_composition, false);
SETTING_BOOL("pause_nonactive", &settings->pause_nonactive, true, pause_nonactive, false);
SETTING_BOOL("video_gpu_screenshot", &settings->video.gpu_screenshot, true, gpu_screenshot, false);
SETTING_BOOL("video_post_filter_record", &settings->video.post_filter_record, true, post_filter_record, false);
SETTING_BOOL("keyboard_gamepad_enable", &settings->input.keyboard_gamepad_enable, true, true, false);
SETTING_BOOL("core_set_supports_no_game_enable", &settings->set_supports_no_game_enable, true, true, false);
SETTING_BOOL("audio_enable", &settings->audio.enable, true, audio_enable, false);
SETTING_BOOL("audio_mute_enable", &settings->audio.mute_enable, true, false, false);
SETTING_BOOL("location_allow", &settings->location.allow, true, false, false);
SETTING_BOOL("video_font_enable", &settings->video.font_enable, true, font_enable, false);
SETTING_BOOL("core_updater_auto_extract_archive", &settings->network.buildbot_auto_extract_archive, true, true, false);
SETTING_BOOL("camera_allow", &settings->camera.allow, true, false, false);
2016-08-29 17:10:00 +00:00
#if TARGET_OS_IPHONE
2016-09-01 01:51:54 +00:00
SETTING_BOOL("small_keyboard_enable", &settings->input.small_keyboard_enable, true, false, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef GEKKO
2016-09-01 01:51:54 +00:00
SETTING_BOOL("video_vfilter", &settings->video.vfilter, true, video_vfilter, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_MENU
#ifdef HAVE_THREADS
2016-09-01 01:51:54 +00:00
SETTING_BOOL("threaded_data_runloop_enable", &settings->threaded_data_runloop_enable, true, threaded_data_runloop_enable, false);
#endif
SETTING_BOOL("menu_throttle_framerate", &settings->menu.throttle_framerate, true, true, false);
SETTING_BOOL("menu_linear_filter", &settings->menu.linear_filter, true, true, false);
SETTING_BOOL("dpi_override_enable", &settings->menu.dpi.override_enable, true, menu_dpi_override_enable, false);
SETTING_BOOL("menu_pause_libretro", &settings->menu.pause_libretro, true, true, false);
SETTING_BOOL("menu_mouse_enable", &settings->menu.mouse.enable, true, def_mouse_enable, false);
SETTING_BOOL("menu_pointer_enable", &settings->menu.pointer.enable, true, pointer_enable, false);
SETTING_BOOL("menu_timedate_enable", &settings->menu.timedate_enable, true, true, false);
SETTING_BOOL("menu_core_enable", &settings->menu.core_enable, true, true, false);
SETTING_BOOL("menu_dynamic_wallpaper_enable", &settings->menu.dynamic_wallpaper_enable, true, false, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_XMB
2016-09-01 01:51:54 +00:00
SETTING_BOOL("xmb_shadows_enable", &settings->menu.xmb.shadows_enable, true, xmb_shadows_enable, false);
SETTING_BOOL("xmb_show_settings", &settings->menu.xmb.show_settings, true, xmb_show_settings, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_IMAGEVIEWER
2016-09-01 01:51:54 +00:00
SETTING_BOOL("xmb_show_images", &settings->menu.xmb.show_images, true, xmb_show_images, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_FFMPEG
2016-09-01 01:51:54 +00:00
SETTING_BOOL("xmb_show_music", &settings->menu.xmb.show_music, true, xmb_show_music, false);
SETTING_BOOL("xmb_show_video", &settings->menu.xmb.show_video, true, xmb_show_video, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_BOOL("xmb_show_history", &settings->menu.xmb.show_history, true, xmb_show_history, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_BOOL("rgui_show_start_screen", &settings->menu_show_start_screen, false, false /* TODO */, false);
SETTING_BOOL("menu_navigation_wraparound_enable", &settings->menu.navigation.wraparound.enable, true, true, false);
2016-08-29 17:10:00 +00:00
SETTING_BOOL("menu_navigation_browser_filter_supported_extensions_enable",
2016-09-01 01:51:54 +00:00
&settings->menu.navigation.browser.filter.supported_extensions_enable, true, true, false);
SETTING_BOOL("menu_show_advanced_settings", &settings->menu.show_advanced_settings, true, show_advanced_settings, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_CHEEVOS
2016-09-01 01:51:54 +00:00
SETTING_BOOL("cheevos_enable", &settings->cheevos.enable, true, cheevos_enable, false);
SETTING_BOOL("cheevos_test_unofficial", &settings->cheevos.test_unofficial, true, false, false);
SETTING_BOOL("cheevos_hardcore_mode_enable", &settings->cheevos.hardcore_mode_enable, true, false, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_OVERLAY
2016-09-01 01:51:54 +00:00
SETTING_BOOL("input_overlay_enable", &settings->input.overlay_enable, true, config_overlay_enable_default(), false);
SETTING_BOOL("input_overlay_enable_autopreferred", &settings->input.overlay_enable_autopreferred, true, true, false);
SETTING_BOOL("input_overlay_hide_in_menu", &settings->input.overlay_hide_in_menu, true, overlay_hide_in_menu, false);
SETTING_BOOL("input_osk_overlay_enable", &settings->osk.enable, true, true, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_COMMAND
2016-09-01 01:51:54 +00:00
SETTING_BOOL("network_cmd_enable", &settings->network_cmd_enable, true, network_cmd_enable, false);
SETTING_BOOL("stdin_cmd_enable", &settings->stdin_cmd_enable, true, stdin_cmd_enable, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_NETWORKGAMEPAD
2016-09-01 01:51:54 +00:00
SETTING_BOOL("network_remote_enable", &settings->network_remote_enable, false, false /* TODO */, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_NETPLAY
2016-09-01 01:51:54 +00:00
SETTING_BOOL("netplay_spectator_mode_enable",&global->netplay.is_spectate, false, false /* TODO */, false);
SETTING_BOOL("netplay_mode", &global->netplay.is_client, false, false /* TODO */, false);
#endif
SETTING_BOOL("block_sram_overwrite", &settings->block_sram_overwrite, true, block_sram_overwrite, false);
SETTING_BOOL("savestate_auto_index", &settings->savestate_auto_index, true, savestate_auto_index, false);
SETTING_BOOL("savestate_auto_save", &settings->savestate_auto_save, true, savestate_auto_save, false);
SETTING_BOOL("savestate_auto_load", &settings->savestate_auto_load, true, savestate_auto_load, false);
SETTING_BOOL("history_list_enable", &settings->history_list_enable, true, def_history_list_enable, false);
SETTING_BOOL("game_specific_options", &settings->game_specific_options, true, default_game_specific_options, false);
SETTING_BOOL("auto_overrides_enable", &settings->auto_overrides_enable, true, default_auto_overrides_enable, false);
SETTING_BOOL("auto_remaps_enable", &settings->auto_remaps_enable, true, default_auto_remaps_enable, false);
SETTING_BOOL("auto_shaders_enable", &settings->auto_shaders_enable, true, default_auto_shaders_enable, false);
SETTING_BOOL("sort_savefiles_enable", &settings->sort_savefiles_enable, true, default_sort_savefiles_enable, false);
SETTING_BOOL("sort_savestates_enable", &settings->sort_savestates_enable, true, default_sort_savestates_enable, false);
SETTING_BOOL("config_save_on_exit", &settings->config_save_on_exit, true, config_save_on_exit, false);
SETTING_BOOL("confirm_on_exit", &settings->confirm_on_exit, true, confirm_on_exit, false);
2016-09-01 01:51:54 +00:00
SETTING_BOOL("show_hidden_files", &settings->show_hidden_files, true, show_hidden_files, false);
SETTING_BOOL("input_autodetect_enable", &settings->input.autodetect_enable, true, input_autodetect_enable, false);
SETTING_BOOL("audio_rate_control", &settings->audio.rate_control, true, rate_control, false);
2016-08-29 17:10:00 +00:00
*out =
2016-09-05 15:16:37 +00:00
(struct config_bool_setting*) malloc(count *sizeof(struct config_bool_setting));
memcpy(*out, tmp, sizeof(struct config_bool_setting) * count);
2016-08-29 17:10:00 +00:00
free(tmp);
return count;
}
2016-09-05 15:16:37 +00:00
static int populate_settings_float(settings_t *settings, struct config_float_setting **out)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
2016-09-05 15:16:37 +00:00
struct config_float_setting *tmp = NULL;
2016-08-29 17:10:00 +00:00
2016-09-01 01:51:54 +00:00
SETTING_FLOAT("video_aspect_ratio", &settings->video.aspect_ratio, true, aspect_ratio, false);
SETTING_FLOAT("video_scale", &settings->video.scale, false, 0.0f, false);
SETTING_FLOAT("video_refresh_rate", &settings->video.refresh_rate, true, refresh_rate, false);
SETTING_FLOAT("audio_rate_control_delta", &settings->audio.rate_control_delta, true, rate_control_delta, false);
SETTING_FLOAT("audio_max_timing_skew", &settings->audio.max_timing_skew, true, max_timing_skew, false);
SETTING_FLOAT("audio_volume", &settings->audio.volume, true, audio_volume, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_OVERLAY
2016-09-01 01:51:54 +00:00
SETTING_FLOAT("input_overlay_opacity", &settings->input.overlay_opacity, true, 0.7f, false);
SETTING_FLOAT("input_overlay_scale", &settings->input.overlay_scale, true, 1.0f, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_MENU
2016-09-01 01:51:54 +00:00
SETTING_FLOAT("menu_wallpaper_opacity", &settings->menu.wallpaper.opacity, true, menu_wallpaper_opacity, false);
SETTING_FLOAT("menu_footer_opacity", &settings->menu.footer.opacity, true, menu_footer_opacity, false);
SETTING_FLOAT("menu_header_opacity", &settings->menu.header.opacity, true, menu_header_opacity, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_FLOAT("video_message_pos_x", &settings->video.msg_pos_x, true, message_pos_offset_x, false);
SETTING_FLOAT("video_message_pos_y", &settings->video.msg_pos_y, true, message_pos_offset_y, false);
SETTING_FLOAT("video_font_size", &settings->video.font_size, true, font_size, false);
SETTING_FLOAT("fastforward_ratio", &settings->fastforward_ratio, true, fastforward_ratio, false);
SETTING_FLOAT("slowmotion_ratio", &settings->slowmotion_ratio, true, slowmotion_ratio, false);
SETTING_FLOAT("input_axis_threshold", &settings->input.axis_threshold, true, axis_threshold, false);
2016-08-29 17:10:00 +00:00
*out =
2016-09-05 15:16:37 +00:00
(struct config_float_setting*) malloc(count * sizeof(struct config_float_setting));
memcpy(*out, tmp, sizeof(struct config_float_setting) * count);
2016-08-29 17:10:00 +00:00
free(tmp);
return count;
}
2016-09-05 15:16:37 +00:00
static int populate_settings_int(settings_t *settings, struct config_int_setting **out)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
2016-09-05 15:16:37 +00:00
struct config_int_setting *tmp = NULL;
2016-08-29 17:10:00 +00:00
#ifdef HAVE_NETPLAY
global_t *global = global_get_ptr();
#endif
2016-09-01 01:51:54 +00:00
SETTING_INT("input_bind_timeout", &settings->input.bind_timeout, true, input_bind_timeout, false);
SETTING_INT("input_turbo_period", &settings->input.turbo_period, true, turbo_period, false);
SETTING_INT("input_duty_cycle", &settings->input.turbo_duty_cycle, true, turbo_duty_cycle, false);
SETTING_INT("input_max_users", &settings->input.max_users, true, input_max_users, false);
SETTING_INT("input_menu_toggle_gamepad_combo", &settings->input.menu_toggle_gamepad_combo, true, menu_toggle_gamepad_combo, false);
SETTING_INT("audio_latency", &settings->audio.latency, false, 0 /* TODO */, false);
SETTING_INT("audio_block_frames", &settings->audio.block_frames, true, 0, false);
SETTING_INT("rewind_granularity", &settings->rewind_granularity, true, rewind_granularity, false);
SETTING_INT("autosave_interval", &settings->autosave_interval, true, autosave_interval, false);
SETTING_INT("libretro_log_level", &settings->libretro_log_level, true, libretro_log_level, false);
SETTING_INT("keyboard_gamepad_mapping_type",&settings->input.keyboard_gamepad_mapping_type, true, 1, false);
SETTING_INT("input_poll_type_behavior", &settings->input.poll_type_behavior, true, 2, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
2016-09-01 01:51:54 +00:00
SETTING_INT("menu_ok_btn", &settings->menu_ok_btn, true, config_menu_btn_ok_default(), false);
SETTING_INT("menu_cancel_btn", &settings->menu_cancel_btn, true, config_menu_btn_cancel_default(), false);
SETTING_INT("menu_search_btn", &settings->menu_search_btn, true, default_menu_btn_search, false);
SETTING_INT("menu_info_btn", &settings->menu_info_btn, true, default_menu_btn_info, false);
SETTING_INT("menu_default_btn", &settings->menu_default_btn, true, default_menu_btn_default, false);
SETTING_INT("menu_scroll_down_btn", &settings->menu_scroll_down_btn, true, default_menu_btn_scroll_down, false);
#endif
SETTING_INT("video_monitor_index", &settings->video.monitor_index, true, monitor_index, false);
SETTING_INT("video_fullscreen_x", &settings->video.fullscreen_x, true, fullscreen_x, false);
SETTING_INT("video_fullscreen_y", &settings->video.fullscreen_y, true, fullscreen_y, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_COMMAND
2016-09-01 01:51:54 +00:00
SETTING_INT("network_cmd_port", &settings->network_cmd_port, true, network_cmd_port, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_NETWORKGAMEPAD
2016-09-01 01:51:54 +00:00
SETTING_INT("network_remote_base_port", &settings->network_remote_base_port, true, network_remote_base_port, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_INT("menu_scroll_up_btn", &settings->menu_scroll_up_btn, true, default_menu_btn_scroll_up, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_GEKKO
2016-09-01 01:51:54 +00:00
SETTING_INT("video_viwidth", &settings->video.viwidth, true, video_viwidth, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_MENU
2016-09-01 01:51:54 +00:00
SETTING_INT("dpi_override_value", &settings->menu.dpi.override_value, true, menu_dpi_override_value, false);
SETTING_INT("menu_thumbnails", &settings->menu.thumbnails, true, menu_thumbnails_default, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_XMB
2016-09-01 01:51:54 +00:00
SETTING_INT("xmb_alpha_factor", &settings->menu.xmb.alpha_factor, true, xmb_alpha_factor, false);
SETTING_INT("xmb_scale_factor", &settings->menu.xmb.scale_factor, true, xmb_scale_factor, false);
SETTING_INT("xmb_theme", &settings->menu.xmb.theme, true, xmb_icon_theme, false);
2016-09-06 17:50:13 +00:00
SETTING_INT("xmb_menu_color_theme", &settings->menu.xmb.menu_color_theme, true, xmb_theme, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_INT("materialui_menu_color_theme", &settings->menu.materialui.menu_color_theme, true, MATERIALUI_THEME_BLUE, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_SHADERPIPELINE
2016-09-01 01:51:54 +00:00
SETTING_INT("menu_shader_pipeline", &settings->menu.xmb.shader_pipeline, true, menu_shader_pipeline, false);
#endif
#endif
SETTING_INT("audio_out_rate", &settings->audio.out_rate, true, out_rate, false);
SETTING_INT("custom_viewport_width", &settings->video_viewport_custom.width, false, 0 /* TODO */, false);
SETTING_INT("custom_viewport_height", &settings->video_viewport_custom.height, false, 0 /* TODO */, false);
SETTING_INT("custom_viewport_x", (unsigned*)&settings->video_viewport_custom.x, false, 0 /* TODO */, false);
SETTING_INT("custom_viewport_y", (unsigned*)&settings->video_viewport_custom.y, false, 0 /* TODO */, false);
SETTING_INT("content_history_size", &settings->content_history_size, true, default_content_history_size, false);
SETTING_INT("video_hard_sync_frames", &settings->video.hard_sync_frames, true, hard_sync_frames, false);
SETTING_INT("video_frame_delay", &settings->video.frame_delay, true, frame_delay, false);
SETTING_INT("video_max_swapchain_images", &settings->video.max_swapchain_images, true, max_swapchain_images, false);
SETTING_INT("video_swap_interval", &settings->video.swap_interval, true, swap_interval, false);
SETTING_INT("video_rotation", &settings->video.rotation, true, ORIENTATION_NORMAL, false);
SETTING_INT("aspect_ratio_index", &settings->video.aspect_ratio_idx, true, aspect_ratio_idx, false);
SETTING_INT("state_slot", (unsigned*)&settings->state_slot, false, 0 /* TODO */, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_NETPLAY
2016-09-01 01:51:54 +00:00
SETTING_INT("netplay_ip_port", &global->netplay.port, false, 0 /* TODO */, false);
SETTING_INT("netplay_delay_frames", &global->netplay.sync_frames, false, 16, false);
SETTING_INT("netplay_check_frames", &global->netplay.check_frames, false, 0, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_LANGEXTRA
2016-09-01 01:51:54 +00:00
SETTING_INT("user_language", &settings->user_language, true, RETRO_LANGUAGE_ENGLISH, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-01 01:51:54 +00:00
SETTING_INT("bundle_assets_extract_version_current", &settings->bundle_assets_extract_version_current, true, 0, false);
SETTING_INT("bundle_assets_extract_last_version", &settings->bundle_assets_extract_last_version, true, 0, false);
2016-08-29 17:10:00 +00:00
2016-09-05 15:16:37 +00:00
*out = (struct config_int_setting*)malloc(count * sizeof(struct config_int_setting));
memcpy(*out, tmp, sizeof(struct config_int_setting) * count);
2016-08-29 17:10:00 +00:00
free(tmp);
return count;
}
/**
* config_set_defaults:
*
* Set 'default' configuration values.
**/
static void config_set_defaults(void)
{
unsigned i, j;
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
const char *def_video = config_get_default_video();
const char *def_audio = config_get_default_audio();
const char *def_audio_resampler = config_get_default_audio_resampler();
const char *def_input = config_get_default_input();
const char *def_joypad = config_get_default_joypad();
#ifdef HAVE_MENU
const char *def_menu = config_get_default_menu();
#endif
const char *def_camera = config_get_default_camera();
const char *def_wifi = config_get_default_wifi();
2016-08-29 17:10:00 +00:00
const char *def_location = config_get_default_location();
const char *def_record = config_get_default_record();
2016-09-05 15:16:37 +00:00
struct config_bool_setting *bool_settings = NULL;
struct config_float_setting *float_settings = NULL;
struct config_int_setting *int_settings = NULL;
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
static bool first_initialized = true;
#endif
2016-08-29 18:57:24 +00:00
unsigned float_settings_size = populate_settings_float (settings, &float_settings);
unsigned bool_settings_size = populate_settings_bool (settings, &bool_settings);
2016-08-30 01:20:55 +00:00
int int_settings_size = populate_settings_int (settings, &int_settings);
for (i = 0; i < (unsigned)bool_settings_size; i++)
{
if (bool_settings[i].def_enable)
*bool_settings[i].ptr = bool_settings[i].def;
}
2016-08-29 17:10:00 +00:00
for (i = 0; i < (unsigned)int_settings_size; i++)
2016-08-30 01:20:55 +00:00
{
if (int_settings[i].def_enable)
*int_settings[i].ptr = int_settings[i].def;
}
for (i = 0; i < (unsigned)float_settings_size; i++)
2016-08-29 18:57:24 +00:00
{
if (float_settings[i].def_enable)
*float_settings[i].ptr = float_settings[i].def;
}
2016-08-29 17:10:00 +00:00
if (def_camera)
strlcpy(settings->camera.driver,
def_camera, sizeof(settings->camera.driver));
if (def_wifi)
strlcpy(settings->wifi.driver,
def_wifi, sizeof(settings->wifi.driver));
2016-08-29 17:10:00 +00:00
if (def_location)
strlcpy(settings->location.driver,
def_location, sizeof(settings->location.driver));
if (def_video)
strlcpy(settings->video.driver,
def_video, sizeof(settings->video.driver));
if (def_audio)
strlcpy(settings->audio.driver,
def_audio, sizeof(settings->audio.driver));
if (def_audio_resampler)
strlcpy(settings->audio.resampler,
def_audio_resampler, sizeof(settings->audio.resampler));
if (def_input)
strlcpy(settings->input.driver,
def_input, sizeof(settings->input.driver));
if (def_joypad)
strlcpy(settings->input.joypad_driver,
def_joypad, sizeof(settings->input.joypad_driver));
if (def_record)
strlcpy(settings->record.driver,
def_record, sizeof(settings->record.driver));
#ifdef HAVE_MENU
if (def_menu)
strlcpy(settings->menu.driver,
def_menu, sizeof(settings->menu.driver));
#ifdef HAVE_XMB
2016-08-29 19:07:22 +00:00
*settings->menu.xmb.font = '\0';
2016-08-29 17:10:00 +00:00
#endif
2016-08-30 01:30:38 +00:00
#ifdef HAVE_MATERIALUI
2016-08-29 17:10:00 +00:00
if (g_defaults.menu.materialui.menu_color_theme_enable)
settings->menu.materialui.menu_color_theme = g_defaults.menu.materialui.menu_color_theme;
#endif
#endif
#ifdef HAVE_FFMPEG
settings->multimedia.builtin_mediaplayer_enable = true;
#else
settings->multimedia.builtin_mediaplayer_enable = false;
#endif
2016-09-01 02:11:53 +00:00
settings->video.scale = scale;
2016-08-29 17:10:00 +00:00
2016-08-29 19:09:18 +00:00
if (rarch_ctl(RARCH_CTL_IS_FORCE_FULLSCREEN, NULL))
2016-09-01 02:11:53 +00:00
settings->video.fullscreen = true;
2016-08-29 19:09:18 +00:00
2016-08-29 17:10:00 +00:00
if (g_defaults.settings.video_threaded_enable != video_threaded)
2016-09-01 02:11:53 +00:00
settings->video.threaded = g_defaults.settings.video_threaded_enable;
2016-08-29 17:10:00 +00:00
2015-05-08 07:15:53 +00:00
settings->video.msg_color_r = ((message_color >> 16) & 0xff) / 255.0f;
settings->video.msg_color_g = ((message_color >> 8) & 0xff) / 255.0f;
settings->video.msg_color_b = ((message_color >> 0) & 0xff) / 255.0f;
2011-01-23 01:48:06 +00:00
2014-09-01 23:27:46 +00:00
if (g_defaults.settings.video_refresh_rate > 0.0 &&
g_defaults.settings.video_refresh_rate != refresh_rate)
2015-04-13 00:12:28 +00:00
settings->video.refresh_rate = g_defaults.settings.video_refresh_rate;
2010-12-29 18:00:21 +00:00
if (audio_device)
2015-03-20 18:32:46 +00:00
strlcpy(settings->audio.device,
audio_device, sizeof(settings->audio.device));
2014-06-12 16:30:41 +00:00
if (!g_defaults.settings.out_latency)
2015-04-13 00:12:28 +00:00
g_defaults.settings.out_latency = out_latency;
settings->audio.latency = g_defaults.settings.out_latency;
audio_driver_set_volume_gain(db_to_gain(settings->audio.volume));
2015-04-13 00:12:28 +00:00
settings->rewind_buffer_size = rewind_buffer_size;
2015-03-20 18:32:46 +00:00
#ifdef HAVE_LAKKA
2016-09-01 02:11:53 +00:00
settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH);
settings->samba_enable = path_file_exists(LAKKA_SAMBA_PATH);
settings->bluetooth_enable = path_file_exists(LAKKA_BLUETOOTH_PATH);
#endif
2014-02-10 19:26:48 +00:00
#ifdef HAVE_MENU
2016-01-11 21:52:17 +00:00
if (first_initialized)
settings->menu_show_start_screen = default_menu_show_start_screen;
2015-05-08 07:15:53 +00:00
settings->menu.entry_normal_color = menu_entry_normal_color;
settings->menu.entry_hover_color = menu_entry_hover_color;
settings->menu.title_color = menu_title_color;
2014-02-10 19:26:48 +00:00
#endif
#ifdef HAVE_CHEEVOS
2016-09-01 02:11:53 +00:00
*settings->cheevos.username = '\0';
*settings->cheevos.password = '\0';
#endif
retro_assert(sizeof(settings->input.binds[0]) >= sizeof(retro_keybinds_1));
retro_assert(sizeof(settings->input.binds[1]) >= sizeof(retro_keybinds_rest));
2015-01-05 01:36:10 +00:00
2015-03-20 18:32:46 +00:00
memcpy(settings->input.binds[0], retro_keybinds_1, sizeof(retro_keybinds_1));
2015-01-05 01:36:10 +00:00
2015-01-05 00:58:00 +00:00
for (i = 1; i < MAX_USERS; i++)
2015-03-20 18:32:46 +00:00
memcpy(settings->input.binds[i], retro_keybinds_rest,
2014-09-01 23:27:46 +00:00
sizeof(retro_keybinds_rest));
input_remapping_set_defaults();
2010-12-29 18:43:17 +00:00
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
{
for (j = 0; j < RARCH_BIND_LIST_END; j++)
{
2015-04-13 00:12:28 +00:00
settings->input.autoconf_binds[i][j].joykey = NO_BTN;
2015-03-20 18:32:46 +00:00
settings->input.autoconf_binds[i][j].joyaxis = AXIS_NONE;
}
}
2015-03-20 18:32:46 +00:00
memset(settings->input.autoconfigured, 0,
sizeof(settings->input.autoconfigured));
2013-04-26 12:36:36 +00:00
2014-09-01 23:27:46 +00:00
/* Verify that binds are in proper order. */
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
2016-09-01 02:11:53 +00:00
{
for (j = 0; j < RARCH_BIND_LIST_END; j++)
2015-01-05 01:36:10 +00:00
{
2015-03-20 18:32:46 +00:00
if (settings->input.binds[i][j].valid)
retro_assert(j == settings->input.binds[i][j].id);
2015-01-05 01:36:10 +00:00
}
2016-09-01 02:11:53 +00:00
}
2015-03-20 18:32:46 +00:00
strlcpy(settings->network.buildbot_url, buildbot_server_url,
sizeof(settings->network.buildbot_url));
strlcpy(settings->network.buildbot_assets_url, buildbot_assets_server_url,
sizeof(settings->network.buildbot_assets_url));
2015-01-19 03:09:28 +00:00
2015-05-08 07:15:53 +00:00
*settings->input.keyboard_layout = '\0';
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
{
2015-03-20 18:32:46 +00:00
settings->input.joypad_map[i] = i;
settings->input.analog_dpad_mode[i] = ANALOG_DPAD_NONE;
2015-07-27 15:18:10 +00:00
if (!global->has_set.libretro_device[i])
2015-03-20 18:32:46 +00:00
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
}
2016-05-08 12:00:51 +00:00
video_driver_reset_custom_viewport();
/* Make sure settings from other configs carry over into defaults
2014-09-01 23:27:46 +00:00
* for another config. */
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH))
2016-09-17 12:53:30 +00:00
dir_clear_savefile();
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH))
2016-09-17 12:53:30 +00:00
dir_clear_savestate();
2016-04-28 17:52:25 +00:00
*settings->path.libretro_info = '\0';
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY))
2016-04-28 17:26:02 +00:00
*settings->directory.libretro = '\0';
*settings->directory.cursor = '\0';
*settings->directory.resampler = '\0';
*settings->directory.screenshot = '\0';
*settings->directory.system = '\0';
*settings->directory.cache = '\0';
*settings->directory.input_remapping = '\0';
*settings->directory.core_assets = '\0';
*settings->directory.assets = '\0';
*settings->directory.dynamic_wallpapers = '\0';
*settings->directory.thumbnails = '\0';
*settings->directory.playlist = '\0';
2016-04-28 18:49:13 +00:00
*settings->directory.autoconfig = '\0';
2016-04-28 17:26:02 +00:00
#ifdef HAVE_MENU
*settings->directory.menu_content = '\0';
*settings->directory.menu_config = '\0';
#endif
2016-04-28 18:49:13 +00:00
*settings->directory.video_shader = '\0';
*settings->directory.video_filter = '\0';
*settings->directory.audio_filter = '\0';
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
2015-07-27 15:18:10 +00:00
global->patch.ups_pref = false;
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
2015-07-27 15:18:10 +00:00
global->patch.bps_pref = false;
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
2015-07-27 15:18:10 +00:00
global->patch.ips_pref = false;
2015-04-15 10:42:36 +00:00
*global->record.output_dir = '\0';
*global->record.config_dir = '\0';
2016-04-28 17:52:25 +00:00
*settings->path.core_options = '\0';
*settings->path.content_history = '\0';
*settings->path.content_music_history = '\0';
*settings->path.content_image_history = '\0';
*settings->path.content_video_history = '\0';
2016-04-28 17:52:25 +00:00
*settings->path.cheat_settings = '\0';
*settings->path.shader = '\0';
#ifndef IOS
2016-04-28 17:52:25 +00:00
*settings->path.bundle_assets_src = '\0';
*settings->path.bundle_assets_dst = '\0';
*settings->path.bundle_assets_dst_subdir = '\0';
#endif
2016-04-28 18:49:13 +00:00
*settings->path.cheat_database = '\0';
*settings->path.menu_wallpaper = '\0';
*settings->path.content_database = '\0';
*settings->path.overlay = '\0';
*settings->path.softfilter_plugin = '\0';
2016-04-28 17:52:25 +00:00
*settings->playlist_names = '\0';
*settings->playlist_cores = '\0';
2016-04-28 17:26:02 +00:00
*settings->directory.content_history = '\0';
2016-04-28 18:49:13 +00:00
*settings->path.audio_dsp_plugin = '\0';
2016-05-08 12:00:51 +00:00
video_driver_default_settings();
2015-11-21 08:54:55 +00:00
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.wallpapers))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.dynamic_wallpapers,
g_defaults.dir.wallpapers, sizeof(settings->directory.dynamic_wallpapers));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.thumbnails))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.thumbnails,
g_defaults.dir.thumbnails, sizeof(settings->directory.thumbnails));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.remap))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.input_remapping,
g_defaults.dir.remap, sizeof(settings->directory.input_remapping));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.cache))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.cache,
g_defaults.dir.cache, sizeof(settings->directory.cache));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.assets))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.assets,
g_defaults.dir.assets, sizeof(settings->directory.assets));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.core_assets))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.core_assets,
g_defaults.dir.core_assets, sizeof(settings->directory.core_assets));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.playlist))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.playlist,
g_defaults.dir.playlist, sizeof(settings->directory.playlist));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.core))
2016-04-28 17:26:02 +00:00
fill_pathname_expand_special(settings->directory.libretro,
g_defaults.dir.core, sizeof(settings->directory.libretro));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.audio_filter))
2016-04-28 18:49:13 +00:00
strlcpy(settings->directory.audio_filter,
g_defaults.dir.audio_filter, sizeof(settings->directory.audio_filter));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.video_filter))
2016-04-28 18:49:13 +00:00
strlcpy(settings->directory.video_filter,
g_defaults.dir.video_filter, sizeof(settings->directory.video_filter));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.shader))
2016-04-28 18:49:13 +00:00
fill_pathname_expand_special(settings->directory.video_shader,
g_defaults.dir.shader, sizeof(settings->directory.video_shader));
2016-04-28 17:26:02 +00:00
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.path.buildbot_server_url))
2016-04-28 17:26:02 +00:00
strlcpy(settings->network.buildbot_url,
g_defaults.path.buildbot_server_url, sizeof(settings->network.buildbot_url));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.path.core))
2015-11-30 20:42:59 +00:00
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, g_defaults.path.core);
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.database))
2016-04-28 18:49:13 +00:00
strlcpy(settings->path.content_database, g_defaults.dir.database,
sizeof(settings->path.content_database));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.cursor))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.cursor, g_defaults.dir.cursor,
sizeof(settings->directory.cursor));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.cheats))
2016-04-28 18:49:13 +00:00
strlcpy(settings->path.cheat_database, g_defaults.dir.cheats,
sizeof(settings->path.cheat_database));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.core_info))
2016-04-28 17:52:25 +00:00
fill_pathname_expand_special(settings->path.libretro_info,
g_defaults.dir.core_info, sizeof(settings->path.libretro_info));
#ifdef HAVE_OVERLAY
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.overlay))
{
2016-04-28 17:26:02 +00:00
fill_pathname_expand_special(settings->directory.overlay,
g_defaults.dir.overlay, sizeof(settings->directory.overlay));
#ifdef RARCH_MOBILE
2016-07-23 01:13:24 +00:00
if (string_is_empty(settings->path.overlay))
2016-04-28 18:51:08 +00:00
fill_pathname_join(settings->path.overlay,
2016-04-28 17:26:02 +00:00
settings->directory.overlay,
2014-09-01 23:27:46 +00:00
"gamepads/retropad/retropad.cfg",
2016-04-28 18:51:08 +00:00
sizeof(settings->path.overlay));
#endif
}
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.osk_overlay))
{
2016-09-17 14:28:46 +00:00
char temp_path[PATH_MAX_LENGTH] = {0};
fill_pathname_expand_special(temp_path,
g_defaults.dir.osk_overlay, sizeof(temp_path));
#ifdef RARCH_MOBILE
2016-06-26 09:08:38 +00:00
if (string_is_empty(settings->path.osk_overlay))
2016-04-28 18:51:08 +00:00
fill_pathname_join(settings->path.osk_overlay,
2016-09-17 14:28:46 +00:00
temp_path,
2015-09-01 19:08:29 +00:00
"keyboards/modular-keyboard/opaque/big.cfg",
2016-04-28 18:51:08 +00:00
sizeof(settings->path.osk_overlay));
#endif
2016-09-17 14:28:46 +00:00
dir_set_osk_overlay(temp_path);
}
else
2016-09-17 14:28:46 +00:00
{
char temp_path[PATH_MAX_LENGTH] = {0};
strlcpy(temp_path,
2016-07-01 06:53:27 +00:00
settings->directory.overlay,
2016-09-17 14:28:46 +00:00
sizeof(temp_path));
dir_set_osk_overlay(temp_path);
}
#endif
#ifdef HAVE_MENU
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.menu_config))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.menu_config,
2015-07-27 15:18:10 +00:00
g_defaults.dir.menu_config,
2016-04-28 17:26:02 +00:00
sizeof(settings->directory.menu_config));
2016-08-29 04:21:29 +00:00
if (!string_is_empty(g_defaults.dir.menu_content))
strlcpy(settings->directory.menu_content,
g_defaults.dir.menu_content,
sizeof(settings->directory.menu_content));
#endif
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.autoconfig))
2016-04-28 18:49:13 +00:00
strlcpy(settings->directory.autoconfig,
2015-07-27 15:18:10 +00:00
g_defaults.dir.autoconfig,
2016-04-28 18:49:13 +00:00
sizeof(settings->directory.autoconfig));
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
!string_is_empty(g_defaults.dir.savestate))
2016-09-17 12:49:35 +00:00
dir_set_savestate(g_defaults.dir.savestate);
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) &&
!string_is_empty(g_defaults.dir.sram))
2016-09-17 12:49:35 +00:00
dir_set_savefile(g_defaults.dir.sram);
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.system))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.system,
g_defaults.dir.system, sizeof(settings->directory.system));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.screenshot))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.screenshot,
2015-07-27 15:18:10 +00:00
g_defaults.dir.screenshot,
2016-04-28 17:26:02 +00:00
sizeof(settings->directory.screenshot));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.resampler))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.resampler,
2015-07-27 15:18:10 +00:00
g_defaults.dir.resampler,
2016-04-28 17:26:02 +00:00
sizeof(settings->directory.resampler));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.dir.content_history))
2016-04-28 17:26:02 +00:00
strlcpy(settings->directory.content_history,
2015-07-27 15:18:10 +00:00
g_defaults.dir.content_history,
2016-04-28 17:26:02 +00:00
sizeof(settings->directory.content_history));
2014-06-12 16:06:29 +00:00
2016-06-28 09:02:51 +00:00
if (!string_is_empty(g_defaults.path.config))
{
char temp_str[PATH_MAX_LENGTH];
fill_pathname_expand_special(temp_str,
g_defaults.path.config, sizeof(temp_str));
path_set_config(temp_str);
}
2015-01-13 23:35:27 +00:00
2016-08-29 17:10:00 +00:00
/* Avoid reloading config on every content load */
if (default_block_config_read)
rarch_ctl(RARCH_CTL_SET_BLOCK_CONFIG_READ, NULL);
else
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
#ifdef HAVE_MENU
first_initialized = false;
#endif
if (bool_settings)
free(bool_settings);
2016-08-29 18:57:24 +00:00
if (float_settings)
free(float_settings);
2016-08-30 01:20:55 +00:00
if (int_settings)
free(int_settings);
2015-01-11 04:29:32 +00:00
}
2016-08-29 17:10:00 +00:00
/**
* open_default_config_file
*
* Open a default config file. Platform-specific.
*
* Returns: handle to config file if found, otherwise NULL.
**/
static config_file_t *open_default_config_file(void)
2015-01-11 04:29:32 +00:00
{
2016-08-29 17:10:00 +00:00
char application_data[PATH_MAX_LENGTH] = {0};
char conf_path[PATH_MAX_LENGTH] = {0};
char app_path[PATH_MAX_LENGTH] = {0};
config_file_t *conf = NULL;
2015-01-13 23:35:27 +00:00
2016-08-29 17:10:00 +00:00
#if defined(_WIN32) && !defined(_XBOX)
fill_pathname_application_path(app_path, sizeof(app_path));
fill_pathname_resolve_relative(conf_path, app_path,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
2015-01-11 04:29:32 +00:00
2016-08-29 17:10:00 +00:00
conf = config_file_new(conf_path);
2015-01-11 04:29:32 +00:00
2016-08-29 17:10:00 +00:00
if (!conf)
{
if (fill_pathname_application_data(application_data,
sizeof(application_data)))
{
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
conf = config_file_new(conf_path);
}
2015-01-11 04:29:32 +00:00
}
2016-08-29 17:10:00 +00:00
if (!conf)
{
bool saved = false;
2015-01-13 23:35:27 +00:00
2016-08-29 17:10:00 +00:00
/* Try to create a new config file. */
conf = config_file_new(NULL);
2012-02-29 18:25:54 +00:00
2015-01-09 15:59:19 +00:00
2016-08-29 17:10:00 +00:00
if (conf)
{
/* Since this is a clean config file, we can
* safely use config_save_on_exit. */
fill_pathname_resolve_relative(conf_path, app_path,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path);
}
2016-08-29 17:10:00 +00:00
if (!saved)
{
/* WARN here to make sure user has a good chance of seeing it. */
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
conf_path);
config_file_free(conf);
return NULL;
}
2015-01-13 23:35:27 +00:00
2016-08-29 17:10:00 +00:00
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
}
2016-08-29 17:10:00 +00:00
#elif defined(OSX)
if (!fill_pathname_application_data(application_data,
sizeof(application_data)))
return NULL;
2015-11-21 17:08:37 +00:00
2016-08-29 17:10:00 +00:00
path_mkdir(application_data);
2015-11-21 17:08:37 +00:00
2016-08-29 17:10:00 +00:00
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
conf = config_file_new(conf_path);
2016-08-29 14:57:33 +00:00
2016-08-29 17:10:00 +00:00
if (!conf)
{
bool saved = false;
2016-08-29 14:57:33 +00:00
2016-08-29 17:10:00 +00:00
conf = config_file_new(NULL);
if (conf)
{
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path);
}
if (!saved)
{
/* WARN here to make sure user has a good chance of seeing it. */
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
conf_path);
config_file_free(conf);
return NULL;
}
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
}
#elif !defined(RARCH_CONSOLE)
2016-08-30 02:42:02 +00:00
bool has_application_data =
fill_pathname_application_data(application_data,
2016-08-29 17:10:00 +00:00
sizeof(application_data));
if (has_application_data)
{
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
/* Fallback to $HOME/.retroarch.cfg. */
if (!conf && getenv("HOME"))
{
fill_pathname_join(conf_path, getenv("HOME"),
".retroarch.cfg", sizeof(conf_path));
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
if (!conf && has_application_data)
{
char basedir[PATH_MAX_LENGTH] = {0};
/* Try to create a new config file. */
strlcpy(conf_path, application_data, sizeof(conf_path));
fill_pathname_basedir(basedir, conf_path, sizeof(basedir));
2016-08-30 02:42:02 +00:00
fill_pathname_join(conf_path, conf_path,
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(conf_path));
2016-08-29 17:10:00 +00:00
if (path_mkdir(basedir))
{
bool saved = false;
char skeleton_conf[PATH_MAX_LENGTH] = {0};
#if defined(__HAIKU__)
fill_pathname_join(skeleton_conf, "/system/settings",
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(skeleton_conf));
#else
fill_pathname_join(skeleton_conf, "/etc",
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(skeleton_conf));
2016-08-29 13:36:55 +00:00
#endif
2016-08-29 17:10:00 +00:00
conf = config_file_new(skeleton_conf);
if (conf)
RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf);
else
conf = config_file_new(NULL);
if (conf)
{
/* Since this is a clean config file, we can safely use config_save_on_exit. */
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path);
}
if (!saved)
{
/* WARN here to make sure user has a good chance of seeing it. */
RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
config_file_free(conf);
return NULL;
}
RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path);
}
}
2016-08-29 13:36:55 +00:00
#endif
2016-08-29 14:57:33 +00:00
2016-08-29 17:10:00 +00:00
(void)application_data;
(void)conf_path;
(void)app_path;
if (!conf)
return NULL;
path_set_config(conf_path);
2016-08-29 17:10:00 +00:00
return conf;
2016-08-29 13:36:55 +00:00
}
2016-08-29 17:10:00 +00:00
static void read_keybinds_keyboard(config_file_t *conf, unsigned user,
unsigned idx, struct retro_keybind *bind)
{
const char *prefix = NULL;
if (!input_config_bind_map_get_valid(idx))
return;
if (!input_config_bind_map_get_base(idx))
return;
prefix = input_config_get_prefix(user, input_config_bind_map_get_meta(idx));
if (prefix)
input_config_parse_key(conf, prefix,
input_config_bind_map_get_base(idx), bind);
2016-08-29 14:57:33 +00:00
}
2016-08-29 17:10:00 +00:00
static void read_keybinds_button(config_file_t *conf, unsigned user,
unsigned idx, struct retro_keybind *bind)
{
2016-08-29 17:10:00 +00:00
const char *prefix = NULL;
2016-08-29 17:10:00 +00:00
if (!input_config_bind_map_get_valid(idx))
return;
if (!input_config_bind_map_get_base(idx))
return;
2016-08-29 17:10:00 +00:00
prefix = input_config_get_prefix(user,
input_config_bind_map_get_meta(idx));
if (prefix)
input_config_parse_joy_button(conf, prefix,
input_config_bind_map_get_base(idx), bind);
}
2016-08-29 17:10:00 +00:00
static void read_keybinds_axis(config_file_t *conf, unsigned user,
unsigned idx, struct retro_keybind *bind)
{
const char *prefix = NULL;
if (!input_config_bind_map_get_valid(idx))
return;
if (!input_config_bind_map_get_base(idx))
return;
prefix = input_config_get_prefix(user,
input_config_bind_map_get_meta(idx));
if (prefix)
input_config_parse_joy_axis(conf, prefix,
input_config_bind_map_get_base(idx), bind);
}
2016-08-29 17:10:00 +00:00
static void read_keybinds_user(config_file_t *conf, unsigned user)
2016-08-29 13:26:42 +00:00
{
2016-08-29 17:10:00 +00:00
unsigned i;
settings_t *settings = config_get_ptr();
2016-08-29 17:10:00 +00:00
for (i = 0; input_config_bind_map_get_valid(i); i++)
{
struct retro_keybind *bind = (struct retro_keybind*)
&settings->input.binds[user][i];
if (!bind->valid)
continue;
read_keybinds_keyboard(conf, user, i, bind);
read_keybinds_button(conf, user, i, bind);
read_keybinds_axis(conf, user, i, bind);
}
}
static void config_read_keybinds_conf(config_file_t *conf)
{
unsigned i;
for (i = 0; i < MAX_USERS; i++)
read_keybinds_user(conf, i);
}
/* Also dumps inherited values, useful for logging. */
#if 0
static void config_file_dump_all(config_file_t *conf)
{
struct config_entry_list *list = NULL;
struct config_include_list *includes = conf->includes;
while (includes)
{
RARCH_LOG("#include \"%s\"\n", includes->path);
includes = includes->next;
}
list = conf->entries;
while (list)
{
RARCH_LOG("%s = \"%s\"%s\n", list->key,
list->value, list->readonly ? " (included)" : "");
list = list->next;
}
}
2016-08-29 13:26:42 +00:00
#endif
2016-08-29 17:10:00 +00:00
2016-08-29 13:26:42 +00:00
#ifdef HAVE_MENU
2016-08-30 02:37:49 +00:00
static void config_get_hex_base(config_file_t *conf,
const char *key, unsigned *base)
2016-08-29 17:10:00 +00:00
{
unsigned tmp = 0;
if (!base)
return;
if (config_get_hex(conf, key, &tmp))
*base = tmp;
}
2016-08-29 13:26:42 +00:00
#endif
/**
* config_load:
* @path : path to be read from.
* @set_defaults : set default values first before
* reading the values from the config file
*
* Loads a config file and reads all the values into memory.
*
*/
static bool config_load_file(const char *path, bool set_defaults,
settings_t *settings)
{
unsigned i;
2016-09-20 14:32:33 +00:00
bool ret = false;
2016-08-29 13:26:42 +00:00
bool tmp_bool = false;
char *save = NULL;
char tmp_str[PATH_MAX_LENGTH] = {0};
unsigned msg_color = 0;
config_file_t *conf = NULL;
2016-09-05 15:16:37 +00:00
struct config_int_setting *int_settings = NULL;
struct config_float_setting *float_settings = NULL;
struct config_bool_setting *bool_settings = NULL;
struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL;
2016-09-03 06:12:40 +00:00
char *override_username = NULL;
2016-09-05 06:03:25 +00:00
#ifdef HAVE_NETPLAY
2016-09-03 06:12:40 +00:00
char *override_netplay_ip_address = NULL;
2016-09-05 06:03:25 +00:00
#endif
2016-08-29 13:26:42 +00:00
global_t *global = global_get_ptr();
2016-08-29 18:18:20 +00:00
int bool_settings_size = populate_settings_bool (settings, &bool_settings);
int float_settings_size = populate_settings_float (settings, &float_settings);
int int_settings_size = populate_settings_int (settings, &int_settings);
int array_settings_size = populate_settings_array (settings, &array_settings);
2016-09-01 02:37:22 +00:00
int path_settings_size = populate_settings_path (settings, &path_settings);
2016-07-24 08:42:49 +00:00
if (path)
2010-12-29 18:00:21 +00:00
{
conf = config_file_new(path);
2010-12-30 00:33:40 +00:00
if (!conf)
2016-09-20 14:32:33 +00:00
goto end;
2010-12-29 18:00:21 +00:00
}
else
conf = open_default_config_file();
2010-12-29 18:00:21 +00:00
if (!conf)
2016-09-20 14:32:33 +00:00
{
ret = true;
goto end;
2016-09-20 14:32:33 +00:00
}
2010-12-29 18:00:21 +00:00
if (set_defaults)
config_set_defaults();
2016-09-17 12:14:58 +00:00
if (!path_is_config_append_empty())
2012-09-10 22:10:44 +00:00
{
2016-09-17 12:14:58 +00:00
/* Don't destroy append_config_path, store in temporary
* variable. */
char tmp_append_path[PATH_MAX_LENGTH] = {0};
const char *extra_path = NULL;
strlcpy(tmp_append_path, path_get_config_append(),
sizeof(tmp_append_path));
extra_path = strtok_r(tmp_append_path, "|", &save);
2016-09-17 12:14:58 +00:00
while (extra_path)
{
bool ret = config_append_file(conf, extra_path);
2016-09-17 12:14:58 +00:00
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
if (!ret)
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
extra_path = strtok_r(NULL, "|", &save);
}
2012-09-10 22:10:44 +00:00
}
2016-09-17 12:14:58 +00:00
2015-04-15 20:31:24 +00:00
#if 0
2016-05-31 02:42:04 +00:00
if (verbosity_is_enabled())
2011-10-17 17:11:31 +00:00
{
RARCH_LOG_OUTPUT("=== Config ===\n");
config_file_dump_all(conf);
RARCH_LOG_OUTPUT("=== Config end ===\n");
2011-10-17 17:11:31 +00:00
}
2015-04-15 20:31:24 +00:00
#endif
2010-12-29 18:00:21 +00:00
2016-09-03 06:12:40 +00:00
/* Overrides */
if (rarch_ctl(RARCH_CTL_HAS_SET_USERNAME, NULL))
override_username = strdup(settings->username);
#ifdef HAVE_NETPLAY
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS))
override_netplay_ip_address = strdup(global->netplay.server);
#endif
2016-08-29 13:26:42 +00:00
/* Boolean settings */
2016-07-25 06:01:47 +00:00
for (i = 0; i < (unsigned)bool_settings_size; i++)
2016-07-24 07:43:16 +00:00
{
bool tmp = false;
if (config_get_bool(conf, bool_settings[i].ident, &tmp))
2016-07-25 09:08:23 +00:00
*bool_settings[i].ptr = tmp;
2016-07-24 07:43:16 +00:00
}
2016-09-17 12:14:58 +00:00
2015-11-30 21:02:54 +00:00
if (!rarch_ctl(RARCH_CTL_IS_FORCE_FULLSCREEN, NULL))
CONFIG_GET_BOOL_BASE(conf, settings, video.fullscreen, "video_fullscreen");
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
2016-07-24 07:43:16 +00:00
{
CONFIG_GET_BOOL_BASE(conf, global, patch.ups_pref, "ups_pref");
}
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
2016-07-24 07:43:16 +00:00
{
CONFIG_GET_BOOL_BASE(conf, global, patch.bps_pref, "bps_pref");
}
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
2016-07-24 07:43:16 +00:00
{
CONFIG_GET_BOOL_BASE(conf, global, patch.ips_pref, "ips_pref");
}
2016-08-01 19:51:23 +00:00
2016-07-24 07:43:16 +00:00
#ifdef HAVE_NETPLAY
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE))
2016-07-24 07:43:16 +00:00
CONFIG_GET_BOOL_BASE(conf, global, netplay.is_spectate,
"netplay_spectator_mode_enable");
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_MODE))
2016-07-24 07:43:16 +00:00
CONFIG_GET_BOOL_BASE(conf, global, netplay.is_client, "netplay_mode");
#endif
2016-07-25 06:01:47 +00:00
#ifdef HAVE_NETWORKGAMEPAD
for (i = 0; i < MAX_USERS; i++)
{
char tmp[64] = {0};
snprintf(tmp, sizeof(tmp), "network_remote_enable_user_p%u", i + 1);
if (config_get_bool(conf, tmp, &tmp_bool))
settings->network_remote_enable_user[i] = tmp_bool;
}
#endif
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_VERBOSITY))
2016-07-25 06:01:47 +00:00
{
if (config_get_bool(conf, "log_verbosity", &tmp_bool))
{
if (tmp_bool)
verbosity_enable();
else
verbosity_disable();
}
}
{
char tmp[64] = {0};
strlcpy(tmp, "perfcnt_enable", sizeof(tmp));
if (config_get_bool(conf, tmp, &tmp_bool))
{
if (tmp_bool)
runloop_ctl(RUNLOOP_CTL_SET_PERFCNT_ENABLE, NULL);
else
runloop_ctl(RUNLOOP_CTL_UNSET_PERFCNT_ENABLE, NULL);
}
}
2016-08-29 13:26:42 +00:00
/* Integer settings */
2016-07-24 07:43:16 +00:00
for (i = 0; i < (unsigned)int_settings_size; i++)
2016-07-24 07:43:16 +00:00
{
int tmp = 0;
if (config_get_int(conf, int_settings[i].ident, &tmp))
2016-07-25 09:08:23 +00:00
*int_settings[i].ptr = tmp;
2016-07-24 07:43:16 +00:00
}
2016-07-24 07:12:23 +00:00
#ifdef HAVE_NETPLAY
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_DELAY_FRAMES))
2016-07-24 07:12:23 +00:00
CONFIG_GET_INT_BASE(conf, global, netplay.sync_frames, "netplay_delay_frames");
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES))
CONFIG_GET_INT_BASE(conf, global, netplay.check_frames, "netplay_check_frames");
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT))
2016-07-24 07:12:23 +00:00
CONFIG_GET_INT_BASE(conf, global, netplay.port, "netplay_ip_port");
#endif
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
{
2015-06-12 15:00:37 +00:00
char buf[64] = {0};
2012-02-18 11:09:20 +00:00
snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1);
2015-03-21 07:05:50 +00:00
CONFIG_GET_INT_BASE(conf, settings, input.joypad_map[i], buf);
snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1);
2015-03-21 07:05:50 +00:00
CONFIG_GET_INT_BASE(conf, settings, input.analog_dpad_mode[i], buf);
2015-07-27 15:18:10 +00:00
if (!global->has_set.libretro_device[i])
{
snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1);
2015-03-21 07:05:50 +00:00
CONFIG_GET_INT_BASE(conf, settings, input.libretro_device[i], buf);
}
}
2016-07-24 07:12:23 +00:00
{
/* ugly hack around C89 not allowing mixing declarations and code */
int buffer_size = 0;
if (config_get_int(conf, "rewind_buffer_size", &buffer_size))
settings->rewind_buffer_size = buffer_size * UINT64_C(1000000);
}
2016-07-25 06:01:47 +00:00
2016-08-29 13:26:42 +00:00
/* Hexadecimal settings */
2016-07-24 06:52:03 +00:00
if (config_get_hex(conf, "video_message_color", &msg_color))
{
settings->video.msg_color_r = ((msg_color >> 16) & 0xff) / 255.0f;
settings->video.msg_color_g = ((msg_color >> 8) & 0xff) / 255.0f;
settings->video.msg_color_b = ((msg_color >> 0) & 0xff) / 255.0f;
}
#ifdef HAVE_MENU
config_get_hex_base(conf, "menu_entry_normal_color",
&settings->menu.entry_normal_color);
config_get_hex_base(conf, "menu_entry_hover_color",
&settings->menu.entry_hover_color);
config_get_hex_base(conf, "menu_title_color",
&settings->menu.title_color);
#endif
2016-08-29 13:26:42 +00:00
/* Float settings */
for (i = 0; i < (unsigned)float_settings_size; i++)
2016-07-24 08:42:49 +00:00
{
float tmp = 0.0f;
if (config_get_float(conf, float_settings[i].ident, &tmp))
2016-07-25 09:08:23 +00:00
*float_settings[i].ptr = tmp;
2016-07-24 08:42:49 +00:00
}
2016-08-29 13:26:42 +00:00
/* Array settings */
for (i = 0; i < (unsigned)array_settings_size; i++)
2016-09-01 00:40:05 +00:00
{
2016-09-01 02:40:02 +00:00
if (!array_settings[i].handle)
continue;
config_get_array(conf, array_settings[i].ident,
array_settings[i].ptr, PATH_MAX_LENGTH);
2016-09-01 00:40:05 +00:00
}
2016-08-29 13:26:42 +00:00
/* Path settings */
for (i = 0; i < (unsigned)path_settings_size; i++)
2016-09-01 02:37:22 +00:00
{
if (!path_settings[i].handle)
continue;
if (config_get_path(conf, path_settings[i].ident, tmp_str, sizeof(tmp_str)))
2016-09-01 03:24:47 +00:00
strlcpy(path_settings[i].ptr, tmp_str, PATH_MAX_LENGTH);
2016-09-01 02:37:22 +00:00
}
2016-06-25 05:12:37 +00:00
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DIRECTORY))
2016-07-24 06:52:03 +00:00
{
if (config_get_path(conf, "libretro_directory", tmp_str, sizeof(tmp_str)))
strlcpy(settings->directory.libretro, tmp_str, sizeof(settings->directory.libretro));
}
2016-08-01 19:51:23 +00:00
2016-07-24 06:52:03 +00:00
#ifndef HAVE_DYNAMIC
if (config_get_path(conf, "libretro_path", tmp_str, sizeof(tmp_str)))
2016-09-17 10:51:44 +00:00
path_set_core(tmp_str);
2016-07-24 06:52:03 +00:00
#endif
2016-09-01 02:37:22 +00:00
2016-09-03 06:12:40 +00:00
#ifdef RARCH_CONSOLE
video_driver_load_settings(conf);
#endif
/* Post-settings load */
if (rarch_ctl(RARCH_CTL_HAS_SET_USERNAME, NULL) && override_username)
2016-07-24 06:52:03 +00:00
{
2016-09-03 06:12:40 +00:00
strlcpy(settings->username, override_username, sizeof(settings->username));
free(override_username);
2016-07-24 06:52:03 +00:00
}
2016-09-03 06:12:40 +00:00
2016-07-24 06:52:03 +00:00
#ifdef HAVE_NETPLAY
2016-09-03 06:12:40 +00:00
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_NETPLAY_IP_ADDRESS))
2016-07-24 06:52:03 +00:00
{
2016-09-03 06:12:40 +00:00
strlcpy(global->netplay.server, override_netplay_ip_address, sizeof(global->netplay.server));
free(override_netplay_ip_address);
2016-07-24 06:52:03 +00:00
}
#endif
if (settings->video.hard_sync_frames > 3)
settings->video.hard_sync_frames = 3;
if (settings->video.frame_delay > 15)
settings->video.frame_delay = 15;
settings->video.swap_interval = MAX(settings->video.swap_interval, 1);
settings->video.swap_interval = MIN(settings->video.swap_interval, 4);
audio_driver_set_volume_gain(db_to_gain(settings->audio.volume));
2016-04-28 18:49:13 +00:00
if (string_is_empty(settings->path.content_history))
{
if (string_is_empty(settings->directory.content_history))
{
fill_pathname_resolve_relative(
settings->path.content_history,
path_get_config(),
2016-06-20 03:11:01 +00:00
file_path_str(FILE_PATH_CONTENT_HISTORY),
2016-04-28 18:49:13 +00:00
sizeof(settings->path.content_history));
}
else
{
fill_pathname_join(settings->path.content_history,
settings->directory.content_history,
2016-06-20 03:11:01 +00:00
file_path_str(FILE_PATH_CONTENT_HISTORY),
2016-04-28 18:49:13 +00:00
sizeof(settings->path.content_history));
}
}
if (string_is_empty(settings->path.content_music_history))
{
if (string_is_empty(settings->directory.content_history))
{
fill_pathname_resolve_relative(
settings->path.content_music_history,
path_get_config(),
file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY),
sizeof(settings->path.content_music_history));
}
else
{
fill_pathname_join(settings->path.content_music_history,
settings->directory.content_history,
file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY),
sizeof(settings->path.content_music_history));
}
}
2016-04-28 18:49:13 +00:00
if (string_is_empty(settings->path.content_video_history))
{
if (string_is_empty(settings->directory.content_history))
{
fill_pathname_resolve_relative(
settings->path.content_video_history,
path_get_config(),
file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY),
sizeof(settings->path.content_video_history));
}
else
{
fill_pathname_join(settings->path.content_video_history,
settings->directory.content_history,
file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY),
sizeof(settings->path.content_video_history));
}
}
if (string_is_empty(settings->path.content_image_history))
{
if (string_is_empty(settings->directory.content_history))
{
fill_pathname_resolve_relative(
settings->path.content_image_history,
path_get_config(),
file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY),
sizeof(settings->path.content_image_history));
}
else
{
fill_pathname_join(settings->path.content_image_history,
settings->directory.content_history,
file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY),
sizeof(settings->path.content_image_history));
}
}
2016-07-24 06:54:38 +00:00
2016-06-25 05:12:37 +00:00
if (!string_is_empty(settings->directory.screenshot))
2011-08-24 13:47:39 +00:00
{
2016-04-28 17:26:02 +00:00
if (string_is_equal(settings->directory.screenshot, "default"))
*settings->directory.screenshot = '\0';
else if (!path_is_directory(settings->directory.screenshot))
{
RARCH_WARN("screenshot_directory is not an existing directory, ignoring ...\n");
2016-04-28 17:26:02 +00:00
*settings->directory.screenshot = '\0';
}
2011-08-24 13:47:39 +00:00
}
2016-04-28 18:49:13 +00:00
/* Safe-guard against older behavior. */
2016-09-17 10:51:44 +00:00
if (path_is_directory(path_get_core()))
2016-04-28 18:49:13 +00:00
{
RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n");
2016-09-17 10:51:44 +00:00
strlcpy(settings->directory.libretro, path_get_core(),
2016-04-28 18:49:13 +00:00
sizeof(settings->directory.libretro));
2016-09-17 10:51:44 +00:00
path_clear_core();
2016-04-28 18:49:13 +00:00
}
2011-01-31 17:06:57 +00:00
2016-07-24 08:49:38 +00:00
if (string_is_equal(settings->path.menu_wallpaper, "default"))
*settings->path.menu_wallpaper = '\0';
if (string_is_equal(settings->directory.video_shader, "default"))
*settings->directory.video_shader = '\0';
if (string_is_equal(settings->directory.video_filter, "default"))
*settings->directory.video_filter = '\0';
if (string_is_equal(settings->directory.audio_filter, "default"))
*settings->directory.audio_filter = '\0';
2016-04-28 17:26:02 +00:00
if (string_is_equal(settings->directory.core_assets, "default"))
*settings->directory.core_assets = '\0';
if (string_is_equal(settings->directory.assets, "default"))
*settings->directory.assets = '\0';
if (string_is_equal(settings->directory.dynamic_wallpapers, "default"))
*settings->directory.dynamic_wallpapers = '\0';
if (string_is_equal(settings->directory.thumbnails, "default"))
*settings->directory.thumbnails = '\0';
if (string_is_equal(settings->directory.playlist, "default"))
*settings->directory.playlist = '\0';
#ifdef HAVE_MENU
2016-06-25 05:12:37 +00:00
2016-04-28 17:26:02 +00:00
if (string_is_equal(settings->directory.menu_content, "default"))
*settings->directory.menu_content = '\0';
if (string_is_equal(settings->directory.menu_config, "default"))
*settings->directory.menu_config = '\0';
#endif
#ifdef HAVE_OVERLAY
2016-04-28 17:26:02 +00:00
if (string_is_equal(settings->directory.overlay, "default"))
*settings->directory.overlay = '\0';
2016-09-17 14:28:46 +00:00
if (string_is_equal(dir_get_osk_overlay(), "default"))
dir_clear_osk_overlay();
#endif
2016-07-24 07:18:08 +00:00
if (string_is_equal(settings->directory.system, "default"))
*settings->directory.system = '\0';
2011-02-05 10:31:35 +00:00
if (settings->slowmotion_ratio < 1.0f)
settings->slowmotion_ratio = 1.0f;
2011-01-31 17:06:57 +00:00
/* Sanitize fastforward_ratio value - previously range was -1
* and up (with 0 being skipped) */
if (settings->fastforward_ratio < 0.0f)
settings->fastforward_ratio = 0.0f;
#ifdef HAVE_LAKKA
settings->ssh_enable = path_file_exists(LAKKA_SSH_PATH);
settings->samba_enable = path_file_exists(LAKKA_SAMBA_PATH);
2016-03-23 13:06:53 +00:00
settings->bluetooth_enable = path_file_exists(LAKKA_BLUETOOTH_PATH);
#endif
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) &&
2014-09-01 23:27:46 +00:00
config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
2011-08-24 13:47:39 +00:00
{
2016-01-20 03:07:24 +00:00
if (string_is_equal(tmp_str, "default"))
2016-09-17 12:49:35 +00:00
dir_set_savefile(g_defaults.dir.sram);
else if (path_is_directory(tmp_str))
2011-08-24 13:47:39 +00:00
{
2016-09-17 12:49:35 +00:00
dir_set_savefile(tmp_str);
2015-07-27 15:18:10 +00:00
strlcpy(global->name.savefile, tmp_str,
sizeof(global->name.savefile));
2016-06-26 07:58:10 +00:00
fill_pathname_dir(global->name.savefile,
2016-09-17 17:41:16 +00:00
path_get_basename(),
2016-06-26 07:58:10 +00:00
file_path_str(FILE_PATH_SRM_EXTENSION),
sizeof(global->name.savefile));
2011-08-24 13:47:39 +00:00
}
else
2013-05-01 10:50:40 +00:00
RARCH_WARN("savefile_directory is not a directory, ignoring ...\n");
2011-08-24 13:47:39 +00:00
}
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
2014-09-01 23:27:46 +00:00
config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str)))
2011-08-24 13:47:39 +00:00
{
2016-01-20 03:07:24 +00:00
if (string_is_equal(tmp_str, "default"))
2016-09-17 12:49:35 +00:00
dir_set_savestate(g_defaults.dir.savestate);
else if (path_is_directory(tmp_str))
2011-08-24 13:47:39 +00:00
{
2016-09-17 12:49:35 +00:00
dir_set_savestate(tmp_str);
2015-07-27 15:18:10 +00:00
strlcpy(global->name.savestate, tmp_str,
sizeof(global->name.savestate));
2016-06-26 07:58:10 +00:00
fill_pathname_dir(global->name.savestate,
2016-09-17 17:41:16 +00:00
path_get_basename(),
2016-06-26 07:58:10 +00:00
file_path_str(FILE_PATH_STATE_EXTENSION),
sizeof(global->name.savestate));
2011-08-24 13:47:39 +00:00
}
else
2012-04-21 21:25:32 +00:00
RARCH_WARN("savestate_directory is not a directory, ignoring ...\n");
2011-08-24 13:47:39 +00:00
}
2012-02-29 18:25:54 +00:00
config_read_keybinds_conf(conf);
2010-12-29 20:12:56 +00:00
2016-09-20 14:32:33 +00:00
ret = true;
2015-05-07 01:55:15 +00:00
end:
if (conf)
config_file_free(conf);
if (bool_settings)
free(bool_settings);
if (int_settings)
free(int_settings);
if (float_settings)
free(float_settings);
if (array_settings)
free(array_settings);
2016-09-01 02:37:22 +00:00
if (path_settings)
free(path_settings);
2016-09-20 14:32:33 +00:00
return ret;
2010-12-29 18:00:21 +00:00
}
2010-12-30 03:51:08 +00:00
/**
* config_load_override:
*
* Tries to append game-specific and core-specific configuration.
* These settings will always have precedence, thus this feature
* can be used to enforce overrides.
*
* This function only has an effect if a game-specific or core-specific
* configuration file exists at respective locations.
*
2016-08-30 02:37:49 +00:00
* core-specific: $CONFIG_DIR/$CORE_NAME/$CORE_NAME.cfg
* fallback: $CURRENT_CFG_LOCATION/$CORE_NAME/$CORE_NAME.cfg
*
* game-specific: $CONFIG_DIR/$CORE_NAME/$ROM_NAME.cfg
* fallback: $CURRENT_CFG_LOCATION/$CORE_NAME/$GAME_NAME.cfg
*
* Returns: false if there was an error or no action was performed.
*
*/
bool config_load_override(void)
{
2016-06-03 02:35:07 +00:00
char buf[PATH_MAX_LENGTH] = {0};
char config_directory[PATH_MAX_LENGTH] = {0};
char core_path[PATH_MAX_LENGTH] = {0};
char game_path[PATH_MAX_LENGTH] = {0};
2015-06-12 15:00:37 +00:00
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
bool should_append = false;
rarch_system_info_t *system = NULL;
2016-09-17 17:43:30 +00:00
#ifdef HAVE_NETPLAY
2016-08-30 02:00:16 +00:00
global_t *global = global_get_ptr();
2016-09-17 17:43:30 +00:00
#endif
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
2016-01-26 01:38:09 +00:00
if (system)
core_name = system->info.library_name;
2016-09-17 17:41:16 +00:00
game_name = path_basename(path_get_basename());
2015-12-26 06:19:04 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
2016-06-11 20:00:29 +00:00
fill_pathname_application_special(config_directory, sizeof(config_directory),
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
/* Concatenate strings into full paths for core_path, game_path */
2016-06-30 03:02:45 +00:00
fill_pathname_join_special_ext(game_path,
config_directory, core_name,
game_name,
2016-06-29 16:40:36 +00:00
file_path_str(FILE_PATH_CONFIG_EXTENSION),
2016-06-30 03:02:45 +00:00
sizeof(game_path));
2016-06-30 03:02:45 +00:00
fill_pathname_join_special_ext(core_path,
config_directory, core_name,
core_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(core_path));
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
2015-06-26 16:35:35 +00:00
/* If a core override exists, add its location to append_config_path */
if (new_conf)
{
2016-08-26 05:46:49 +00:00
RARCH_LOG("[overrides] core-specific overrides found at %s.\n", core_path);
2016-09-17 12:14:58 +00:00
config_file_free(new_conf);
path_set_config_append(core_path);
should_append = true;
}
else
2016-08-26 05:46:49 +00:00
RARCH_LOG("[overrides] no core-specific overrides found at %s.\n", core_path);
2015-06-26 15:46:13 +00:00
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
2015-06-26 15:46:13 +00:00
/* If a game override exists, add it's location to append_config_path */
if (new_conf)
{
2016-09-17 12:14:58 +00:00
char temp_path[PATH_MAX_LENGTH] = {0};
config_file_free(new_conf);
2016-08-26 05:46:49 +00:00
RARCH_LOG("[overrides] game-specific overrides found at %s.\n", game_path);
2016-09-17 12:14:58 +00:00
2015-04-08 03:20:09 +00:00
if (should_append)
{
2016-09-17 12:14:58 +00:00
strlcpy(temp_path, path_get_config_append(), sizeof(temp_path));
strlcat(temp_path, "|", sizeof(temp_path));
strlcat(temp_path, game_path, sizeof(temp_path));
}
else
2016-09-17 12:14:58 +00:00
strlcpy(temp_path, game_path, sizeof(temp_path));
path_set_config_append(temp_path);
2015-04-07 00:58:57 +00:00
should_append = true;
}
else
2016-08-26 05:46:49 +00:00
RARCH_LOG("[overrides] no game-specific overrides found at %s.\n", game_path);
if (!should_append)
return false;
/* Re-load the configuration with any overrides that might have been found */
2015-04-11 21:03:30 +00:00
#ifdef HAVE_NETPLAY
2016-09-17 17:41:16 +00:00
if (global && global->netplay.enable)
{
2016-08-26 05:46:49 +00:00
RARCH_WARN("[overrides] can't use overrides in conjunction with netplay, disabling overrides.\n");
return false;
}
2015-04-11 21:03:30 +00:00
#endif
2016-07-01 06:53:27 +00:00
/* Store the libretro_path we're using since it will be
* overwritten by the override when reloading. */
2016-09-17 10:51:44 +00:00
strlcpy(buf, path_get_core(), sizeof(buf));
/* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH);
if (!config_load_file(path_get_config(), false, config_get_ptr()))
return false;
/* Restore the libretro_path we're using
* since it will be overwritten by the override when reloading. */
2016-09-17 10:51:44 +00:00
path_set_core(buf);
2016-07-01 06:53:27 +00:00
runloop_msg_queue_push("Configuration override loaded.", 1, 100, true);
2016-07-01 06:53:27 +00:00
/* Reset save paths. */
2016-08-01 19:51:23 +00:00
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH);
2016-09-17 12:14:58 +00:00
path_clear_config_append();
return true;
}
/**
* config_unload_override:
*
* Unloads configuration overrides if overrides are active.
*
*
* Returns: false if there was an error.
*/
2016-05-27 03:13:05 +00:00
bool config_unload_override(void)
{
2016-09-17 12:14:58 +00:00
path_clear_config_append();
/* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH);
if (config_load_file(path_get_config(), false, config_get_ptr()))
{
2016-08-26 05:46:49 +00:00
RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n");
/* Reset save paths */
2016-08-01 19:51:23 +00:00
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH);
return true;
2015-04-07 00:58:57 +00:00
}
return false;
}
/**
* config_load_remap:
*
* Tries to append game-specific and core-specific remap files.
*
* This function only has an effect if a game-specific or core-specific
* configuration file exists at respective locations.
*
* core-specific: $REMAP_DIR/$CORE_NAME/$CORE_NAME.cfg
* game-specific: $REMAP_DIR/$CORE_NAME/$GAME_NAME.cfg
*
* Returns: false if there was an error or no action was performed.
*/
2015-04-05 20:41:24 +00:00
bool config_load_remap(void)
{
2016-06-03 02:35:07 +00:00
char remap_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */
char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */
char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */
2015-06-12 15:00:37 +00:00
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
2015-04-05 20:41:24 +00:00
2016-01-26 01:42:23 +00:00
if (system)
core_name = system->info.library_name;
2016-09-17 17:41:16 +00:00
game_name = path_basename(path_get_basename());
2015-12-26 06:19:04 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
/* Remap directory: remap_directory.
* Try remap directory setting, no fallbacks defined */
2016-04-28 17:26:02 +00:00
if (string_is_empty(settings->directory.input_remapping))
return false;
2015-12-26 06:19:04 +00:00
2016-01-26 01:42:23 +00:00
strlcpy(remap_directory,
2016-04-28 17:26:02 +00:00
settings->directory.input_remapping,
sizeof(remap_directory));
RARCH_LOG("Remaps: remap directory: %s\n", remap_directory);
2015-04-05 20:41:24 +00:00
/* Concatenate strings into full paths for core_path, game_path */
2016-06-30 03:02:45 +00:00
fill_pathname_join_special_ext(core_path,
remap_directory, core_name,
core_name,
2016-06-29 16:43:00 +00:00
file_path_str(FILE_PATH_REMAP_EXTENSION),
sizeof(core_path));
2015-04-05 20:41:24 +00:00
2016-06-30 03:02:45 +00:00
fill_pathname_join_special_ext(game_path,
remap_directory, core_name,
game_name,
2016-06-29 16:43:00 +00:00
file_path_str(FILE_PATH_REMAP_EXTENSION),
sizeof(game_path));
2015-04-05 20:41:24 +00:00
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
2015-04-05 20:41:24 +00:00
/* If a game remap file exists, load it. */
2015-04-05 20:41:24 +00:00
if (new_conf)
{
2016-07-01 06:53:27 +00:00
RARCH_LOG("Remaps: game-specific remap found at %s.\n", game_path);
if (input_remapping_load_file(new_conf, game_path))
{
2016-07-01 06:53:27 +00:00
runloop_msg_queue_push("Game remap file loaded.", 1, 100, true);
return true;
}
2015-04-05 20:41:24 +00:00
}
2015-04-08 03:51:31 +00:00
else
{
2016-07-01 06:53:27 +00:00
RARCH_LOG("Remaps: no game-specific remap found at %s.\n", game_path);
input_remapping_set_defaults();
}
2015-04-05 20:41:24 +00:00
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
2015-04-05 20:41:24 +00:00
/* If a core remap file exists, load it. */
2015-04-05 20:41:24 +00:00
if (new_conf)
{
2016-07-01 06:53:27 +00:00
RARCH_LOG("Remaps: core-specific remap found at %s.\n", core_path);
if (input_remapping_load_file(new_conf, core_path))
{
2016-07-01 06:53:27 +00:00
runloop_msg_queue_push("Core remap file loaded.", 1, 100, true);
return true;
}
2015-04-05 20:41:24 +00:00
}
else
{
2016-07-01 06:53:27 +00:00
RARCH_LOG("Remaps: no core-specific remap found at %s.\n", core_path);
2015-04-15 20:31:24 +00:00
input_remapping_set_defaults();
}
new_conf = NULL;
2015-04-05 20:41:24 +00:00
return false;
2015-04-05 20:41:24 +00:00
}
static bool check_shader_compatibility(enum file_path_enum enum_idx)
{
settings_t *settings = config_get_ptr();
if (string_is_equal("vulkan", settings->video.driver))
{
if (enum_idx != FILE_PATH_SLANGP_EXTENSION)
return false;
return true;
}
if (string_is_equal("gl", settings->video.driver) ||
string_is_equal("d3d9", settings->video.driver))
{
if (enum_idx == FILE_PATH_SLANGP_EXTENSION)
return false;
return true;
}
return false;
}
2016-07-30 18:55:50 +00:00
/**
* config_load_shader_preset:
*
* Tries to append game-specific and core-specific shader presets.
*
* This function only has an effect if a game-specific or core-specific
* configuration file exists at respective locations.
*
* core-specific: $SHADER_DIR/presets/$CORE_NAME/$CORE_NAME.cfg
* game-specific: $SHADER_DIR/presets/$CORE_NAME/$GAME_NAME.cfg
*
* Returns: false if there was an error or no action was performed.
*/
bool config_load_shader_preset(void)
{
2016-07-31 21:42:55 +00:00
unsigned idx;
2016-09-17 10:37:53 +00:00
char shader_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */
2016-07-30 18:55:50 +00:00
char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */
char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */
const char *core_name = NULL;
const char *game_name = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
2016-07-30 18:55:50 +00:00
if (system)
core_name = system->info.library_name;
2016-09-17 17:41:16 +00:00
game_name = path_basename(path_get_basename());
2016-07-30 18:55:50 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
/* Shader directory: shader_directory.
* Try shader directory setting, no fallbacks defined */
if (string_is_empty(settings->directory.video_shader))
return false;
fill_pathname_join (shader_directory, settings->directory.video_shader,
"presets", sizeof(shader_directory));
RARCH_LOG("Shaders: preset directory: %s\n", shader_directory);
for(idx = FILE_PATH_CGP_EXTENSION; idx < FILE_PATH_SLANGP_EXTENSION; idx++)
2016-07-30 18:55:50 +00:00
{
2016-08-17 15:48:13 +00:00
config_file_t *new_conf = NULL;
2016-07-31 21:42:55 +00:00
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, game_path */
fill_pathname_join_special_ext(core_path,
shader_directory, core_name,
core_name,
2016-07-31 21:42:55 +00:00
file_path_str((enum file_path_enum)(idx)),
sizeof(core_path));
fill_pathname_join_special_ext(game_path,
shader_directory, core_name,
game_name,
2016-07-31 21:42:55 +00:00
file_path_str((enum file_path_enum)(idx)),
sizeof(game_path));
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
2016-08-17 15:48:13 +00:00
if (!new_conf)
{
RARCH_LOG("Shaders: no game-specific preset found at %s.\n", game_path);
2016-08-17 15:48:13 +00:00
continue;
}
2016-08-17 15:48:13 +00:00
/* Game shader preset exists, load it. */
RARCH_LOG("Shaders: game-specific shader preset found at %s.\n", game_path);
path_set_default_shader_preset(settings->path.shader);
2016-08-17 15:48:13 +00:00
strlcpy(settings->path.shader, game_path, sizeof(settings->path.shader));
config_file_free(new_conf);
return true;
2016-07-30 18:55:50 +00:00
}
for(idx = FILE_PATH_CGP_EXTENSION; idx < FILE_PATH_SLANGP_EXTENSION; idx++)
2016-07-30 18:55:50 +00:00
{
2016-08-17 15:48:13 +00:00
config_file_t *new_conf = NULL;
2016-07-31 21:42:55 +00:00
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, game_path */
fill_pathname_join_special_ext(core_path,
shader_directory, core_name,
core_name,
2016-07-31 21:42:55 +00:00
file_path_str((enum file_path_enum)(idx)),
sizeof(core_path));
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
2016-08-17 15:48:13 +00:00
if (!new_conf)
{
RARCH_LOG("Shaders: no core-specific preset found at %s.\n", core_path);
2016-08-17 15:48:13 +00:00
continue;
}
2016-08-17 15:48:13 +00:00
/* Core shader preset exists, load it. */
RARCH_LOG("Shaders: core-specific shader preset found at %s.\n", core_path);
path_set_default_shader_preset(settings->path.shader);
2016-08-17 15:48:13 +00:00
strlcpy(settings->path.shader, core_path, sizeof(settings->path.shader));
config_file_free(new_conf);
return true;
2016-07-30 18:55:50 +00:00
}
return false;
}
2014-10-02 23:07:35 +00:00
static void parse_config_file(void)
{
bool ret = config_load_file(path_get_config(), false, config_get_ptr());
2015-01-24 22:42:31 +00:00
if (!path_is_config_empty())
2014-10-02 23:07:35 +00:00
{
RARCH_LOG("Config: loading config from: %s.\n", path_get_config());
2014-10-02 23:07:35 +00:00
}
else
{
RARCH_LOG("Loading default config.\n");
if (!path_is_config_empty())
RARCH_LOG("Config: found default config: %s.\n", path_get_config());
2014-10-02 23:07:35 +00:00
}
2015-01-24 22:42:31 +00:00
if (ret)
return;
RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", path_get_config());
2014-10-02 23:07:35 +00:00
}
#if 0
static bool config_read_keybinds(const char *path)
2012-02-29 18:25:54 +00:00
{
config_file_t *conf = (config_file_t*)config_file_new(path);
2012-02-29 18:25:54 +00:00
if (!conf)
return false;
2012-02-29 18:25:54 +00:00
config_read_keybinds_conf(conf);
config_file_free(conf);
2012-02-29 18:25:54 +00:00
return true;
}
#endif
2012-02-29 18:25:54 +00:00
2014-09-01 23:27:46 +00:00
static void save_keybind_key(config_file_t *conf, const char *prefix,
const char *base, const struct retro_keybind *bind)
2012-02-20 19:36:21 +00:00
{
2015-06-12 15:00:37 +00:00
char key[64] = {0};
char btn[64] = {0};
fill_pathname_join_delim(key, prefix, base, '_', sizeof(key));
input_keymaps_translate_rk_to_str(bind->key, btn, sizeof(btn));
config_set_string(conf, key, btn);
2012-02-20 19:36:21 +00:00
}
2014-09-01 23:27:46 +00:00
static void save_keybind_hat(config_file_t *conf, const char *key,
const struct retro_keybind *bind)
2012-02-20 19:36:21 +00:00
{
2015-06-12 15:00:37 +00:00
char config[16] = {0};
unsigned hat = GET_HAT(bind->joykey);
const char *dir = NULL;
2012-02-20 19:36:21 +00:00
2013-10-06 14:51:50 +00:00
switch (GET_HAT_DIR(bind->joykey))
2012-02-20 19:36:21 +00:00
{
case HAT_UP_MASK:
dir = "up";
break;
case HAT_DOWN_MASK:
dir = "down";
break;
case HAT_LEFT_MASK:
dir = "left";
break;
case HAT_RIGHT_MASK:
dir = "right";
break;
default:
retro_assert(0);
break;
2012-02-20 19:36:21 +00:00
}
snprintf(config, sizeof(config), "h%u%s", hat, dir);
config_set_string(conf, key, config);
2012-02-20 19:36:21 +00:00
}
2014-09-01 23:27:46 +00:00
static void save_keybind_joykey(config_file_t *conf, const char *prefix,
const char *base, const struct retro_keybind *bind, bool save_empty)
2012-02-20 19:36:21 +00:00
{
2015-06-12 15:00:37 +00:00
char key[64] = {0};
2016-07-01 06:53:27 +00:00
fill_pathname_join_delim_concat(key, prefix,
base, '_', "_btn", sizeof(key));
2012-02-20 19:36:21 +00:00
if (bind->joykey == NO_BTN)
{
if (save_empty)
2016-06-28 09:10:30 +00:00
config_set_string(conf, key, file_path_str(FILE_PATH_NUL));
}
2012-02-20 19:36:21 +00:00
else if (GET_HAT_DIR(bind->joykey))
save_keybind_hat(conf, key, bind);
2012-02-20 19:36:21 +00:00
else
config_set_uint64(conf, key, bind->joykey);
2012-02-20 19:36:21 +00:00
}
2014-09-01 23:27:46 +00:00
static void save_keybind_axis(config_file_t *conf, const char *prefix,
const char *base, const struct retro_keybind *bind, bool save_empty)
2012-02-20 19:36:21 +00:00
{
2015-06-12 15:00:37 +00:00
char key[64] = {0};
unsigned axis = 0;
char dir = '\0';
2012-02-20 19:36:21 +00:00
2016-06-29 15:51:25 +00:00
fill_pathname_join_delim_concat(key,
prefix, base, '_',
"_axis",
sizeof(key));
2012-02-20 19:36:21 +00:00
if (bind->joyaxis == AXIS_NONE)
{
if (save_empty)
2016-06-28 09:10:30 +00:00
config_set_string(conf, key, file_path_str(FILE_PATH_NUL));
}
2012-03-09 17:17:53 +00:00
else if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
2012-02-20 19:36:21 +00:00
{
dir = '-';
axis = AXIS_NEG_GET(bind->joyaxis);
}
2012-03-09 17:17:53 +00:00
else if (AXIS_POS_GET(bind->joyaxis) != AXIS_DIR_NONE)
2012-02-20 19:36:21 +00:00
{
dir = '+';
axis = AXIS_POS_GET(bind->joyaxis);
}
if (dir)
{
2016-06-03 02:35:07 +00:00
char config[16] = {0};
snprintf(config, sizeof(config), "%c%u", dir, axis);
config_set_string(conf, key, config);
}
2012-02-20 19:36:21 +00:00
}
/**
* save_keybind:
* @conf : pointer to config file object
* @prefix : prefix name of keybind
* @base : base name of keybind
* @bind : pointer to key binding object
* @kb : save keyboard binds
*
* Save a key binding to the config file.
*/
2014-09-01 23:27:46 +00:00
static void save_keybind(config_file_t *conf, const char *prefix,
2016-07-01 06:53:27 +00:00
const char *base, const struct retro_keybind *bind,
bool save_kb, bool save_empty)
2012-02-20 19:36:21 +00:00
{
if (!bind->valid)
2012-02-20 19:36:21 +00:00
return;
2015-07-11 01:16:32 +00:00
if (save_kb)
save_keybind_key(conf, prefix, base, bind);
save_keybind_joykey(conf, prefix, base, bind, save_empty);
save_keybind_axis(conf, prefix, base, bind, save_empty);
2012-02-20 19:36:21 +00:00
}
/**
* save_keybinds_user:
* @conf : pointer to config file object
* @user : user number
*
* Save the current keybinds of a user (@user) to the config file (@conf).
*/
2014-12-05 12:48:54 +00:00
static void save_keybinds_user(config_file_t *conf, unsigned user)
2012-02-20 19:36:21 +00:00
{
unsigned i = 0;
2015-03-20 19:52:54 +00:00
settings_t *settings = config_get_ptr();
2015-01-11 04:29:32 +00:00
for (i = 0; input_config_bind_map_get_valid(i); i++)
{
2014-12-05 12:48:54 +00:00
const char *prefix = input_config_get_prefix(user,
input_config_bind_map_get_meta(i));
2015-01-11 04:29:32 +00:00
if (prefix)
save_keybind(conf, prefix, input_config_bind_map_get_base(i),
&settings->input.binds[user][i], true, true);
}
2012-02-20 19:36:21 +00:00
}
/**
* config_load:
*
* Loads a config file and reads all the values into memory.
*
*/
void config_load(void)
{
2016-07-01 06:53:27 +00:00
/* Flush out some states that could have been
* set by core environment variables */
2016-05-07 23:33:57 +00:00
core_unset_input_descriptors();
2016-09-03 06:15:41 +00:00
if (rarch_ctl(RARCH_CTL_IS_BLOCK_CONFIG_READ, NULL))
return;
config_set_defaults();
parse_config_file();
}
#if 0
2015-01-19 06:43:28 +00:00
/**
* config_save_keybinds_file:
* @path : Path that shall be written to.
*
* Writes a keybinds config file to disk.
*
* Returns: true (1) on success, otherwise returns false (0).
**/
static bool config_save_keybinds_file(const char *path)
2015-01-19 06:43:28 +00:00
{
2015-06-12 15:00:37 +00:00
unsigned i = 0;
bool ret = false;
2015-01-19 06:43:28 +00:00
config_file_t *conf = config_file_new(path);
if (!conf)
conf = config_file_new(NULL);
if (!conf)
return false;
RARCH_LOG("Saving keybinds config at path: \"%s\"\n", path);
for (i = 0; i < MAX_USERS; i++)
save_keybinds_user(conf, i);
ret = config_file_write(conf, path);
config_file_free(conf);
return ret;
}
#endif
2015-01-19 06:43:28 +00:00
/**
* config_save_autoconf_profile:
* @path : Path that shall be written to.
* @user : Controller number to save
* Writes a controller autoconf file to disk.
**/
bool config_save_autoconf_profile(const char *path, unsigned user)
{
2015-07-11 01:40:15 +00:00
unsigned i;
2016-05-27 03:13:05 +00:00
bool ret = false;
2015-07-11 01:40:15 +00:00
char buf[PATH_MAX_LENGTH] = {0};
char autoconf_file[PATH_MAX_LENGTH] = {0};
2015-07-11 01:40:15 +00:00
config_file_t *conf = NULL;
settings_t *settings = config_get_ptr();
2016-04-28 18:49:13 +00:00
fill_pathname_join(buf, settings->directory.autoconfig,
2015-07-11 04:12:48 +00:00
settings->input.joypad_driver, sizeof(buf));
if(path_is_directory(buf))
{
char buf_new[PATH_MAX_LENGTH] = {0};
fill_pathname_join(buf_new, buf,
path, sizeof(buf_new));
fill_pathname_noext(autoconf_file, buf_new,
2016-06-29 16:40:36 +00:00
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(autoconf_file));
}
else
{
2016-04-28 18:49:13 +00:00
fill_pathname_join(buf, settings->directory.autoconfig,
path, sizeof(buf));
2016-06-29 16:40:36 +00:00
fill_pathname_noext(autoconf_file, buf,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(autoconf_file));
}
conf = config_file_new(autoconf_file);
2015-07-11 01:40:15 +00:00
if (!conf)
{
conf = config_file_new(NULL);
2015-07-11 01:40:15 +00:00
if (!conf)
return false;
}
2015-07-11 01:40:15 +00:00
2016-07-01 06:53:27 +00:00
config_set_string(conf, "input_driver",
settings->input.joypad_driver);
config_set_string(conf, "input_device",
settings->input.device_names[user]);
if(settings->input.vid[user] && settings->input.pid[user])
{
2016-07-01 06:53:27 +00:00
config_set_int(conf, "input_vendor_id",
settings->input.vid[user]);
config_set_int(conf, "input_product_id",
settings->input.pid[user]);
}
2015-07-11 01:40:15 +00:00
for (i = 0; i < RARCH_FIRST_META_KEY; i++)
{
save_keybind(conf, "input", input_config_bind_map_get_base(i),
2015-07-11 01:40:15 +00:00
&settings->input.binds[user][i], false, false);
}
2016-05-27 03:13:05 +00:00
ret = config_file_write(conf, autoconf_file);
2016-05-27 03:13:05 +00:00
config_file_free(conf);
return ret;
}
2016-08-26 00:00:06 +00:00
2016-08-26 01:10:01 +00:00
/**
* config_save_file:
* @path : Path that shall be written to.
*
* Writes a config file to disk.
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_file(const char *path)
{
float msg_color;
2016-09-05 15:16:37 +00:00
unsigned i = 0;
bool ret = false;
int bool_settings_size = 0;
int int_settings_size = 0;
int float_settings_size = 0;
int array_settings_size = 0;
int path_settings_size = 0;
struct config_bool_setting *bool_settings = NULL;
struct config_int_setting *int_settings = NULL;
struct config_float_setting *float_settings = NULL;
struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL;
config_file_t *conf = config_file_new(path);
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
2016-08-26 16:26:24 +00:00
if (!conf)
conf = config_file_new(NULL);
if (!conf || runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL))
{
if (conf)
config_file_free(conf);
return false;
}
bool_settings_size = populate_settings_bool (settings, &bool_settings);
2016-08-29 15:31:24 +00:00
int_settings_size = populate_settings_int (settings, &int_settings);
float_settings_size = populate_settings_float (settings, &float_settings);
array_settings_size = populate_settings_array (settings, &array_settings);
path_settings_size = populate_settings_path (settings, &path_settings);
2016-08-26 01:10:01 +00:00
2016-08-29 18:18:20 +00:00
/* Path settings */
for (i = 0; i < (unsigned)path_settings_size; i++)
2016-07-24 05:14:24 +00:00
{
2016-09-01 01:05:31 +00:00
const char *value = path_settings[i].ptr;
2016-08-30 02:20:28 +00:00
2016-09-01 01:41:10 +00:00
if (path_settings[i].def_enable && string_is_empty(path_settings[i].ptr))
2016-08-30 02:20:28 +00:00
value = "default";
config_set_path(conf, path_settings[i].ident, value);
2016-07-24 05:14:24 +00:00
}
2016-07-25 06:06:04 +00:00
#ifdef HAVE_MENU
config_set_path(conf, "xmb_font",
!string_is_empty(settings->menu.xmb.font) ? settings->menu.xmb.font : "");
#endif
2016-08-29 18:18:20 +00:00
/* String settings */
for (i = 0; i < (unsigned)array_settings_size; i++)
config_set_string(conf, array_settings[i].ident,
2016-09-01 01:05:31 +00:00
array_settings[i].ptr);
2016-08-29 18:18:20 +00:00
/* Float settings */
for (i = 0; i < (unsigned)float_settings_size; i++)
2016-07-24 03:50:36 +00:00
config_set_float(conf, float_settings[i].ident,
*float_settings[i].ptr);
2016-07-23 12:59:07 +00:00
2016-08-29 18:18:20 +00:00
/* Integer settings */
for (i = 0; i < (unsigned)int_settings_size; i++)
2016-07-24 03:01:11 +00:00
config_set_int(conf, int_settings[i].ident,
2016-08-29 13:26:42 +00:00
*int_settings[i].ptr);
2016-07-24 03:01:11 +00:00
for (i = 0; i < MAX_USERS; i++)
{
char cfg[64] = {0};
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
config_set_int(conf, cfg, settings->input.device[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
config_set_int(conf, cfg, settings->input.joypad_map[i]);
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
config_set_int(conf, cfg, settings->input.libretro_device[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1);
config_set_int(conf, cfg, settings->input.analog_dpad_mode[i]);
}
2016-08-29 18:18:20 +00:00
/* Boolean settings */
for (i = 0; i < (unsigned)bool_settings_size; i++)
2016-07-23 12:59:07 +00:00
config_set_bool(conf, bool_settings[i].ident,
2016-08-29 13:36:55 +00:00
*bool_settings[i].ptr);
2016-08-30 02:20:28 +00:00
2016-07-24 02:37:46 +00:00
#ifdef HAVE_NETWORKGAMEPAD
for (i = 0; i < MAX_USERS; i++)
{
char tmp[64] = {0};
snprintf(tmp, sizeof(tmp), "network_remote_enable_user_p%u", i + 1);
config_set_bool(conf, tmp, settings->network_remote_enable_user[i]);
}
#endif
2016-08-30 02:20:28 +00:00
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_UPS_PREF))
2016-07-24 02:37:46 +00:00
config_set_bool(conf, "ups_pref", global->patch.ups_pref);
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_BPS_PREF))
2016-07-24 02:37:46 +00:00
config_set_bool(conf, "bps_pref", global->patch.bps_pref);
2016-08-01 19:51:23 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_IPS_PREF))
2016-07-24 02:37:46 +00:00
config_set_bool(conf, "ips_pref", global->patch.ips_pref);
config_set_bool(conf, "log_verbosity",
verbosity_is_enabled());
config_set_bool(conf, "perfcnt_enable",
runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL));
msg_color = (((int)(settings->video.msg_color_r * 255.0f) & 0xff) << 16) +
(((int)(settings->video.msg_color_g * 255.0f) & 0xff) << 8) +
(((int)(settings->video.msg_color_b * 255.0f) & 0xff));
2016-07-25 06:06:04 +00:00
2016-08-29 18:18:20 +00:00
/* Hexadecimal settings */
config_set_hex(conf, "video_message_color", msg_color);
#ifdef HAVE_MENU
config_set_hex(conf, "menu_entry_normal_color",
settings->menu.entry_normal_color);
config_set_hex(conf, "menu_entry_hover_color",
settings->menu.entry_hover_color);
config_set_hex(conf, "menu_title_color",
settings->menu.title_color);
#endif
2016-05-08 12:00:51 +00:00
video_driver_save_settings(conf);
#ifdef HAVE_LAKKA
if (settings->ssh_enable)
2016-03-22 18:25:27 +00:00
fclose(fopen(LAKKA_SSH_PATH, "w"));
else
remove(LAKKA_SSH_PATH);
if (settings->samba_enable)
fclose(fopen(LAKKA_SAMBA_PATH, "w"));
else
remove(LAKKA_SAMBA_PATH);
2016-03-23 13:06:53 +00:00
if (settings->bluetooth_enable)
fclose(fopen(LAKKA_BLUETOOTH_PATH, "w"));
else
remove(LAKKA_BLUETOOTH_PATH);
#endif
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
2014-12-05 12:48:54 +00:00
save_keybinds_user(conf, i);
2013-09-29 17:37:48 +00:00
ret = config_file_write(conf, path);
config_file_free(conf);
2016-08-26 00:00:06 +00:00
if (bool_settings)
free(bool_settings);
if (int_settings)
free(int_settings);
if (float_settings)
free(float_settings);
if (array_settings)
free(array_settings);
if (path_settings)
free(path_settings);
2016-08-26 16:26:24 +00:00
return ret;
}
2016-05-27 14:42:20 +00:00
2016-08-25 06:34:51 +00:00
/**
2016-08-26 14:43:29 +00:00
* config_save_overrides:
2016-08-25 06:34:51 +00:00
* @path : Path that shall be written to.
*
2016-08-26 14:43:29 +00:00
* Writes a config file override to disk.
2016-08-25 06:34:51 +00:00
*
* Returns: true (1) on success, otherwise returns false (0).
**/
2016-08-26 14:43:29 +00:00
bool config_save_overrides(int override_type)
2016-08-25 06:34:51 +00:00
{
2016-09-05 15:17:28 +00:00
unsigned i = 0;
int bool_settings_size = 0;
int int_settings_size = 0;
int float_settings_size = 0;
int array_settings_size = 0;
int path_settings_size = 0;
2016-08-27 00:35:21 +00:00
bool ret = false;
char config_directory[PATH_MAX_LENGTH] = {0};
char override_directory[PATH_MAX_LENGTH] = {0};
char core_path[PATH_MAX_LENGTH] = {0};
char game_path[PATH_MAX_LENGTH] = {0};
const char *core_name = NULL;
const char *game_name = NULL;
config_file_t *conf = NULL;
settings_t *settings = NULL;
settings_t *overrides = config_get_ptr();
rarch_system_info_t *system = NULL;
2016-09-05 15:16:37 +00:00
struct config_bool_setting *bool_settings = NULL;
struct config_bool_setting *bool_overrides = NULL;
struct config_int_setting *int_settings = NULL;
struct config_int_setting *int_overrides = NULL;
struct config_float_setting *float_settings = NULL;
struct config_float_setting *float_overrides= NULL;
struct config_array_setting *array_settings = NULL;
struct config_array_setting *array_overrides= NULL;
struct config_path_setting *path_settings = NULL;
struct config_path_setting *path_overrides = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
2016-08-26 16:26:24 +00:00
if (system)
core_name = system->info.library_name;
2016-09-17 17:41:16 +00:00
game_name = path_basename(path_get_basename());
2016-08-26 16:26:24 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
2016-08-27 00:35:21 +00:00
settings = (settings_t*)calloc(1, sizeof(settings_t));
2016-08-26 16:26:24 +00:00
2016-08-26 05:44:05 +00:00
fill_pathname_application_special(config_directory, sizeof(config_directory),
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
2016-08-26 14:43:29 +00:00
fill_pathname_join(override_directory, config_directory, core_name,
sizeof(override_directory));
if(!path_file_exists(override_directory))
path_mkdir(override_directory);
2016-08-26 05:44:05 +00:00
/* Concatenate strings into full paths for core_path, game_path */
fill_pathname_join_special_ext(game_path,
config_directory, core_name,
game_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(game_path));
fill_pathname_join_special_ext(core_path,
config_directory, core_name,
core_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(core_path));
2016-08-26 14:43:29 +00:00
if (!conf)
conf = config_file_new(NULL);
2016-08-26 05:44:05 +00:00
2016-08-26 00:00:06 +00:00
/* Load the original config file in memory */
config_load_file(path_get_config(), false, settings);
2016-08-25 15:30:30 +00:00
bool_settings_size = populate_settings_bool(settings, &bool_settings);
populate_settings_bool (overrides, &bool_overrides);
2016-08-29 15:31:24 +00:00
int_settings_size = populate_settings_int(settings, &int_settings);
populate_settings_int (overrides, &int_overrides);
float_settings_size = populate_settings_float(settings, &float_settings);
populate_settings_float (overrides, &float_overrides);
array_settings_size = populate_settings_array(settings, &array_settings);
populate_settings_array (overrides, &array_overrides);
path_settings_size = populate_settings_path(settings, &path_settings);
populate_settings_path (overrides, &path_overrides);
2016-08-26 01:10:01 +00:00
2016-08-29 13:36:55 +00:00
RARCH_LOG("[overrides] looking for changed settings... \n");
if (conf)
2016-08-25 15:30:30 +00:00
{
for (i = 0; i < (unsigned)bool_settings_size; i++)
2016-08-26 00:00:06 +00:00
{
if ((*bool_settings[i].ptr) != (*bool_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%d\n",
bool_settings[i].ident, (*bool_settings[i].ptr));
RARCH_LOG(" override: %s=%d\n",
bool_overrides[i].ident, (*bool_overrides[i].ptr));
config_set_bool(conf, bool_overrides[i].ident,
(*bool_overrides[i].ptr));
}
2016-08-26 00:00:06 +00:00
}
for (i = 0; i < (unsigned)int_settings_size; i++)
2016-08-26 00:14:10 +00:00
{
if ((*int_settings[i].ptr) != (*int_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%d\n",
int_settings[i].ident, (*int_settings[i].ptr));
RARCH_LOG(" override: %s=%d\n",
int_overrides[i].ident, (*int_overrides[i].ptr));
config_set_int(conf, int_overrides[i].ident,
(*int_overrides[i].ptr));
}
2016-08-26 00:14:10 +00:00
}
for (i = 0; i < (unsigned)float_settings_size; i++)
2016-08-26 00:30:10 +00:00
{
if ((*float_settings[i].ptr) != (*float_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%f\n",
float_settings[i].ident, *float_settings[i].ptr);
RARCH_LOG(" override: %s=%f\n",
float_overrides[i].ident, *float_overrides[i].ptr);
config_set_float(conf, float_overrides[i].ident,
*float_overrides[i].ptr);
}
2016-08-26 00:30:10 +00:00
}
for (i = 0; i < (unsigned)array_settings_size; i++)
2016-08-26 00:49:31 +00:00
{
if (!string_is_equal(array_settings[i].ptr, array_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%s\n",
array_settings[i].ident, array_settings[i].ptr);
RARCH_LOG(" override: %s=%s\n",
array_overrides[i].ident, array_overrides[i].ptr);
config_set_string(conf, array_overrides[i].ident,
array_overrides[i].ptr);
}
2016-08-26 00:49:31 +00:00
}
for (i = 0; i < (unsigned)path_settings_size; i++)
2016-08-26 01:10:01 +00:00
{
if (!string_is_equal(path_settings[i].ptr, path_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%s\n",
path_settings[i].ident, path_settings[i].ptr);
RARCH_LOG(" override: %s=%s\n",
path_overrides[i].ident, path_overrides[i].ptr);
config_set_path(conf, path_overrides[i].ident,
path_overrides[i].ptr);
}
2016-08-26 01:10:01 +00:00
}
2016-08-25 15:30:30 +00:00
ret = false;
2016-09-21 22:58:19 +00:00
switch (override_type)
{
case OVERRIDE_CORE:
/* Create a new config file from core_path */
RARCH_LOG ("[overrides] path %s\n", core_path);
ret = config_file_write(conf, core_path);
break;
case OVERRIDE_GAME:
/* Create a new config file from core_path */
RARCH_LOG ("[overrides] path %s\n", game_path);
ret = config_file_write(conf, game_path);
break;
default:
break;
}
2016-09-21 22:58:19 +00:00
config_file_free(conf);
}
if (bool_settings)
free(bool_settings);
if (bool_overrides)
free(bool_overrides);
if (int_settings)
free(int_settings);
if (int_overrides)
free(int_overrides);
if (float_settings)
free(float_settings);
if (float_overrides)
free(float_overrides);
if (array_settings)
free(array_settings);
if (array_overrides)
free(array_overrides);
if (path_settings)
free(path_settings);
if (path_overrides)
free(path_overrides);
2016-08-26 05:44:05 +00:00
free(settings);
return ret;
2016-08-25 06:34:51 +00:00
}
2016-05-27 14:42:20 +00:00
/* Replaces currently loaded configuration file with
* another one. Will load a dummy core to flush state
* properly. */
bool config_replace(char *path)
{
content_ctx_info_t content_info = {0};
settings_t *settings = config_get_ptr();
if (!path)
2016-05-27 14:42:20 +00:00
return false;
/* If config file to be replaced is the same as the
* current config file, exit. */
if (string_is_equal(path, path_get_config()))
2016-05-27 14:42:20 +00:00
return false;
if (settings->config_save_on_exit && !path_is_config_empty())
config_save_file(path_get_config());
2016-05-27 14:42:20 +00:00
path_set_config(path);
2016-05-27 14:42:20 +00:00
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
/* Load core in new config. */
2016-09-17 10:51:44 +00:00
path_clear_core();
2016-05-27 14:42:20 +00:00
2016-05-27 16:14:47 +00:00
if (!task_push_content_load_default(
2016-05-27 14:42:20 +00:00
NULL, NULL,
&content_info,
CORE_TYPE_DUMMY,
CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE,
NULL, NULL))
return false;
return true;
}
2016-07-23 12:18:17 +00:00
void config_free_state(void)
{
}