RetroArch/configuration.c

4762 lines
179 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
2017-03-22 02:09:18 +00:00
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Jean-André Santoni
2017-08-05 05:37:26 +00:00
* Copyright (C) 2015-2017 - Andrés Suárez
2019-01-09 22:19:19 +00:00
* Copyright (C) 2016-2019 - Brad Parker
*
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>
2017-12-11 11:15:00 +00:00
#include <libretro.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>
2016-02-05 12:51:30 +00:00
#include <retro_assert.h>
2015-12-26 06:19:04 +00:00
#include <string/stdstring.h>
#include <streams/file_stream.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"
2017-05-10 05:07:06 +00:00
#include "input/input_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 "config.features.h"
#include "input/input_keymaps.h"
#include "input/input_remapping.h"
#include "led/led_defines.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"
2015-11-23 11:03:38 +00:00
#include "verbosity.h"
#include "lakka.h"
2011-01-07 16:59:53 +00:00
2019-01-20 02:16:58 +00:00
#include "tasks/task_content.h"
2016-05-27 14:42:20 +00:00
#include "tasks/tasks_internal.h"
2018-06-04 05:48:08 +00:00
#include "../list_special.h"
2018-09-23 23:43:26 +00:00
#include "record/record_driver.h"
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#include "uwp/uwp_func.h"
#endif
static const char* invalid_filename_chars[] = {
/* https://support.microsoft.com/en-us/help/905231/information-about-the-characters-that-you-cannot-use-in-site-names--fo */
"~", "#", "%", "&", "*", "{", "}", "\\", ":", "[", "]", "?", "/", "|", "\'", "\"",
NULL
};
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
2017-07-14 19:11:27 +00:00
{
2016-09-01 16:53:34 +00:00
const char *ident;
bool *ptr;
bool def_enable;
bool def;
bool handle;
enum rarch_override_setting override;
2016-09-01 16:53:34 +00:00
};
2016-09-05 15:16:37 +00:00
struct config_int_setting
2017-07-14 19:11:27 +00:00
{
2017-04-28 17:55:09 +00:00
const char *ident;
2017-09-08 22:12:40 +00:00
int *ptr;
bool def_enable;
2017-09-08 22:12:40 +00:00
int def;
bool handle;
enum rarch_override_setting override;
2017-04-28 17:55:09 +00:00
};
struct config_uint_setting
2017-07-14 19:11:27 +00:00
{
2016-09-01 16:53:34 +00:00
const char *ident;
2017-09-08 22:12:40 +00:00
unsigned *ptr;
bool def_enable;
2017-09-08 22:12:40 +00:00
unsigned def;
bool handle;
enum rarch_override_setting override;
2016-09-01 16:53:34 +00:00
};
struct config_size_setting
{
const char *ident;
size_t *ptr;
bool def_enable;
size_t def;
bool handle;
enum rarch_override_setting override;
};
2016-09-05 15:16:37 +00:00
struct config_float_setting
2017-07-14 19:11:27 +00:00
{
2016-09-01 16:53:34 +00:00
const char *ident;
2017-09-08 22:12:40 +00:00
float *ptr;
bool def_enable;
2017-09-08 22:12:40 +00:00
float def;
bool handle;
enum rarch_override_setting override;
2016-09-01 16:53:34 +00:00
};
2016-09-05 15:16:37 +00:00
struct config_array_setting
2017-07-14 19:11:27 +00:00
{
2016-09-01 16:53:34 +00:00
const char *ident;
char *ptr;
2017-09-08 22:12:40 +00:00
bool def_enable;
const char *def;
2016-09-01 16:53:34 +00:00
bool handle;
enum rarch_override_setting override;
2016-09-01 16:53:34 +00:00
};
2016-09-05 15:16:37 +00:00
struct config_path_setting
2017-07-14 19:11:27 +00:00
{
2016-09-01 16:53:34 +00:00
const char *ident;
char *ptr;
2017-09-08 22:12:40 +00:00
bool def_enable;
char *def;
2016-09-01 16:53:34 +00:00
bool handle;
};
2017-05-08 00:25:55 +00:00
enum video_driver_enum
{
VIDEO_GL = 0,
VIDEO_VULKAN,
VIDEO_METAL,
2017-05-08 00:25:55 +00:00
VIDEO_DRM,
VIDEO_XVIDEO,
VIDEO_SDL,
VIDEO_SDL2,
VIDEO_EXT,
VIDEO_WII,
VIDEO_WIIU,
VIDEO_XENON360,
VIDEO_PSP1,
VIDEO_VITA2D,
2018-09-18 06:08:06 +00:00
VIDEO_PS2,
2017-05-08 00:25:55 +00:00
VIDEO_CTR,
2017-12-24 01:26:58 +00:00
VIDEO_SWITCH,
2018-01-23 01:55:33 +00:00
VIDEO_D3D8,
2017-05-08 00:25:55 +00:00
VIDEO_D3D9,
VIDEO_D3D10,
VIDEO_D3D11,
VIDEO_D3D12,
2017-05-08 00:25:55 +00:00
VIDEO_VG,
VIDEO_OMAP,
VIDEO_EXYNOS,
VIDEO_SUNXI,
VIDEO_DISPMANX,
VIDEO_CACA,
VIDEO_GDI,
VIDEO_VGA,
VIDEO_NULL
};
enum audio_driver_enum
{
AUDIO_RSOUND = VIDEO_NULL + 1,
AUDIO_OSS,
AUDIO_ALSA,
AUDIO_ALSATHREAD,
2017-06-24 01:44:00 +00:00
AUDIO_TINYALSA,
2017-05-08 00:25:55 +00:00
AUDIO_ROAR,
AUDIO_AL,
AUDIO_SL,
AUDIO_JACK,
AUDIO_SDL,
AUDIO_SDL2,
AUDIO_XAUDIO,
AUDIO_PULSE,
AUDIO_EXT,
AUDIO_DSOUND,
AUDIO_WASAPI,
AUDIO_COREAUDIO,
AUDIO_COREAUDIO3,
2017-05-08 00:25:55 +00:00
AUDIO_PS3,
AUDIO_XENON360,
AUDIO_WII,
AUDIO_WIIU,
AUDIO_RWEBAUDIO,
AUDIO_PSP,
2018-09-18 06:08:06 +00:00
AUDIO_PS2,
2017-05-08 00:25:55 +00:00
AUDIO_CTR,
2017-12-24 22:33:48 +00:00
AUDIO_SWITCH,
2017-05-08 00:25:55 +00:00
AUDIO_NULL
};
enum audio_resampler_driver_enum
{
AUDIO_RESAMPLER_CC = AUDIO_NULL + 1,
AUDIO_RESAMPLER_SINC,
AUDIO_RESAMPLER_NEAREST,
AUDIO_RESAMPLER_NULL
};
enum input_driver_enum
{
INPUT_ANDROID = AUDIO_RESAMPLER_NULL + 1,
INPUT_SDL,
INPUT_SDL2,
INPUT_X,
INPUT_WAYLAND,
INPUT_DINPUT,
2018-12-30 00:29:34 +00:00
INPUT_PS4,
2017-05-08 00:25:55 +00:00
INPUT_PS3,
INPUT_PSP,
2018-09-18 06:08:06 +00:00
INPUT_PS2,
2017-05-08 00:25:55 +00:00
INPUT_CTR,
2017-12-24 01:26:58 +00:00
INPUT_SWITCH,
2017-05-08 00:25:55 +00:00
INPUT_XENON360,
INPUT_WII,
INPUT_WIIU,
INPUT_XINPUT,
INPUT_UWP,
2017-05-08 00:25:55 +00:00
INPUT_UDEV,
INPUT_LINUXRAW,
INPUT_COCOA,
INPUT_QNX,
INPUT_RWEBINPUT,
INPUT_DOS,
INPUT_NULL
};
enum joypad_driver_enum
{
JOYPAD_PS3 = INPUT_NULL + 1,
JOYPAD_XINPUT,
JOYPAD_GX,
JOYPAD_WIIU,
JOYPAD_XDK,
2018-12-30 13:00:18 +00:00
JOYPAD_PS4,
2017-05-08 00:25:55 +00:00
JOYPAD_PSP,
2018-09-18 06:08:06 +00:00
JOYPAD_PS2,
2017-05-08 00:25:55 +00:00
JOYPAD_CTR,
2017-12-24 01:26:58 +00:00
JOYPAD_SWITCH,
2017-05-08 00:25:55 +00:00
JOYPAD_DINPUT,
JOYPAD_UDEV,
JOYPAD_LINUXRAW,
JOYPAD_ANDROID,
JOYPAD_SDL,
JOYPAD_DOS,
JOYPAD_HID,
JOYPAD_QNX,
JOYPAD_RWEBPAD,
JOYPAD_MFI,
2017-05-08 00:25:55 +00:00
JOYPAD_NULL
};
enum camera_driver_enum
{
CAMERA_V4L2 = JOYPAD_NULL + 1,
CAMERA_RWEBCAM,
CAMERA_ANDROID,
CAMERA_AVFOUNDATION,
CAMERA_NULL
};
enum wifi_driver_enum
{
WIFI_CONNMANCTL = CAMERA_NULL + 1,
WIFI_NULL
};
enum location_driver_enum
{
LOCATION_ANDROID = WIFI_NULL + 1,
LOCATION_CORELOCATION,
LOCATION_NULL
};
enum osk_driver_enum
{
OSK_PS3 = LOCATION_NULL + 1,
OSK_NULL
};
enum menu_driver_enum
{
MENU_RGUI = OSK_NULL + 1,
MENU_XUI,
MENU_MATERIALUI,
MENU_XMB,
2018-04-08 02:55:16 +00:00
MENU_STRIPES,
2017-05-08 00:25:55 +00:00
MENU_NUKLEAR,
MENU_OZONE,
2017-05-08 00:25:55 +00:00
MENU_NULL
};
enum record_driver_enum
{
RECORD_FFMPEG = MENU_NULL + 1,
RECORD_NULL
};
2018-06-04 05:48:08 +00:00
enum midi_driver_enum
{
MIDI_WINMM = RECORD_NULL + 1,
2018-09-28 14:07:51 +00:00
MIDI_ALSA,
2018-06-04 05:48:08 +00:00
MIDI_NULL
};
2017-05-08 00:25:55 +00:00
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_GL;
#elif defined(HAVE_METAL)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_METAL;
2017-05-08 00:25:55 +00:00
#elif defined(GEKKO)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_WII;
#elif defined(WIIU)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_WIIU;
#elif defined(XENON)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_XENON360;
2018-12-28 13:24:31 +00:00
#elif defined(HAVE_D3D12) && false
/* FIXME: DX12 performance on Xbox is horrible for some reason, so use d3d11 as default */
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D12;
#elif defined(HAVE_D3D11)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D11;
#elif defined(HAVE_D3D10)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D10;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_D3D9)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D9;
2018-01-23 01:55:33 +00:00
#elif defined(HAVE_D3D8)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_D3D8;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_VG)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VG;
#elif defined(HAVE_VITA2D)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VITA2D;
#elif defined(PSP)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_PSP1;
2018-09-18 06:08:06 +00:00
#elif defined(PS2)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_PS2;
2017-05-08 00:25:55 +00:00
#elif defined(_3DS)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_CTR;
2017-12-24 01:26:58 +00:00
#elif defined(SWITCH)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_SWITCH;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_XVIDEO)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_XVIDEO;
#elif defined(HAVE_SDL)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_SDL;
#elif defined(HAVE_SDL2)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_SDL2;
#elif defined(_WIN32) && !defined(_XBOX)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_GDI;
#elif defined(DJGPP)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_VGA;
#elif defined(HAVE_DYLIB) && !defined(ANDROID)
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_EXT;
#else
static enum video_driver_enum VIDEO_DEFAULT_DRIVER = VIDEO_NULL;
#endif
#if defined(__CELLOS_LV2__)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PS3;
#elif defined(XENON)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_XENON360;
#elif defined(GEKKO)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WII;
#elif defined(WIIU)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WIIU;
2018-12-30 23:37:08 +00:00
#elif defined(PSP) || defined(VITA) || defined(ORBIS)
2017-05-08 00:25:55 +00:00
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PSP;
2018-09-18 06:08:06 +00:00
#elif defined(PS2)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PS2;
2017-05-08 00:25:55 +00:00
#elif defined(_3DS)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_CTR;
2017-12-24 22:33:48 +00:00
#elif defined(SWITCH)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SWITCH;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_PULSE)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PULSE;
#elif defined(HAVE_ALSA) && defined(HAVE_VIDEOCORE)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_ALSATHREAD;
#elif defined(HAVE_ALSA)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_ALSA;
2017-06-24 01:44:00 +00:00
#elif defined(HAVE_TINYALSA)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_TINYALSA;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_OSS)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_OSS;
#elif defined(HAVE_JACK)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_JACK;
#elif defined(HAVE_COREAUDIO3)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO3;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_COREAUDIO)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_COREAUDIO;
#elif defined(HAVE_XAUDIO)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_XAUDIO;
#elif defined(HAVE_DSOUND)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_DSOUND;
#elif defined(HAVE_WASAPI)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WASAPI;
#elif defined(HAVE_AL)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_AL;
#elif defined(HAVE_SL)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SL;
#elif defined(EMSCRIPTEN)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_RWEBAUDIO;
#elif defined(HAVE_SDL)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SDL;
#elif defined(HAVE_SDL2)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SDL2;
#elif defined(HAVE_RSOUND)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_RSOUND;
#elif defined(HAVE_ROAR)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_ROAR;
#elif defined(HAVE_DYLIB) && !defined(ANDROID)
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_EXT;
#else
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_NULL;
#endif
#if defined(PSP) || defined(EMSCRIPTEN)
static enum audio_resampler_driver_enum AUDIO_DEFAULT_RESAMPLER_DRIVER = AUDIO_RESAMPLER_CC;
#else
static enum audio_resampler_driver_enum AUDIO_DEFAULT_RESAMPLER_DRIVER = AUDIO_RESAMPLER_SINC;
#endif
#if defined(HAVE_FFMPEG)
static enum record_driver_enum RECORD_DEFAULT_DRIVER = RECORD_FFMPEG;
#else
static enum record_driver_enum RECORD_DEFAULT_DRIVER = RECORD_NULL;
#endif
2018-06-04 05:48:08 +00:00
#ifdef HAVE_WINMM
static enum midi_driver_enum MIDI_DEFAULT_DRIVER = MIDI_WINMM;
2018-09-28 14:07:51 +00:00
#elif defined HAVE_ALSA
static enum midi_driver_enum MIDI_DEFAULT_DRIVER = MIDI_ALSA;
2018-06-04 05:48:08 +00:00
#else
static enum midi_driver_enum MIDI_DEFAULT_DRIVER = MIDI_NULL;
#endif
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_UWP;
#elif defined(XENON)
2017-05-08 00:25:55 +00:00
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_XENON360;
#elif defined(_XBOX360) || defined(_XBOX) || defined(HAVE_XINPUT2) || defined(HAVE_XINPUT_XBOX1)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_XINPUT;
#elif defined(ANDROID)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_ANDROID;
#elif defined(EMSCRIPTEN) && defined(HAVE_SDL2)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL2;
#elif defined(EMSCRIPTEN)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_RWEBINPUT;
#elif defined(_WIN32)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_DINPUT;
2018-12-30 00:29:34 +00:00
#elif defined(ORBIS)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PS4;
2017-05-08 00:25:55 +00:00
#elif defined(__CELLOS_LV2__)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PS3;
#elif defined(PSP) || defined(VITA)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PSP;
2018-09-18 06:08:06 +00:00
#elif defined(PS2)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PS2;
2017-05-08 00:25:55 +00:00
#elif defined(_3DS)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_CTR;
2017-12-24 01:26:58 +00:00
#elif defined(SWITCH)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SWITCH;
2017-05-08 00:25:55 +00:00
#elif defined(GEKKO)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_WII;
#elif defined(WIIU)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_WIIU;
#elif defined(HAVE_X11)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_X;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_UDEV)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_UDEV;
#elif defined(__linux__) && !defined(ANDROID)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_LINUXRAW;
#elif defined(HAVE_WAYLAND)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_WAYLAND;
#elif defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA_METAL)
2017-05-08 00:25:55 +00:00
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_COCOA;
#elif defined(__QNX__)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_QNX;
#elif defined(HAVE_SDL)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL;
#elif defined(HAVE_SDL2)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL2;
#elif defined(DJGPP)
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_DOS;
#else
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_NULL;
#endif
#if defined(__CELLOS_LV2__)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PS3;
#elif defined(HAVE_XINPUT)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_XINPUT;
#elif defined(GEKKO)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_GX;
#elif defined(WIIU)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_WIIU;
#elif defined(_XBOX)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_XDK;
2018-12-30 13:00:18 +00:00
#elif defined(ORBIS)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PS4;
2017-05-08 00:25:55 +00:00
#elif defined(PSP) || defined(VITA)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PSP;
2018-09-18 06:08:06 +00:00
#elif defined(PS2)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PS2;
2017-05-08 00:25:55 +00:00
#elif defined(_3DS)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_CTR;
2017-12-24 01:26:58 +00:00
#elif defined(SWITCH)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_SWITCH;
2017-05-08 00:25:55 +00:00
#elif defined(HAVE_DINPUT)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_DINPUT;
#elif defined(HAVE_UDEV)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_UDEV;
#elif defined(__linux) && !defined(ANDROID)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_LINUXRAW;
#elif defined(ANDROID)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_ANDROID;
#elif defined(HAVE_SDL) || defined(HAVE_SDL2)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_SDL;
#elif defined(DJGPP)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_DOS;
#elif defined(HAVE_HID)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_HID;
#elif defined(__QNX__)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_QNX;
#elif defined(EMSCRIPTEN)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_RWEBPAD;
#elif defined(IOS)
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_MFI;
2017-05-08 00:25:55 +00:00
#else
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_NULL;
#endif
#if defined(HAVE_V4L2)
static enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_V4L2;
#elif defined(EMSCRIPTEN)
static enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_RWEBCAM;
#elif defined(ANDROID)
static enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_ANDROID;
#elif defined(HAVE_AVFOUNDATION) && (defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA_METAL))
2017-05-08 00:25:55 +00:00
static enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_AVFOUNDATION;
#else
static enum camera_driver_enum CAMERA_DEFAULT_DRIVER = CAMERA_NULL;
#endif
#if defined(HAVE_LAKKA)
static enum wifi_driver_enum WIFI_DEFAULT_DRIVER = WIFI_CONNMANCTL;
#else
static enum wifi_driver_enum WIFI_DEFAULT_DRIVER = WIFI_NULL;
#endif
#if defined(ANDROID)
static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_ANDROID;
#elif defined(HAVE_CORELOCATION) && (defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA_METAL))
2017-05-08 00:25:55 +00:00
static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_CORELOCATION;
#else
static enum location_driver_enum LOCATION_DEFAULT_DRIVER = LOCATION_NULL;
#endif
2018-12-07 14:18:43 +00:00
#if defined(_3DS) && defined(HAVE_RGUI)
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_RGUI;
#else
2017-05-08 00:25:55 +00:00
#if defined(HAVE_XUI)
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XUI;
#elif defined(HAVE_MATERIALUI) && defined(RARCH_MOBILE)
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_MATERIALUI;
#elif defined(HAVE_OZONE) && defined(HAVE_LIBNX)
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_OZONE;
2018-01-20 05:47:46 +00:00
#elif defined(HAVE_XMB) && !defined(_XBOX)
2017-05-08 00:25:55 +00:00
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_XMB;
#elif defined(HAVE_RGUI)
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_RGUI;
#else
static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_NULL;
#endif
2018-12-07 14:18:43 +00:00
#endif
2017-05-08 00:25:55 +00:00
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
{ \
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++; \
2017-07-14 19:11:27 +00:00
}
2016-08-29 17:10:00 +00:00
2016-09-01 01:51:54 +00:00
#define SETTING_BOOL(key, configval, default_enable, default_setting, handle_setting) \
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) \
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) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_int_setting, handle_setting)
2016-08-30 02:05:27 +00:00
2017-04-28 17:55:09 +00:00
#define SETTING_UINT(key, configval, default_enable, default_setting, handle_setting) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_uint_setting, handle_setting)
2017-04-28 17:55:09 +00:00
#define SETTING_SIZE(key, configval, default_enable, default_setting, handle_setting) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_size_setting, handle_setting)
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) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_array_setting, handle_setting)
2016-08-29 17:10:00 +00:00
#define SETTING_OVERRIDE(override_setting) \
tmp[count-1].override = override_setting
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
{
2016-12-05 05:37:26 +00:00
enum audio_driver_enum default_driver = AUDIO_DEFAULT_DRIVER;
switch (default_driver)
2010-12-29 19:50:50 +00:00
{
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";
2017-06-24 01:44:00 +00:00
case AUDIO_TINYALSA:
return "tinyalsa";
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";
2017-04-09 21:53:55 +00:00
case AUDIO_WASAPI:
return "wasapi";
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_WIIU:
return "AX";
case AUDIO_PSP:
2018-12-30 23:37:08 +00:00
#if defined(VITA)
return "vita";
2018-12-30 23:37:08 +00:00
#elif defined(ORBIS)
return "orbis";
#else
return "psp";
#endif
2018-09-18 06:08:06 +00:00
case AUDIO_PS2:
return "ps2";
2015-04-01 21:14:13 +00:00
case AUDIO_CTR:
2018-12-07 14:18:43 +00:00
return "dsp";
2017-12-24 22:33:48 +00:00
case AUDIO_SWITCH:
return "switch";
case AUDIO_RWEBAUDIO:
return "rwebaudio";
2016-12-05 05:37:26 +00:00
case AUDIO_JACK:
return "jack";
case AUDIO_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum record_driver_enum default_driver = RECORD_DEFAULT_DRIVER;
switch (default_driver)
2015-04-15 11:37:38 +00:00
{
case RECORD_FFMPEG:
return "ffmpeg";
2016-12-05 05:37:26 +00:00
case RECORD_NULL:
2015-04-15 11:37:38 +00:00
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)
{
2016-12-05 05:37:26 +00:00
enum audio_resampler_driver_enum default_driver = AUDIO_DEFAULT_RESAMPLER_DRIVER;
switch (default_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";
2016-12-05 05:37:26 +00:00
case AUDIO_RESAMPLER_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum video_driver_enum default_driver = VIDEO_DEFAULT_DRIVER;
switch (default_driver)
2012-05-07 21:20:13 +00:00
{
case VIDEO_GL:
return "gl";
case VIDEO_VULKAN:
return "vulkan";
case VIDEO_METAL:
return "metal";
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";
2016-10-27 00:34:10 +00:00
case VIDEO_WIIU:
return "gx2";
2012-05-07 21:20:13 +00:00
case VIDEO_XENON360:
return "xenon360";
2018-01-23 01:55:33 +00:00
case VIDEO_D3D8:
return "d3d8";
2012-10-26 19:09:30 +00:00
case VIDEO_D3D9:
2018-01-23 01:55:33 +00:00
return "d3d9";
case VIDEO_D3D10:
return "d3d10";
case VIDEO_D3D11:
return "d3d11";
case VIDEO_D3D12:
return "d3d12";
case VIDEO_PSP1:
return "psp1";
2018-09-18 06:08:06 +00:00
case VIDEO_PS2:
return "ps2";
case VIDEO_VITA2D:
return "vita2d";
2015-04-01 21:14:13 +00:00
case VIDEO_CTR:
return "ctr";
2017-12-24 01:26:58 +00:00
case VIDEO_SWITCH:
return "switch";
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";
2017-01-04 07:07:19 +00:00
case VIDEO_CACA:
return "caca";
case VIDEO_GDI:
return "gdi";
2017-01-21 22:41:20 +00:00
case VIDEO_VGA:
return "vga";
2016-12-05 05:37:26 +00:00
case VIDEO_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum input_driver_enum default_driver = INPUT_DEFAULT_DRIVER;
switch (default_driver)
{
case INPUT_ANDROID:
return "android";
2018-12-30 00:29:34 +00:00
case INPUT_PS4:
return "ps4";
case INPUT_PS3:
2012-05-07 21:20:13 +00:00
return "ps3";
case INPUT_PSP:
#ifdef VITA
return "vita";
#else
return "psp";
#endif
2018-09-18 06:08:06 +00:00
case INPUT_PS2:
return "ps2";
2015-04-01 21:14:13 +00:00
case INPUT_CTR:
return "ctr";
2017-12-24 01:26:58 +00:00
case INPUT_SWITCH:
return "switch";
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";
case INPUT_UWP:
return "uwp";
2011-12-14 12:20:22 +00:00
case INPUT_WII:
return "gx";
2016-10-27 00:34:10 +00:00
case INPUT_WIIU:
return "wiiu";
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";
2017-01-24 05:55:55 +00:00
case INPUT_DOS:
return "dos";
2016-12-05 05:37:26 +00:00
case INPUT_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum joypad_driver_enum default_driver = JOYPAD_DEFAULT_DRIVER;
switch (default_driver)
{
2018-12-30 13:00:18 +00:00
case JOYPAD_PS4:
return "ps4";
case JOYPAD_PS3:
return "ps3";
case JOYPAD_XINPUT:
return "xinput";
case JOYPAD_GX:
return "gx";
2016-10-27 00:34:10 +00:00
case JOYPAD_WIIU:
return "wiiu";
case JOYPAD_XDK:
return "xdk";
case JOYPAD_PSP:
#ifdef VITA
return "vita";
#else
return "psp";
#endif
2018-09-18 06:08:06 +00:00
case JOYPAD_PS2:
return "ps2";
2015-04-01 21:14:13 +00:00
case JOYPAD_CTR:
return "ctr";
2017-12-24 01:26:58 +00:00
case JOYPAD_SWITCH:
return "switch";
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";
case JOYPAD_RWEBPAD:
return "rwebpad";
2017-01-24 05:55:55 +00:00
case JOYPAD_DOS:
return "dos";
case JOYPAD_MFI:
return "mfi";
2016-12-05 05:37:26 +00:00
case JOYPAD_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum camera_driver_enum default_driver = CAMERA_DEFAULT_DRIVER;
switch (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";
2016-12-05 05:37:26 +00:00
case CAMERA_NULL:
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)
{
2016-12-05 05:37:26 +00:00
enum wifi_driver_enum default_driver = WIFI_DEFAULT_DRIVER;
switch (default_driver)
{
case WIFI_CONNMANCTL:
return "connmanctl";
2016-12-05 05:37:26 +00:00
case WIFI_NULL:
break;
}
return "null";
}
/**
* config_get_default_led:
*
* Gets default led driver.
*
* Returns: Default led driver.
**/
const char *config_get_default_led(void)
{
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)
{
2016-12-05 05:37:26 +00:00
enum location_driver_enum default_driver = LOCATION_DEFAULT_DRIVER;
switch (default_driver)
{
case LOCATION_ANDROID:
return "android";
case LOCATION_CORELOCATION:
return "corelocation";
2016-12-05 05:37:26 +00:00
case LOCATION_NULL:
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
/**
* 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
{
2017-09-27 22:01:42 +00:00
#ifdef HAVE_MENU
2016-12-05 05:37:26 +00:00
enum menu_driver_enum default_driver = MENU_DEFAULT_DRIVER;
2016-09-16 23:40:11 +00:00
if (!string_is_empty(g_defaults.settings.menu))
return g_defaults.settings.menu;
2016-12-05 05:37:26 +00:00
switch (default_driver)
2016-09-16 23:40:11 +00:00
{
case MENU_RGUI:
return "rgui";
case MENU_XUI:
return "xui";
case MENU_OZONE:
return "ozone";
2016-09-16 23:40:11 +00:00
case MENU_MATERIALUI:
return "glui";
case MENU_XMB:
return "xmb";
2018-04-08 02:55:16 +00:00
case MENU_STRIPES:
return "stripes";
2016-09-16 23:40:11 +00:00
case MENU_NUKLEAR:
return "nuklear";
2016-12-05 05:37:26 +00:00
case MENU_NULL:
2016-09-16 23:40:11 +00:00
break;
}
2017-09-27 22:01:42 +00:00
#endif
2016-09-16 23:40:11 +00:00
return "null";
2016-08-01 12:14:21 +00:00
}
2018-06-04 05:48:08 +00:00
const char *config_get_default_midi(void)
{
enum midi_driver_enum default_driver = MIDI_DEFAULT_DRIVER;
switch (default_driver)
{
case MIDI_WINMM:
return "winmm";
2018-09-28 14:07:51 +00:00
case MIDI_ALSA:
return "alsa";
2018-06-04 05:48:08 +00:00
case MIDI_NULL:
break;
}
return "null";
}
const char *config_get_midi_driver_options(void)
{
return char_list_new_special(STRING_LIST_MIDI_DRIVERS, NULL);
}
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;
}
static struct config_array_setting *populate_settings_array(settings_t *settings, int *size)
2012-05-07 21:20:13 +00:00
{
2016-08-29 17:10:00 +00:00
unsigned count = 0;
struct config_array_setting *tmp = (struct config_array_setting*)calloc(1, (*size + 1) * sizeof(struct config_array_setting));
2016-09-01 01:01:04 +00:00
if (!tmp)
return NULL;
2016-09-01 00:46:09 +00:00
/* Arrays */
2017-04-28 20:59:13 +00:00
SETTING_ARRAY("playlist_names", settings->arrays.playlist_names, false, NULL, true);
SETTING_ARRAY("playlist_cores", settings->arrays.playlist_cores, false, NULL, true);
SETTING_ARRAY("video_driver", settings->arrays.video_driver, false, NULL, true);
SETTING_ARRAY("record_driver", settings->arrays.record_driver, false, NULL, true);
SETTING_ARRAY("camera_driver", settings->arrays.camera_driver, false, NULL, true);
SETTING_ARRAY("wifi_driver", settings->arrays.wifi_driver, false, NULL, true);
SETTING_ARRAY("location_driver", settings->arrays.location_driver,false, NULL, true);
#ifdef HAVE_MENU
2017-04-28 20:59:13 +00:00
SETTING_ARRAY("menu_driver", settings->arrays.menu_driver, false, NULL, true);
2016-07-09 11:05:58 +00:00
#endif
2017-04-28 20:59:13 +00:00
SETTING_ARRAY("audio_device", settings->arrays.audio_device, false, NULL, true);
SETTING_ARRAY("camera_device", settings->arrays.camera_device, false, NULL, true);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_CHEEVOS
2017-04-28 20:59:13 +00:00
SETTING_ARRAY("cheevos_username", settings->arrays.cheevos_username, false, NULL, true);
SETTING_ARRAY("cheevos_password", settings->arrays.cheevos_password, false, NULL, true);
SETTING_ARRAY("cheevos_token", settings->arrays.cheevos_token, false, NULL, true);
2017-04-28 20:59:13 +00:00
#endif
SETTING_ARRAY("video_context_driver", settings->arrays.video_context_driver, false, NULL, true);
SETTING_ARRAY("audio_driver", settings->arrays.audio_driver, false, NULL, true);
SETTING_ARRAY("audio_resampler", settings->arrays.audio_resampler, false, NULL, true);
SETTING_ARRAY("input_driver", settings->arrays.input_driver, false, NULL, true);
SETTING_ARRAY("input_joypad_driver", settings->arrays.input_joypad_driver, false, NULL, true);
SETTING_ARRAY("input_keyboard_layout", settings->arrays.input_keyboard_layout, false, NULL, true);
SETTING_ARRAY("bundle_assets_src_path", settings->arrays.bundle_assets_src, false, NULL, true);
SETTING_ARRAY("bundle_assets_dst_path", settings->arrays.bundle_assets_dst, false, NULL, true);
SETTING_ARRAY("bundle_assets_dst_path_subdir", settings->arrays.bundle_assets_dst_subdir, false, NULL, true);
SETTING_ARRAY("led_driver", settings->arrays.led_driver, false, NULL, true);
SETTING_ARRAY("netplay_mitm_server", settings->arrays.netplay_mitm_server, false, NULL, true);
2018-06-04 05:48:08 +00:00
SETTING_ARRAY("midi_driver", settings->arrays.midi_driver, false, NULL, true);
SETTING_ARRAY("midi_input", settings->arrays.midi_input, true, midi_input, true);
SETTING_ARRAY("midi_output", settings->arrays.midi_output, true, midi_output, true);
2018-09-26 21:22:12 +00:00
SETTING_ARRAY("youtube_stream_key", settings->arrays.youtube_stream_key, true, NULL, true);
2018-10-13 23:17:17 +00:00
SETTING_ARRAY("discord_app_id", settings->arrays.discord_app_id, true, default_discord_app_id, true);
*size = count;
return tmp;
2016-08-29 17:10:00 +00:00
}
static struct config_path_setting *populate_settings_path(settings_t *settings, int *size)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
global_t *global = global_get_ptr();
2018-08-18 04:56:10 +00:00
struct config_path_setting *tmp = (struct config_path_setting*)calloc(1, (*size + 1) * sizeof(struct config_path_setting));
if (!tmp)
return NULL;
2016-09-01 01:00:27 +00:00
/* Paths */
2016-09-01 02:37:22 +00:00
#ifdef HAVE_XMB
2017-04-28 22:39:29 +00:00
SETTING_PATH("xmb_font", settings->paths.path_menu_xmb_font, false, NULL, true);
2016-09-01 02:37:22 +00:00
#endif
SETTING_PATH("content_show_settings_password", settings->paths.menu_content_show_settings_password, false, NULL, true);
SETTING_PATH("kiosk_mode_password", settings->paths.kiosk_mode_password, false, NULL, true);
2017-04-28 22:39:29 +00:00
SETTING_PATH("netplay_nickname", settings->paths.username, false, NULL, true);
SETTING_PATH("video_filter", settings->paths.path_softfilter_plugin, false, NULL, true);
SETTING_PATH("audio_dsp_plugin", settings->paths.path_audio_dsp_plugin, false, NULL, true);
SETTING_PATH("core_updater_buildbot_url", settings->paths.network_buildbot_url, false, NULL, true);
SETTING_PATH("core_updater_buildbot_assets_url", settings->paths.network_buildbot_assets_url, false, NULL, true);
2016-09-29 19:07:10 +00:00
#ifdef HAVE_NETWORKING
2017-04-28 22:39:29 +00:00
SETTING_PATH("netplay_ip_address", settings->paths.netplay_server, false, NULL, true);
SETTING_PATH("netplay_password", settings->paths.netplay_password, false, NULL, true);
SETTING_PATH("netplay_spectate_password", settings->paths.netplay_spectate_password, false, NULL, true);
2016-09-01 01:41:10 +00:00
#endif
SETTING_PATH("libretro_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_libretro, false, NULL, false);
2016-09-01 01:41:10 +00:00
SETTING_PATH("core_options_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_core_options, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("libretro_info_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_libretro_info, false, NULL, true);
SETTING_PATH("video_shader",
settings->paths.path_shader, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_database_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_content_database, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cheat_database_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_cheat_database, false, NULL, true);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
2017-07-14 19:11:27 +00:00
SETTING_PATH("menu_wallpaper",
2017-04-28 22:39:29 +00:00
settings->paths.path_menu_wallpaper, false, NULL, true);
SETTING_PATH("rgui_menu_theme_preset",
settings->paths.path_rgui_theme_preset, false, NULL, true);
2016-09-01 01:41:10 +00:00
#endif
SETTING_PATH("content_history_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_content_history, false, NULL, true);
2017-08-12 15:10:14 +00:00
SETTING_PATH("content_favorites_path",
settings->paths.path_content_favorites, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_music_history_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_content_music_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_video_history_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_content_video_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("content_image_history_path",
2017-04-28 22:39:29 +00:00
settings->paths.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",
2017-04-28 22:39:29 +00:00
settings->paths.path_overlay, false, NULL, true);
#endif
SETTING_PATH("video_record_config",
settings->paths.path_record_config, false, NULL, true);
SETTING_PATH("video_stream_config",
settings->paths.path_stream_config, false, NULL, true);
SETTING_PATH("video_stream_url",
settings->paths.path_stream_url, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_font_path",
2017-04-28 22:39:29 +00:00
settings->paths.path_font, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cursor_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_cursor, false, NULL, true);
2017-07-14 19:11:27 +00:00
SETTING_PATH("content_history_dir",
2017-04-28 22:39:29 +00:00
settings->paths.directory_content_history, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("screenshot_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_screenshot, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("system_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_system, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("cache_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_cache, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("input_remapping_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_input_remapping, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("resampler_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_resampler, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_shader_dir",
2017-04-28 22:39:29 +00:00
settings->paths.directory_video_shader, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("video_filter_dir",
2017-04-28 22:39:29 +00:00
settings->paths.directory_video_filter, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("core_assets_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_core_assets, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("assets_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_assets, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("dynamic_wallpapers_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_dynamic_wallpapers, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("thumbnails_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_thumbnails, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("playlist_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_playlist, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("joypad_autoconfig_dir",
2017-04-28 22:39:29 +00:00
settings->paths.directory_autoconfig, false, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("audio_filter_dir",
2017-04-28 22:39:29 +00:00
settings->paths.directory_audio_filter, true, NULL, true);
2017-07-14 19:11:27 +00:00
SETTING_PATH("savefile_directory",
2016-10-03 06:15:41 +00:00
dir_get_ptr(RARCH_DIR_SAVEFILE), true, NULL, false);
2016-09-01 01:41:10 +00:00
SETTING_PATH("savestate_directory",
2016-10-03 06:15:41 +00:00
dir_get_ptr(RARCH_DIR_SAVESTATE), 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",
2017-04-28 22:39:29 +00:00
settings->paths.directory_menu_content, true, NULL, true);
2016-09-01 01:41:10 +00:00
SETTING_PATH("rgui_config_directory",
2017-04-28 22:39:29 +00:00
settings->paths.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",
2017-04-28 22:39:29 +00:00
settings->paths.directory_overlay, true, NULL, true);
2016-08-29 17:10:00 +00:00
#endif
#ifndef HAVE_DYNAMIC
2017-07-14 19:11:27 +00:00
SETTING_PATH("libretro_path",
2016-10-03 13:46:07 +00:00
path_get_ptr(RARCH_PATH_CORE), false, NULL, false);
2016-08-29 17:10:00 +00:00
#endif
SETTING_PATH(
2017-07-14 19:11:27 +00:00
"screenshot_directory",
2017-04-28 22:39:29 +00:00
settings->paths.directory_screenshot, true, NULL, false);
2016-08-29 17:10:00 +00:00
2016-12-26 02:16:27 +00:00
if (global)
{
SETTING_PATH("recording_output_directory",
global->record.output_dir, false, NULL, true);
SETTING_PATH("recording_config_directory",
global->record.config_dir, false, NULL, true);
}
*size = count;
return tmp;
2016-08-29 17:10:00 +00:00
}
static struct config_bool_setting *populate_settings_bool(settings_t *settings, int *size)
2016-08-29 17:10:00 +00:00
{
2017-04-28 13:14:51 +00:00
struct config_bool_setting *tmp = (struct config_bool_setting*)malloc((*size + 1) * sizeof(struct config_bool_setting));
2016-08-29 17:10:00 +00:00
unsigned count = 0;
2018-09-16 23:56:18 +00:00
SETTING_BOOL("crt_switch_resolution_use_custom_refresh_rate", &settings->bools.crt_switch_custom_refresh_enable, true, false, false);
SETTING_BOOL("automatically_add_content_to_playlist", &settings->bools.automatically_add_content_to_playlist, true, automatically_add_content_to_playlist, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("ui_companion_start_on_boot", &settings->bools.ui_companion_start_on_boot, true, ui_companion_start_on_boot, false);
SETTING_BOOL("ui_companion_enable", &settings->bools.ui_companion_enable, true, ui_companion_enable, false);
2018-04-30 18:33:05 +00:00
SETTING_BOOL("ui_companion_toggle", &settings->bools.ui_companion_toggle, false, ui_companion_toggle, false);
SETTING_BOOL("desktop_menu_enable", &settings->bools.desktop_menu_enable, true, desktop_menu_enable, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_gpu_record", &settings->bools.video_gpu_record, true, gpu_record, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("input_remap_binds_enable", &settings->bools.input_remap_binds_enable, true, true, false);
SETTING_BOOL("all_users_control_menu", &settings->bools.input_all_users_control_menu, true, all_users_control_menu, false);
SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->bools.input_menu_swap_ok_cancel_buttons, true, menu_swap_ok_cancel_buttons, false);
2016-10-03 03:06:01 +00:00
#ifdef HAVE_NETWORKING
2017-04-28 11:43:47 +00:00
SETTING_BOOL("netplay_public_announce", &settings->bools.netplay_public_announce, true, netplay_public_announce, false);
SETTING_BOOL("netplay_start_as_spectator", &settings->bools.netplay_start_as_spectator, false, netplay_start_as_spectator, false);
SETTING_BOOL("netplay_allow_slaves", &settings->bools.netplay_allow_slaves, true, netplay_allow_slaves, false);
SETTING_BOOL("netplay_require_slaves", &settings->bools.netplay_require_slaves, true, netplay_require_slaves, false);
SETTING_BOOL("netplay_stateless_mode", &settings->bools.netplay_stateless_mode, true, netplay_stateless_mode, false);
SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_NETPLAY_STATELESS_MODE);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("netplay_use_mitm_server", &settings->bools.netplay_use_mitm_server, true, netplay_use_mitm_server, false);
SETTING_BOOL("netplay_request_device_p1", &settings->bools.netplay_request_devices[0], true, false, false);
SETTING_BOOL("netplay_request_device_p2", &settings->bools.netplay_request_devices[1], true, false, false);
SETTING_BOOL("netplay_request_device_p3", &settings->bools.netplay_request_devices[2], true, false, false);
SETTING_BOOL("netplay_request_device_p4", &settings->bools.netplay_request_devices[3], true, false, false);
SETTING_BOOL("netplay_request_device_p5", &settings->bools.netplay_request_devices[4], true, false, false);
SETTING_BOOL("netplay_request_device_p6", &settings->bools.netplay_request_devices[5], true, false, false);
SETTING_BOOL("netplay_request_device_p7", &settings->bools.netplay_request_devices[6], true, false, false);
SETTING_BOOL("netplay_request_device_p8", &settings->bools.netplay_request_devices[7], true, false, false);
SETTING_BOOL("netplay_request_device_p9", &settings->bools.netplay_request_devices[8], true, false, false);
SETTING_BOOL("netplay_request_device_p10", &settings->bools.netplay_request_devices[9], true, false, false);
SETTING_BOOL("netplay_request_device_p11", &settings->bools.netplay_request_devices[10], true, false, false);
SETTING_BOOL("netplay_request_device_p12", &settings->bools.netplay_request_devices[11], true, false, false);
SETTING_BOOL("netplay_request_device_p13", &settings->bools.netplay_request_devices[12], true, false, false);
SETTING_BOOL("netplay_request_device_p14", &settings->bools.netplay_request_devices[13], true, false, false);
SETTING_BOOL("netplay_request_device_p15", &settings->bools.netplay_request_devices[14], true, false, false);
SETTING_BOOL("netplay_request_device_p16", &settings->bools.netplay_request_devices[15], true, false, false);
2017-04-28 11:43:47 +00:00
#endif
SETTING_BOOL("input_descriptor_label_show", &settings->bools.input_descriptor_label_show, true, input_descriptor_label_show, false);
SETTING_BOOL("input_descriptor_hide_unbound", &settings->bools.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false);
SETTING_BOOL("load_dummy_on_core_shutdown", &settings->bools.load_dummy_on_core_shutdown, true, load_dummy_on_core_shutdown, false);
SETTING_BOOL("check_firmware_before_loading", &settings->bools.check_firmware_before_loading, true, check_firmware_before_loading, false);
SETTING_BOOL("builtin_mediaplayer_enable", &settings->bools.multimedia_builtin_mediaplayer_enable, false, false /* TODO */, false);
SETTING_BOOL("builtin_imageviewer_enable", &settings->bools.multimedia_builtin_imageviewer_enable, true, true, false);
2017-04-28 10:26:01 +00:00
SETTING_BOOL("fps_show", &settings->bools.video_fps_show, true, false, false);
SETTING_BOOL("statistics_show", &settings->bools.video_statistics_show, true, false, false);
2018-12-01 10:27:39 +00:00
SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, false, false);
SETTING_BOOL("memory_show", &settings->bools.video_memory_show, true, false, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("ui_menubar_enable", &settings->bools.ui_menubar_enable, true, true, false);
SETTING_BOOL("suspend_screensaver_enable", &settings->bools.ui_suspend_screensaver_enable, true, true, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("rewind_enable", &settings->bools.rewind_enable, true, rewind_enable, false);
2018-08-04 22:34:10 +00:00
SETTING_BOOL("vrr_runloop_enable", &settings->bools.vrr_runloop_enable, true, vrr_runloop_enable, false);
SETTING_BOOL("apply_cheats_after_toggle", &settings->bools.apply_cheats_after_toggle, true, apply_cheats_after_toggle, false);
SETTING_BOOL("apply_cheats_after_load", &settings->bools.apply_cheats_after_load, true, apply_cheats_after_load, false);
2018-03-28 19:22:07 +00:00
SETTING_BOOL("run_ahead_enabled", &settings->bools.run_ahead_enabled, true, false, false);
SETTING_BOOL("run_ahead_secondary_instance", &settings->bools.run_ahead_secondary_instance, true, false, false);
SETTING_BOOL("run_ahead_hide_warnings", &settings->bools.run_ahead_hide_warnings, true, false, false);
2017-04-28 10:23:59 +00:00
SETTING_BOOL("audio_sync", &settings->bools.audio_sync, true, audio_sync, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_shader_enable", &settings->bools.video_shader_enable, true, shader_enable, false);
SETTING_BOOL("video_shader_watch_files", &settings->bools.video_shader_watch_files, true, video_shader_watch_files, false);
2016-08-29 19:03:01 +00:00
/* Let implementation decide if automatic, or 1:1 PAR. */
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_aspect_ratio_auto", &settings->bools.video_aspect_ratio_auto, true, aspect_ratio_auto, false);
SETTING_BOOL("video_allow_rotate", &settings->bools.video_allow_rotate, true, allow_rotate, false);
SETTING_BOOL("video_windowed_fullscreen", &settings->bools.video_windowed_fullscreen, true, windowed_fullscreen, false);
SETTING_BOOL("video_crop_overscan", &settings->bools.video_crop_overscan, true, crop_overscan, false);
SETTING_BOOL("video_scale_integer", &settings->bools.video_scale_integer, true, scale_integer, false);
SETTING_BOOL("video_smooth", &settings->bools.video_smooth, true, video_smooth, false);
SETTING_BOOL("video_force_aspect", &settings->bools.video_force_aspect, true, force_aspect, false);
2019-01-20 19:06:14 +00:00
SETTING_BOOL("video_threaded", video_driver_get_threaded(), true, video_threaded, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_shared_context", &settings->bools.video_shared_context, true, video_shared_context, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("auto_screenshot_filename", &settings->bools.auto_screenshot_filename, true, auto_screenshot_filename, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_force_srgb_disable", &settings->bools.video_force_srgb_disable, true, false, false);
SETTING_BOOL("video_fullscreen", &settings->bools.video_fullscreen, true, fullscreen, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("bundle_assets_extract_enable", &settings->bools.bundle_assets_extract_enable, true, bundle_assets_extract_enable, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, vsync, false);
SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, adaptive_vsync, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, hard_sync, false);
SETTING_BOOL("video_black_frame_insertion", &settings->bools.video_black_frame_insertion, true, black_frame_insertion, false);
SETTING_BOOL("video_disable_composition", &settings->bools.video_disable_composition, true, disable_composition, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("pause_nonactive", &settings->bools.pause_nonactive, true, pause_nonactive, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_gpu_screenshot", &settings->bools.video_gpu_screenshot, true, gpu_screenshot, false);
SETTING_BOOL("video_post_filter_record", &settings->bools.video_post_filter_record, true, post_filter_record, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("keyboard_gamepad_enable", &settings->bools.input_keyboard_gamepad_enable, true, true, false);
SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false);
2017-04-28 10:23:59 +00:00
SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, audio_enable, false);
2019-01-27 16:22:16 +00:00
SETTING_BOOL("audio_enable_menu", &settings->bools.audio_enable_menu, true, audio_enable_menu, false);
SETTING_BOOL("audio_enable_menu_ok", &settings->bools.audio_enable_menu_ok, true, audio_enable_menu_ok, false);
SETTING_BOOL("audio_enable_menu_cancel", &settings->bools.audio_enable_menu_cancel, true, audio_enable_menu_cancel, false);
SETTING_BOOL("audio_enable_menu_notice", &settings->bools.audio_enable_menu_notice, true, audio_enable_menu_notice, false);
SETTING_BOOL("audio_enable_menu_bgm", &settings->bools.audio_enable_menu_bgm, true, audio_enable_menu_bgm, false);
SETTING_BOOL("audio_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE), true, false, false);
2017-06-08 21:53:24 +00:00
SETTING_BOOL("audio_mixer_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE), true, false, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("location_allow", &settings->bools.location_allow, true, false, false);
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_font_enable", &settings->bools.video_font_enable, true, font_enable, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("core_updater_auto_extract_archive", &settings->bools.network_buildbot_auto_extract_archive, true, true, false);
SETTING_BOOL("camera_allow", &settings->bools.camera_allow, true, false, false);
2018-05-29 10:18:01 +00:00
SETTING_BOOL("discord_allow", &settings->bools.discord_enable, true, false, false);
2016-10-14 19:57:18 +00:00
#if defined(VITA)
2017-04-28 11:43:47 +00:00
SETTING_BOOL("input_backtouch_enable", &settings->bools.input_backtouch_enable, false, false, false);
SETTING_BOOL("input_backtouch_toggle", &settings->bools.input_backtouch_toggle, false, false, false);
2016-10-14 19:57:18 +00:00
#endif
2016-08-29 17:10:00 +00:00
#if TARGET_OS_IPHONE
2017-04-28 11:43:47 +00:00
SETTING_BOOL("small_keyboard_enable", &settings->bools.input_small_keyboard_enable, true, false, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef GEKKO
2017-04-27 22:53:06 +00:00
SETTING_BOOL("video_vfilter", &settings->bools.video_vfilter, true, video_vfilter, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_THREADS
2017-04-28 11:43:47 +00:00
SETTING_BOOL("threaded_data_runloop_enable", &settings->bools.threaded_data_runloop_enable, true, threaded_data_runloop_enable, false);
#endif
#ifdef HAVE_MENU
SETTING_BOOL("menu_unified_controls", &settings->bools.menu_unified_controls, true, false, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("menu_throttle_framerate", &settings->bools.menu_throttle_framerate, true, true, false);
SETTING_BOOL("menu_linear_filter", &settings->bools.menu_linear_filter, true, true, false);
2017-07-14 19:11:27 +00:00
SETTING_BOOL("menu_horizontal_animation", &settings->bools.menu_horizontal_animation, true, true, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("dpi_override_enable", &settings->bools.menu_dpi_override_enable, true, menu_dpi_override_enable, false);
SETTING_BOOL("menu_pause_libretro", &settings->bools.menu_pause_libretro, true, true, false);
SETTING_BOOL("menu_mouse_enable", &settings->bools.menu_mouse_enable, true, def_mouse_enable, false);
SETTING_BOOL("menu_pointer_enable", &settings->bools.menu_pointer_enable, true, pointer_enable, false);
SETTING_BOOL("menu_timedate_enable", &settings->bools.menu_timedate_enable, true, true, false);
SETTING_BOOL("menu_battery_level_enable", &settings->bools.menu_battery_level_enable, true, true, false);
SETTING_BOOL("menu_core_enable", &settings->bools.menu_core_enable, true, true, false);
SETTING_BOOL("menu_dynamic_wallpaper_enable", &settings->bools.menu_dynamic_wallpaper_enable, true, false, false);
SETTING_BOOL("quick_menu_show_recording", &settings->bools.quick_menu_show_recording, true, quick_menu_show_recording, false);
SETTING_BOOL("quick_menu_show_streaming", &settings->bools.quick_menu_show_streaming, true, quick_menu_show_streaming, false);
SETTING_BOOL("quick_menu_show_save_load_state", &settings->bools.quick_menu_show_save_load_state, true, quick_menu_show_save_load_state, false);
SETTING_BOOL("quick_menu_show_take_screenshot", &settings->bools.quick_menu_show_take_screenshot, true, quick_menu_show_take_screenshot, false);
SETTING_BOOL("quick_menu_show_save_load_state", &settings->bools.quick_menu_show_save_load_state, true, quick_menu_show_save_load_state, false);
SETTING_BOOL("quick_menu_show_undo_save_load_state", &settings->bools.quick_menu_show_undo_save_load_state, true, quick_menu_show_undo_save_load_state, false);
SETTING_BOOL("quick_menu_show_add_to_favorites", &settings->bools.quick_menu_show_add_to_favorites, true, quick_menu_show_add_to_favorites, false);
SETTING_BOOL("quick_menu_show_start_recording", &settings->bools.quick_menu_show_start_recording, true, quick_menu_show_start_recording, false);
SETTING_BOOL("quick_menu_show_start_streaming", &settings->bools.quick_menu_show_start_streaming, true, quick_menu_show_start_streaming, false);
SETTING_BOOL("quick_menu_show_reset_core_association", &settings->bools.quick_menu_show_reset_core_association, true, quick_menu_show_reset_core_association, false);
SETTING_BOOL("quick_menu_show_options", &settings->bools.quick_menu_show_options, true, quick_menu_show_options, false);
SETTING_BOOL("quick_menu_show_controls", &settings->bools.quick_menu_show_controls, true, quick_menu_show_controls, false);
SETTING_BOOL("quick_menu_show_cheats", &settings->bools.quick_menu_show_cheats, true, quick_menu_show_cheats, false);
SETTING_BOOL("quick_menu_show_shaders", &settings->bools.quick_menu_show_shaders, true, quick_menu_show_shaders, false);
SETTING_BOOL("quick_menu_show_save_core_overrides", &settings->bools.quick_menu_show_save_core_overrides, true, quick_menu_show_save_core_overrides, false);
SETTING_BOOL("quick_menu_show_save_game_overrides", &settings->bools.quick_menu_show_save_game_overrides, true, quick_menu_show_save_game_overrides, false);
2018-05-14 03:33:06 +00:00
SETTING_BOOL("quick_menu_show_save_content_dir_overrides", &settings->bools.quick_menu_show_save_content_dir_overrides, true, quick_menu_show_save_content_dir_overrides, false);
SETTING_BOOL("quick_menu_show_information", &settings->bools.quick_menu_show_information, true, quick_menu_show_information, false);
SETTING_BOOL("kiosk_mode_enable", &settings->bools.kiosk_mode_enable, true, kiosk_mode_enable, false);
SETTING_BOOL("menu_use_preferred_system_color_theme", &settings->bools.menu_use_preferred_system_color_theme, true, menu_use_preferred_system_color_theme, false);
SETTING_BOOL("content_show_settings", &settings->bools.menu_content_show_settings, true, content_show_settings, false);
SETTING_BOOL("content_show_favorites", &settings->bools.menu_content_show_favorites, true, content_show_favorites, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_IMAGEVIEWER
SETTING_BOOL("content_show_images", &settings->bools.menu_content_show_images, true, content_show_images, false);
#endif
SETTING_BOOL("content_show_music", &settings->bools.menu_content_show_music, true, content_show_music, false);
2018-06-20 02:50:58 +00:00
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
SETTING_BOOL("content_show_video", &settings->bools.menu_content_show_video, true, content_show_video, false);
#endif
#ifdef HAVE_NETWORKING
SETTING_BOOL("content_show_netplay", &settings->bools.menu_content_show_netplay, true, content_show_netplay, false);
#endif
SETTING_BOOL("content_show_history", &settings->bools.menu_content_show_history, true, content_show_history, false);
#ifdef HAVE_LIBRETRODB
SETTING_BOOL("content_show_add", &settings->bools.menu_content_show_add, true, content_show_add, false);
2016-08-29 17:10:00 +00:00
#endif
2018-04-17 15:53:24 +00:00
SETTING_BOOL("content_show_playlists", &settings->bools.menu_content_show_playlists, true, content_show_playlists, false);
SETTING_BOOL("menu_show_load_core", &settings->bools.menu_show_load_core, true, menu_show_load_core, false);
SETTING_BOOL("menu_show_load_content", &settings->bools.menu_show_load_content, true, menu_show_load_content, false);
SETTING_BOOL("menu_show_information", &settings->bools.menu_show_information, true, menu_show_information, false);
SETTING_BOOL("menu_show_configurations", &settings->bools.menu_show_configurations, true, menu_show_configurations, false);
SETTING_BOOL("menu_show_latency", &settings->bools.menu_show_latency, true, true, false);
SETTING_BOOL("menu_show_rewind", &settings->bools.menu_show_rewind, true, true, false);
SETTING_BOOL("menu_show_overlays", &settings->bools.menu_show_overlays, true, true, false);
SETTING_BOOL("menu_show_help", &settings->bools.menu_show_help, true, menu_show_help, false);
SETTING_BOOL("menu_show_quit_retroarch", &settings->bools.menu_show_quit_retroarch, true, menu_show_quit_retroarch, false);
SETTING_BOOL("menu_show_reboot", &settings->bools.menu_show_reboot, true, menu_show_reboot, false);
SETTING_BOOL("menu_show_shutdown", &settings->bools.menu_show_shutdown, true, menu_show_shutdown, false);
2017-06-19 23:42:28 +00:00
SETTING_BOOL("menu_show_online_updater", &settings->bools.menu_show_online_updater, true, menu_show_online_updater, false);
2017-06-20 00:22:07 +00:00
SETTING_BOOL("menu_show_core_updater", &settings->bools.menu_show_core_updater, true, menu_show_core_updater, false);
2017-05-31 22:25:13 +00:00
SETTING_BOOL("filter_by_current_core", &settings->bools.filter_by_current_core, false, false /* TODO */, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("rgui_show_start_screen", &settings->bools.menu_show_start_screen, false, false /* TODO */, false);
SETTING_BOOL("menu_navigation_wraparound_enable", &settings->bools.menu_navigation_wraparound_enable, true, true, false);
2017-07-14 19:11:27 +00:00
SETTING_BOOL("menu_navigation_browser_filter_supported_extensions_enable",
2017-04-28 11:43:47 +00:00
&settings->bools.menu_navigation_browser_filter_supported_extensions_enable, true, true, false);
SETTING_BOOL("menu_show_advanced_settings", &settings->bools.menu_show_advanced_settings, true, show_advanced_settings, false);
#ifdef HAVE_MATERIALUI
SETTING_BOOL("materialui_icons_enable", &settings->bools.menu_materialui_icons_enable, true, materialui_icons_enable, false);
#endif
2018-04-24 14:01:51 +00:00
#ifdef HAVE_RGUI
SETTING_BOOL("rgui_background_filler_thickness_enable", &settings->bools.menu_rgui_background_filler_thickness_enable, true, true, false);
SETTING_BOOL("rgui_border_filler_thickness_enable", &settings->bools.menu_rgui_border_filler_thickness_enable, true, true, false);
2018-04-24 14:01:51 +00:00
SETTING_BOOL("rgui_border_filler_enable", &settings->bools.menu_rgui_border_filler_enable, true, true, false);
#endif
#ifdef HAVE_XMB
SETTING_BOOL("xmb_shadows_enable", &settings->bools.menu_xmb_shadows_enable, true, xmb_shadows_enable, false);
2018-04-04 22:52:46 +00:00
SETTING_BOOL("xmb_vertical_thumbnails", &settings->bools.menu_xmb_vertical_thumbnails, true, xmb_vertical_thumbnails, false);
#endif
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_CHEEVOS
2017-04-28 11:43:47 +00:00
SETTING_BOOL("cheevos_enable", &settings->bools.cheevos_enable, true, cheevos_enable, false);
SETTING_BOOL("cheevos_test_unofficial", &settings->bools.cheevos_test_unofficial, true, false, false);
SETTING_BOOL("cheevos_hardcore_mode_enable", &settings->bools.cheevos_hardcore_mode_enable, true, false, false);
2017-10-31 05:58:35 +00:00
SETTING_BOOL("cheevos_leaderboards_enable", &settings->bools.cheevos_leaderboards_enable, true, false, false);
2018-03-14 07:49:48 +00:00
SETTING_BOOL("cheevos_verbose_enable", &settings->bools.cheevos_verbose_enable, true, false, false);
SETTING_BOOL("cheevos_auto_screenshot", &settings->bools.cheevos_auto_screenshot, true, false, false);
2017-11-23 16:55:53 +00:00
#ifdef HAVE_XMB
SETTING_BOOL("cheevos_badges_enable", &settings->bools.cheevos_badges_enable, true, false, false);
#endif
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_OVERLAY
2017-04-28 11:43:47 +00:00
SETTING_BOOL("input_overlay_enable", &settings->bools.input_overlay_enable, true, config_overlay_enable_default(), false);
SETTING_BOOL("input_overlay_enable_autopreferred", &settings->bools.input_overlay_enable_autopreferred, true, true, false);
SETTING_BOOL("input_overlay_show_physical_inputs", &settings->bools.input_overlay_show_physical_inputs, true, false, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("input_overlay_hide_in_menu", &settings->bools.input_overlay_hide_in_menu, true, overlay_hide_in_menu, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_COMMAND
2017-04-28 11:43:47 +00:00
SETTING_BOOL("network_cmd_enable", &settings->bools.network_cmd_enable, true, network_cmd_enable, false);
SETTING_BOOL("stdin_cmd_enable", &settings->bools.stdin_cmd_enable, true, stdin_cmd_enable, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_NETWORKGAMEPAD
2017-04-28 11:43:47 +00:00
SETTING_BOOL("network_remote_enable", &settings->bools.network_remote_enable, false, false /* TODO */, false);
2016-08-29 17:10:00 +00:00
#endif
2016-09-29 19:07:10 +00:00
#ifdef HAVE_NETWORKING
2017-04-28 11:43:47 +00:00
SETTING_BOOL("netplay_nat_traversal", &settings->bools.netplay_nat_traversal, true, true, false);
#endif
SETTING_BOOL("block_sram_overwrite", &settings->bools.block_sram_overwrite, true, block_sram_overwrite, false);
SETTING_BOOL("savestate_auto_index", &settings->bools.savestate_auto_index, true, savestate_auto_index, false);
SETTING_BOOL("savestate_auto_save", &settings->bools.savestate_auto_save, true, savestate_auto_save, false);
SETTING_BOOL("savestate_auto_load", &settings->bools.savestate_auto_load, true, savestate_auto_load, false);
SETTING_BOOL("savestate_thumbnail_enable", &settings->bools.savestate_thumbnail_enable, true, savestate_thumbnail_enable, false);
SETTING_BOOL("history_list_enable", &settings->bools.history_list_enable, true, def_history_list_enable, false);
SETTING_BOOL("playlist_entry_remove", &settings->bools.playlist_entry_remove, true, def_playlist_entry_remove, false);
SETTING_BOOL("playlist_entry_rename", &settings->bools.playlist_entry_rename, true, def_playlist_entry_rename, false);
2017-04-28 11:43:47 +00:00
SETTING_BOOL("game_specific_options", &settings->bools.game_specific_options, true, default_game_specific_options, false);
SETTING_BOOL("auto_overrides_enable", &settings->bools.auto_overrides_enable, true, default_auto_overrides_enable, false);
SETTING_BOOL("auto_remaps_enable", &settings->bools.auto_remaps_enable, true, default_auto_remaps_enable, false);
SETTING_BOOL("auto_shaders_enable", &settings->bools.auto_shaders_enable, true, default_auto_shaders_enable, false);
SETTING_BOOL("sort_savefiles_enable", &settings->bools.sort_savefiles_enable, true, default_sort_savefiles_enable, false);
SETTING_BOOL("sort_savestates_enable", &settings->bools.sort_savestates_enable, true, default_sort_savestates_enable, false);
SETTING_BOOL("config_save_on_exit", &settings->bools.config_save_on_exit, true, config_save_on_exit, false);
SETTING_BOOL("show_hidden_files", &settings->bools.show_hidden_files, true, show_hidden_files, false);
SETTING_BOOL("input_autodetect_enable", &settings->bools.input_autodetect_enable, true, input_autodetect_enable, false);
2017-04-28 10:23:59 +00:00
SETTING_BOOL("audio_rate_control", &settings->bools.audio_rate_control, true, rate_control, false);
#ifdef HAVE_WASAPI
2017-04-29 02:40:24 +00:00
SETTING_BOOL("audio_wasapi_exclusive_mode", &settings->bools.audio_wasapi_exclusive_mode, true, wasapi_exclusive_mode, false);
SETTING_BOOL("audio_wasapi_float_format", &settings->bools.audio_wasapi_float_format, true, wasapi_float_format, false);
#endif
2016-08-29 17:10:00 +00:00
2017-08-05 17:31:58 +00:00
SETTING_BOOL("savestates_in_content_dir", &settings->bools.savestates_in_content_dir, true, default_savestates_in_content_dir, false);
SETTING_BOOL("savefiles_in_content_dir", &settings->bools.savefiles_in_content_dir, true, default_savefiles_in_content_dir, false);
SETTING_BOOL("systemfiles_in_content_dir", &settings->bools.systemfiles_in_content_dir, true, default_systemfiles_in_content_dir, false);
SETTING_BOOL("screenshots_in_content_dir", &settings->bools.screenshots_in_content_dir, true, default_screenshots_in_content_dir, false);
SETTING_BOOL("video_msg_bgcolor_enable", &settings->bools.video_msg_bgcolor_enable, true, message_bgcolor_enable, false);
SETTING_BOOL("video_window_show_decorations", &settings->bools.video_window_show_decorations, true, window_decorations, false);
SETTING_BOOL("video_window_save_positions", &settings->bools.video_window_save_positions, true, false, false);
SETTING_BOOL("sustained_performance_mode", &settings->bools.sustained_performance_mode, true, sustained_performance_mode, false);
#ifdef _3DS
SETTING_BOOL("video_3ds_lcd_bottom", &settings->bools.video_3ds_lcd_bottom, true, video_3ds_lcd_bottom, false);
#endif
2019-01-09 22:13:13 +00:00
SETTING_BOOL("playlist_use_old_format", &settings->bools.playlist_use_old_format, true, playlist_use_old_format, false);
*size = count;
return tmp;
2016-08-29 17:10:00 +00:00
}
static struct config_float_setting *populate_settings_float(settings_t *settings, int *size)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
2018-08-18 14:15:55 +00:00
struct config_float_setting *tmp = (struct config_float_setting*)calloc(1, (*size + 1) * sizeof(struct config_float_setting));
2016-08-29 17:10:00 +00:00
if (!tmp)
return NULL;
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, aspect_ratio, false);
SETTING_FLOAT("video_scale", &settings->floats.video_scale, false, 0.0f, false);
2018-09-16 23:56:18 +00:00
SETTING_FLOAT("crt_video_refresh_rate", &settings->floats.crt_video_refresh_rate, true, crt_refresh_rate, false);
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("video_refresh_rate", &settings->floats.video_refresh_rate, true, refresh_rate, false);
SETTING_FLOAT("audio_rate_control_delta", audio_get_float_ptr(AUDIO_ACTION_RATE_CONTROL_DELTA), true, rate_control_delta, false);
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("audio_max_timing_skew", &settings->floats.audio_max_timing_skew, true, max_timing_skew, false);
SETTING_FLOAT("audio_volume", &settings->floats.audio_volume, true, audio_volume, false);
2017-06-08 20:58:43 +00:00
SETTING_FLOAT("audio_mixer_volume", &settings->floats.audio_mixer_volume, true, audio_mixer_volume, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_OVERLAY
2018-07-27 17:26:15 +00:00
SETTING_FLOAT("input_overlay_opacity", &settings->floats.input_overlay_opacity, true, default_input_overlay_opacity, false);
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("input_overlay_scale", &settings->floats.input_overlay_scale, true, 1.0f, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_MENU
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("menu_wallpaper_opacity", &settings->floats.menu_wallpaper_opacity, true, menu_wallpaper_opacity, false);
SETTING_FLOAT("menu_framebuffer_opacity", &settings->floats.menu_framebuffer_opacity, true, menu_framebuffer_opacity, false);
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("menu_footer_opacity", &settings->floats.menu_footer_opacity, true, menu_footer_opacity, false);
SETTING_FLOAT("menu_header_opacity", &settings->floats.menu_header_opacity, true, menu_header_opacity, false);
2016-08-29 17:10:00 +00:00
#endif
2017-04-28 12:57:55 +00:00
SETTING_FLOAT("video_message_pos_x", &settings->floats.video_msg_pos_x, true, message_pos_offset_x, false);
SETTING_FLOAT("video_message_pos_y", &settings->floats.video_msg_pos_y, true, message_pos_offset_y, false);
SETTING_FLOAT("video_font_size", &settings->floats.video_font_size, true, font_size, false);
SETTING_FLOAT("fastforward_ratio", &settings->floats.fastforward_ratio, true, fastforward_ratio, false);
SETTING_FLOAT("slowmotion_ratio", &settings->floats.slowmotion_ratio, true, slowmotion_ratio, false);
2017-05-10 05:07:06 +00:00
SETTING_FLOAT("input_axis_threshold", input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD), true, axis_threshold, false);
SETTING_FLOAT("video_msg_bgcolor_opacity", &settings->floats.video_msg_bgcolor_opacity, true, message_bgcolor_opacity, false);
2016-08-29 17:10:00 +00:00
*size = count;
return tmp;
2016-08-29 17:10:00 +00:00
}
2017-04-28 17:55:09 +00:00
static struct config_uint_setting *populate_settings_uint(settings_t *settings, int *size)
2016-08-29 17:10:00 +00:00
{
unsigned count = 0;
2017-04-28 19:05:34 +00:00
struct config_uint_setting *tmp = (struct config_uint_setting*)malloc((*size + 1) * sizeof(struct config_uint_setting));
2017-04-28 17:55:09 +00:00
if (!tmp)
return NULL;
#ifdef HAVE_NETWORKING
2018-09-26 21:34:45 +00:00
SETTING_UINT("streaming_mode", &settings->uints.streaming_mode, true, STREAMING_MODE_TWITCH, false);
#endif
SETTING_UINT("crt_switch_resolution", &settings->uints.crt_switch_resolution, true, crt_switch_resolution, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("input_bind_timeout", &settings->uints.input_bind_timeout, true, input_bind_timeout, false);
2018-04-04 08:33:59 +00:00
SETTING_UINT("input_bind_hold", &settings->uints.input_bind_hold, true, input_bind_hold, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("input_turbo_period", &settings->uints.input_turbo_period, true, turbo_period, false);
SETTING_UINT("input_duty_cycle", &settings->uints.input_turbo_duty_cycle, true, turbo_duty_cycle, false);
2017-05-11 05:36:21 +00:00
SETTING_UINT("input_max_users", input_driver_get_uint(INPUT_ACTION_MAX_USERS), true, input_max_users, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("input_menu_toggle_gamepad_combo", &settings->uints.input_menu_toggle_gamepad_combo, true, menu_toggle_gamepad_combo, false);
SETTING_UINT("audio_latency", &settings->uints.audio_latency, false, 0 /* TODO */, false);
SETTING_UINT("audio_resampler_quality", &settings->uints.audio_resampler_quality, true, audio_resampler_quality_level, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("audio_block_frames", &settings->uints.audio_block_frames, true, 0, false);
SETTING_UINT("rewind_granularity", &settings->uints.rewind_granularity, true, rewind_granularity, false);
SETTING_UINT("rewind_buffer_size_step", &settings->uints.rewind_buffer_size_step, true, rewind_buffer_size_step, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("autosave_interval", &settings->uints.autosave_interval, true, autosave_interval, false);
SETTING_UINT("libretro_log_level", &settings->uints.libretro_log_level, true, libretro_log_level, false);
SETTING_UINT("keyboard_gamepad_mapping_type",&settings->uints.input_keyboard_gamepad_mapping_type, true, 1, false);
SETTING_UINT("input_poll_type_behavior", &settings->uints.input_poll_type_behavior, true, 2, false);
SETTING_UINT("video_monitor_index", &settings->uints.video_monitor_index, true, monitor_index, false);
SETTING_UINT("video_fullscreen_x", &settings->uints.video_fullscreen_x, true, fullscreen_x, false);
SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, fullscreen_y, false);
SETTING_UINT("video_window_opacity", &settings->uints.video_window_opacity, true, window_opacity, false);
2016-08-29 17:10:00 +00:00
#ifdef HAVE_COMMAND
2017-04-28 19:03:04 +00:00
SETTING_UINT("network_cmd_port", &settings->uints.network_cmd_port, true, network_cmd_port, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_NETWORKGAMEPAD
2017-04-28 19:03:04 +00:00
SETTING_UINT("network_remote_base_port", &settings->uints.network_remote_base_port, true, network_remote_base_port, false);
2016-08-29 17:10:00 +00:00
#endif
2016-12-25 03:13:30 +00:00
#ifdef GEKKO
2017-04-28 19:03:04 +00:00
SETTING_UINT("video_viwidth", &settings->uints.video_viwidth, true, video_viwidth, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_MENU
2017-04-28 19:03:04 +00:00
SETTING_UINT("dpi_override_value", &settings->uints.menu_dpi_override_value, true, menu_dpi_override_value, false);
SETTING_UINT("menu_thumbnails", &settings->uints.menu_thumbnails, true, menu_thumbnails_default, false);
SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, menu_timedate_style, false);
2019-01-09 10:44:38 +00:00
SETTING_UINT("rgui_menu_color_theme", &settings->uints.menu_rgui_color_theme, true, rgui_color_theme, false);
SETTING_UINT("rgui_thumbnail_downscaler", &settings->uints.menu_rgui_thumbnail_downscaler, true, rgui_thumbnail_downscaler, false);
2018-10-10 18:31:55 +00:00
#ifdef HAVE_LIBNX
SETTING_UINT("split_joycon_p1", &settings->uints.input_split_joycon[0], true, 0, false);
SETTING_UINT("split_joycon_p2", &settings->uints.input_split_joycon[1], true, 0, false);
SETTING_UINT("split_joycon_p3", &settings->uints.input_split_joycon[2], true, 0, false);
SETTING_UINT("split_joycon_p4", &settings->uints.input_split_joycon[3], true, 0, false);
SETTING_UINT("split_joycon_p5", &settings->uints.input_split_joycon[4], true, 0, false);
SETTING_UINT("split_joycon_p6", &settings->uints.input_split_joycon[5], true, 0, false);
SETTING_UINT("split_joycon_p7", &settings->uints.input_split_joycon[6], true, 0, false);
SETTING_UINT("split_joycon_p8", &settings->uints.input_split_joycon[7], true, 0, false);
#endif
2016-08-29 17:10:00 +00:00
#ifdef HAVE_XMB
SETTING_UINT("menu_left_thumbnails", &settings->uints.menu_left_thumbnails, true, menu_left_thumbnails_default, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("xmb_alpha_factor", &settings->uints.menu_xmb_alpha_factor, true, xmb_alpha_factor, false);
SETTING_UINT("xmb_scale_factor", &settings->uints.menu_xmb_scale_factor, true, xmb_scale_factor, false);
2018-04-24 06:33:14 +00:00
SETTING_UINT("xmb_layout", &settings->uints.menu_xmb_layout, true, xmb_menu_layout, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("xmb_theme", &settings->uints.menu_xmb_theme, true, xmb_icon_theme, false);
SETTING_UINT("xmb_menu_color_theme", &settings->uints.menu_xmb_color_theme, true, xmb_theme, false);
SETTING_UINT("menu_font_color_red", &settings->uints.menu_font_color_red, true, menu_font_color_red, false);
SETTING_UINT("menu_font_color_green", &settings->uints.menu_font_color_green, true, menu_font_color_green, false);
SETTING_UINT("menu_font_color_blue", &settings->uints.menu_font_color_blue, true, menu_font_color_blue, false);
2016-08-29 17:10:00 +00:00
#endif
2017-04-28 19:03:04 +00:00
SETTING_UINT("materialui_menu_color_theme", &settings->uints.menu_materialui_color_theme, true, MATERIALUI_THEME_BLUE, false);
SETTING_UINT("menu_shader_pipeline", &settings->uints.menu_xmb_shader_pipeline, true, menu_shader_pipeline, false);
2018-10-27 14:50:48 +00:00
#ifdef HAVE_OZONE
SETTING_UINT("ozone_menu_color_theme", &settings->uints.menu_ozone_color_theme, true, 0, false);
#endif
2017-04-28 17:55:09 +00:00
#endif
2017-04-28 19:03:04 +00:00
SETTING_UINT("audio_out_rate", &settings->uints.audio_out_rate, true, out_rate, false);
SETTING_UINT("custom_viewport_width", &settings->video_viewport_custom.width, false, 0 /* TODO */, false);
SETTING_UINT("crt_switch_resolution_super", &settings->uints.crt_switch_resolution_super, true, crt_switch_resolution_super, false);
SETTING_UINT("custom_viewport_height", &settings->video_viewport_custom.height, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_x", (unsigned*)&settings->video_viewport_custom.x, false, 0 /* TODO */, false);
SETTING_UINT("custom_viewport_y", (unsigned*)&settings->video_viewport_custom.y, false, 0 /* TODO */, false);
2017-04-28 19:03:04 +00:00
SETTING_UINT("content_history_size", &settings->uints.content_history_size, true, default_content_history_size, false);
SETTING_UINT("video_hard_sync_frames", &settings->uints.video_hard_sync_frames, true, hard_sync_frames, false);
SETTING_UINT("video_frame_delay", &settings->uints.video_frame_delay, true, frame_delay, false);
SETTING_UINT("video_max_swapchain_images", &settings->uints.video_max_swapchain_images, true, max_swapchain_images, false);
SETTING_UINT("video_swap_interval", &settings->uints.video_swap_interval, true, swap_interval, false);
SETTING_UINT("video_rotation", &settings->uints.video_rotation, true, ORIENTATION_NORMAL, false);
SETTING_UINT("aspect_ratio_index", &settings->uints.video_aspect_ratio_idx, true, aspect_ratio_idx, false);
2016-09-29 19:07:10 +00:00
#ifdef HAVE_NETWORKING
2017-04-28 19:03:04 +00:00
SETTING_UINT("netplay_ip_port", &settings->uints.netplay_port, true, RARCH_DEFAULT_PORT, false);
SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_NETPLAY_IP_PORT);
2017-04-28 19:03:04 +00:00
SETTING_UINT("netplay_input_latency_frames_min",&settings->uints.netplay_input_latency_frames_min, true, 0, false);
SETTING_UINT("netplay_input_latency_frames_range",&settings->uints.netplay_input_latency_frames_range, true, 0, false);
2017-09-11 02:49:25 +00:00
SETTING_UINT("netplay_share_digital", &settings->uints.netplay_share_digital, true, netplay_share_digital, false);
SETTING_UINT("netplay_share_analog", &settings->uints.netplay_share_analog, true, netplay_share_analog, false);
2016-08-29 17:10:00 +00:00
#endif
#ifdef HAVE_LANGEXTRA
SETTING_UINT("user_language", msg_hash_get_uint(MSG_HASH_USER_LANGUAGE), true, RETRO_LANGUAGE_ENGLISH, false);
2016-08-29 17:10:00 +00:00
#endif
2017-04-28 19:03:04 +00:00
SETTING_UINT("bundle_assets_extract_version_current", &settings->uints.bundle_assets_extract_version_current, true, 0, false);
SETTING_UINT("bundle_assets_extract_last_version", &settings->uints.bundle_assets_extract_last_version, true, 0, false);
SETTING_UINT("input_overlay_show_physical_inputs_port", &settings->uints.input_overlay_show_physical_inputs_port, true, 0, false);
SETTING_UINT("video_msg_bgcolor_red", &settings->uints.video_msg_bgcolor_red, true, message_bgcolor_red, false);
SETTING_UINT("video_msg_bgcolor_green", &settings->uints.video_msg_bgcolor_green, true, message_bgcolor_green, false);
SETTING_UINT("video_msg_bgcolor_blue", &settings->uints.video_msg_bgcolor_blue, true, message_bgcolor_blue, false);
2018-03-28 19:22:07 +00:00
SETTING_UINT("run_ahead_frames", &settings->uints.run_ahead_frames, true, 1, false);
2018-06-04 05:48:08 +00:00
SETTING_UINT("midi_volume", &settings->uints.midi_volume, true, midi_volume, false);
2018-09-23 23:43:26 +00:00
SETTING_UINT("video_stream_port", &settings->uints.video_stream_port, true, RARCH_STREAM_DEFAULT_PORT, false);
SETTING_UINT("video_record_quality", &settings->uints.video_record_quality, true, RECORD_CONFIG_TYPE_RECORDING_LOSSLESS_QUALITY, false);
2018-09-24 00:02:12 +00:00
SETTING_UINT("video_stream_quality", &settings->uints.video_stream_quality, true, RECORD_CONFIG_TYPE_STREAMING_LOW_QUALITY, false);
SETTING_UINT("video_record_scale_factor", &settings->uints.video_record_scale_factor, true, 1, false);
SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false);
SETTING_UINT("video_windowed_position_x", &settings->uints.window_position_x, true, 0, false);
SETTING_UINT("video_windowed_position_y", &settings->uints.window_position_y, true, 0, false);
SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, window_width, false);
SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, window_height, false);
2018-09-23 23:43:26 +00:00
2018-11-25 20:41:26 +00:00
SETTING_UINT("video_record_threads", &settings->uints.video_record_threads, true, video_record_threads, false);
#ifdef HAVE_LIBNX
SETTING_UINT("libnx_overclock", &settings->uints.libnx_overclock, true, SWITCH_DEFAULT_CPU_PROFILE, false);
#endif
2017-04-28 17:55:09 +00:00
*size = count;
return tmp;
}
static struct config_size_setting *populate_settings_size(settings_t *settings, int *size)
{
unsigned count = 0;
struct config_size_setting *tmp = (struct config_size_setting*)calloc((*size + 1), sizeof(struct config_size_setting));
if (!tmp)
return NULL;
SETTING_SIZE("rewind_buffer_size", &settings->sizes.rewind_buffer_size, true, rewind_buffer_size, false);
2017-04-28 17:55:09 +00:00
*size = count;
return tmp;
}
static struct config_int_setting *populate_settings_int(settings_t *settings, int *size)
{
unsigned count = 0;
struct config_int_setting *tmp = (struct config_int_setting*)calloc((*size + 1), sizeof(struct config_int_setting));
2017-04-28 17:55:09 +00:00
if (!tmp)
return NULL;
2017-04-28 17:55:09 +00:00
SETTING_INT("state_slot", &settings->ints.state_slot, false, 0 /* TODO */, false);
#ifdef HAVE_NETWORKING
SETTING_INT("netplay_check_frames", &settings->ints.netplay_check_frames, true, netplay_check_frames, false);
SETTING_OVERRIDE(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES);
2017-04-25 03:09:57 +00:00
#endif
2017-05-24 14:25:36 +00:00
#ifdef HAVE_WASAPI
SETTING_INT("audio_wasapi_sh_buffer_length", &settings->ints.audio_wasapi_sh_buffer_length, true, wasapi_sh_buffer_length, false);
#endif
SETTING_INT("crt_switch_center_adjust", &settings->ints.crt_switch_center_adjust, false, 0 /* TODO */, false);
2016-08-29 17:10:00 +00:00
*size = count;
return tmp;
2016-08-29 17:10:00 +00:00
}
/**
* config_set_defaults:
*
* Set 'default' configuration values.
**/
2018-10-01 00:13:53 +00:00
void config_set_defaults(void)
2016-08-29 17:10:00 +00:00
{
unsigned i, j;
2017-04-27 22:00:43 +00:00
#ifdef HAVE_MENU
static bool first_initialized = true;
#endif
2016-08-29 17:10:00 +00:00
settings_t *settings = config_get_ptr();
2017-04-28 19:05:34 +00:00
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
2016-08-29 17:10:00 +00:00
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();
const char *def_led = config_get_default_led();
2016-08-29 17:10:00 +00:00
const char *def_location = config_get_default_location();
const char *def_record = config_get_default_record();
2018-06-04 05:48:08 +00:00
const char *def_midi = config_get_default_midi();
const char *def_mitm = netplay_mitm_server;
2017-04-27 22:01:47 +00:00
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
2017-04-28 18:08:12 +00:00
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
struct config_uint_setting *uint_settings = populate_settings_uint (settings, &uint_settings_size);
struct config_size_setting *size_settings = populate_settings_size (settings, &size_settings_size);
2016-12-26 02:16:27 +00:00
if (bool_settings && (bool_settings_size > 0))
{
2016-12-26 02:16:27 +00:00
for (i = 0; i < (unsigned)bool_settings_size; i++)
{
if (bool_settings[i].def_enable)
*bool_settings[i].ptr = bool_settings[i].def;
}
free(bool_settings);
}
2016-08-29 17:10:00 +00:00
2016-12-26 02:16:27 +00:00
if (int_settings && (int_settings_size > 0))
2016-08-30 01:20:55 +00:00
{
2016-12-26 02:16:27 +00:00
for (i = 0; i < (unsigned)int_settings_size; i++)
{
if (int_settings[i].def_enable)
*int_settings[i].ptr = int_settings[i].def;
}
free(int_settings);
2016-08-30 01:20:55 +00:00
}
2017-04-28 17:55:09 +00:00
if (uint_settings && (uint_settings_size > 0))
{
for (i = 0; i < (unsigned)uint_settings_size; i++)
{
if (uint_settings[i].def_enable)
*uint_settings[i].ptr = uint_settings[i].def;
}
free(uint_settings);
}
if (size_settings && (size_settings_size > 0))
{
for (i = 0; i < (unsigned)size_settings_size; i++)
{
if (size_settings[i].def_enable)
*size_settings[i].ptr = size_settings[i].def;
}
free(size_settings);
}
2016-12-26 02:16:27 +00:00
if (float_settings && (float_settings_size > 0))
2016-08-29 18:57:24 +00:00
{
2016-12-26 02:16:27 +00:00
for (i = 0; i < (unsigned)float_settings_size; i++)
{
if (float_settings[i].def_enable)
*float_settings[i].ptr = float_settings[i].def;
}
free(float_settings);
2016-08-29 18:57:24 +00:00
}
2016-08-29 17:10:00 +00:00
if (def_camera)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.camera_driver,
def_camera, sizeof(settings->arrays.camera_driver));
if (def_wifi)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.wifi_driver,
def_wifi, sizeof(settings->arrays.wifi_driver));
if (def_led)
strlcpy(settings->arrays.led_driver,
def_led, sizeof(settings->arrays.led_driver));
2016-08-29 17:10:00 +00:00
if (def_location)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.location_driver,
def_location, sizeof(settings->arrays.location_driver));
2016-08-29 17:10:00 +00:00
if (def_video)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.video_driver,
def_video, sizeof(settings->arrays.video_driver));
2016-08-29 17:10:00 +00:00
if (def_audio)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.audio_driver,
def_audio, sizeof(settings->arrays.audio_driver));
2016-08-29 17:10:00 +00:00
if (def_audio_resampler)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.audio_resampler,
def_audio_resampler, sizeof(settings->arrays.audio_resampler));
2016-08-29 17:10:00 +00:00
if (def_input)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.input_driver,
def_input, sizeof(settings->arrays.input_driver));
2016-08-29 17:10:00 +00:00
if (def_joypad)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.input_joypad_driver,
def_joypad, sizeof(settings->arrays.input_joypad_driver));
2016-08-29 17:10:00 +00:00
if (def_record)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.record_driver,
def_record, sizeof(settings->arrays.record_driver));
2018-06-04 05:48:08 +00:00
if (def_midi)
strlcpy(settings->arrays.midi_driver,
def_midi, sizeof(settings->arrays.midi_driver));
if (def_mitm)
strlcpy(settings->arrays.netplay_mitm_server,
def_mitm, sizeof(settings->arrays.netplay_mitm_server));
2016-08-29 17:10:00 +00:00
#ifdef HAVE_MENU
if (def_menu)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.menu_driver,
def_menu, sizeof(settings->arrays.menu_driver));
2016-08-29 17:10:00 +00:00
#ifdef HAVE_XMB
2017-04-28 22:39:29 +00:00
*settings->paths.path_menu_xmb_font = '\0';
2016-08-29 17:10:00 +00:00
#endif
2018-10-13 23:17:17 +00:00
strlcpy(settings->arrays.discord_app_id,
default_discord_app_id, sizeof(settings->arrays.discord_app_id));
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)
2017-04-28 19:03:04 +00:00
settings->uints.menu_materialui_color_theme = g_defaults.menu.materialui.menu_color_theme;
2016-08-29 17:10:00 +00:00
#endif
#endif
2018-06-20 02:50:58 +00:00
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
2017-04-28 11:43:47 +00:00
configuration_set_bool(settings, settings->bools.multimedia_builtin_mediaplayer_enable, true);
2016-08-29 17:10:00 +00:00
#else
2017-04-28 11:43:47 +00:00
configuration_set_bool(settings, settings->bools.multimedia_builtin_mediaplayer_enable, false);
2016-08-29 17:10:00 +00:00
#endif
2017-04-28 12:57:55 +00:00
settings->floats.video_scale = scale;
2016-08-29 17:10:00 +00:00
if (g_defaults.settings.video_threaded_enable != video_threaded)
video_driver_set_threaded(g_defaults.settings.video_threaded_enable);
2016-08-29 17:10:00 +00:00
2017-04-28 12:57:55 +00:00
settings->floats.video_msg_color_r = ((message_color >> 16) & 0xff) / 255.0f;
settings->floats.video_msg_color_g = ((message_color >> 8) & 0xff) / 255.0f;
settings->floats.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)
2017-04-28 12:57:55 +00:00
settings->floats.video_refresh_rate = g_defaults.settings.video_refresh_rate;
2010-12-29 18:00:21 +00:00
if (audio_device)
2017-04-28 20:59:13 +00:00
strlcpy(settings->arrays.audio_device,
audio_device, sizeof(settings->arrays.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;
2017-04-28 19:03:04 +00:00
settings->uints.audio_latency = g_defaults.settings.out_latency;
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, settings->floats.audio_volume);
2017-06-08 20:58:43 +00:00
audio_set_float(AUDIO_ACTION_MIXER_VOLUME_GAIN, settings->floats.audio_mixer_volume);
2015-04-13 00:12:28 +00:00
#ifdef HAVE_LAKKA
settings->bools.ssh_enable = filestream_exists(LAKKA_SSH_PATH);
settings->bools.samba_enable = filestream_exists(LAKKA_SAMBA_PATH);
settings->bools.bluetooth_enable = filestream_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)
2017-04-28 11:43:47 +00:00
settings->bools.menu_show_start_screen = default_menu_show_start_screen;
2014-02-10 19:26:48 +00:00
#endif
#ifdef HAVE_CHEEVOS
2017-04-28 20:59:13 +00:00
*settings->arrays.cheevos_username = '\0';
*settings->arrays.cheevos_password = '\0';
*settings->arrays.cheevos_token = '\0';
#endif
input_config_reset();
2017-09-12 03:49:39 +00:00
input_remapping_set_defaults(true);
input_autoconfigure_reset();
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
{
2017-04-25 22:24:59 +00:00
const struct retro_keybind *keyval = &input_config_binds[i][j];
2017-04-25 16:12:13 +00:00
if (keyval->valid)
retro_assert(j == keyval->id);
2015-01-05 01:36:10 +00:00
}
2016-09-01 02:11:53 +00:00
}
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.network_buildbot_url, buildbot_server_url,
sizeof(settings->paths.network_buildbot_url));
strlcpy(settings->paths.network_buildbot_assets_url, buildbot_assets_server_url,
sizeof(settings->paths.network_buildbot_assets_url));
2015-01-19 03:09:28 +00:00
2017-04-28 20:59:13 +00:00
*settings->arrays.input_keyboard_layout = '\0';
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
{
2017-04-28 19:03:04 +00:00
settings->uints.input_joypad_map[i] = i;
2018-12-16 14:38:56 +00:00
#ifdef SWITCH /* Switch prefered default dpad mode */
settings->uints.input_analog_dpad_mode[i] = ANALOG_DPAD_LSTICK;
#else
2017-04-28 19:03:04 +00:00
settings->uints.input_analog_dpad_mode[i] = ANALOG_DPAD_NONE;
#endif
input_config_set_device(i, RETRO_DEVICE_JOYPAD);
2017-06-08 14:13:45 +00:00
settings->uints.input_mouse_index[i] = 0;
}
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. */
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL))
dir_clear(RARCH_DIR_SAVEFILE);
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL))
dir_clear(RARCH_DIR_SAVESTATE);
2017-04-28 22:39:29 +00:00
*settings->paths.path_libretro_info = '\0';
*settings->paths.directory_libretro = '\0';
2017-04-28 22:39:29 +00:00
*settings->paths.directory_cursor = '\0';
*settings->paths.directory_resampler = '\0';
*settings->paths.directory_screenshot = '\0';
*settings->paths.directory_system = '\0';
*settings->paths.directory_cache = '\0';
*settings->paths.directory_input_remapping = '\0';
*settings->paths.directory_core_assets = '\0';
*settings->paths.directory_assets = '\0';
*settings->paths.directory_dynamic_wallpapers = '\0';
*settings->paths.directory_thumbnails = '\0';
*settings->paths.directory_playlist = '\0';
*settings->paths.directory_autoconfig = '\0';
2016-04-28 17:26:02 +00:00
#ifdef HAVE_MENU
2017-04-28 22:39:29 +00:00
*settings->paths.directory_menu_content = '\0';
*settings->paths.directory_menu_config = '\0';
2016-04-28 17:26:02 +00:00
#endif
2017-04-28 22:39:29 +00:00
*settings->paths.directory_video_shader = '\0';
*settings->paths.directory_video_filter = '\0';
*settings->paths.directory_audio_filter = '\0';
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_BPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
2016-10-01 06:24:02 +00:00
{
2016-12-26 02:16:27 +00:00
global_t *global = global_get_ptr();
if (global)
{
*global->record.output_dir = '\0';
*global->record.config_dir = '\0';
}
2016-10-01 06:24:02 +00:00
}
2017-04-28 22:39:29 +00:00
*settings->paths.path_core_options = '\0';
*settings->paths.path_content_history = '\0';
2017-08-12 15:10:14 +00:00
*settings->paths.path_content_favorites = '\0';
2017-04-28 22:39:29 +00:00
*settings->paths.path_content_music_history = '\0';
*settings->paths.path_content_image_history = '\0';
*settings->paths.path_content_video_history = '\0';
*settings->paths.path_cheat_settings = '\0';
*settings->paths.path_shader = '\0';
#ifndef IOS
2017-04-28 20:59:13 +00:00
*settings->arrays.bundle_assets_src = '\0';
*settings->arrays.bundle_assets_dst = '\0';
*settings->arrays.bundle_assets_dst_subdir = '\0';
#endif
2017-04-28 22:39:29 +00:00
*settings->paths.path_cheat_database = '\0';
*settings->paths.path_menu_wallpaper = '\0';
*settings->paths.path_rgui_theme_preset = '\0';
2017-04-28 22:39:29 +00:00
*settings->paths.path_content_database = '\0';
*settings->paths.path_overlay = '\0';
*settings->paths.path_record_config = '\0';
*settings->paths.path_stream_config = '\0';
*settings->paths.path_stream_url = '\0';
2017-04-28 22:39:29 +00:00
*settings->paths.path_softfilter_plugin = '\0';
2016-04-28 17:52:25 +00:00
2017-04-28 20:59:13 +00:00
*settings->arrays.playlist_names = '\0';
*settings->arrays.playlist_cores = '\0';
2017-04-28 22:39:29 +00:00
*settings->paths.directory_content_history = '\0';
*settings->paths.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
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_dynamic_wallpapers,
g_defaults.dirs[DEFAULT_DIR_WALLPAPERS],
sizeof(settings->paths.directory_dynamic_wallpapers));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_thumbnails,
g_defaults.dirs[DEFAULT_DIR_THUMBNAILS],
sizeof(settings->paths.directory_thumbnails));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_REMAP]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_input_remapping,
g_defaults.dirs[DEFAULT_DIR_REMAP],
sizeof(settings->paths.directory_input_remapping));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CACHE]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_cache,
g_defaults.dirs[DEFAULT_DIR_CACHE],
sizeof(settings->paths.directory_cache));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_ASSETS]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_assets,
g_defaults.dirs[DEFAULT_DIR_ASSETS],
sizeof(settings->paths.directory_assets));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_core_assets,
g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS],
sizeof(settings->paths.directory_core_assets));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_playlist,
g_defaults.dirs[DEFAULT_DIR_PLAYLIST],
sizeof(settings->paths.directory_playlist));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE]))
2017-04-28 22:39:29 +00:00
fill_pathname_expand_special(settings->paths.directory_libretro,
g_defaults.dirs[DEFAULT_DIR_CORE],
sizeof(settings->paths.directory_libretro));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_audio_filter,
g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER],
sizeof(settings->paths.directory_audio_filter));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_video_filter,
g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER],
sizeof(settings->paths.directory_video_filter));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SHADER]))
2017-04-28 22:39:29 +00:00
fill_pathname_expand_special(settings->paths.directory_video_shader,
g_defaults.dirs[DEFAULT_DIR_SHADER],
sizeof(settings->paths.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))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.network_buildbot_url,
g_defaults.path.buildbot_server_url,
sizeof(settings->paths.network_buildbot_url));
2016-06-25 00:30:54 +00:00
if (!string_is_empty(g_defaults.path.core))
2017-05-15 03:06:23 +00:00
rarch_ctl(RARCH_CTL_SET_LIBRETRO_PATH, g_defaults.path.core);
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_DATABASE]))
strlcpy(settings->paths.path_content_database,
g_defaults.dirs[DEFAULT_DIR_DATABASE],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_database));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CURSOR]))
strlcpy(settings->paths.directory_cursor,
g_defaults.dirs[DEFAULT_DIR_CURSOR],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_cursor));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CHEATS]))
strlcpy(settings->paths.path_cheat_database,
g_defaults.dirs[DEFAULT_DIR_CHEATS],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_cheat_database));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE_INFO]))
2017-04-28 22:39:29 +00:00
fill_pathname_expand_special(settings->paths.path_libretro_info,
g_defaults.dirs[DEFAULT_DIR_CORE_INFO],
sizeof(settings->paths.path_libretro_info));
#ifdef HAVE_OVERLAY
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_OVERLAY]))
{
2017-04-28 22:39:29 +00:00
fill_pathname_expand_special(settings->paths.directory_overlay,
g_defaults.dirs[DEFAULT_DIR_OVERLAY],
sizeof(settings->paths.directory_overlay));
#ifdef RARCH_MOBILE
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.path_overlay))
fill_pathname_join(settings->paths.path_overlay,
settings->paths.directory_overlay,
"gamepads/flat/retropad.cfg",
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_overlay));
#endif
}
#endif
2016-11-27 01:46:09 +00:00
#ifdef HAVE_MENU
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]))
{
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_menu_config,
g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_menu_config));
2017-02-26 21:24:07 +00:00
#if TARGET_OS_IPHONE
2018-03-25 10:17:05 +00:00
{
char *config_file_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
size_t config_file_path_size = PATH_MAX_LENGTH * sizeof(char);
fill_pathname_join(config_file_path, settings->paths.directory_menu_config, file_path_str(FILE_PATH_MAIN_CONFIG), config_file_path_size);
path_set(RARCH_PATH_CONFIG,
config_file_path);
}
2017-02-26 21:24:07 +00:00
#endif
}
2017-02-26 21:24:07 +00:00
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_menu_content,
g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_menu_content));
#endif
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_autoconfig,
g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_autoconfig));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SAVESTATE]))
dir_set(RARCH_DIR_SAVESTATE, g_defaults.dirs[DEFAULT_DIR_SAVESTATE]);
2016-09-17 12:49:35 +00:00
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SRAM]))
dir_set(RARCH_DIR_SAVEFILE, g_defaults.dirs[DEFAULT_DIR_SRAM]);
2016-09-17 12:49:35 +00:00
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SYSTEM]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_system,
g_defaults.dirs[DEFAULT_DIR_SYSTEM],
sizeof(settings->paths.directory_system));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_screenshot,
g_defaults.dirs[DEFAULT_DIR_SCREENSHOT],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_screenshot));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_RESAMPLER]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_resampler,
g_defaults.dirs[DEFAULT_DIR_RESAMPLER],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.directory_resampler));
if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY]))
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.directory_content_history,
g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY],
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.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 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2016-10-09 07:05:41 +00:00
temp_str[0] = '\0';
fill_pathname_expand_special(temp_str,
2017-11-23 16:55:53 +00:00
g_defaults.path.config,
PATH_MAX_LENGTH * sizeof(char));
2016-09-29 05:46:21 +00:00
path_set(RARCH_PATH_CONFIG, temp_str);
free(temp_str);
}
2015-01-13 23:35:27 +00:00
2018-06-04 05:48:08 +00:00
if (midi_input)
strlcpy(settings->arrays.midi_input,
midi_input, sizeof(settings->arrays.midi_input));
if (midi_output)
strlcpy(settings->arrays.midi_output,
midi_output, sizeof(settings->arrays.midi_output));
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
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
{
bool has_application_data = false;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *application_data = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *conf_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *app_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2016-08-29 17:10:00 +00:00
config_file_t *conf = NULL;
2015-01-13 23:35:27 +00:00
(void)has_application_data;
application_data[0] = conf_path[0] = app_path[0] = '\0';
2017-11-06 18:13:39 +00:00
(void)path_size;
#if defined(_WIN32) && !defined(_XBOX)
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
/* On UWP, the app install directory is not writable so use the writable LocalState dir instead */
fill_pathname_home_dir(app_path, path_size);
#else
fill_pathname_application_dir(app_path, path_size);
#endif
2016-08-29 17:10:00 +00:00
fill_pathname_resolve_relative(conf_path, app_path,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
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,
path_size))
2016-08-29 17:10:00 +00:00
{
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
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)
{
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
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), path_size);
2016-08-29 17:10:00 +00:00
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path, true);
2016-08-29 17:10:00 +00:00
}
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);
goto error;
2016-08-29 17:10:00 +00:00
}
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,
path_size))
goto error;
2015-11-21 17:08:37 +00:00
2016-12-19 22:17:36 +00:00
/* Group config file with menu configs, remaps, etc: */
strlcat(application_data, "/config", path_size);
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), path_size);
2016-08-29 17:10:00 +00:00
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, true);
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);
goto error;
2016-08-29 17:10:00 +00:00
}
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
}
#elif !defined(RARCH_CONSOLE)
has_application_data =
2016-08-30 02:42:02 +00:00
fill_pathname_application_data(application_data,
path_size);
2016-08-29 17:10:00 +00:00
if (has_application_data)
{
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
2016-08-29 17:10:00 +00:00
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", path_size);
2016-08-29 17:10:00 +00:00
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
if (!conf && has_application_data)
{
char *basedir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
basedir[0] = '\0';
2016-08-29 17:10:00 +00:00
/* Try to create a new config file. */
strlcpy(conf_path, application_data, path_size);
2016-08-29 17:10:00 +00:00
fill_pathname_basedir(basedir, conf_path, path_size);
2016-08-29 17:10:00 +00:00
2016-08-30 02:42:02 +00:00
fill_pathname_join(conf_path, conf_path,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
2016-08-29 17:10:00 +00:00
if (path_mkdir(basedir))
{
char *skeleton_conf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
bool saved = false;
skeleton_conf[0] = '\0';
2016-08-29 17:10:00 +00:00
free(basedir);
2017-06-25 02:05:34 +00:00
/* Build a retroarch.cfg path from the global config directory (/etc). */
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
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);
free(skeleton_conf);
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. */
config_set_bool(conf, "config_save_on_exit", true);
saved = config_file_write(conf, conf_path, true);
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);
goto error;
2016-08-29 17:10:00 +00:00
}
RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path);
}
else
{
free(basedir);
}
2016-08-29 17:10:00 +00:00
}
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)
goto error;
2016-08-29 17:10:00 +00:00
2016-09-29 05:46:21 +00:00
path_set(RARCH_PATH_CONFIG, conf_path);
free(application_data);
free(conf_path);
free(app_path);
2016-08-29 17:10:00 +00:00
return conf;
error:
if (conf)
config_file_free(conf);
free(application_data);
free(conf_path);
free(app_path);
return NULL;
2016-08-29 13:36:55 +00:00
}
#if defined(HAVE_MENU) && defined(HAVE_RGUI)
static bool check_menu_driver_compatibility(void)
{
settings_t *settings = config_get_ptr();
char *video_driver = settings->arrays.video_driver;
char *menu_driver = settings->arrays.menu_driver;
if (string_is_equal (menu_driver, "rgui") ||
string_is_equal(menu_driver, "null") ||
string_is_equal(video_driver, "null"))
return true;
/* TODO/FIXME - maintenance hazard */
if (string_is_equal(video_driver, "d3d9") ||
string_is_equal(video_driver, "d3d10") ||
string_is_equal(video_driver, "d3d11") ||
string_is_equal(video_driver, "d3d12") ||
2018-10-10 15:17:02 +00:00
string_is_equal(video_driver, "gdi") ||
string_is_equal(video_driver, "gl") ||
string_is_equal(video_driver, "gx2") ||
string_is_equal(video_driver, "vulkan") ||
string_is_equal(video_driver, "metal") ||
2018-10-20 01:04:53 +00:00
string_is_equal(video_driver, "ctr") ||
2018-10-19 05:41:41 +00:00
string_is_equal(video_driver, "vita2d"))
return true;
return false;
}
#endif
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);
}
static void read_keybinds_mbutton(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_mouse_button(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;
2016-08-29 17:10:00 +00:00
for (i = 0; input_config_bind_map_get_valid(i); i++)
{
2017-04-25 22:24:59 +00:00
struct retro_keybind *bind = &input_config_binds[user][i];
2016-08-29 17:10:00 +00:00
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);
read_keybinds_mbutton(conf, user, i, bind);
2016-08-29 17:10:00 +00:00
}
}
static void config_read_keybinds_conf(config_file_t *conf)
{
unsigned i;
for (i = 0; i < MAX_USERS; i++)
read_keybinds_user(conf, i);
}
static bool check_shader_compatibility(enum file_path_enum enum_idx)
{
settings_t *settings = config_get_ptr();
2018-01-27 23:59:05 +00:00
if (string_is_equal(settings->arrays.video_driver, "vulkan") ||
string_is_equal(settings->arrays.video_driver, "metal") ||
string_is_equal(settings->arrays.video_driver, "d3d11") ||
2018-02-10 23:00:20 +00:00
string_is_equal(settings->arrays.video_driver, "d3d12") ||
string_is_equal(settings->arrays.video_driver, "gx2"))
{
if (enum_idx != FILE_PATH_SLANGP_EXTENSION)
return false;
return true;
}
2018-01-23 02:09:55 +00:00
if (string_is_equal(settings->arrays.video_driver, "gl") ||
string_is_equal(settings->arrays.video_driver, "d3d8") ||
string_is_equal(settings->arrays.video_driver, "d3d9")
)
{
if (enum_idx == FILE_PATH_SLANGP_EXTENSION)
return false;
return true;
}
return false;
}
2016-08-29 17:10:00 +00:00
#if 0
2016-09-30 06:27:26 +00:00
static bool config_read_keybinds(const char *path)
{
config_file_t *conf = (config_file_t*)config_file_new(path);
if (!conf)
return false;
config_read_keybinds_conf(conf);
config_file_free(conf);
return true;
}
/* Also dumps inherited values, useful for logging. */
2016-08-29 17:10:00 +00:00
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
/*
* This is no longer used, so comment out to silence warnings...
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
*/
2016-08-29 13:26:42 +00:00
/**
* 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.
*
*/
2017-07-14 19:11:27 +00:00
static bool config_load_file(const char *path, bool set_defaults,
settings_t *settings)
{
unsigned i;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *tmp_str = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
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;
unsigned msg_color = 0;
config_file_t *conf = NULL;
2016-09-03 06:12:40 +00:00
char *override_username = NULL;
2017-11-24 05:45:21 +00:00
const char *path_core = NULL;
const char *path_config = NULL;
2018-02-09 18:27:18 +00:00
const char *shader_ext = NULL;
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
2017-04-28 13:01:11 +00:00
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
2017-04-28 18:08:12 +00:00
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
2017-04-28 18:08:12 +00:00
struct config_uint_setting *uint_settings = populate_settings_uint (settings, &uint_settings_size);
struct config_size_setting *size_settings = populate_settings_size (settings, &size_settings_size);
struct config_array_setting *array_settings = populate_settings_array (settings, &array_settings_size);
struct config_path_setting *path_settings = populate_settings_path (settings, &path_settings_size);
2016-07-24 08:42:49 +00:00
tmp_str[0] = '\0';
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-30 02:43:16 +00:00
if (!path_is_empty(RARCH_PATH_CONFIG_APPEND))
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 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
const char *extra_path = NULL;
2016-09-17 12:14:58 +00:00
2016-10-09 07:05:41 +00:00
tmp_append_path[0] = '\0';
2016-09-29 06:31:41 +00:00
strlcpy(tmp_append_path, path_get(RARCH_PATH_CONFIG_APPEND),
path_size);
2016-09-17 12:14:58 +00:00
extra_path = strtok_r(tmp_append_path, "|", &save);
2016-09-17 12:14:58 +00:00
while (extra_path)
{
bool result = config_append_file(conf, extra_path);
2016-09-17 12:14:58 +00:00
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
if (!result)
2016-09-17 12:14:58 +00:00
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
extra_path = strtok_r(NULL, "|", &save);
}
2017-09-09 23:03:26 +00:00
free(tmp_append_path);
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))
2017-04-28 22:39:29 +00:00
override_username = strdup(settings->paths.username);
2016-09-03 06:12:40 +00:00
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
2016-07-25 06:01:47 +00:00
#ifdef HAVE_NETWORKGAMEPAD
for (i = 0; i < MAX_USERS; i++)
{
2016-10-09 07:05:41 +00:00
char tmp[64];
tmp[0] = '\0';
2016-07-25 06:01:47 +00:00
snprintf(tmp, sizeof(tmp), "network_remote_enable_user_p%u", i + 1);
if (config_get_bool(conf, tmp, &tmp_bool))
2017-04-28 11:43:47 +00:00
settings->bools.network_remote_enable_user[i] = tmp_bool;
2016-07-25 06:01:47 +00:00
}
#endif
if (config_get_bool(conf, "log_verbosity", &tmp_bool))
2016-07-25 06:01:47 +00:00
{
if (tmp_bool)
verbosity_enable();
else
verbosity_disable();
2016-07-25 06:01:47 +00:00
}
{
2016-10-09 07:05:41 +00:00
char tmp[64];
tmp[0] = '\0';
2016-07-25 06:01:47 +00:00
strlcpy(tmp, "perfcnt_enable", sizeof(tmp));
if (config_get_bool(conf, tmp, &tmp_bool))
{
if (tmp_bool)
2017-05-15 03:06:23 +00:00
rarch_ctl(RARCH_CTL_SET_PERFCNT_ENABLE, NULL);
2016-07-25 06:01:47 +00:00
else
2017-05-15 03:06:23 +00:00
rarch_ctl(RARCH_CTL_UNSET_PERFCNT_ENABLE, NULL);
2016-07-25 06:01:47 +00:00
}
}
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
}
2017-04-28 17:55:09 +00:00
for (i = 0; i < (unsigned)uint_settings_size; i++)
{
int tmp = 0;
if (config_get_int(conf, uint_settings[i].ident, &tmp))
*uint_settings[i].ptr = tmp;
}
for (i = 0; i < (unsigned)size_settings_size; i++)
{
size_t tmp = 0;
if (config_get_size_t(conf, size_settings[i].ident, &tmp))
*size_settings[i].ptr = tmp ;
/* Special case for rewind_buffer_size - need to convert low values to what they were
* intended to be based on the default value in config.def.h
* If the value is less than 10000 then multiple by 1MB because if the retroarch.cfg
* file contains rewind_buffer_size = "100" then that ultimately gets interpreted as
* 100MB, so ensure the internal values represent that.*/
if (string_is_equal(size_settings[i].ident, "rewind_buffer_size"))
if (*size_settings[i].ptr < 10000)
*size_settings[i].ptr = *size_settings[i].ptr * 1024 * 1024;
}
2015-01-05 00:58:00 +00:00
for (i = 0; i < MAX_USERS; i++)
{
2016-10-09 07:05:41 +00:00
char buf[64];
buf[0] = '\0';
2012-02-18 11:09:20 +00:00
snprintf(buf, sizeof(buf), "input_player%u_joypad_index", i + 1);
2017-04-28 19:03:04 +00:00
CONFIG_GET_INT_BASE(conf, settings, uints.input_joypad_map[i], buf);
snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1);
2017-04-28 19:03:04 +00:00
CONFIG_GET_INT_BASE(conf, settings, uints.input_analog_dpad_mode[i], buf);
2017-06-08 14:13:45 +00:00
snprintf(buf, sizeof(buf), "input_player%u_mouse_index", i + 1);
CONFIG_GET_INT_BASE(conf, settings, uints.input_mouse_index[i], buf);
snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1);
CONFIG_GET_INT_BASE(conf, settings, uints.input_libretro_device[i], buf);
}
/* LED map for use by the led driver */
for (i = 0; i < MAX_LEDS; i++)
{
char buf[64];
buf[0] = '\0';
snprintf(buf, sizeof(buf), "led%u_map", i + 1);
settings->uints.led_map[i]=-1;
CONFIG_GET_INT_BASE(conf, settings, uints.led_map[i], buf);
}
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))
{
2017-04-28 12:57:55 +00:00
settings->floats.video_msg_color_r = ((msg_color >> 16) & 0xff) / 255.0f;
settings->floats.video_msg_color_g = ((msg_color >> 8) & 0xff) / 255.0f;
settings->floats.video_msg_color_b = ((msg_color >> 0) & 0xff) / 255.0f;
2016-07-24 06:52:03 +00:00
}
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, path_size))
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
if (config_get_path(conf, "libretro_directory", tmp_str, path_size))
strlcpy(settings->paths.directory_libretro, tmp_str, sizeof(settings->paths.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, path_size))
2016-09-29 05:46:21 +00:00
path_set(RARCH_PATH_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
{
2017-04-28 22:39:29 +00:00
strlcpy(settings->paths.username,
override_username,
sizeof(settings->paths.username));
2016-09-03 06:12:40 +00:00
free(override_username);
2016-07-24 06:52:03 +00:00
}
2016-09-03 06:12:40 +00:00
2017-04-28 19:03:04 +00:00
if (settings->uints.video_hard_sync_frames > 3)
settings->uints.video_hard_sync_frames = 3;
2016-07-24 06:52:03 +00:00
2017-04-28 19:03:04 +00:00
if (settings->uints.video_frame_delay > 15)
settings->uints.video_frame_delay = 15;
2016-07-24 06:52:03 +00:00
2017-04-28 19:03:04 +00:00
settings->uints.video_swap_interval = MAX(settings->uints.video_swap_interval, 1);
settings->uints.video_swap_interval = MIN(settings->uints.video_swap_interval, 4);
2016-07-24 06:52:03 +00:00
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, settings->floats.audio_volume);
2017-06-08 20:58:43 +00:00
audio_set_float(AUDIO_ACTION_MIXER_VOLUME_GAIN, settings->floats.audio_mixer_volume);
2016-07-24 06:52:03 +00:00
2017-11-24 05:45:21 +00:00
path_config = path_get(RARCH_PATH_CONFIG);
path_core = path_get(RARCH_PATH_CORE);
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.path_content_history))
2016-04-28 18:49:13 +00:00
{
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_content_history))
2016-04-28 18:49:13 +00:00
{
fill_pathname_resolve_relative(
2017-04-28 22:39:29 +00:00
settings->paths.path_content_history,
2017-11-24 05:45:21 +00:00
path_config,
2016-06-20 03:11:01 +00:00
file_path_str(FILE_PATH_CONTENT_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_history));
2016-04-28 18:49:13 +00:00
}
else
{
2017-04-28 22:39:29 +00:00
fill_pathname_join(settings->paths.path_content_history,
settings->paths.directory_content_history,
2016-06-20 03:11:01 +00:00
file_path_str(FILE_PATH_CONTENT_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_history));
2016-04-28 18:49:13 +00:00
}
}
2017-08-12 15:10:14 +00:00
if (string_is_empty(settings->paths.path_content_favorites))
{
if (string_is_empty(settings->paths.directory_content_history))
{
fill_pathname_resolve_relative(
settings->paths.path_content_favorites,
2017-11-24 05:45:21 +00:00
path_config,
2017-08-12 15:10:14 +00:00
file_path_str(FILE_PATH_CONTENT_FAVORITES),
sizeof(settings->paths.path_content_favorites));
}
else
{
fill_pathname_join(settings->paths.path_content_favorites,
settings->paths.directory_content_history,
file_path_str(FILE_PATH_CONTENT_FAVORITES),
sizeof(settings->paths.path_content_favorites));
}
}
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.path_content_music_history))
{
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_content_history))
{
fill_pathname_resolve_relative(
2017-04-28 22:39:29 +00:00
settings->paths.path_content_music_history,
2017-11-24 05:45:21 +00:00
path_config,
file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_music_history));
}
else
{
2017-04-28 22:39:29 +00:00
fill_pathname_join(settings->paths.path_content_music_history,
settings->paths.directory_content_history,
file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_music_history));
}
}
2016-04-28 18:49:13 +00:00
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.path_content_video_history))
{
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_content_history))
{
fill_pathname_resolve_relative(
2017-04-28 22:39:29 +00:00
settings->paths.path_content_video_history,
2017-11-24 05:45:21 +00:00
path_config,
file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_video_history));
}
else
{
2017-04-28 22:39:29 +00:00
fill_pathname_join(settings->paths.path_content_video_history,
settings->paths.directory_content_history,
file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_video_history));
}
}
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.path_content_image_history))
{
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_content_history))
{
fill_pathname_resolve_relative(
2017-04-28 22:39:29 +00:00
settings->paths.path_content_image_history,
2017-11-24 05:45:21 +00:00
path_config,
file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_image_history));
}
else
{
2017-04-28 22:39:29 +00:00
fill_pathname_join(settings->paths.path_content_image_history,
settings->paths.directory_content_history,
file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY),
2017-04-28 22:39:29 +00:00
sizeof(settings->paths.path_content_image_history));
}
}
2016-07-24 06:54:38 +00:00
2017-04-28 22:39:29 +00:00
if (!string_is_empty(settings->paths.directory_screenshot))
2011-08-24 13:47:39 +00:00
{
if (string_is_equal(settings->paths.directory_screenshot, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_screenshot = '\0';
else if (!path_is_directory(settings->paths.directory_screenshot))
{
RARCH_WARN("screenshot_directory is not an existing directory, ignoring ...\n");
2017-04-28 22:39:29 +00:00
*settings->paths.directory_screenshot = '\0';
}
2011-08-24 13:47:39 +00:00
}
2016-04-28 18:49:13 +00:00
#ifdef RARCH_CONSOLE
2017-11-24 05:45:21 +00:00
if (!string_is_empty(path_core))
2016-04-28 18:49:13 +00:00
{
#endif
/* Safe-guard against older behavior. */
2017-11-24 05:45:21 +00:00
if (path_is_directory(path_core))
{
RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n");
2017-11-24 05:45:21 +00:00
strlcpy(settings->paths.directory_libretro, path_core,
sizeof(settings->paths.directory_libretro));
path_clear(RARCH_PATH_CORE);
}
#ifdef RARCH_CONSOLE
2016-04-28 18:49:13 +00:00
}
#endif
2011-01-31 17:06:57 +00:00
if (string_is_equal(settings->paths.path_menu_wallpaper, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.path_menu_wallpaper = '\0';
if (string_is_equal(settings->paths.path_rgui_theme_preset, "default"))
*settings->paths.path_rgui_theme_preset = '\0';
if (string_is_equal(settings->paths.directory_video_shader, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_video_shader = '\0';
if (string_is_equal(settings->paths.directory_video_filter, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_video_filter = '\0';
if (string_is_equal(settings->paths.directory_audio_filter, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_audio_filter = '\0';
if (string_is_equal(settings->paths.directory_core_assets, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_core_assets = '\0';
if (string_is_equal(settings->paths.directory_assets, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_assets = '\0';
if (string_is_equal(settings->paths.directory_dynamic_wallpapers, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_dynamic_wallpapers = '\0';
if (string_is_equal(settings->paths.directory_thumbnails, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_thumbnails = '\0';
if (string_is_equal(settings->paths.directory_playlist, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_playlist = '\0';
#ifdef HAVE_MENU
if (string_is_equal(settings->paths.directory_menu_content, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_menu_content = '\0';
if (string_is_equal(settings->paths.directory_menu_config, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_menu_config = '\0';
#endif
#ifdef HAVE_OVERLAY
if (string_is_equal(settings->paths.directory_overlay, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_overlay = '\0';
#endif
if (string_is_equal(settings->paths.directory_system, "default"))
2017-04-28 22:39:29 +00:00
*settings->paths.directory_system = '\0';
2011-02-05 10:31:35 +00:00
2017-04-28 12:57:55 +00:00
if (settings->floats.slowmotion_ratio < 1.0f)
2017-12-03 02:37:06 +00:00
configuration_set_float(settings, settings->floats.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) */
2017-04-28 12:57:55 +00:00
if (settings->floats.fastforward_ratio < 0.0f)
configuration_set_float(settings, settings->floats.fastforward_ratio, 0.0f);
#ifdef HAVE_LAKKA
settings->bools.ssh_enable = filestream_exists(LAKKA_SSH_PATH);
settings->bools.samba_enable = filestream_exists(LAKKA_SAMBA_PATH);
settings->bools.bluetooth_enable = filestream_exists(LAKKA_BLUETOOTH_PATH);
#endif
2016-10-01 04:05:08 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL) &&
config_get_path(conf, "savefile_directory", tmp_str, path_size))
2011-08-24 13:47:39 +00:00
{
if (string_is_equal(tmp_str, "default"))
dir_set(RARCH_DIR_SAVEFILE, g_defaults.dirs[DEFAULT_DIR_SRAM]);
2016-09-17 12:49:35 +00:00
else if (path_is_directory(tmp_str))
2011-08-24 13:47:39 +00:00
{
2016-12-26 02:16:27 +00:00
global_t *global = global_get_ptr();
2016-10-03 06:20:33 +00:00
dir_set(RARCH_DIR_SAVEFILE, tmp_str);
2016-09-17 12:49:35 +00:00
2016-12-26 02:16:27 +00:00
if (global)
{
strlcpy(global->name.savefile, tmp_str,
sizeof(global->name.savefile));
fill_pathname_dir(global->name.savefile,
path_get(RARCH_PATH_BASENAME),
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-10-01 04:05:08 +00:00
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL) &&
config_get_path(conf, "savestate_directory", tmp_str, path_size))
2011-08-24 13:47:39 +00:00
{
if (string_is_equal(tmp_str, "default"))
dir_set(RARCH_DIR_SAVESTATE, g_defaults.dirs[DEFAULT_DIR_SAVESTATE]);
else if (path_is_directory(tmp_str))
2011-08-24 13:47:39 +00:00
{
2016-12-26 02:16:27 +00:00
global_t *global = global_get_ptr();
2016-10-03 06:20:33 +00:00
dir_set(RARCH_DIR_SAVESTATE, tmp_str);
2016-09-17 12:49:35 +00:00
2016-12-26 02:16:27 +00:00
if (global)
{
strlcpy(global->name.savestate, tmp_str,
sizeof(global->name.savestate));
fill_pathname_dir(global->name.savestate,
path_get(RARCH_PATH_BASENAME),
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
2018-02-09 18:27:18 +00:00
shader_ext = path_get_extension(settings->paths.path_shader);
if (!string_is_empty(shader_ext))
{
for(i = FILE_PATH_CGP_EXTENSION; i <= FILE_PATH_SLANGP_EXTENSION; i++)
{
enum file_path_enum ext = (enum file_path_enum)(i);
if (!strstr(file_path_str(ext), shader_ext))
continue;
if (check_shader_compatibility(ext))
continue;
2017-01-24 14:03:23 +00:00
RARCH_LOG("Incompatible shader for backend %s, clearing...\n",
settings->arrays.video_driver);
settings->paths.path_shader[0] = '\0';
break;
}
}
#if defined(HAVE_MENU) && defined(HAVE_RGUI)
if (!check_menu_driver_compatibility())
strlcpy(settings->arrays.menu_driver, "rgui", sizeof(settings->arrays.menu_driver));
#endif
#ifdef HAVE_LIBNX
// Apply initial clocks
extern void libnx_apply_overclock();
libnx_apply_overclock();
#endif
frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode);
recording_driver_update_streaming_url();
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);
2017-04-28 17:55:09 +00:00
if (uint_settings)
free(uint_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);
2018-08-18 04:56:10 +00:00
if (size_settings)
free(size_settings);
free(tmp_str);
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.
*
2017-07-14 19:11:27 +00:00
* core-specific: $CONFIG_DIR/$CORE_NAME/$CORE_NAME.cfg
2016-08-30 02:37:49 +00:00
* fallback: $CURRENT_CFG_LOCATION/$CORE_NAME/$CORE_NAME.cfg
*
2017-07-14 19:11:27 +00:00
* game-specific: $CONFIG_DIR/$CORE_NAME/$ROM_NAME.cfg
2016-08-30 02:37:49 +00:00
* 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)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
2018-02-04 22:02:52 +00:00
char *buf = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *content_path = NULL;
2018-02-04 22:02:52 +00:00
char *config_directory = NULL;
2015-06-12 15:00:37 +00:00
config_file_t *new_conf = NULL;
2016-10-03 02:34:08 +00:00
bool should_append = false;
2017-04-23 14:41:26 +00:00
rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ?
system->info.library_name : NULL;
2018-02-04 22:02:52 +00:00
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
2015-12-26 06:19:04 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
2018-02-04 22:02:52 +00:00
return false;
game_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
core_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
content_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
buf = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
config_directory = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2016-10-20 16:36:01 +00:00
config_directory[0] = core_path[0] = game_path[0] = '\0';
fill_pathname_application_special(config_directory, path_size,
2016-06-11 20:00:29 +00:00
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
/* Concatenate strings into full paths for core_path, game_path, content_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),
path_size);
fill_pathname_join_special_ext(content_path,
config_directory, core_name,
content_dir_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
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),
path_size);
/* per-core overrides */
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
if (new_conf)
{
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);
2016-09-29 05:49:54 +00:00
path_set(RARCH_PATH_CONFIG_APPEND, core_path);
should_append = true;
}
else
RARCH_LOG("[overrides] no core-specific overrides found at %s.\n",
core_path);
/* per-content-dir overrides */
/* Create a new config file from content_path */
new_conf = config_file_new(content_path);
if (new_conf)
{
char *temp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
temp_path[0] = '\0';
config_file_free(new_conf);
RARCH_LOG("[overrides] content-dir-specific overrides found at %s.\n",
game_path);
if (should_append)
{
RARCH_LOG("[overrides] content-dir-specific overrides stacking on top of previous overrides.\n");
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), path_size);
strlcat(temp_path, "|", path_size);
strlcat(temp_path, content_path, path_size);
}
else
strlcpy(temp_path, content_path, path_size);
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);
free(temp_path);
should_append = true;
}
else
RARCH_LOG("[overrides] no content-dir-specific overrides found at %s.\n",
content_path);
/* per-game overrides */
2015-06-26 15:46:13 +00:00
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
if (new_conf)
{
char *temp_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
temp_path[0] = '\0';
2016-09-17 12:14:58 +00:00
config_file_free(new_conf);
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)
{
RARCH_LOG("[overrides] game-specific overrides stacking on top of previous overrides\n");
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), path_size);
strlcat(temp_path, "|", path_size);
strlcat(temp_path, game_path, path_size);
}
else
strlcpy(temp_path, game_path, path_size);
2016-09-17 12:14:58 +00:00
2016-09-29 05:49:54 +00:00
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);
2015-04-07 00:58:57 +00:00
free(temp_path);
should_append = true;
}
else
RARCH_LOG("[overrides] no game-specific overrides found at %s.\n",
game_path);
if (!should_append)
goto error;
/* Re-load the configuration with any overrides
* that might have been found */
2016-10-20 16:36:01 +00:00
buf[0] = '\0';
2015-04-11 21:03:30 +00:00
2017-07-14 19:11:27 +00:00
/* Store the libretro_path we're using since it will be
2016-07-01 06:53:27 +00:00
* overwritten by the override when reloading. */
strlcpy(buf, path_get(RARCH_PATH_CORE), path_size);
/* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
2016-09-29 06:31:41 +00:00
if (!config_load_file(path_get(RARCH_PATH_CONFIG), false, config_get_ptr()))
goto error;
/* Restore the libretro_path we're using
* since it will be overwritten by the override when reloading. */
2016-09-29 05:46:21 +00:00
path_set(RARCH_PATH_CORE, buf);
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_OVERRIDE_LOADED),
1, 100, true);
2016-07-01 06:53:27 +00:00
/* Reset save paths. */
2016-10-01 03:51:03 +00:00
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
2016-09-17 12:14:58 +00:00
2016-09-30 02:31:19 +00:00
path_clear(RARCH_PATH_CONFIG_APPEND);
2016-09-17 12:14:58 +00:00
free(buf);
free(config_directory);
free(core_path);
free(content_path);
free(game_path);
return true;
error:
free(buf);
free(config_directory);
free(core_path);
free(content_path);
free(game_path);
return false;
}
/**
* 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-30 02:31:19 +00:00
path_clear(RARCH_PATH_CONFIG_APPEND);
/* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
2016-12-15 11:07:02 +00:00
if (!config_load_file(path_get(RARCH_PATH_CONFIG), false, config_get_ptr()))
return false;
2016-12-15 11:07:02 +00:00
RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n");
2016-12-15 11:07:02 +00:00
/* Reset save paths */
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL);
2016-12-15 11:07:02 +00:00
return true;
}
/**
* 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)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *remap_directory = NULL;
2018-02-04 22:02:52 +00:00
char *core_path = NULL;
char *game_path = NULL;
2018-05-13 21:20:51 +00:00
char *content_path = NULL;
2017-04-23 14:41:26 +00:00
config_file_t *new_conf = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
2018-02-04 22:02:52 +00:00
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
2018-05-13 21:20:51 +00:00
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
2015-12-26 06:19:04 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
2018-02-04 22:02:52 +00:00
return false;
/* Remap directory: remap_directory.
* Try remap directory setting, no fallbacks defined */
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_input_remapping))
2018-02-04 22:02:52 +00:00
return false;
2015-12-26 06:19:04 +00:00
2018-02-04 22:02:52 +00:00
/* path to the directory containing retroarch.cfg (prefix) */
remap_directory = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for core-specific configuration (prefix+suffix) */
core_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-04 22:02:52 +00:00
/* final path for game-specific configuration (prefix+suffix) */
game_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-05-13 21:20:51 +00:00
/* final path for content-dir-specific configuration (prefix+suffix) */
content_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2016-10-20 16:33:25 +00:00
remap_directory[0] = core_path[0] = game_path[0] = '\0';
2016-01-26 01:42:23 +00:00
strlcpy(remap_directory,
2017-04-28 22:39:29 +00:00
settings->paths.directory_input_remapping,
path_size);
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),
path_size);
2015-04-05 20:41:24 +00:00
2018-05-13 21:20:51 +00:00
fill_pathname_join_special_ext(content_path,
remap_directory, core_name,
content_dir_name,
file_path_str(FILE_PATH_REMAP_EXTENSION),
path_size);
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),
path_size);
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))
{
runloop_msg_queue_push(msg_hash_to_str(
MSG_GAME_REMAP_FILE_LOADED), 1, 100, true);
2017-08-05 05:37:26 +00:00
rarch_ctl(RARCH_CTL_SET_REMAPS_GAME_ACTIVE, NULL);
goto success;
}
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);
2017-09-12 03:49:39 +00:00
input_remapping_set_defaults(false);
}
2015-04-05 20:41:24 +00:00
2018-05-13 21:20:51 +00:00
/* Create a new config file from content_path */
new_conf = config_file_new(content_path);
/* If a content-dir remap file exists, load it. */
if (new_conf)
{
RARCH_LOG("Remaps: content-dir-specific remap found at %s.\n", content_path);
if (input_remapping_load_file(new_conf, content_path))
{
runloop_msg_queue_push(msg_hash_to_str(
MSG_GAME_REMAP_FILE_LOADED), 1, 100, true);
rarch_ctl(RARCH_CTL_SET_REMAPS_CONTENT_DIR_ACTIVE, NULL);
2018-05-13 21:20:51 +00:00
goto success;
}
}
else
{
RARCH_LOG("Remaps: no content-dir-specific remap found at %s.\n", content_path);
input_remapping_set_defaults(false);
}
/* 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))
{
runloop_msg_queue_push(
msg_hash_to_str(MSG_CORE_REMAP_FILE_LOADED), 1, 100, true);
2017-08-05 05:37:26 +00:00
rarch_ctl(RARCH_CTL_SET_REMAPS_CORE_ACTIVE, NULL);
goto success;
}
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);
2017-09-12 03:49:39 +00:00
input_remapping_set_defaults(false);
}
new_conf = NULL;
2015-04-05 20:41:24 +00:00
free(content_path);
free(remap_directory);
free(core_path);
free(game_path);
return false;
success:
free(content_path);
free(remap_directory);
free(core_path);
free(game_path);
return true;
2015-04-05 20:41:24 +00:00
}
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;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
2018-02-04 22:02:52 +00:00
config_file_t *new_conf = NULL;
char *shader_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *content_path = NULL;
2017-04-23 14:41:26 +00:00
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system
? system->info.library_name : NULL;
2018-02-04 22:02:52 +00:00
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
2016-07-30 18:55:50 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
2018-02-04 22:02:52 +00:00
return false;
2016-07-30 18:55:50 +00:00
/* Shader directory: shader_directory.
* Try shader directory setting, no fallbacks defined */
2017-04-28 22:39:29 +00:00
if (string_is_empty(settings->paths.directory_video_shader))
2018-02-04 22:02:52 +00:00
return false;
2016-07-30 18:55:50 +00:00
2018-02-04 22:02:52 +00:00
/* path to the directory containing retroarch.cfg (prefix) */
shader_directory = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-04 22:02:52 +00:00
/* final path for core-specific configuration (prefix+suffix) */
core_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-04 22:02:52 +00:00
/* final path for game-specific configuration (prefix+suffix) */
game_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-07 03:39:36 +00:00
/* final path for parent-dir-specific configuration (prefix+suffix) */
content_path = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-07 03:39:36 +00:00
2016-10-20 16:33:25 +00:00
shader_directory[0] = core_path[0] = game_path[0] = '\0';
fill_pathname_join (shader_directory,
settings->paths.directory_video_shader,
"presets", path_size);
2016-07-30 18:55:50 +00:00
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
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)),
path_size);
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)),
path_size);
/* 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);
retroarch_set_shader_preset(game_path);
goto success;
2016-07-30 18:55:50 +00:00
}
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
{
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, parent path */
fill_pathname_join_special_ext(content_path,
shader_directory, core_name,
content_dir_name,
file_path_str((enum file_path_enum)(idx)),
path_size);
/* Create a new config file from parent path */
new_conf = config_file_new(content_path);
if (!new_conf)
{
RARCH_LOG("Shaders: no content-dir-specific preset found at %s.\n",
content_path);
continue;
}
/* Parent-dir shader preset exists, load it. */
RARCH_LOG("Shaders: content-dir-specific shader preset found at %s.\n",
content_path);
retroarch_set_shader_preset(content_path);
goto success;
}
2016-11-20 18:31:11 +00:00
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
2016-07-30 18:55:50 +00:00
{
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)),
path_size);
/* 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);
retroarch_set_shader_preset(core_path);
goto success;
2016-07-30 18:55:50 +00:00
}
free(shader_directory);
free(core_path);
free(game_path);
free(content_path);
2016-07-30 18:55:50 +00:00
return false;
success:
free(shader_directory);
free(core_path);
free(game_path);
free(content_path);
config_file_free(new_conf);
return true;
2016-07-30 18:55:50 +00:00
}
2014-10-02 23:07:35 +00:00
static void parse_config_file(void)
{
2017-05-23 19:14:53 +00:00
if (path_is_empty(RARCH_PATH_CONFIG))
2014-10-02 23:07:35 +00:00
{
2017-05-23 19:14:53 +00:00
RARCH_LOG("[Config]: Loading default config.\n");
2016-09-30 02:43:16 +00:00
if (!path_is_empty(RARCH_PATH_CONFIG))
RARCH_LOG("[Config]: found default config: %s.\n",
path_get(RARCH_PATH_CONFIG));
2014-10-02 23:07:35 +00:00
}
RARCH_LOG("[Config]: loading config from: %s.\n",
path_get(RARCH_PATH_CONFIG));
if (config_load_file(path_get(RARCH_PATH_CONFIG),
false, config_get_ptr()))
2015-01-24 22:42:31 +00:00
return;
RARCH_ERR("[Config]: couldn't find config at path: \"%s\"\n",
path_get(RARCH_PATH_CONFIG));
2014-10-02 23:07:35 +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
{
2016-10-09 07:05:41 +00:00
char key[64];
char btn[64];
key[0] = btn[0] = '\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
{
2016-10-09 07:05:41 +00:00
char config[16];
unsigned hat = (unsigned)GET_HAT(bind->joykey);
2015-06-12 15:00:37 +00:00
const char *dir = NULL;
2012-02-20 19:36:21 +00:00
2016-10-09 07:05:41 +00:00
config[0] = '\0';
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:
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
}
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
{
2016-10-09 07:05:41 +00:00
char key[64];
key[0] = '\0';
2015-06-12 15:00:37 +00:00
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
}
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
{
2016-10-09 07:05:41 +00:00
char key[64];
2015-06-12 15:00:37 +00:00
unsigned axis = 0;
char dir = '\0';
2012-02-20 19:36:21 +00:00
2016-10-09 07:05:41 +00:00
key[0] = '\0';
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-10-09 07:05:41 +00:00
char config[16];
config[0] = '\0';
snprintf(config, sizeof(config), "%c%u", dir, axis);
config_set_string(conf, key, config);
}
2012-02-20 19:36:21 +00:00
}
static void save_keybind_mbutton(config_file_t *conf,
const char *prefix,
const char *base,
const struct retro_keybind *bind, bool save_empty)
{
2018-04-30 18:33:05 +00:00
char key[64];
2018-04-30 18:33:05 +00:00
key[0] = '\0';
2018-04-30 18:33:05 +00:00
fill_pathname_join_delim_concat(key, prefix,
base, '_', "_mbtn", sizeof(key));
2018-04-30 18:33:05 +00:00
switch ( bind->mbutton )
{
case RETRO_DEVICE_ID_MOUSE_LEFT:
config_set_uint64(conf, key, 1);
break;
case RETRO_DEVICE_ID_MOUSE_RIGHT:
config_set_uint64(conf, key, 2);
break;
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
config_set_uint64(conf, key, 3);
break;
case RETRO_DEVICE_ID_MOUSE_BUTTON_4:
config_set_uint64(conf, key, 4);
break;
case RETRO_DEVICE_ID_MOUSE_BUTTON_5:
config_set_uint64(conf, key, 5);
break;
case RETRO_DEVICE_ID_MOUSE_WHEELUP:
config_set_string(conf, key, "wu");
break;
case RETRO_DEVICE_ID_MOUSE_WHEELDOWN:
config_set_string(conf, key, "wd");
break;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP:
config_set_string(conf, key, "whu");
break;
case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN:
config_set_string(conf, key, "whd");
break;
default:
if (save_empty)
config_set_string(conf, key, file_path_str(FILE_PATH_NUL));
break;
}
}
/**
* 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);
save_keybind_mbutton(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-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),
2017-04-25 22:24:59 +00:00
&input_config_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)
{
2017-07-14 19:11:27 +00:00
/* Flush out some states that could have been
2016-07-01 06:53:27 +00:00
* 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, true);
2015-01-19 06:43:28 +00:00
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;
2018-02-04 22:02:52 +00:00
char *buf = NULL;
char *autoconf_file = NULL;
char *path_new = NULL;
2018-02-04 22:02:52 +00:00
config_file_t *conf = NULL;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
int32_t pid_user = 0;
int32_t vid_user = 0;
2016-05-27 03:13:05 +00:00
bool ret = false;
2015-07-11 01:40:15 +00:00
settings_t *settings = config_get_ptr();
2017-04-28 22:39:29 +00:00
const char *autoconf_dir = settings->paths.directory_autoconfig;
2017-04-28 20:59:13 +00:00
const char *joypad_ident = settings->arrays.input_joypad_driver;
if (string_is_empty(path))
2018-02-04 22:02:52 +00:00
return false;
buf = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
autoconf_file = (char*)
malloc(PATH_MAX_LENGTH * sizeof(char));
2018-02-04 22:02:52 +00:00
buf[0] = autoconf_file[0] = '\0';
path_new = strdup(path);
for (i = 0; invalid_filename_chars[i]; i++)
{
while (1)
{
char *tmp = strstr(path_new, invalid_filename_chars[i]);
if (tmp)
*tmp = '_';
else
break;
}
}
path = path_new;
fill_pathname_join(buf, autoconf_dir, joypad_ident, path_size);
if (path_is_directory(buf))
{
char *buf_new = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2016-10-09 07:05:41 +00:00
buf_new[0] = '\0';
fill_pathname_join(buf_new, buf,
path, path_size);
fill_pathname_noext(autoconf_file, buf_new,
2016-06-29 16:40:36 +00:00
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
free(buf_new);
}
else
{
2017-04-25 14:38:47 +00:00
fill_pathname_join(buf, autoconf_dir,
path, path_size);
2016-06-29 16:40:36 +00:00
fill_pathname_noext(autoconf_file, buf,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
}
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)
goto error;
}
2015-07-11 01:40:15 +00:00
config_set_string(conf, "input_driver",
joypad_ident);
2016-07-01 06:53:27 +00:00
config_set_string(conf, "input_device",
2017-04-25 14:07:17 +00:00
input_config_get_device_name(user));
pid_user = input_config_get_pid(user);
vid_user = input_config_get_vid(user);
if (pid_user && vid_user)
{
2016-07-01 06:53:27 +00:00
config_set_int(conf, "input_vendor_id",
vid_user);
2016-07-01 06:53:27 +00:00
config_set_int(conf, "input_product_id",
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),
2017-04-25 22:24:59 +00:00
&input_config_binds[user][i], false, false);
}
2016-05-27 03:13:05 +00:00
ret = config_file_write(conf, autoconf_file, false);
2016-05-27 03:13:05 +00:00
config_file_free(conf);
free(buf);
free(autoconf_file);
2017-11-26 00:06:48 +00:00
free(path_new);
return ret;
error:
free(buf);
free(autoconf_file);
2018-04-23 12:07:10 +00:00
free(path_new);
return false;
}
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;
struct config_bool_setting *bool_settings = NULL;
struct config_int_setting *int_settings = NULL;
2017-04-28 17:55:09 +00:00
struct config_uint_setting *uint_settings = NULL;
struct config_size_setting *size_settings = NULL;
2016-09-05 15:16:37 +00:00
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();
2017-04-28 19:05:34 +00:00
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats)/ sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays)/ sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
2016-08-26 16:26:24 +00:00
if (!conf)
conf = config_file_new(NULL);
2017-05-15 03:06:23 +00:00
if (!conf || rarch_ctl(RARCH_CTL_IS_OVERRIDES_ACTIVE, NULL))
2016-08-26 16:26:24 +00:00
{
if (conf)
config_file_free(conf);
return false;
}
bool_settings = populate_settings_bool (settings, &bool_settings_size);
int_settings = populate_settings_int (settings, &int_settings_size);
2017-04-28 17:55:09 +00:00
uint_settings = populate_settings_uint (settings, &uint_settings_size);
size_settings = populate_settings_size (settings, &size_settings_size);
float_settings = populate_settings_float (settings, &float_settings_size);
array_settings = populate_settings_array (settings, &array_settings_size);
path_settings = populate_settings_path (settings, &path_settings_size);
2016-08-26 01:10:01 +00:00
2016-08-29 18:18:20 +00:00
/* Path settings */
2016-12-26 02:01:29 +00:00
if (path_settings && (path_settings_size > 0))
2016-07-24 05:14:24 +00:00
{
2016-12-26 02:01:29 +00:00
for (i = 0; i < (unsigned)path_settings_size; i++)
{
const char *value = path_settings[i].ptr;
2016-08-30 02:20:28 +00:00
2016-12-26 02:01:29 +00:00
if (path_settings[i].def_enable && string_is_empty(path_settings[i].ptr))
value = "default";
2016-08-30 02:20:28 +00:00
2016-12-26 02:01:29 +00:00
config_set_path(conf, path_settings[i].ident, value);
}
free(path_settings);
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",
2017-07-14 19:11:27 +00:00
!string_is_empty(settings->paths.path_menu_xmb_font)
2017-04-28 22:39:29 +00:00
? settings->paths.path_menu_xmb_font : "");
2016-07-25 06:06:04 +00:00
#endif
2016-08-29 18:18:20 +00:00
/* String settings */
2016-12-26 02:01:29 +00:00
if (array_settings && (array_settings_size > 0))
{
for (i = 0; i < (unsigned)array_settings_size; i++)
if (!array_settings[i].override ||
!retroarch_override_setting_is_set(array_settings[i].override, NULL))
config_set_string(conf,
array_settings[i].ident,
array_settings[i].ptr);
2016-12-26 02:01:29 +00:00
free(array_settings);
}
2016-08-29 18:18:20 +00:00
/* Float settings */
2016-12-26 02:01:29 +00:00
if (float_settings && (float_settings_size > 0))
{
for (i = 0; i < (unsigned)float_settings_size; i++)
if (!float_settings[i].override ||
!retroarch_override_setting_is_set(float_settings[i].override, NULL))
config_set_float(conf,
float_settings[i].ident,
*float_settings[i].ptr);
2016-12-26 02:01:29 +00:00
free(float_settings);
}
2016-07-23 12:59:07 +00:00
2016-08-29 18:18:20 +00:00
/* Integer settings */
2016-12-26 02:01:29 +00:00
if (int_settings && (int_settings_size > 0))
{
for (i = 0; i < (unsigned)int_settings_size; i++)
if (!int_settings[i].override ||
!retroarch_override_setting_is_set(int_settings[i].override, NULL))
config_set_int(conf,
int_settings[i].ident,
*int_settings[i].ptr);
2016-12-26 02:01:29 +00:00
free(int_settings);
}
2016-07-24 03:01:11 +00:00
2017-04-28 17:55:09 +00:00
if (uint_settings && (uint_settings_size > 0))
{
for (i = 0; i < (unsigned)uint_settings_size; i++)
if (!uint_settings[i].override ||
!retroarch_override_setting_is_set(uint_settings[i].override, NULL))
config_set_int(conf,
uint_settings[i].ident,
*uint_settings[i].ptr);
2017-04-28 17:55:09 +00:00
free(uint_settings);
}
if (size_settings && (size_settings_size > 0))
{
for (i = 0; i < (unsigned)size_settings_size; i++)
if (!size_settings[i].override ||
!retroarch_override_setting_is_set(size_settings[i].override, NULL))
config_set_int(conf,
size_settings[i].ident,
2018-08-04 18:02:33 +00:00
(int)*size_settings[i].ptr);
free(size_settings);
}
for (i = 0; i < MAX_USERS; i++)
{
2016-10-09 07:05:41 +00:00
char cfg[64];
cfg[0] = '\0';
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, settings->uints.input_device[i]);
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, settings->uints.input_joypad_map[i]);
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
2017-04-25 15:14:46 +00:00
config_set_int(conf, cfg, input_config_get_device(i));
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, settings->uints.input_analog_dpad_mode[i]);
2017-06-08 14:13:45 +00:00
snprintf(cfg, sizeof(cfg), "input_player%u_mouse_index", i + 1);
config_set_int(conf, cfg, settings->uints.input_mouse_index[i]);
}
2016-08-29 18:18:20 +00:00
/* Boolean settings */
2016-12-26 02:01:29 +00:00
if (bool_settings && (bool_settings_size > 0))
{
for (i = 0; i < (unsigned)bool_settings_size; i++)
if (!bool_settings[i].override ||
!retroarch_override_setting_is_set(bool_settings[i].override, NULL))
config_set_bool(conf, bool_settings[i].ident,
*bool_settings[i].ptr);
2016-12-26 02:01:29 +00:00
free(bool_settings);
}
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++)
{
2016-10-09 07:05:41 +00:00
char tmp[64];
tmp[0] = '\0';
2016-07-24 02:37:46 +00:00
snprintf(tmp, sizeof(tmp), "network_remote_enable_user_p%u", i + 1);
2017-04-28 11:43:47 +00:00
config_set_bool(conf, tmp, settings->bools.network_remote_enable_user[i]);
2016-07-24 02:37:46 +00:00
}
#endif
2016-08-30 02:20:28 +00:00
/* Verbosity isn't in bool_settings since it needs to be loaded differently */
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_VERBOSITY, NULL))
{
config_set_bool(conf, "log_verbosity",
verbosity_is_enabled());
}
2016-07-24 02:37:46 +00:00
config_set_bool(conf, "perfcnt_enable",
2017-05-15 03:06:23 +00:00
rarch_ctl(RARCH_CTL_IS_PERFCNT_ENABLE, NULL));
2016-07-24 02:37:46 +00:00
2017-04-28 12:57:55 +00:00
msg_color = (((int)(settings->floats.video_msg_color_r * 255.0f) & 0xff) << 16) +
(((int)(settings->floats.video_msg_color_g * 255.0f) & 0xff) << 8) +
(((int)(settings->floats.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);
2016-05-08 12:00:51 +00:00
video_driver_save_settings(conf);
#ifdef HAVE_LAKKA
2017-05-03 15:01:37 +00:00
if (settings->bools.ssh_enable)
filestream_close(filestream_open(LAKKA_SSH_PATH,
2017-12-11 11:53:47 +00:00
RETRO_VFS_FILE_ACCESS_WRITE,
RETRO_VFS_FILE_ACCESS_HINT_NONE));
else
filestream_delete(LAKKA_SSH_PATH);
2017-05-03 15:01:37 +00:00
if (settings->bools.samba_enable)
filestream_close(filestream_open(LAKKA_SAMBA_PATH,
2017-12-11 11:53:47 +00:00
RETRO_VFS_FILE_ACCESS_WRITE,
RETRO_VFS_FILE_ACCESS_HINT_NONE));
else
filestream_delete(LAKKA_SAMBA_PATH);
2017-05-03 15:01:37 +00:00
if (settings->bools.bluetooth_enable)
filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH,
2017-12-11 11:53:47 +00:00
RETRO_VFS_FILE_ACCESS_WRITE,
RETRO_VFS_FILE_ACCESS_HINT_NONE));
2016-03-23 13:06:53 +00:00
else
filestream_delete(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, true);
config_file_free(conf);
2016-08-26 00:00:06 +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
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
int tmp_i = 0;
2016-09-05 15:17:28 +00:00
unsigned i = 0;
2016-08-27 00:35:21 +00:00
bool ret = false;
config_file_t *conf = NULL;
settings_t *settings = 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;
2017-04-28 17:55:09 +00:00
struct config_uint_setting *uint_settings = NULL;
struct config_size_setting *size_settings = NULL;
2016-09-05 15:16:37 +00:00
struct config_int_setting *int_overrides = NULL;
2017-04-28 17:55:09 +00:00
struct config_uint_setting *uint_overrides = NULL;
struct config_size_setting *size_overrides = NULL;
2016-09-05 15:16:37 +00:00
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;
2018-02-04 22:02:52 +00:00
char *config_directory = NULL;
char *override_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
2018-05-13 21:20:51 +00:00
char *content_path = NULL;
2017-04-23 14:41:26 +00:00
settings_t *overrides = config_get_ptr();
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
2017-04-28 13:01:11 +00:00
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
2017-04-28 18:08:12 +00:00
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
2017-04-23 14:41:26 +00:00
rarch_system_info_t *system = runloop_get_system_info();
2018-02-04 22:02:52 +00:00
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
2018-05-13 21:20:51 +00:00
char content_dir_name[PATH_MAX_LENGTH];
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(content_dir_name, path_get(RARCH_PATH_BASENAME), sizeof(content_dir_name));
2016-08-26 16:26:24 +00:00
if (string_is_empty(core_name) || string_is_empty(game_name))
2018-02-04 22:02:52 +00:00
return false;
2016-08-26 16:26:24 +00:00
2018-02-04 22:02:52 +00:00
settings = (settings_t*)calloc(1, sizeof(settings_t));
config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2018-05-13 21:20:51 +00:00
content_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
2016-08-26 16:26:24 +00:00
2016-10-20 16:36:01 +00:00
config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0';
fill_pathname_application_special(config_directory, path_size,
2016-08-26 05:44:05 +00:00
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
2017-07-14 19:11:27 +00:00
fill_pathname_join(override_directory, config_directory, core_name,
path_size);
2016-08-26 14:43:29 +00:00
if (!filestream_exists(override_directory))
2016-08-26 14:43:29 +00:00
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),
path_size);
2016-08-26 05:44:05 +00:00
2018-05-13 21:20:51 +00:00
fill_pathname_join_special_ext(content_path,
config_directory, core_name,
content_dir_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
2016-08-26 05:44:05 +00:00
fill_pathname_join_special_ext(core_path,
config_directory, core_name,
core_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
path_size);
2016-08-26 05:44:05 +00:00
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 */
2016-09-29 06:31:41 +00:00
config_load_file(path_get(RARCH_PATH_CONFIG), false, settings);
2016-08-25 15:30:30 +00:00
bool_settings = populate_settings_bool(settings, &bool_settings_size);
2017-04-28 12:33:18 +00:00
tmp_i = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
bool_overrides = populate_settings_bool(overrides, &tmp_i);
int_settings = populate_settings_int(settings, &int_settings_size);
2017-04-28 18:08:12 +00:00
tmp_i = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int_overrides = populate_settings_int (overrides, &tmp_i);
2017-04-28 17:55:09 +00:00
uint_settings = populate_settings_uint(settings, &uint_settings_size);
2017-04-28 19:05:34 +00:00
tmp_i = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
2017-04-28 17:55:09 +00:00
uint_overrides = populate_settings_uint (overrides, &tmp_i);
size_settings = populate_settings_size(settings, &size_settings_size);
tmp_i = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
size_overrides = populate_settings_size (overrides, &tmp_i);
float_settings = populate_settings_float(settings, &float_settings_size);
2017-04-28 13:01:11 +00:00
tmp_i = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
float_overrides = populate_settings_float(overrides, &tmp_i);
array_settings = populate_settings_array(settings, &array_settings_size);
2017-04-28 21:02:22 +00:00
tmp_i = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
array_overrides = populate_settings_array (overrides, &tmp_i);
path_settings = populate_settings_path(settings, &path_settings_size);
tmp_i = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
path_overrides = populate_settings_path (overrides, &tmp_i);
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))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%d\n",
bool_settings[i].ident, (*bool_settings[i].ptr));
2017-07-14 19:11:27 +00:00
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))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%d\n",
int_settings[i].ident, (*int_settings[i].ptr));
2017-07-14 19:11:27 +00:00
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
}
2017-04-28 17:55:09 +00:00
for (i = 0; i < (unsigned)uint_settings_size; i++)
{
if ((*uint_settings[i].ptr) != (*uint_overrides[i].ptr))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%d\n",
2017-04-28 17:55:09 +00:00
uint_settings[i].ident, (*uint_settings[i].ptr));
2017-07-14 19:11:27 +00:00
RARCH_LOG(" override: %s=%d\n",
2017-04-28 17:55:09 +00:00
uint_overrides[i].ident, (*uint_overrides[i].ptr));
config_set_int(conf, uint_overrides[i].ident,
(*uint_overrides[i].ptr));
}
}
for (i = 0; i < (unsigned)size_settings_size; i++)
{
if ((*size_settings[i].ptr) != (*size_overrides[i].ptr))
{
RARCH_LOG(" original: %s=%d\n",
size_settings[i].ident, (*size_settings[i].ptr));
RARCH_LOG(" override: %s=%d\n",
size_overrides[i].ident, (*size_overrides[i].ptr));
config_set_int(conf, size_overrides[i].ident,
2018-08-04 18:02:33 +00:00
(int)(*size_overrides[i].ptr));
}
}
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))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%f\n",
float_settings[i].ident, *float_settings[i].ptr);
2017-07-14 19:11:27 +00:00
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))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%s\n",
array_settings[i].ident, array_settings[i].ptr);
2017-07-14 19:11:27 +00:00
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
{
2018-05-14 04:58:55 +00:00
/* blacklist video_shader, better handled by shader presets*/
2018-05-14 04:58:55 +00:00
/* to-do: add setting to control blacklisting */
if (string_is_equal(path_settings[i].ident, "video_shader"))
continue;
if (!string_is_equal(path_settings[i].ptr, path_overrides[i].ptr))
{
2017-07-14 19:11:27 +00:00
RARCH_LOG(" original: %s=%s\n",
path_settings[i].ident, path_settings[i].ptr);
2017-07-14 19:11:27 +00:00
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
for (i = 0; i < MAX_USERS; i++)
{
char cfg[64];
cfg[0] = '\0';
if (settings->uints.input_device[i]
!= overrides->uints.input_device[i])
{
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, overrides->uints.input_device[i]);
}
if (settings->uints.input_joypad_map[i]
!= overrides->uints.input_joypad_map[i])
{
snprintf(cfg, sizeof(cfg), "input_player%u_joypad_index", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, overrides->uints.input_joypad_map[i]);
}
2018-05-14 04:58:55 +00:00
/* blacklist these since they are handled by remaps */
/* to-do: add setting to control blacklisting
if (settings->uints.input_libretro_device[i]
!= overrides->uints.input_libretro_device[i])
{
snprintf(cfg, sizeof(cfg), "input_libretro_device_p%u", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, overrides->uints.input_libretro_device[i]);
}
if (settings->uints.input_analog_dpad_mode[i]
!= overrides->uints.input_analog_dpad_mode[i])
{
snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1);
2017-04-28 19:03:04 +00:00
config_set_int(conf, cfg, overrides->uints.input_analog_dpad_mode[i]);
}
2018-05-14 04:58:55 +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, true);
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, true);
break;
2018-05-13 21:20:51 +00:00
case OVERRIDE_CONTENT_DIR:
/* Create a new config file from content_path */
RARCH_LOG ("[overrides] path %s\n", content_path);
ret = config_file_write(conf, content_path, true);
2018-05-13 21:20:51 +00:00
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);
2017-04-28 17:55:09 +00:00
if (uint_settings)
free(uint_settings);
if (size_settings)
free(size_settings);
if (int_overrides)
free(int_overrides);
2017-04-28 19:47:26 +00:00
if (uint_overrides)
free(uint_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);
2018-08-18 04:56:10 +00:00
if (size_overrides)
free(size_overrides);
2016-08-26 05:44:05 +00:00
free(settings);
free(config_directory);
free(override_directory);
free(core_path);
free(game_path);
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(bool config_replace_save_on_exit, char *path)
2016-05-27 14:42:20 +00:00
{
content_ctx_info_t content_info = {0};
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. */
2016-09-29 06:31:41 +00:00
if (string_is_equal(path, path_get(RARCH_PATH_CONFIG)))
2016-05-27 14:42:20 +00:00
return false;
if (config_replace_save_on_exit && !path_is_empty(RARCH_PATH_CONFIG))
2016-09-29 06:31:41 +00:00
config_save_file(path_get(RARCH_PATH_CONFIG));
2016-05-27 14:42:20 +00:00
2016-09-29 05:46:21 +00:00
path_set(RARCH_PATH_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-30 02:31:19 +00:00
path_clear(RARCH_PATH_CORE);
2016-05-27 14:42:20 +00:00
2017-02-21 15:50:39 +00:00
if (!task_push_start_dummy_core(&content_info))
2016-05-27 14:42:20 +00:00
return false;
return true;
}