2016-01-29 08:33:56 +00:00
|
|
|
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
2014-12-03 08:39:06 +00:00
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2015-02-03 07:52:37 +00:00
|
|
|
#include "config.h"
|
2014-11-01 10:04:10 +00:00
|
|
|
|
2016-05-04 08:36:25 +00:00
|
|
|
#include "core/version.h"
|
2015-02-11 08:19:55 +00:00
|
|
|
#include "util/formatting.h"
|
2015-06-18 04:50:10 +00:00
|
|
|
#include "util/string.h"
|
2015-04-02 04:13:16 +00:00
|
|
|
#include "util/vfs.h"
|
2015-02-11 08:19:55 +00:00
|
|
|
|
2014-11-10 07:27:43 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2014-11-11 08:46:30 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
2015-07-02 04:30:14 +00:00
|
|
|
#include <shlwapi.h>
|
2014-11-11 08:46:30 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
#endif
|
|
|
|
|
2015-08-22 07:39:40 +00:00
|
|
|
#ifdef PSP2
|
|
|
|
#include <psp2/io/stat.h>
|
|
|
|
#endif
|
|
|
|
|
2015-09-08 04:45:19 +00:00
|
|
|
#ifdef _3DS
|
|
|
|
#include "platform/3ds/3ds-vfs.h"
|
|
|
|
#endif
|
|
|
|
|
2014-11-01 10:04:10 +00:00
|
|
|
#define SECTION_NAME_MAX 128
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
static const char* _lookupValue(const struct mCoreConfig* config, const char* key) {
|
2014-11-05 07:54:09 +00:00
|
|
|
const char* value;
|
2015-10-07 04:27:25 +00:00
|
|
|
if (config->port) {
|
|
|
|
value = ConfigurationGetValue(&config->overridesTable, config->port, key);
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
value = ConfigurationGetValue(&config->overridesTable, 0, key);
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
if (config->port) {
|
|
|
|
value = ConfigurationGetValue(&config->configTable, config->port, key);
|
2014-11-01 10:04:10 +00:00
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
value = ConfigurationGetValue(&config->configTable, 0, key);
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
if (config->port) {
|
|
|
|
value = ConfigurationGetValue(&config->defaultsTable, config->port, key);
|
|
|
|
if (value) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ConfigurationGetValue(&config->defaultsTable, 0, key);
|
2014-11-01 10:04:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
static bool _lookupCharValue(const struct mCoreConfig* config, const char* key, char** out) {
|
2014-11-05 07:54:09 +00:00
|
|
|
const char* value = _lookupValue(config, key);
|
2014-11-02 08:31:12 +00:00
|
|
|
if (!value) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
if (*out) {
|
|
|
|
free(*out);
|
|
|
|
}
|
2014-11-02 08:31:12 +00:00
|
|
|
*out = strdup(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
static bool _lookupIntValue(const struct mCoreConfig* config, const char* key, int* out) {
|
2014-11-05 07:54:09 +00:00
|
|
|
const char* charValue = _lookupValue(config, key);
|
2014-11-01 10:04:10 +00:00
|
|
|
if (!charValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char* end;
|
|
|
|
long value = strtol(charValue, &end, 10);
|
|
|
|
if (*end) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*out = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
static bool _lookupUIntValue(const struct mCoreConfig* config, const char* key, unsigned* out) {
|
2014-11-05 07:54:09 +00:00
|
|
|
const char* charValue = _lookupValue(config, key);
|
2014-11-02 10:34:16 +00:00
|
|
|
if (!charValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char* end;
|
|
|
|
unsigned long value = strtoul(charValue, &end, 10);
|
|
|
|
if (*end) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*out = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
static bool _lookupFloatValue(const struct mCoreConfig* config, const char* key, float* out) {
|
2014-11-05 07:54:09 +00:00
|
|
|
const char* charValue = _lookupValue(config, key);
|
2014-11-02 10:34:16 +00:00
|
|
|
if (!charValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char* end;
|
2015-02-11 08:19:55 +00:00
|
|
|
float value = strtof_u(charValue, &end);
|
2014-11-02 10:34:16 +00:00
|
|
|
if (*end) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
*out = value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigInit(struct mCoreConfig* config, const char* port) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationInit(&config->configTable);
|
|
|
|
ConfigurationInit(&config->defaultsTable);
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationInit(&config->overridesTable);
|
2014-11-17 09:17:56 +00:00
|
|
|
if (port) {
|
|
|
|
config->port = malloc(strlen("ports.") + strlen(port) + 1);
|
|
|
|
snprintf(config->port, strlen("ports.") + strlen(port) + 1, "ports.%s", port);
|
|
|
|
} else {
|
|
|
|
config->port = 0;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigDeinit(struct mCoreConfig* config) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationDeinit(&config->configTable);
|
|
|
|
ConfigurationDeinit(&config->defaultsTable);
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationDeinit(&config->overridesTable);
|
2014-11-05 07:54:09 +00:00
|
|
|
free(config->port);
|
2014-11-01 10:04:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-02 01:54:37 +00:00
|
|
|
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigLoad(struct mCoreConfig* config) {
|
2014-11-10 07:27:43 +00:00
|
|
|
char path[PATH_MAX];
|
2016-01-29 08:33:56 +00:00
|
|
|
mCoreConfigDirectory(path, PATH_MAX);
|
2014-12-21 02:41:41 +00:00
|
|
|
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path));
|
2016-01-29 08:33:56 +00:00
|
|
|
return mCoreConfigLoadPath(config, path);
|
2014-11-05 07:54:09 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigSave(const struct mCoreConfig* config) {
|
2014-11-10 07:27:43 +00:00
|
|
|
char path[PATH_MAX];
|
2016-01-29 08:33:56 +00:00
|
|
|
mCoreConfigDirectory(path, PATH_MAX);
|
2014-12-21 02:41:41 +00:00
|
|
|
strncat(path, PATH_SEP "config.ini", PATH_MAX - strlen(path));
|
2016-01-29 08:33:56 +00:00
|
|
|
return mCoreConfigSavePath(config, path);
|
2015-07-22 02:22:02 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigLoadPath(struct mCoreConfig* config, const char* path) {
|
2015-07-22 02:22:02 +00:00
|
|
|
return ConfigurationRead(&config->configTable, path);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigSavePath(const struct mCoreConfig* config, const char* path) {
|
2014-12-21 02:41:41 +00:00
|
|
|
return ConfigurationWrite(&config->configTable, path);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigMakePortable(const struct mCoreConfig* config) {
|
2015-08-22 07:39:40 +00:00
|
|
|
struct VFile* portable = 0;
|
|
|
|
#ifdef _WIN32
|
2015-07-05 22:00:29 +00:00
|
|
|
char out[MAX_PATH];
|
2015-07-05 21:42:11 +00:00
|
|
|
wchar_t wpath[MAX_PATH];
|
|
|
|
wchar_t wprojectName[MAX_PATH];
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, projectName, -1, wprojectName, MAX_PATH);
|
|
|
|
HMODULE hModule = GetModuleHandleW(NULL);
|
|
|
|
GetModuleFileNameW(hModule, wpath, MAX_PATH);
|
|
|
|
PathRemoveFileSpecW(wpath);
|
2015-07-05 22:00:29 +00:00
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, MAX_PATH, 0, 0);
|
|
|
|
StringCchCatA(out, MAX_PATH, "\\portable.ini");
|
2015-07-05 21:42:11 +00:00
|
|
|
portable = VFileOpen(out, O_WRONLY | O_CREAT);
|
2015-09-08 04:45:19 +00:00
|
|
|
#elif defined(PSP2) || defined(_3DS) || defined(GEKKO)
|
2015-08-22 07:39:40 +00:00
|
|
|
// Already portable
|
|
|
|
#else
|
|
|
|
char out[PATH_MAX];
|
|
|
|
getcwd(out, PATH_MAX);
|
|
|
|
strncat(out, PATH_SEP "portable.ini", PATH_MAX - strlen(out));
|
|
|
|
portable = VFileOpen(out, O_WRONLY | O_CREAT);
|
2015-07-05 21:42:11 +00:00
|
|
|
#endif
|
|
|
|
if (portable) {
|
|
|
|
portable->close(portable);
|
2016-01-29 08:33:56 +00:00
|
|
|
mCoreConfigSave(config);
|
2015-07-05 21:42:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigDirectory(char* out, size_t outLength) {
|
2015-07-02 04:30:14 +00:00
|
|
|
struct VFile* portable;
|
2015-08-22 07:39:40 +00:00
|
|
|
#ifdef _WIN32
|
2015-06-30 04:45:32 +00:00
|
|
|
wchar_t wpath[MAX_PATH];
|
|
|
|
wchar_t wprojectName[MAX_PATH];
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, projectName, -1, wprojectName, MAX_PATH);
|
2015-07-02 04:30:14 +00:00
|
|
|
HMODULE hModule = GetModuleHandleW(NULL);
|
|
|
|
GetModuleFileNameW(hModule, wpath, MAX_PATH);
|
|
|
|
PathRemoveFileSpecW(wpath);
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0);
|
|
|
|
StringCchCatA(out, outLength, "\\portable.ini");
|
|
|
|
portable = VFileOpen(out, O_RDONLY);
|
|
|
|
if (portable) {
|
|
|
|
portable->close(portable);
|
|
|
|
} else {
|
|
|
|
wchar_t* home;
|
|
|
|
SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &home);
|
|
|
|
StringCchPrintfW(wpath, MAX_PATH, L"%ws\\%ws", home, wprojectName);
|
|
|
|
CoTaskMemFree(home);
|
|
|
|
CreateDirectoryW(wpath, NULL);
|
|
|
|
}
|
2015-06-30 04:45:32 +00:00
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wpath, -1, out, outLength, 0, 0);
|
2015-08-22 07:39:40 +00:00
|
|
|
#elif defined(PSP2)
|
|
|
|
UNUSED(portable);
|
2016-08-28 08:15:47 +00:00
|
|
|
snprintf(out, outLength, "ux0:data/%s", projectName);
|
2015-08-22 07:39:40 +00:00
|
|
|
sceIoMkdir(out, 0777);
|
2015-09-08 04:45:19 +00:00
|
|
|
#elif defined(GEKKO)
|
|
|
|
UNUSED(portable);
|
2015-12-19 22:21:20 +00:00
|
|
|
snprintf(out, outLength, "/%s", projectName);
|
2015-09-08 04:45:19 +00:00
|
|
|
mkdir(out, 0777);
|
|
|
|
#elif defined(_3DS)
|
2016-01-02 09:49:03 +00:00
|
|
|
UNUSED(portable);
|
2015-09-08 04:45:19 +00:00
|
|
|
snprintf(out, outLength, "/%s", projectName);
|
2016-01-02 09:49:03 +00:00
|
|
|
FSUSER_CreateDirectory(sdmcArchive, fsMakePath(PATH_ASCII, out), 0);
|
2015-08-22 07:39:40 +00:00
|
|
|
#else
|
|
|
|
getcwd(out, outLength);
|
|
|
|
strncat(out, PATH_SEP "portable.ini", outLength - strlen(out));
|
|
|
|
portable = VFileOpen(out, O_RDONLY);
|
|
|
|
if (portable) {
|
|
|
|
getcwd(out, outLength);
|
|
|
|
portable->close(portable);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* home = getenv("HOME");
|
|
|
|
snprintf(out, outLength, "%s/.config", home);
|
|
|
|
mkdir(out, 0755);
|
|
|
|
snprintf(out, outLength, "%s/.config/%s", home, binaryName);
|
|
|
|
mkdir(out, 0755);
|
2014-11-11 08:46:30 +00:00
|
|
|
#endif
|
2014-11-05 07:54:09 +00:00
|
|
|
}
|
2016-01-02 01:54:37 +00:00
|
|
|
#endif
|
2014-11-05 07:54:09 +00:00
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
const char* mCoreConfigGetValue(const struct mCoreConfig* config, const char* key) {
|
2014-11-05 10:16:35 +00:00
|
|
|
return _lookupValue(config, key);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigGetIntValue(const struct mCoreConfig* config, const char* key, int* value) {
|
2015-09-18 02:49:45 +00:00
|
|
|
return _lookupIntValue(config, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigGetUIntValue(const struct mCoreConfig* config, const char* key, unsigned* value) {
|
2015-09-18 02:49:45 +00:00
|
|
|
return _lookupUIntValue(config, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
bool mCoreConfigGetFloatValue(const struct mCoreConfig* config, const char* key, float* value) {
|
2015-09-18 02:49:45 +00:00
|
|
|
return _lookupFloatValue(config, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetValue(struct mCoreConfig* config, const char* key, const char* value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetValue(&config->configTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetIntValue(struct mCoreConfig* config, const char* key, int value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetIntValue(&config->configTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetUIntValue(struct mCoreConfig* config, const char* key, unsigned value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetUIntValue(&config->configTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetFloatValue(struct mCoreConfig* config, const char* key, float value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetFloatValue(&config->configTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetDefaultValue(struct mCoreConfig* config, const char* key, const char* value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetValue(&config->defaultsTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetDefaultIntValue(struct mCoreConfig* config, const char* key, int value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetDefaultUIntValue(struct mCoreConfig* config, const char* key, unsigned value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetUIntValue(&config->defaultsTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetDefaultFloatValue(struct mCoreConfig* config, const char* key, float value) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetFloatValue(&config->defaultsTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetOverrideValue(struct mCoreConfig* config, const char* key, const char* value) {
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationSetValue(&config->overridesTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetOverrideIntValue(struct mCoreConfig* config, const char* key, int value) {
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationSetIntValue(&config->overridesTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetOverrideUIntValue(struct mCoreConfig* config, const char* key, unsigned value) {
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationSetUIntValue(&config->overridesTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
void mCoreConfigSetOverrideFloatValue(struct mCoreConfig* config, const char* key, float value) {
|
2015-10-07 04:27:25 +00:00
|
|
|
ConfigurationSetFloatValue(&config->overridesTable, config->port, key, value);
|
|
|
|
}
|
|
|
|
|
2016-02-05 05:58:45 +00:00
|
|
|
void mCoreConfigMap(const struct mCoreConfig* config, struct mCoreOptions* opts) {
|
2014-11-05 07:54:09 +00:00
|
|
|
_lookupCharValue(config, "bios", &opts->bios);
|
2015-11-02 02:41:24 +00:00
|
|
|
_lookupCharValue(config, "shader", &opts->shader);
|
2014-11-05 07:54:09 +00:00
|
|
|
_lookupIntValue(config, "logLevel", &opts->logLevel);
|
|
|
|
_lookupIntValue(config, "frameskip", &opts->frameskip);
|
2015-04-08 07:32:29 +00:00
|
|
|
_lookupIntValue(config, "volume", &opts->volume);
|
2014-11-05 07:54:09 +00:00
|
|
|
_lookupIntValue(config, "rewindBufferCapacity", &opts->rewindBufferCapacity);
|
|
|
|
_lookupFloatValue(config, "fpsTarget", &opts->fpsTarget);
|
2014-11-02 10:34:16 +00:00
|
|
|
unsigned audioBuffers;
|
2014-11-05 07:54:09 +00:00
|
|
|
if (_lookupUIntValue(config, "audioBuffers", &audioBuffers)) {
|
2014-11-02 10:34:16 +00:00
|
|
|
opts->audioBuffers = audioBuffers;
|
|
|
|
}
|
2015-08-10 04:36:43 +00:00
|
|
|
_lookupUIntValue(config, "sampleRate", &opts->sampleRate);
|
2014-11-04 09:19:10 +00:00
|
|
|
|
|
|
|
int fakeBool;
|
2015-03-29 06:19:21 +00:00
|
|
|
if (_lookupIntValue(config, "useBios", &fakeBool)) {
|
2015-03-17 06:14:52 +00:00
|
|
|
opts->useBios = fakeBool;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
if (_lookupIntValue(config, "audioSync", &fakeBool)) {
|
2014-11-04 09:19:10 +00:00
|
|
|
opts->audioSync = fakeBool;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
if (_lookupIntValue(config, "videoSync", &fakeBool)) {
|
2014-11-04 09:19:10 +00:00
|
|
|
opts->videoSync = fakeBool;
|
|
|
|
}
|
2014-12-16 09:33:08 +00:00
|
|
|
if (_lookupIntValue(config, "lockAspectRatio", &fakeBool)) {
|
|
|
|
opts->lockAspectRatio = fakeBool;
|
|
|
|
}
|
2014-12-22 00:50:55 +00:00
|
|
|
if (_lookupIntValue(config, "resampleVideo", &fakeBool)) {
|
|
|
|
opts->resampleVideo = fakeBool;
|
|
|
|
}
|
2015-05-06 05:43:44 +00:00
|
|
|
if (_lookupIntValue(config, "suspendScreensaver", &fakeBool)) {
|
|
|
|
opts->suspendScreensaver = fakeBool;
|
|
|
|
}
|
2015-04-08 07:32:29 +00:00
|
|
|
if (_lookupIntValue(config, "mute", &fakeBool)) {
|
|
|
|
opts->mute = fakeBool;
|
|
|
|
}
|
2014-12-22 01:48:36 +00:00
|
|
|
if (_lookupIntValue(config, "skipBios", &fakeBool)) {
|
|
|
|
opts->skipBios = fakeBool;
|
|
|
|
}
|
2015-01-06 07:11:56 +00:00
|
|
|
if (_lookupIntValue(config, "rewindEnable", &fakeBool)) {
|
|
|
|
opts->rewindEnable = fakeBool;
|
|
|
|
}
|
2014-11-05 07:54:09 +00:00
|
|
|
|
|
|
|
_lookupIntValue(config, "fullscreen", &opts->fullscreen);
|
|
|
|
_lookupIntValue(config, "width", &opts->width);
|
|
|
|
_lookupIntValue(config, "height", &opts->height);
|
2015-01-13 10:39:48 +00:00
|
|
|
|
2016-01-15 22:29:19 +00:00
|
|
|
_lookupCharValue(config, "savegamePath", &opts->savegamePath);
|
|
|
|
_lookupCharValue(config, "savestatePath", &opts->savestatePath);
|
|
|
|
_lookupCharValue(config, "screenshotPath", &opts->screenshotPath);
|
|
|
|
_lookupCharValue(config, "patchPath", &opts->patchPath);
|
2014-11-01 10:04:10 +00:00
|
|
|
}
|
|
|
|
|
2016-02-05 05:58:45 +00:00
|
|
|
void mCoreConfigLoadDefaults(struct mCoreConfig* config, const struct mCoreOptions* opts) {
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetValue(&config->defaultsTable, 0, "bios", opts->bios);
|
2015-11-02 02:41:24 +00:00
|
|
|
ConfigurationSetValue(&config->defaultsTable, 0, "shader", opts->shader);
|
2014-12-22 01:48:36 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "skipBios", opts->skipBios);
|
2015-03-17 06:14:52 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "useBios", opts->useBios);
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "logLevel", opts->logLevel);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "frameskip", opts->frameskip);
|
2015-01-06 07:11:56 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindEnable", opts->rewindEnable);
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "rewindBufferCapacity", opts->rewindBufferCapacity);
|
|
|
|
ConfigurationSetFloatValue(&config->defaultsTable, 0, "fpsTarget", opts->fpsTarget);
|
|
|
|
ConfigurationSetUIntValue(&config->defaultsTable, 0, "audioBuffers", opts->audioBuffers);
|
2015-08-10 04:36:43 +00:00
|
|
|
ConfigurationSetUIntValue(&config->defaultsTable, 0, "sampleRate", opts->sampleRate);
|
2014-11-05 07:54:09 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "audioSync", opts->audioSync);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "videoSync", opts->videoSync);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "fullscreen", opts->fullscreen);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "width", opts->width);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "height", opts->height);
|
2015-04-08 07:32:29 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "volume", opts->volume);
|
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "mute", opts->mute);
|
2014-12-16 09:33:08 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "lockAspectRatio", opts->lockAspectRatio);
|
2014-12-22 00:50:55 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "resampleVideo", opts->resampleVideo);
|
2015-05-06 05:43:44 +00:00
|
|
|
ConfigurationSetIntValue(&config->defaultsTable, 0, "suspendScreensaver", opts->suspendScreensaver);
|
2014-11-01 10:04:10 +00:00
|
|
|
}
|
2014-11-02 09:49:15 +00:00
|
|
|
|
2015-01-30 07:16:25 +00:00
|
|
|
// These two are basically placeholders in case the internal layout changes, e.g. for loading separate files
|
2016-01-29 08:33:56 +00:00
|
|
|
struct Configuration* mCoreConfigGetInput(struct mCoreConfig* config) {
|
2015-01-30 07:16:25 +00:00
|
|
|
return &config->configTable;
|
|
|
|
}
|
|
|
|
|
2016-01-29 08:33:56 +00:00
|
|
|
struct Configuration* mCoreConfigGetOverrides(struct mCoreConfig* config) {
|
2015-01-30 07:16:25 +00:00
|
|
|
return &config->configTable;
|
|
|
|
}
|
|
|
|
|
2016-02-09 04:43:48 +00:00
|
|
|
const struct Configuration* mCoreConfigGetOverridesConst(const struct mCoreConfig* config) {
|
|
|
|
return &config->configTable;
|
|
|
|
}
|
|
|
|
|
2016-02-05 05:58:45 +00:00
|
|
|
void mCoreConfigFreeOpts(struct mCoreOptions* opts) {
|
2014-11-02 09:49:15 +00:00
|
|
|
free(opts->bios);
|
2015-11-02 02:41:24 +00:00
|
|
|
free(opts->shader);
|
2016-01-15 22:29:19 +00:00
|
|
|
free(opts->savegamePath);
|
|
|
|
free(opts->savestatePath);
|
|
|
|
free(opts->screenshotPath);
|
|
|
|
free(opts->patchPath);
|
2014-11-02 09:49:15 +00:00
|
|
|
opts->bios = 0;
|
2015-11-02 02:41:24 +00:00
|
|
|
opts->shader = 0;
|
2016-01-15 22:29:19 +00:00
|
|
|
opts->savegamePath = 0;
|
|
|
|
opts->savestatePath = 0;
|
|
|
|
opts->screenshotPath = 0;
|
|
|
|
opts->patchPath = 0;
|
2014-11-02 09:49:15 +00:00
|
|
|
}
|