2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2016-10-12 09:32:24 +00:00
|
|
|
#include <algorithm>
|
2014-06-19 19:38:54 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
2016-10-12 09:32:24 +00:00
|
|
|
#include <functional>
|
2018-09-01 20:57:20 +00:00
|
|
|
#include <set>
|
2014-06-19 19:38:54 +00:00
|
|
|
|
2013-05-08 13:22:45 +00:00
|
|
|
#include "base/display.h"
|
2013-08-20 13:41:19 +00:00
|
|
|
#include "base/NativeApp.h"
|
2013-11-26 13:04:29 +00:00
|
|
|
#include "file/ini_file.h"
|
|
|
|
#include "i18n/i18n.h"
|
2018-04-15 18:24:10 +00:00
|
|
|
#include "json/json_reader.h"
|
2013-11-26 13:04:29 +00:00
|
|
|
#include "gfx_es2/gpu_features.h"
|
|
|
|
#include "net/http_client.h"
|
|
|
|
#include "util/text/parsers.h"
|
2014-02-10 01:15:00 +00:00
|
|
|
#include "net/url.h"
|
2013-11-26 13:04:29 +00:00
|
|
|
|
|
|
|
#include "Common/CPUDetect.h"
|
2013-04-13 19:24:07 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2017-12-11 07:46:36 +00:00
|
|
|
#include "Common/KeyMap.h"
|
2017-03-06 10:44:35 +00:00
|
|
|
#include "Common/LogManager.h"
|
2017-12-11 07:46:36 +00:00
|
|
|
#include "Common/OSVersion.h"
|
|
|
|
#include "Common/StringUtils.h"
|
|
|
|
#include "Common/Vulkan/VulkanLoader.h"
|
2014-12-01 07:54:22 +00:00
|
|
|
#include "Core/Config.h"
|
2018-06-17 01:42:31 +00:00
|
|
|
#include "Core/ConfigValues.h"
|
2014-12-01 07:54:22 +00:00
|
|
|
#include "Core/Loaders.h"
|
2017-12-11 07:46:36 +00:00
|
|
|
#include "Core/HLE/sceUtility.h"
|
2015-02-09 22:10:57 +00:00
|
|
|
#include "GPU/Common/FramebufferCommon.h"
|
2013-11-26 13:04:29 +00:00
|
|
|
|
|
|
|
// TODO: Find a better place for this.
|
|
|
|
http::Downloader g_DownloadManager;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-24 19:03:42 +00:00
|
|
|
Config g_Config;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2015-11-03 17:34:33 +00:00
|
|
|
bool jitForcedOff;
|
|
|
|
|
2017-03-06 10:44:35 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
static const char *logSectionName = "LogDebug";
|
|
|
|
#else
|
|
|
|
static const char *logSectionName = "Log";
|
|
|
|
#endif
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
struct ConfigSetting {
|
2014-02-10 01:55:24 +00:00
|
|
|
enum Type {
|
2014-02-09 23:46:49 +00:00
|
|
|
TYPE_TERMINATOR,
|
|
|
|
TYPE_BOOL,
|
|
|
|
TYPE_INT,
|
2017-03-26 16:51:33 +00:00
|
|
|
TYPE_UINT32,
|
2014-02-10 01:08:40 +00:00
|
|
|
TYPE_FLOAT,
|
2014-02-09 23:46:49 +00:00
|
|
|
TYPE_STRING,
|
2018-06-17 05:14:41 +00:00
|
|
|
TYPE_TOUCH_POS,
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
2014-02-10 01:55:24 +00:00
|
|
|
union Value {
|
2014-02-09 23:46:49 +00:00
|
|
|
bool b;
|
|
|
|
int i;
|
2017-03-26 16:51:33 +00:00
|
|
|
uint32_t u;
|
2014-02-10 01:08:40 +00:00
|
|
|
float f;
|
2014-02-09 23:46:49 +00:00
|
|
|
const char *s;
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigTouchPos touchPos;
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
2014-02-10 01:55:24 +00:00
|
|
|
union SettingPtr {
|
|
|
|
bool *b;
|
|
|
|
int *i;
|
2017-03-26 16:51:33 +00:00
|
|
|
uint32_t *u;
|
2014-02-10 01:55:24 +00:00
|
|
|
float *f;
|
|
|
|
std::string *s;
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigTouchPos *touchPos;
|
2014-02-10 01:55:24 +00:00
|
|
|
};
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
typedef bool (*BoolDefaultCallback)();
|
|
|
|
typedef int (*IntDefaultCallback)();
|
2017-03-26 16:51:33 +00:00
|
|
|
typedef uint32_t (*Uint32DefaultCallback)();
|
2014-02-10 01:08:40 +00:00
|
|
|
typedef float (*FloatDefaultCallback)();
|
|
|
|
typedef const char *(*StringDefaultCallback)();
|
2018-06-17 05:14:41 +00:00
|
|
|
typedef ConfigTouchPos (*TouchPosDefaultCallback)();
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2014-02-10 01:55:24 +00:00
|
|
|
union Callback {
|
|
|
|
BoolDefaultCallback b;
|
|
|
|
IntDefaultCallback i;
|
2017-03-26 16:51:33 +00:00
|
|
|
Uint32DefaultCallback u;
|
2014-02-10 01:55:24 +00:00
|
|
|
FloatDefaultCallback f;
|
|
|
|
StringDefaultCallback s;
|
2018-06-17 05:14:41 +00:00
|
|
|
TouchPosDefaultCallback touchPos;
|
2014-02-10 01:55:24 +00:00
|
|
|
};
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting(bool v)
|
2014-12-14 19:33:20 +00:00
|
|
|
: ini_(""), type_(TYPE_TERMINATOR), report_(false), save_(false), perGame_(false) {
|
2017-03-26 16:51:33 +00:00
|
|
|
ptr_.b = nullptr;
|
|
|
|
cb_.b = nullptr;
|
2014-02-09 23:46:49 +00:00
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, bool *v, bool def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_BOOL), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.b = v;
|
2017-03-26 16:51:33 +00:00
|
|
|
cb_.b = nullptr;
|
2014-02-09 23:46:49 +00:00
|
|
|
default_.b = def;
|
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, int *v, int def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.i = v;
|
2017-03-26 16:51:33 +00:00
|
|
|
cb_.i = nullptr;
|
2014-02-09 23:46:49 +00:00
|
|
|
default_.i = def;
|
|
|
|
}
|
|
|
|
|
2019-06-22 19:15:31 +00:00
|
|
|
ConfigSetting(const char *ini, int *v, int def, std::function<std::string(int)> transTo, std::function<int(const std::string &)> transFrom, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame), translateTo_(transTo), translateFrom_(transFrom) {
|
|
|
|
ptr_.i = v;
|
|
|
|
cb_.i = nullptr;
|
|
|
|
default_.i = def;
|
|
|
|
}
|
|
|
|
|
2017-03-26 16:51:33 +00:00
|
|
|
ConfigSetting(const char *ini, uint32_t *v, uint32_t def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_UINT32), report_(false), save_(save), perGame_(perGame) {
|
|
|
|
ptr_.u = v;
|
|
|
|
cb_.u = nullptr;
|
|
|
|
default_.u = def;
|
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, float *v, float def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.f = v;
|
2017-03-26 16:51:33 +00:00
|
|
|
cb_.f = nullptr;
|
2014-02-10 01:08:40 +00:00
|
|
|
default_.f = def;
|
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, std::string *v, const char *def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_STRING), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.s = v;
|
2017-03-26 16:51:33 +00:00
|
|
|
cb_.s = nullptr;
|
2014-02-09 23:46:49 +00:00
|
|
|
default_.s = def;
|
|
|
|
}
|
|
|
|
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, ConfigTouchPos def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), report_(false), save_(save), perGame_(perGame) {
|
|
|
|
ptr_.touchPos = v;
|
|
|
|
cb_.touchPos = nullptr;
|
|
|
|
default_.touchPos = def;
|
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, bool *v, BoolDefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_BOOL), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.b = v;
|
|
|
|
cb_.b = def;
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame) {
|
2017-03-26 16:51:33 +00:00
|
|
|
ptr_ .i = v;
|
2014-02-10 01:55:24 +00:00
|
|
|
cb_.i = def;
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2019-06-22 19:15:31 +00:00
|
|
|
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, std::function<std::string(int)> transTo, std::function<int(const std::string &)> transFrom, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), perGame_(perGame), translateTo_(transTo), translateFrom_(transFrom) {
|
|
|
|
ptr_.i = v;
|
|
|
|
cb_.i = def;
|
|
|
|
}
|
|
|
|
|
2017-03-26 16:51:33 +00:00
|
|
|
ConfigSetting(const char *ini, uint32_t *v, Uint32DefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_UINT32), report_(false), save_(save), perGame_(perGame) {
|
|
|
|
ptr_ .u = v;
|
|
|
|
cb_.u = def;
|
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, float *v, FloatDefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.f = v;
|
|
|
|
cb_.f = def;
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting(const char *ini, std::string *v, StringDefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(ini), type_(TYPE_STRING), report_(false), save_(save), perGame_(perGame) {
|
2014-02-10 01:55:24 +00:00
|
|
|
ptr_.s = v;
|
|
|
|
cb_.s = def;
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, TouchPosDefaultCallback def, bool save = true, bool perGame = false)
|
|
|
|
: ini_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), report_(false), save_(save), perGame_(perGame) {
|
|
|
|
ptr_.touchPos = v;
|
|
|
|
cb_.touchPos = def;
|
|
|
|
}
|
|
|
|
|
2014-12-03 20:16:11 +00:00
|
|
|
bool HasMore() const {
|
2014-02-09 23:46:49 +00:00
|
|
|
return type_ != TYPE_TERMINATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Get(IniFile::Section *section) {
|
|
|
|
switch (type_) {
|
|
|
|
case TYPE_BOOL:
|
2014-02-10 01:55:24 +00:00
|
|
|
if (cb_.b) {
|
|
|
|
default_.b = cb_.b();
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Get(ini_, ptr_.b, default_.b);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_INT:
|
2014-02-10 01:55:24 +00:00
|
|
|
if (cb_.i) {
|
|
|
|
default_.i = cb_.i();
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
2019-06-22 19:15:31 +00:00
|
|
|
if (translateFrom_) {
|
|
|
|
std::string value;
|
|
|
|
if (section->Get(ini_, &value, nullptr)) {
|
|
|
|
*ptr_.i = translateFrom_(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Get(ini_, ptr_.i, default_.i);
|
2017-03-26 16:51:33 +00:00
|
|
|
case TYPE_UINT32:
|
|
|
|
if (cb_.u) {
|
|
|
|
default_.u = cb_.u();
|
|
|
|
}
|
|
|
|
return section->Get(ini_, ptr_.u, default_.u);
|
2014-02-10 01:08:40 +00:00
|
|
|
case TYPE_FLOAT:
|
2014-02-10 01:55:24 +00:00
|
|
|
if (cb_.f) {
|
|
|
|
default_.f = cb_.f();
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Get(ini_, ptr_.f, default_.f);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_STRING:
|
2014-02-10 01:55:24 +00:00
|
|
|
if (cb_.s) {
|
|
|
|
default_.s = cb_.s();
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Get(ini_, ptr_.s, default_.s);
|
2018-06-17 05:14:41 +00:00
|
|
|
case TYPE_TOUCH_POS:
|
|
|
|
if (cb_.touchPos) {
|
|
|
|
default_.touchPos = cb_.touchPos();
|
|
|
|
}
|
|
|
|
section->Get(ini_, &ptr_.touchPos->x, default_.touchPos.x);
|
|
|
|
section->Get(ini2_, &ptr_.touchPos->y, default_.touchPos.y);
|
|
|
|
section->Get(ini3_, &ptr_.touchPos->scale, default_.touchPos.scale);
|
|
|
|
if (ini4_) {
|
|
|
|
section->Get(ini4_, &ptr_.touchPos->show, default_.touchPos.show);
|
|
|
|
} else {
|
|
|
|
ptr_.touchPos->show = default_.touchPos.show;
|
|
|
|
}
|
|
|
|
return true;
|
2014-02-09 23:46:49 +00:00
|
|
|
default:
|
|
|
|
_dbg_assert_msg_(LOADER, false, "Unexpected ini setting type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Set(IniFile::Section *section) {
|
|
|
|
if (!save_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type_) {
|
|
|
|
case TYPE_BOOL:
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Set(ini_, *ptr_.b);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_INT:
|
2019-06-22 19:15:31 +00:00
|
|
|
if (translateTo_) {
|
|
|
|
std::string value = translateTo_(*ptr_.i);
|
|
|
|
return section->Set(ini_, value);
|
|
|
|
}
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Set(ini_, *ptr_.i);
|
2017-03-26 16:51:33 +00:00
|
|
|
case TYPE_UINT32:
|
|
|
|
return section->Set(ini_, *ptr_.u);
|
2014-02-10 01:08:40 +00:00
|
|
|
case TYPE_FLOAT:
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Set(ini_, *ptr_.f);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_STRING:
|
2014-02-10 01:55:24 +00:00
|
|
|
return section->Set(ini_, *ptr_.s);
|
2018-06-17 05:14:41 +00:00
|
|
|
case TYPE_TOUCH_POS:
|
|
|
|
section->Set(ini_, ptr_.touchPos->x);
|
|
|
|
section->Set(ini2_, ptr_.touchPos->y);
|
|
|
|
section->Set(ini3_, ptr_.touchPos->scale);
|
|
|
|
if (ini4_) {
|
|
|
|
section->Set(ini4_, ptr_.touchPos->show);
|
|
|
|
}
|
|
|
|
return;
|
2014-02-09 23:46:49 +00:00
|
|
|
default:
|
|
|
|
_dbg_assert_msg_(LOADER, false, "Unexpected ini setting type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:15:00 +00:00
|
|
|
void Report(UrlEncoder &data, const std::string &prefix) {
|
|
|
|
if (!report_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (type_) {
|
|
|
|
case TYPE_BOOL:
|
2014-02-10 01:55:24 +00:00
|
|
|
return data.Add(prefix + ini_, *ptr_.b);
|
2014-02-10 01:15:00 +00:00
|
|
|
case TYPE_INT:
|
2014-02-10 01:55:24 +00:00
|
|
|
return data.Add(prefix + ini_, *ptr_.i);
|
2017-03-26 16:51:33 +00:00
|
|
|
case TYPE_UINT32:
|
|
|
|
return data.Add(prefix + ini_, *ptr_.u);
|
2014-02-10 01:15:00 +00:00
|
|
|
case TYPE_FLOAT:
|
2014-02-10 01:55:24 +00:00
|
|
|
return data.Add(prefix + ini_, *ptr_.f);
|
2014-02-10 01:15:00 +00:00
|
|
|
case TYPE_STRING:
|
2014-02-10 01:55:24 +00:00
|
|
|
return data.Add(prefix + ini_, *ptr_.s);
|
2018-06-17 05:14:41 +00:00
|
|
|
case TYPE_TOUCH_POS:
|
|
|
|
// Doesn't report.
|
|
|
|
return;
|
2014-02-10 01:15:00 +00:00
|
|
|
default:
|
|
|
|
_dbg_assert_msg_(LOADER, false, "Unexpected ini setting type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
const char *ini_;
|
2018-06-17 05:14:41 +00:00
|
|
|
const char *ini2_;
|
|
|
|
const char *ini3_;
|
|
|
|
const char *ini4_;
|
2014-02-09 23:46:49 +00:00
|
|
|
Type type_;
|
|
|
|
bool report_;
|
|
|
|
bool save_;
|
2014-12-14 19:33:20 +00:00
|
|
|
bool perGame_;
|
2014-02-10 01:55:24 +00:00
|
|
|
SettingPtr ptr_;
|
2014-02-09 23:46:49 +00:00
|
|
|
Value default_;
|
2014-02-10 01:55:24 +00:00
|
|
|
Callback cb_;
|
2019-06-22 19:15:31 +00:00
|
|
|
|
|
|
|
// We only support transform for ints.
|
|
|
|
std::function<std::string(int)> translateTo_;
|
|
|
|
std::function<int(const std::string &)> translateFrom_;
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportedConfigSetting : public ConfigSetting {
|
2014-02-10 01:08:40 +00:00
|
|
|
template <typename T1, typename T2>
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting(const char *ini, T1 *v, T2 def, bool save = true, bool perGame = false)
|
|
|
|
: ConfigSetting(ini, v, def, save, perGame) {
|
2014-02-09 23:46:49 +00:00
|
|
|
report_ = true;
|
|
|
|
}
|
2019-06-22 19:15:31 +00:00
|
|
|
|
|
|
|
template <typename T1, typename T2>
|
|
|
|
ReportedConfigSetting(const char *ini, T1 *v, T2 def, std::function<std::string(int)> transTo, std::function<int(const std::string &)> transFrom, bool save = true, bool perGame = false)
|
|
|
|
: ConfigSetting(ini, v, def, transTo, transFrom, save, perGame) {
|
|
|
|
report_ = true;
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
const char *DefaultLangRegion() {
|
2015-12-26 03:15:03 +00:00
|
|
|
// Unfortunate default. There's no need to use bFirstRun, since this is only a default.
|
2014-02-10 01:08:40 +00:00
|
|
|
static std::string defaultLangRegion = "en_US";
|
2015-12-26 03:15:03 +00:00
|
|
|
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
|
|
|
|
if (i18nrepo.IniExists(langRegion)) {
|
|
|
|
defaultLangRegion = langRegion;
|
|
|
|
} else if (langRegion.length() >= 3) {
|
|
|
|
// Don't give up. Let's try a fuzzy match - so nl_BE can match nl_NL.
|
|
|
|
IniFile mapping;
|
|
|
|
mapping.LoadFromVFS("langregion.ini");
|
|
|
|
std::vector<std::string> keys;
|
|
|
|
mapping.GetKeys("LangRegionNames", keys);
|
|
|
|
|
|
|
|
for (std::string key : keys) {
|
|
|
|
if (startsWithNoCase(key, langRegion)) {
|
|
|
|
// Exact submatch, or different case. Let's use it.
|
|
|
|
defaultLangRegion = key;
|
|
|
|
break;
|
|
|
|
} else if (startsWithNoCase(key, langRegion.substr(0, 3))) {
|
|
|
|
// Best so far.
|
|
|
|
defaultLangRegion = key;
|
|
|
|
}
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
return defaultLangRegion.c_str();
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2017-04-29 19:48:06 +00:00
|
|
|
std::string CreateRandMAC() {
|
2014-06-29 21:41:33 +00:00
|
|
|
std::stringstream randStream;
|
2014-11-25 19:58:03 +00:00
|
|
|
srand(time(nullptr));
|
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
u32 value = rand() % 256;
|
|
|
|
if (value <= 15)
|
2014-11-13 15:57:16 +00:00
|
|
|
randStream << '0' << std::hex << value;
|
2014-11-13 14:13:57 +00:00
|
|
|
else
|
|
|
|
randStream << std::hex << value;
|
2014-11-25 19:58:03 +00:00
|
|
|
if (i < 5) {
|
2014-06-29 23:08:45 +00:00
|
|
|
randStream << ':'; //we need a : between every octet
|
|
|
|
}
|
|
|
|
}
|
2017-04-29 19:48:06 +00:00
|
|
|
return randStream.str();
|
2014-06-29 21:41:33 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static int DefaultNumWorkers() {
|
|
|
|
return cpu_info.num_cores;
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2016-05-07 23:43:27 +00:00
|
|
|
static int DefaultCpuCore() {
|
2018-01-02 02:51:18 +00:00
|
|
|
#if defined(ARM) || defined(ARM64) || defined(_M_IX86) || defined(_M_X64)
|
2017-03-02 11:36:54 +00:00
|
|
|
return (int)CPUCore::JIT;
|
2016-05-07 23:43:27 +00:00
|
|
|
#else
|
2017-03-02 12:29:51 +00:00
|
|
|
return (int)CPUCore::INTERPRETER;
|
2016-05-07 23:43:27 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool DefaultCodeGen() {
|
2018-01-02 02:51:18 +00:00
|
|
|
#if defined(ARM) || defined(ARM64) || defined(_M_IX86) || defined(_M_X64)
|
2014-02-10 01:08:40 +00:00
|
|
|
return true;
|
2014-11-13 15:41:30 +00:00
|
|
|
#else
|
|
|
|
return false;
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2018-03-18 06:13:20 +00:00
|
|
|
static bool DefaultEnableStateUndo() {
|
|
|
|
#ifdef MOBILE_DEVICE
|
|
|
|
// Off on mobile to save disk space.
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
struct ConfigSectionSettings {
|
|
|
|
const char *section;
|
|
|
|
ConfigSetting *settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting generalSettings[] = {
|
|
|
|
ConfigSetting("FirstRun", &g_Config.bFirstRun, true),
|
|
|
|
ConfigSetting("RunCount", &g_Config.iRunCount, 0),
|
|
|
|
ConfigSetting("Enable Logging", &g_Config.bEnableLogging, true),
|
|
|
|
ConfigSetting("AutoRun", &g_Config.bAutoRun, true),
|
|
|
|
ConfigSetting("Browse", &g_Config.bBrowse, false),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("IgnoreBadMemAccess", &g_Config.bIgnoreBadMemAccess, true, true),
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting("CurrentDirectory", &g_Config.currentDirectory, ""),
|
|
|
|
ConfigSetting("ShowDebuggerOnLoad", &g_Config.bShowDebuggerOnLoad, false),
|
|
|
|
ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion),
|
2019-02-25 14:50:07 +00:00
|
|
|
ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, true, true),
|
2018-08-12 22:08:56 +00:00
|
|
|
ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, true, true, false), // Or maybe it makes sense to have it per-game? Race conditions abound...
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true),
|
2018-06-21 08:00:57 +00:00
|
|
|
ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, true, true),
|
2015-01-26 23:50:50 +00:00
|
|
|
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, true, true),
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, true, true),
|
2016-08-27 18:38:05 +00:00
|
|
|
ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false),
|
|
|
|
ConfigSetting("DumpFrames", &g_Config.bDumpFrames, false),
|
2019-06-03 10:21:22 +00:00
|
|
|
ConfigSetting("DumpVideoOutput", &g_Config.bDumpVideoOutput, false),
|
2016-09-03 14:06:40 +00:00
|
|
|
ConfigSetting("DumpAudio", &g_Config.bDumpAudio, false),
|
2017-11-14 04:12:27 +00:00
|
|
|
ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true),
|
2018-03-18 06:13:20 +00:00
|
|
|
ConfigSetting("EnableStateUndo", &g_Config.bEnableStateUndo, &DefaultEnableStateUndo, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),
|
2014-02-09 23:46:49 +00:00
|
|
|
|
|
|
|
ConfigSetting("GridView1", &g_Config.bGridView1, true),
|
|
|
|
ConfigSetting("GridView2", &g_Config.bGridView2, true),
|
|
|
|
ConfigSetting("GridView3", &g_Config.bGridView3, false),
|
2015-06-28 05:34:05 +00:00
|
|
|
ConfigSetting("ComboMode", &g_Config.iComboMode, 0),
|
2014-02-09 23:46:49 +00:00
|
|
|
|
|
|
|
// "default" means let emulator decide, "" means disable.
|
|
|
|
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default"),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("AutoSaveSymbolMap", &g_Config.bAutoSaveSymbolMap, false, true, true),
|
|
|
|
ConfigSetting("CacheFullIsoInRam", &g_Config.bCacheFullIsoInRam, false, true, true),
|
2016-07-04 04:09:17 +00:00
|
|
|
ConfigSetting("RemoteISOPort", &g_Config.iRemoteISOPort, 0, true, false),
|
2017-02-14 02:18:14 +00:00
|
|
|
ConfigSetting("LastRemoteISOServer", &g_Config.sLastRemoteISOServer, ""),
|
|
|
|
ConfigSetting("LastRemoteISOPort", &g_Config.iLastRemoteISOPort, 0),
|
2017-02-22 01:45:58 +00:00
|
|
|
ConfigSetting("RemoteISOManualConfig", &g_Config.bRemoteISOManual, false),
|
2017-12-11 02:30:28 +00:00
|
|
|
ConfigSetting("RemoteShareOnStartup", &g_Config.bRemoteShareOnStartup, false),
|
2017-02-22 01:45:58 +00:00
|
|
|
ConfigSetting("RemoteISOSubdir", &g_Config.sRemoteISOSubdir, "/"),
|
2018-04-21 20:54:44 +00:00
|
|
|
ConfigSetting("RemoteDebuggerOnStartup", &g_Config.bRemoteDebuggerOnStartup, false),
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2016-10-12 09:13:16 +00:00
|
|
|
#ifdef __ANDROID__
|
2019-02-23 16:17:40 +00:00
|
|
|
ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, ROTATION_AUTO_HORIZONTAL),
|
2014-02-09 23:46:49 +00:00
|
|
|
#endif
|
2018-06-17 02:20:23 +00:00
|
|
|
ConfigSetting("InternalScreenRotation", &g_Config.iInternalScreenRotation, ROTATION_LOCKED_HORIZONTAL),
|
2014-02-09 23:46:49 +00:00
|
|
|
|
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
ConfigSetting("TopMost", &g_Config.bTopMost, false),
|
|
|
|
ConfigSetting("WindowX", &g_Config.iWindowX, -1), // -1 tells us to center the window.
|
|
|
|
ConfigSetting("WindowY", &g_Config.iWindowY, -1),
|
|
|
|
ConfigSetting("WindowWidth", &g_Config.iWindowWidth, 0), // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
|
|
|
|
ConfigSetting("WindowHeight", &g_Config.iWindowHeight, 0),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("PauseOnLostFocus", &g_Config.bPauseOnLostFocus, false, true, true),
|
2014-02-09 23:46:49 +00:00
|
|
|
#endif
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("PauseWhenMinimized", &g_Config.bPauseWhenMinimized, false, true, true),
|
|
|
|
ConfigSetting("DumpDecryptedEboots", &g_Config.bDumpDecryptedEboot, false, true, true),
|
2015-10-14 15:45:21 +00:00
|
|
|
ConfigSetting("FullscreenOnDoubleclick", &g_Config.bFullscreenOnDoubleclick, true, false, false),
|
2016-07-04 04:09:17 +00:00
|
|
|
|
2016-08-06 04:27:53 +00:00
|
|
|
ReportedConfigSetting("MemStickInserted", &g_Config.bMemStickInserted, true, true, true),
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
2015-11-15 19:27:40 +00:00
|
|
|
static bool DefaultSasThread() {
|
|
|
|
return cpu_info.num_cores > 1;
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static ConfigSetting cpuSettings[] = {
|
2016-05-07 23:43:27 +00:00
|
|
|
ReportedConfigSetting("CPUCore", &g_Config.iCpuCore, &DefaultCpuCore, true, true),
|
2015-11-15 19:27:40 +00:00
|
|
|
ReportedConfigSetting("SeparateSASThread", &g_Config.bSeparateSASThread, &DefaultSasThread, true, true),
|
2014-12-26 03:02:49 +00:00
|
|
|
ReportedConfigSetting("IOTimingMethod", &g_Config.iIOTimingMethod, IOTIMING_FAST, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("FastMemoryAccess", &g_Config.bFastMemory, true, true, true),
|
|
|
|
ReportedConfigSetting("FuncReplacements", &g_Config.bFuncReplacements, true, true, true),
|
2017-04-14 15:11:16 +00:00
|
|
|
ConfigSetting("HideSlowWarnings", &g_Config.bHideSlowWarnings, false, true, false),
|
2018-06-19 14:12:33 +00:00
|
|
|
ConfigSetting("HideStateWarnings", &g_Config.bHideStateWarnings, false, true, false),
|
2018-01-07 00:43:38 +00:00
|
|
|
ConfigSetting("PreloadFunctions", &g_Config.bPreloadFunctions, false, true, true),
|
2019-02-03 21:58:24 +00:00
|
|
|
ConfigSetting("JitDisableFlags", &g_Config.uJitDisableFlags, (uint32_t)0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("CPUSpeed", &g_Config.iLockedCPUSpeed, 0, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int DefaultInternalResolution() {
|
|
|
|
// Auto on Windows, 2x on large screens, 1x elsewhere.
|
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
return 0;
|
|
|
|
#else
|
2015-04-03 16:20:56 +00:00
|
|
|
int longestDisplaySide = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES));
|
2017-11-26 13:49:00 +00:00
|
|
|
int scale = longestDisplaySide >= 1000 ? 2 : 1;
|
|
|
|
ILOG("Longest display side: %d pixels. Choosing scale %d", longestDisplaySide, scale);
|
|
|
|
return scale;
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-03-09 13:16:51 +00:00
|
|
|
static bool DefaultFrameskipUnthrottle() {
|
|
|
|
#if !PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(UWP)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-12-21 05:32:05 +00:00
|
|
|
static int DefaultZoomType() {
|
2018-06-17 02:20:23 +00:00
|
|
|
return (int)SmallDisplayZoom::AUTO;
|
2015-12-21 05:32:05 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 22:35:36 +00:00
|
|
|
static int DefaultAndroidHwScale() {
|
2016-10-12 09:13:16 +00:00
|
|
|
#ifdef __ANDROID__
|
2018-10-06 11:43:11 +00:00
|
|
|
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19 || System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
|
2018-09-16 19:05:13 +00:00
|
|
|
// Arbitrary cutoff at Kitkat - modern devices are usually powerful enough that hw scaling
|
|
|
|
// doesn't really help very much and mostly causes problems. See #11151
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-20 22:35:36 +00:00
|
|
|
// Get the real resolution as passed in during startup, not dp_xres and stuff
|
|
|
|
int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
|
|
|
|
int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);
|
|
|
|
|
2016-03-17 21:22:57 +00:00
|
|
|
if (xres <= 960) {
|
2014-07-20 22:35:36 +00:00
|
|
|
// Smaller than the PSP*2, let's go native.
|
|
|
|
return 0;
|
|
|
|
} else if (xres <= 480 * 3) { // 720p xres
|
|
|
|
// Small-ish screen, we should default to 2x
|
|
|
|
return 2 + 1;
|
|
|
|
} else {
|
|
|
|
// Large or very large screen. Default to 3x psp resolution.
|
|
|
|
return 3 + 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-12-11 07:46:36 +00:00
|
|
|
static int DefaultGPUBackend() {
|
|
|
|
#if PPSSPP_PLATFORM(WINDOWS)
|
|
|
|
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
|
|
|
|
if (DoesVersionMatchWindows(6, 2, 0, 0, true)) {
|
2017-12-26 23:55:24 +00:00
|
|
|
return (int)GPUBackend::DIRECT3D11;
|
2017-12-11 07:46:36 +00:00
|
|
|
}
|
2019-08-23 15:14:11 +00:00
|
|
|
#elif PPSSPP_PLATFORM(ANDROID)
|
2019-09-02 19:42:07 +00:00
|
|
|
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer. Drivers before
|
2019-08-23 15:14:11 +00:00
|
|
|
// were generally too unreliable to default to (with some exceptions, of course).
|
2019-09-02 19:42:07 +00:00
|
|
|
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) {
|
2019-08-23 15:14:11 +00:00
|
|
|
return (int)GPUBackend::VULKAN;
|
|
|
|
}
|
2019-08-24 07:56:19 +00:00
|
|
|
#endif
|
2019-08-23 15:14:11 +00:00
|
|
|
// TODO: On some additional Linux platforms, we should also default to Vulkan.
|
2017-12-26 23:55:24 +00:00
|
|
|
return (int)GPUBackend::OPENGL;
|
2017-12-11 07:46:36 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 20:57:20 +00:00
|
|
|
int Config::NextValidBackend() {
|
|
|
|
std::vector<std::string> split;
|
2019-06-22 18:48:36 +00:00
|
|
|
std::set<GPUBackend> failed;
|
|
|
|
|
2018-09-01 20:57:20 +00:00
|
|
|
SplitString(sFailedGPUBackends, ',', split);
|
|
|
|
for (const auto &str : split) {
|
|
|
|
if (!str.empty() && str != "ALL") {
|
2019-06-22 18:48:36 +00:00
|
|
|
failed.insert(GPUBackendFromString(str));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Count these as "failed" too so we don't pick them.
|
|
|
|
SplitString(sDisabledGPUBackends, ',', split);
|
|
|
|
for (const auto &str : split) {
|
|
|
|
if (!str.empty()) {
|
|
|
|
failed.insert(GPUBackendFromString(str));
|
2018-09-01 20:57:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-22 18:48:36 +00:00
|
|
|
if (failed.count((GPUBackend)iGPUBackend)) {
|
2018-09-06 06:13:15 +00:00
|
|
|
ERROR_LOG(LOADER, "Graphics backend failed for %d, trying another", iGPUBackend);
|
|
|
|
|
2018-09-01 20:57:20 +00:00
|
|
|
#if (PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID)) && !PPSSPP_PLATFORM(UWP)
|
2019-06-22 18:48:36 +00:00
|
|
|
if (!failed.count(GPUBackend::VULKAN) && VulkanMayBeAvailable()) {
|
2018-09-01 20:57:20 +00:00
|
|
|
return (int)GPUBackend::VULKAN;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if PPSSPP_PLATFORM(WINDOWS)
|
2019-06-22 18:48:36 +00:00
|
|
|
if (!failed.count(GPUBackend::DIRECT3D11) && DoesVersionMatchWindows(6, 1, 0, 0, true)) {
|
2018-09-01 20:57:20 +00:00
|
|
|
return (int)GPUBackend::DIRECT3D11;
|
|
|
|
}
|
|
|
|
#endif
|
2019-05-10 21:25:57 +00:00
|
|
|
#if PPSSPP_API(ANY_GL)
|
2019-06-22 18:48:36 +00:00
|
|
|
if (!failed.count(GPUBackend::OPENGL)) {
|
2018-09-01 20:57:20 +00:00
|
|
|
return (int)GPUBackend::OPENGL;
|
|
|
|
}
|
|
|
|
#endif
|
2019-05-11 04:36:28 +00:00
|
|
|
#if PPSSPP_API(D3D9)
|
2019-06-22 18:48:36 +00:00
|
|
|
if (!failed.count(GPUBackend::DIRECT3D9)) {
|
2018-09-01 20:57:20 +00:00
|
|
|
return (int)GPUBackend::DIRECT3D9;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-02 19:42:07 +00:00
|
|
|
// They've all failed. Let them try the default - or on Android, OpenGL.
|
2018-09-01 20:57:20 +00:00
|
|
|
sFailedGPUBackends += ",ALL";
|
2018-09-06 06:13:15 +00:00
|
|
|
ERROR_LOG(LOADER, "All graphics backends failed");
|
2019-09-02 19:42:07 +00:00
|
|
|
#if PPSSPP_PLATFORM(ANDROID)
|
|
|
|
return (int)GPUBackend::OPENGL;
|
|
|
|
#else
|
2018-09-01 20:57:20 +00:00
|
|
|
return DefaultGPUBackend();
|
2019-09-02 19:42:07 +00:00
|
|
|
#endif
|
2018-09-01 20:57:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return iGPUBackend;
|
|
|
|
}
|
|
|
|
|
2019-06-22 18:48:36 +00:00
|
|
|
bool Config::IsBackendEnabled(GPUBackend backend, bool validate) {
|
|
|
|
std::vector<std::string> split;
|
|
|
|
|
|
|
|
SplitString(sDisabledGPUBackends, ',', split);
|
|
|
|
for (const auto &str : split) {
|
|
|
|
if (str.empty())
|
|
|
|
continue;
|
|
|
|
auto match = GPUBackendFromString(str);
|
|
|
|
if (match == backend)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if PPSSPP_PLATFORM(IOS)
|
|
|
|
if (backend != GPUBackend::OPENGL)
|
|
|
|
return false;
|
|
|
|
#elif PPSSPP_PLATFORM(UWP)
|
|
|
|
if (backend != GPUBackend::DIRECT3D11)
|
|
|
|
return false;
|
|
|
|
#elif PPSSPP_PLATFORM(WINDOWS)
|
|
|
|
if (validate) {
|
|
|
|
if (backend == GPUBackend::DIRECT3D11 && !DoesVersionMatchWindows(6, 0, 0, 0, true))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (backend == GPUBackend::DIRECT3D11 || backend == GPUBackend::DIRECT3D9)
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !PPSSPP_API(ANY_GL)
|
|
|
|
if (backend == GPUBackend::OPENGL)
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
#if !PPSSPP_PLATFORM(IOS)
|
|
|
|
if (validate) {
|
|
|
|
if (backend == GPUBackend::VULKAN && !VulkanMayBeAvailable())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-11 07:46:36 +00:00
|
|
|
static bool DefaultVertexCache() {
|
2017-12-26 23:55:24 +00:00
|
|
|
return DefaultGPUBackend() == (int)GPUBackend::OPENGL;
|
2017-12-11 07:46:36 +00:00
|
|
|
}
|
|
|
|
|
2019-06-22 19:15:31 +00:00
|
|
|
template <typename T, std::string (*FTo)(T), T (*FFrom)(const std::string &)>
|
|
|
|
struct ConfigTranslator {
|
|
|
|
static std::string To(int v) {
|
2019-06-22 19:36:17 +00:00
|
|
|
return StringFromInt(v) + " (" + FTo(T(v)) + ")";
|
2019-06-22 19:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int From(const std::string &v) {
|
2019-06-22 19:36:17 +00:00
|
|
|
int result;
|
|
|
|
if (TryParse(v, &result)) {
|
|
|
|
return result;
|
|
|
|
}
|
2019-06-22 19:15:31 +00:00
|
|
|
return (int)FFrom(v);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef ConfigTranslator<GPUBackend, GPUBackendToString, GPUBackendFromString> GPUBackendTranslator;
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static ConfigSetting graphicsSettings[] = {
|
2019-10-25 09:01:49 +00:00
|
|
|
ConfigSetting("EnableCardboardVR", &g_Config.bEnableCardboardVR, false, true, true),
|
2019-10-25 08:34:08 +00:00
|
|
|
ConfigSetting("CardboardScreenSize", &g_Config.iCardboardScreenSize, 50, true, true),
|
|
|
|
ConfigSetting("CardboardXShift", &g_Config.iCardboardXShift, 0, true, true),
|
|
|
|
ConfigSetting("CardboardYShift", &g_Config.iCardboardXShift, 0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0, true, true),
|
2019-06-22 19:15:31 +00:00
|
|
|
ReportedConfigSetting("GraphicsBackend", &g_Config.iGPUBackend, &DefaultGPUBackend, &GPUBackendTranslator::To, &GPUBackendTranslator::From, true, false),
|
2018-09-01 20:57:20 +00:00
|
|
|
ConfigSetting("FailedGraphicsBackends", &g_Config.sFailedGPUBackends, ""),
|
2019-06-22 18:48:36 +00:00
|
|
|
ConfigSetting("DisabledGraphicsBackends", &g_Config.sDisabledGPUBackends, ""),
|
2018-06-06 08:24:16 +00:00
|
|
|
ConfigSetting("VulkanDevice", &g_Config.sVulkanDevice, "", true, false),
|
2018-04-15 08:53:07 +00:00
|
|
|
#ifdef _WIN32
|
2018-06-06 08:24:16 +00:00
|
|
|
ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", true, false),
|
2020-01-14 09:15:11 +00:00
|
|
|
#endif
|
2020-01-09 13:57:09 +00:00
|
|
|
ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", true, false),
|
2018-12-15 09:44:05 +00:00
|
|
|
ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false),
|
2019-09-02 19:42:49 +00:00
|
|
|
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true),
|
2017-05-24 18:53:00 +00:00
|
|
|
ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true),
|
2018-04-10 10:22:02 +00:00
|
|
|
ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("TextureFiltering", &g_Config.iTexFiltering, 1, true, true),
|
2018-06-17 02:20:23 +00:00
|
|
|
ReportedConfigSetting("BufferFiltering", &g_Config.iBufFilter, SCALE_LINEAR, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("InternalResolution", &g_Config.iInternalResolution, &DefaultInternalResolution, true, true),
|
2014-07-20 22:35:36 +00:00
|
|
|
ReportedConfigSetting("AndroidHwScale", &g_Config.iAndroidHwScale, &DefaultAndroidHwScale),
|
2016-01-21 06:00:07 +00:00
|
|
|
ReportedConfigSetting("HighQualityDepth", &g_Config.bHighQualityDepth, true, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0, true, true),
|
2018-11-03 01:33:41 +00:00
|
|
|
ReportedConfigSetting("FrameSkipType", &g_Config.iFrameSkipType, 0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true),
|
2018-06-17 03:07:11 +00:00
|
|
|
ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true),
|
|
|
|
ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, true, true),
|
2017-03-09 13:16:51 +00:00
|
|
|
ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, &DefaultFrameskipUnthrottle, true, false),
|
2017-05-21 15:24:40 +00:00
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false),
|
|
|
|
#endif
|
2015-09-05 21:09:06 +00:00
|
|
|
|
2017-12-19 16:59:00 +00:00
|
|
|
// Most low-performance (and many high performance) mobile GPUs do not support aniso anyway so defaulting to 4 is fine.
|
2016-03-18 04:56:04 +00:00
|
|
|
ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 4, true, true),
|
2017-12-19 16:59:00 +00:00
|
|
|
|
2017-12-11 08:01:45 +00:00
|
|
|
ReportedConfigSetting("VertexDecCache", &g_Config.bVertexCache, &DefaultVertexCache, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true),
|
|
|
|
ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true),
|
2016-05-07 23:43:27 +00:00
|
|
|
ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2015-10-24 12:40:29 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting("FullScreen", &g_Config.bFullScreen, false),
|
2017-07-30 15:33:02 +00:00
|
|
|
ConfigSetting("FullScreenMulti", &g_Config.bFullScreenMulti, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-21 05:32:05 +00:00
|
|
|
ConfigSetting("SmallDisplayZoomType", &g_Config.iSmallDisplayZoomType, &DefaultZoomType, true, true),
|
2015-10-24 12:40:29 +00:00
|
|
|
ConfigSetting("SmallDisplayOffsetX", &g_Config.fSmallDisplayOffsetX, 0.5f, true, true),
|
|
|
|
ConfigSetting("SmallDisplayOffsetY", &g_Config.fSmallDisplayOffsetY, 0.5f, true, true),
|
2015-12-21 05:32:05 +00:00
|
|
|
ConfigSetting("SmallDisplayZoomLevel", &g_Config.fSmallDisplayZoomLevel, 1.0f, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),
|
2017-06-09 13:29:57 +00:00
|
|
|
ConfigSetting("SustainedPerformanceMode", &g_Config.bSustainedPerformanceMode, false, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2016-04-30 21:05:03 +00:00
|
|
|
ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true),
|
|
|
|
ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true),
|
2019-07-14 23:01:37 +00:00
|
|
|
ConfigSetting("IgnoreTextureFilenames", &g_Config.bIgnoreTextureFilenames, false, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, true, true),
|
|
|
|
ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, true, true),
|
|
|
|
ReportedConfigSetting("TexDeposterize", &g_Config.bTexDeposterize, false, true, true),
|
2019-09-30 01:10:55 +00:00
|
|
|
ReportedConfigSetting("TexHardwareScaling", &g_Config.bTexHardwareScaling, false, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("VSyncInterval", &g_Config.bVSync, false, true, true),
|
2015-01-23 01:08:20 +00:00
|
|
|
ReportedConfigSetting("BloomHack", &g_Config.iBloomHack, 0, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
// Not really a graphics setting...
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("SplineBezierQuality", &g_Config.iSplineBezierQuality, 2, true, true),
|
2017-01-06 15:14:58 +00:00
|
|
|
ReportedConfigSetting("HardwareTessellation", &g_Config.bHardwareTessellation, false, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("PostShader", &g_Config.sPostShaderName, "Off", true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("MemBlockTransferGPU", &g_Config.bBlockTransferGPU, true, true, true),
|
|
|
|
ReportedConfigSetting("DisableSlowFramebufEffects", &g_Config.bDisableSlowFramebufEffects, false, true, true),
|
|
|
|
ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true),
|
2014-05-25 08:18:14 +00:00
|
|
|
|
2015-10-11 09:46:24 +00:00
|
|
|
ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false),
|
2017-11-22 09:46:23 +00:00
|
|
|
ConfigSetting("GfxDebugSplitSubmit", &g_Config.bGfxDebugSplitSubmit, false, false, false),
|
2017-03-24 02:16:17 +00:00
|
|
|
ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false),
|
2016-07-04 04:09:17 +00:00
|
|
|
|
|
|
|
ConfigSetting(false),
|
2014-02-10 01:08:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting soundSettings[] = {
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("Enable", &g_Config.bEnableSound, true, true, true),
|
2015-01-24 12:50:27 +00:00
|
|
|
ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("AudioLatency", &g_Config.iAudioLatency, 1, true, true),
|
2016-12-01 20:35:32 +00:00
|
|
|
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, true, false),
|
2015-01-31 11:12:01 +00:00
|
|
|
ConfigSetting("AudioResampler", &g_Config.bAudioResampler, true, true, true),
|
2016-01-18 06:47:29 +00:00
|
|
|
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true),
|
2019-06-23 20:34:08 +00:00
|
|
|
ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, true, true),
|
2019-09-15 19:54:55 +00:00
|
|
|
ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", true, false),
|
2019-09-15 20:42:56 +00:00
|
|
|
ConfigSetting("AutoAudioDevice", &g_Config.bAutoAudioDevice, true, true, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool DefaultShowTouchControls() {
|
2015-04-03 09:50:03 +00:00
|
|
|
int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
|
|
|
|
if (deviceType == DEVICE_TYPE_MOBILE) {
|
|
|
|
std::string name = System_GetProperty(SYSPROP_NAME);
|
|
|
|
if (KeyMap::HasBuiltinController(name)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (deviceType == DEVICE_TYPE_TV) {
|
|
|
|
return false;
|
|
|
|
} else if (deviceType == DEVICE_TYPE_DESKTOP) {
|
2014-02-10 01:08:40 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
2015-04-03 09:50:03 +00:00
|
|
|
return false;
|
2014-02-10 01:08:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const float defaultControlScale = 1.15f;
|
2018-06-17 05:14:41 +00:00
|
|
|
static const ConfigTouchPos defaultTouchPosShow = { -1.0f, -1.0f, defaultControlScale, true };
|
|
|
|
static const ConfigTouchPos defaultTouchPosHide = { -1.0f, -1.0f, defaultControlScale, false };
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
static ConfigSetting controlSettings[] = {
|
2018-03-25 11:42:57 +00:00
|
|
|
ConfigSetting("HapticFeedback", &g_Config.bHapticFeedback, false, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ShowTouchCross", &g_Config.bShowTouchCross, true, true, true),
|
|
|
|
ConfigSetting("ShowTouchCircle", &g_Config.bShowTouchCircle, true, true, true),
|
|
|
|
ConfigSetting("ShowTouchSquare", &g_Config.bShowTouchSquare, true, true, true),
|
|
|
|
ConfigSetting("ShowTouchTriangle", &g_Config.bShowTouchTriangle, true, true, true),
|
2018-06-17 05:14:41 +00:00
|
|
|
|
2015-06-28 05:34:05 +00:00
|
|
|
ConfigSetting("ComboKey0Mapping", &g_Config.iCombokey0, 0, true, true),
|
|
|
|
ConfigSetting("ComboKey1Mapping", &g_Config.iCombokey1, 0, true, true),
|
|
|
|
ConfigSetting("ComboKey2Mapping", &g_Config.iCombokey2, 0, true, true),
|
|
|
|
ConfigSetting("ComboKey3Mapping", &g_Config.iCombokey3, 0, true, true),
|
|
|
|
ConfigSetting("ComboKey4Mapping", &g_Config.iCombokey4, 0, true, true),
|
|
|
|
|
2014-06-23 22:45:24 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
// A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes
|
|
|
|
// sense to default this to on.
|
2017-04-14 15:11:16 +00:00
|
|
|
ConfigSetting("ShowTouchPause", &g_Config.bShowTouchPause, true, true, false),
|
2014-06-23 22:45:24 +00:00
|
|
|
#else
|
2017-04-14 15:11:16 +00:00
|
|
|
ConfigSetting("ShowTouchPause", &g_Config.bShowTouchPause, false, true, false),
|
2014-02-25 06:39:10 +00:00
|
|
|
#endif
|
2014-02-10 01:08:40 +00:00
|
|
|
#if defined(USING_WIN_UI)
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("IgnoreWindowsKey", &g_Config.bIgnoreWindowsKey, false, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ShowTouchControls", &g_Config.bShowTouchControls, &DefaultShowTouchControls, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
// ConfigSetting("KeyMapping", &g_Config.iMappingMap, 0),
|
|
|
|
|
|
|
|
#ifdef MOBILE_DEVICE
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("TiltBaseX", &g_Config.fTiltBaseX, 0.0f, true, true),
|
|
|
|
ConfigSetting("TiltBaseY", &g_Config.fTiltBaseY, 0.0f, true, true),
|
|
|
|
ConfigSetting("InvertTiltX", &g_Config.bInvertTiltX, false, true, true),
|
|
|
|
ConfigSetting("InvertTiltY", &g_Config.bInvertTiltY, true, true, true),
|
|
|
|
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100, true, true),
|
|
|
|
ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 100, true, true),
|
|
|
|
ConfigSetting("DeadzoneRadius", &g_Config.fDeadzoneRadius, 0.2f, true, true),
|
|
|
|
ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false, true, true),
|
2015-02-28 22:02:03 +00:00
|
|
|
ConfigSetting("GamepadOnlyFocused", &g_Config.bGamepadOnlyFocused, false, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1, true, true),
|
|
|
|
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
|
2015-12-21 00:14:08 +00:00
|
|
|
ConfigSetting("TouchButtonHideSeconds", &g_Config.iTouchButtonHideSeconds, 20, true, true),
|
2015-03-05 09:58:25 +00:00
|
|
|
ConfigSetting("AutoCenterTouchAnalog", &g_Config.bAutoCenterTouchAnalog, false, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
2019-12-18 23:41:32 +00:00
|
|
|
// Snap touch control position
|
|
|
|
ConfigSetting("TouchSnapToGrid", &g_Config.bTouchSnapToGrid, false, true, true),
|
|
|
|
ConfigSetting("TouchSnapGridSize", &g_Config.iTouchSnapGridSize, 64, true, true),
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
// -1.0f means uninitialized, set in GamepadEmu::CreatePadLayout().
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("ActionButtonSpacing2", &g_Config.fActionButtonSpacing, 1.0f, true, true),
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigSetting("ActionButtonCenterX", "ActionButtonCenterY", "ActionButtonScale", nullptr, &g_Config.touchActionButtonCenter, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("DPadX", "DPadY", "DPadScale", "ShowTouchDpad", &g_Config.touchDpad, defaultTouchPosShow, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
// Note: these will be overwritten if DPadRadius is set.
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("DPadSpacing", &g_Config.fDpadSpacing, 1.0f, true, true),
|
2018-06-17 05:14:41 +00:00
|
|
|
ConfigSetting("StartKeyX", "StartKeyY", "StartKeyScale", "ShowTouchStart", &g_Config.touchStartKey, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("SelectKeyX", "SelectKeyY", "SelectKeyScale", "ShowTouchSelect", &g_Config.touchSelectKey, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("UnthrottleKeyX", "UnthrottleKeyY", "UnthrottleKeyScale", "ShowTouchUnthrottle", &g_Config.touchUnthrottleKey, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("LKeyX", "LKeyY", "LKeyScale", "ShowTouchLTrigger", &g_Config.touchLKey, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("RKeyX", "RKeyY", "RKeyScale", "ShowTouchRTrigger", &g_Config.touchRKey, defaultTouchPosShow, true, true),
|
|
|
|
ConfigSetting("AnalogStickX", "AnalogStickY", "AnalogStickScale", "ShowAnalogStick", &g_Config.touchAnalogStick, defaultTouchPosShow, true, true),
|
2019-07-18 01:16:46 +00:00
|
|
|
ConfigSetting("RightAnalogStickX", "RightAnalogStickY", "RightAnalogStickScale", "ShowRightAnalogStick", &g_Config.touchRightAnalogStick, defaultTouchPosHide, true, true),
|
2018-06-17 05:14:41 +00:00
|
|
|
|
|
|
|
ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCombo0, defaultTouchPosHide, true, true),
|
|
|
|
ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCombo1, defaultTouchPosHide, true, true),
|
|
|
|
ConfigSetting("fcombo2X", "fcombo2Y", "comboKeyScale2", "ShowComboKey2", &g_Config.touchCombo2, defaultTouchPosHide, true, true),
|
|
|
|
ConfigSetting("fcombo3X", "fcombo3Y", "comboKeyScale3", "ShowComboKey3", &g_Config.touchCombo3, defaultTouchPosHide, true, true),
|
|
|
|
ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCombo4, defaultTouchPosHide, true, true),
|
2018-06-17 06:00:21 +00:00
|
|
|
ConfigSetting("Speed1KeyX", "Speed1KeyY", "Speed1KeyScale", "ShowSpeed1Key", &g_Config.touchSpeed1Key, defaultTouchPosHide, true, true),
|
|
|
|
ConfigSetting("Speed2KeyX", "Speed2KeyY", "Speed2KeyScale", "ShowSpeed2Key", &g_Config.touchSpeed2Key, defaultTouchPosHide, true, true),
|
2020-01-28 07:52:18 +00:00
|
|
|
ConfigSetting("RapidFireKeyX", "RapidFireKeyY", "RapidFireKeyScale", "ShowRapidFireKey", &g_Config.touchRapidFireKey, defaultTouchPosHide, true, true),
|
2018-06-17 05:14:41 +00:00
|
|
|
|
2015-01-17 16:47:19 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
ConfigSetting("DInputAnalogDeadzone", &g_Config.fDInputAnalogDeadzone, 0.1f, true, true),
|
2015-02-05 05:30:39 +00:00
|
|
|
ConfigSetting("DInputAnalogInverseMode", &g_Config.iDInputAnalogInverseMode, 0, true, true),
|
|
|
|
ConfigSetting("DInputAnalogInverseDeadzone", &g_Config.fDInputAnalogInverseDeadzone, 0.0f, true, true),
|
2015-02-05 05:48:29 +00:00
|
|
|
ConfigSetting("DInputAnalogSensitivity", &g_Config.fDInputAnalogSensitivity, 1.0f, true, true),
|
2015-01-17 16:47:19 +00:00
|
|
|
|
2015-02-05 05:48:29 +00:00
|
|
|
ConfigSetting("XInputAnalogDeadzone", &g_Config.fXInputAnalogDeadzone, 0.24f, true, true),
|
|
|
|
ConfigSetting("XInputAnalogInverseMode", &g_Config.iXInputAnalogInverseMode, 0, true, true),
|
|
|
|
ConfigSetting("XInputAnalogInverseDeadzone", &g_Config.fXInputAnalogInverseDeadzone, 0.0f, true, true),
|
2015-01-17 16:47:19 +00:00
|
|
|
#endif
|
2017-05-18 13:16:32 +00:00
|
|
|
// Also reused as generic analog sensitivity
|
|
|
|
ConfigSetting("XInputAnalogSensitivity", &g_Config.fXInputAnalogSensitivity, 1.0f, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("AnalogLimiterDeadzone", &g_Config.fAnalogLimiterDeadzone, 0.6f, true, true),
|
2014-08-16 19:33:05 +00:00
|
|
|
|
2017-04-26 14:48:55 +00:00
|
|
|
ConfigSetting("UseMouse", &g_Config.bMouseControl, false, true, true),
|
|
|
|
ConfigSetting("MapMouse", &g_Config.bMapMouse, false, true, true),
|
2017-04-27 14:29:08 +00:00
|
|
|
ConfigSetting("ConfineMap", &g_Config.bMouseConfine, false, true, true),
|
2018-03-20 11:02:57 +00:00
|
|
|
ConfigSetting("MouseSensitivity", &g_Config.fMouseSensitivity, 0.1f, true, true),
|
|
|
|
ConfigSetting("MouseSmoothing", &g_Config.fMouseSmoothing, 0.9f, true, true),
|
2017-04-26 14:48:55 +00:00
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting networkSettings[] = {
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false, true, true),
|
2014-08-23 12:35:05 +00:00
|
|
|
ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, true, true),
|
2016-07-04 04:09:17 +00:00
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int DefaultPSPModel() {
|
|
|
|
// TODO: Can probably default this on, but not sure about its memory differences.
|
2016-10-11 16:48:49 +00:00
|
|
|
#if !defined(_M_X64) && !defined(_WIN32)
|
2014-02-10 01:08:40 +00:00
|
|
|
return PSP_MODEL_FAT;
|
|
|
|
#else
|
|
|
|
return PSP_MODEL_SLIM;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int DefaultSystemParamLanguage() {
|
|
|
|
int defaultLang = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
|
|
|
|
if (g_Config.bFirstRun) {
|
|
|
|
// TODO: Be smart about same language, different country
|
|
|
|
auto langValuesMapping = GetLangValuesMapping();
|
|
|
|
if (langValuesMapping.find(g_Config.sLanguageIni) != langValuesMapping.end()) {
|
|
|
|
defaultLang = langValuesMapping[g_Config.sLanguageIni].second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return defaultLang;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ConfigSetting systemParamSettings[] = {
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("PSPModel", &g_Config.iPSPModel, &DefaultPSPModel, true, true),
|
|
|
|
ReportedConfigSetting("PSPFirmwareVersion", &g_Config.iFirmwareVersion, PSP_DEFAULT_FIRMWARE, true, true),
|
|
|
|
ConfigSetting("NickName", &g_Config.sNickName, "PPSSPP", true, true),
|
2019-09-23 09:38:39 +00:00
|
|
|
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "myneighborsushicat.com", true, true),
|
2017-04-29 19:48:06 +00:00
|
|
|
ConfigSetting("MacAddress", &g_Config.sMACAddress, "", true, true),
|
2016-01-24 08:52:39 +00:00
|
|
|
ConfigSetting("PortOffset", &g_Config.iPortOffset, 0, true, true),
|
2014-12-14 19:33:20 +00:00
|
|
|
ReportedConfigSetting("Language", &g_Config.iLanguage, &DefaultSystemParamLanguage, true, true),
|
|
|
|
ConfigSetting("TimeFormat", &g_Config.iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR, true, true),
|
|
|
|
ConfigSetting("DateFormat", &g_Config.iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD, true, true),
|
|
|
|
ConfigSetting("TimeZone", &g_Config.iTimeZone, 0, true, true),
|
|
|
|
ConfigSetting("DayLightSavings", &g_Config.bDayLightSavings, (bool) PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD, true, true),
|
|
|
|
ReportedConfigSetting("ButtonPreference", &g_Config.iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS, true, true),
|
|
|
|
ConfigSetting("LockParentalLevel", &g_Config.iLockParentalLevel, 0, true, true),
|
|
|
|
ConfigSetting("WlanAdhocChannel", &g_Config.iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
#if defined(USING_WIN_UI)
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("BypassOSKWithKeyboard", &g_Config.bBypassOSKWithKeyboard, false, true, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
#endif
|
2014-12-14 19:33:20 +00:00
|
|
|
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, true, true),
|
|
|
|
ReportedConfigSetting("EncryptSave", &g_Config.bEncryptSave, true, true, true),
|
2018-06-24 22:46:41 +00:00
|
|
|
ConfigSetting("SavedataUpgradeVersion", &g_Config.bSavedataUpgrade, true, true, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting debuggerSettings[] = {
|
|
|
|
ConfigSetting("DisasmWindowX", &g_Config.iDisasmWindowX, -1),
|
|
|
|
ConfigSetting("DisasmWindowY", &g_Config.iDisasmWindowY, -1),
|
|
|
|
ConfigSetting("DisasmWindowW", &g_Config.iDisasmWindowW, -1),
|
|
|
|
ConfigSetting("DisasmWindowH", &g_Config.iDisasmWindowH, -1),
|
|
|
|
ConfigSetting("GEWindowX", &g_Config.iGEWindowX, -1),
|
|
|
|
ConfigSetting("GEWindowY", &g_Config.iGEWindowY, -1),
|
|
|
|
ConfigSetting("GEWindowW", &g_Config.iGEWindowW, -1),
|
|
|
|
ConfigSetting("GEWindowH", &g_Config.iGEWindowH, -1),
|
|
|
|
ConfigSetting("ConsoleWindowX", &g_Config.iConsoleWindowX, -1),
|
|
|
|
ConfigSetting("ConsoleWindowY", &g_Config.iConsoleWindowY, -1),
|
|
|
|
ConfigSetting("FontWidth", &g_Config.iFontWidth, 8),
|
|
|
|
ConfigSetting("FontHeight", &g_Config.iFontHeight, 12),
|
|
|
|
ConfigSetting("DisplayStatusBar", &g_Config.bDisplayStatusBar, true),
|
2019-08-21 08:17:33 +00:00
|
|
|
ConfigSetting("ShowBottomTabTitles",&g_Config.bShowBottomTabTitles, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting("ShowDeveloperMenu", &g_Config.bShowDeveloperMenu, false),
|
2018-01-17 12:59:32 +00:00
|
|
|
ConfigSetting("ShowAllocatorDebug", &g_Config.bShowAllocatorDebug, false, false),
|
2019-08-20 22:03:00 +00:00
|
|
|
ConfigSetting("ShowGpuProfile", &g_Config.bShowGpuProfile, false, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting("SkipDeadbeefFilling", &g_Config.bSkipDeadbeefFilling, false),
|
|
|
|
ConfigSetting("FuncHashMap", &g_Config.bFuncHashMap, false),
|
2020-02-11 07:19:30 +00:00
|
|
|
ConfigSetting("DrawFrameGraph", &g_Config.bDrawFrameGraph, false),
|
2014-02-10 01:08:40 +00:00
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting jitSettings[] = {
|
|
|
|
ReportedConfigSetting("DiscardRegsOnJRRA", &g_Config.bDiscardRegsOnJRRA, false, false),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting upgradeSettings[] = {
|
|
|
|
ConfigSetting("UpgradeMessage", &g_Config.upgradeMessage, ""),
|
|
|
|
ConfigSetting("UpgradeVersion", &g_Config.upgradeVersion, ""),
|
|
|
|
ConfigSetting("DismissedVersion", &g_Config.dismissedVersion, ""),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
2017-03-26 16:51:33 +00:00
|
|
|
static ConfigSetting themeSettings[] = {
|
|
|
|
ConfigSetting("ItemStyleFg", &g_Config.uItemStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ItemStyleBg", &g_Config.uItemStyleBg, 0x55000000, true, false),
|
|
|
|
ConfigSetting("ItemFocusedStyleFg", &g_Config.uItemFocusedStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ItemFocusedStyleBg", &g_Config.uItemFocusedStyleBg, 0xFFEDC24C, true, false),
|
|
|
|
ConfigSetting("ItemDownStyleFg", &g_Config.uItemDownStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ItemDownStyleBg", &g_Config.uItemDownStyleBg, 0xFFBD9939, true, false),
|
|
|
|
ConfigSetting("ItemDisabledStyleFg", &g_Config.uItemDisabledStyleFg, 0x80EEEEEE, true, false),
|
|
|
|
ConfigSetting("ItemDisabledStyleBg", &g_Config.uItemDisabledStyleBg, 0x55E0D4AF, true, false),
|
|
|
|
ConfigSetting("ItemHighlightedStyleFg", &g_Config.uItemHighlightedStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ItemHighlightedStyleBg", &g_Config.uItemHighlightedStyleBg, 0x55BDBB39, true, false),
|
|
|
|
|
|
|
|
ConfigSetting("ButtonStyleFg", &g_Config.uButtonStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ButtonStyleBg", &g_Config.uButtonStyleBg, 0x55000000, true, false),
|
|
|
|
ConfigSetting("ButtonFocusedStyleFg", &g_Config.uButtonFocusedStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ButtonFocusedStyleBg", &g_Config.uButtonFocusedStyleBg, 0xFFEDC24C, true, false),
|
|
|
|
ConfigSetting("ButtonDownStyleFg", &g_Config.uButtonDownStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ButtonDownStyleBg", &g_Config.uButtonDownStyleBg, 0xFFBD9939, true, false),
|
|
|
|
ConfigSetting("ButtonDisabledStyleFg", &g_Config.uButtonDisabledStyleFg, 0x80EEEEEE, true, false),
|
|
|
|
ConfigSetting("ButtonDisabledStyleBg", &g_Config.uButtonDisabledStyleBg, 0x55E0D4AF, true, false),
|
|
|
|
ConfigSetting("ButtonHighlightedStyleFg", &g_Config.uButtonHighlightedStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("ButtonHighlightedStyleBg", &g_Config.uButtonHighlightedStyleBg, 0x55BDBB39, true, false),
|
|
|
|
|
|
|
|
ConfigSetting("HeaderStyleFg", &g_Config.uHeaderStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("InfoStyleFg", &g_Config.uInfoStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("InfoStyleBg", &g_Config.uInfoStyleBg, 0x00000000U, true, false),
|
|
|
|
ConfigSetting("PopupTitleStyleFg", &g_Config.uPopupTitleStyleFg, 0xFFE3BE59, true, false),
|
|
|
|
ConfigSetting("PopupStyleFg", &g_Config.uPopupStyleFg, 0xFFFFFFFF, true, false),
|
|
|
|
ConfigSetting("PopupStyleBg", &g_Config.uPopupStyleBg, 0xFF303030, true, false),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
static ConfigSectionSettings sections[] = {
|
|
|
|
{"General", generalSettings},
|
2014-02-10 01:08:40 +00:00
|
|
|
{"CPU", cpuSettings},
|
|
|
|
{"Graphics", graphicsSettings},
|
|
|
|
{"Sound", soundSettings},
|
|
|
|
{"Control", controlSettings},
|
|
|
|
{"Network", networkSettings},
|
|
|
|
{"SystemParam", systemParamSettings},
|
|
|
|
{"Debugger", debuggerSettings},
|
|
|
|
{"JIT", jitSettings},
|
|
|
|
{"Upgrade", upgradeSettings},
|
2017-03-26 16:51:33 +00:00
|
|
|
{"Theme", themeSettings},
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
static void IterateSettings(IniFile &iniFile, std::function<void(IniFile::Section *section, ConfigSetting *setting)> func) {
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
|
|
|
|
IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
|
|
|
|
for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
|
|
|
|
func(section, setting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-30 18:05:36 +00:00
|
|
|
Config::Config() : bGameSpecific(false) { }
|
2013-06-17 18:28:22 +00:00
|
|
|
Config::~Config() { }
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2014-01-03 18:04:43 +00:00
|
|
|
std::map<std::string, std::pair<std::string, int>> GetLangValuesMapping() {
|
|
|
|
std::map<std::string, std::pair<std::string, int>> langValuesMapping;
|
|
|
|
IniFile mapping;
|
|
|
|
mapping.LoadFromVFS("langregion.ini");
|
|
|
|
std::vector<std::string> keys;
|
|
|
|
mapping.GetKeys("LangRegionNames", keys);
|
|
|
|
|
|
|
|
|
|
|
|
std::map<std::string, int> langCodeMapping;
|
|
|
|
langCodeMapping["JAPANESE"] = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE;
|
|
|
|
langCodeMapping["ENGLISH"] = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
|
|
|
|
langCodeMapping["FRENCH"] = PSP_SYSTEMPARAM_LANGUAGE_FRENCH;
|
|
|
|
langCodeMapping["SPANISH"] = PSP_SYSTEMPARAM_LANGUAGE_SPANISH;
|
|
|
|
langCodeMapping["GERMAN"] = PSP_SYSTEMPARAM_LANGUAGE_GERMAN;
|
|
|
|
langCodeMapping["ITALIAN"] = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN;
|
|
|
|
langCodeMapping["DUTCH"] = PSP_SYSTEMPARAM_LANGUAGE_DUTCH;
|
|
|
|
langCodeMapping["PORTUGUESE"] = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE;
|
|
|
|
langCodeMapping["RUSSIAN"] = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN;
|
|
|
|
langCodeMapping["KOREAN"] = PSP_SYSTEMPARAM_LANGUAGE_KOREAN;
|
|
|
|
langCodeMapping["CHINESE_TRADITIONAL"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL;
|
|
|
|
langCodeMapping["CHINESE_SIMPLIFIED"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;
|
|
|
|
|
|
|
|
IniFile::Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames");
|
|
|
|
IniFile::Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage");
|
|
|
|
|
|
|
|
for (size_t i = 0; i < keys.size(); i++) {
|
|
|
|
std::string langName;
|
|
|
|
langRegionNames->Get(keys[i].c_str(), &langName, "ERROR");
|
|
|
|
std::string langCode;
|
|
|
|
systemLanguage->Get(keys[i].c_str(), &langCode, "ENGLISH");
|
|
|
|
int iLangCode = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
|
|
|
|
if (langCodeMapping.find(langCode) != langCodeMapping.end())
|
|
|
|
iLangCode = langCodeMapping[langCode];
|
|
|
|
langValuesMapping[keys[i]] = std::make_pair(langName, iLangCode);
|
|
|
|
}
|
|
|
|
return langValuesMapping;
|
|
|
|
}
|
|
|
|
|
2013-10-25 09:45:41 +00:00
|
|
|
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
|
2014-08-31 07:19:19 +00:00
|
|
|
const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0;
|
2014-08-31 05:17:25 +00:00
|
|
|
iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini");
|
|
|
|
|
2014-08-31 07:19:19 +00:00
|
|
|
const bool useControllerIniFilename = controllerIniFilename != nullptr && strlen(controllerIniFilename) > 0;
|
2014-08-31 05:17:25 +00:00
|
|
|
controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : "controls.ini");
|
2013-09-15 16:50:42 +00:00
|
|
|
|
2013-09-15 23:01:46 +00:00
|
|
|
INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
|
2012-11-01 15:19:01 +00:00
|
|
|
bSaveSettings = true;
|
|
|
|
|
2015-05-13 20:28:02 +00:00
|
|
|
bShowFrameProfiler = true;
|
2014-12-14 19:33:20 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile iniFile;
|
2013-09-15 16:50:42 +00:00
|
|
|
if (!iniFile.Load(iniFilename_)) {
|
2018-03-24 11:51:54 +00:00
|
|
|
ERROR_LOG(LOADER, "Failed to read '%s'. Setting config to default.", iniFilename_.c_str());
|
2013-01-04 09:26:14 +00:00
|
|
|
// Continue anyway to initialize the config.
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
|
|
|
setting->Get(section);
|
|
|
|
});
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2013-11-26 09:24:31 +00:00
|
|
|
iRunCount++;
|
2013-10-25 16:44:19 +00:00
|
|
|
if (!File::Exists(currentDirectory))
|
|
|
|
currentDirectory = "";
|
|
|
|
|
2017-03-06 10:44:35 +00:00
|
|
|
IniFile::Section *log = iniFile.GetOrCreateSection(logSectionName);
|
|
|
|
|
|
|
|
bool debugDefaults = false;
|
|
|
|
#ifdef _DEBUG
|
|
|
|
debugDefaults = true;
|
|
|
|
#endif
|
|
|
|
LogManager::GetInstance()->LoadConfig(log, debugDefaults);
|
|
|
|
|
2013-08-30 17:48:56 +00:00
|
|
|
IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
|
|
|
|
recent->Get("MaxRecent", &iMaxRecent, 30);
|
2013-10-25 09:45:41 +00:00
|
|
|
|
2013-08-30 17:48:56 +00:00
|
|
|
// Fix issue from switching from uint (hex in .ini) to int (dec)
|
2014-06-29 03:21:36 +00:00
|
|
|
// -1 is okay, though. We'll just ignore recent stuff if it is.
|
2015-09-23 17:29:39 +00:00
|
|
|
if (iMaxRecent == 0)
|
2013-08-30 17:48:56 +00:00
|
|
|
iMaxRecent = 30;
|
|
|
|
|
2015-09-23 17:29:39 +00:00
|
|
|
if (iMaxRecent > 0) {
|
|
|
|
recentIsos.clear();
|
|
|
|
for (int i = 0; i < iMaxRecent; i++) {
|
|
|
|
char keyName[64];
|
|
|
|
std::string fileName;
|
|
|
|
|
|
|
|
snprintf(keyName, sizeof(keyName), "FileName%d", i);
|
|
|
|
if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
|
|
|
|
recentIsos.push_back(fileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-21 15:49:02 +00:00
|
|
|
|
2013-12-08 06:39:35 +00:00
|
|
|
auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
|
|
|
|
vPinnedPaths.clear();
|
2014-02-10 00:11:16 +00:00
|
|
|
for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
|
2018-09-05 04:53:20 +00:00
|
|
|
// Unpin paths that are deleted automatically.
|
2019-10-06 16:31:06 +00:00
|
|
|
const std::string &path = it->second;
|
|
|
|
if (startsWith(path, "http://") || startsWith(path, "https://") || File::Exists(path)) {
|
|
|
|
vPinnedPaths.push_back(File::ResolvePath(path));
|
2018-09-05 04:53:20 +00:00
|
|
|
}
|
2013-12-08 06:39:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 04:56:04 +00:00
|
|
|
// This caps the exponent 4 (so 16x.)
|
2013-07-17 20:27:05 +00:00
|
|
|
if (iAnisotropyLevel > 4) {
|
|
|
|
iAnisotropyLevel = 4;
|
|
|
|
}
|
2017-12-25 19:20:26 +00:00
|
|
|
if (iRenderingMode != FB_NON_BUFFERED_MODE && iRenderingMode != FB_BUFFERED_MODE) {
|
|
|
|
g_Config.iRenderingMode = FB_BUFFERED_MODE;
|
|
|
|
}
|
2013-12-12 13:52:46 +00:00
|
|
|
|
|
|
|
// Check for an old dpad setting
|
2014-02-10 01:08:40 +00:00
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
2013-12-12 13:52:46 +00:00
|
|
|
float f;
|
|
|
|
control->Get("DPadRadius", &f, 0.0f);
|
|
|
|
if (f > 0.0f) {
|
|
|
|
ResetControlLayout();
|
|
|
|
}
|
2013-11-05 04:52:31 +00:00
|
|
|
|
2014-08-16 20:31:07 +00:00
|
|
|
const char *gitVer = PPSSPP_GIT_VERSION;
|
|
|
|
Version installed(gitVer);
|
|
|
|
Version upgrade(upgradeVersion);
|
|
|
|
const bool versionsValid = installed.IsValid() && upgrade.IsValid();
|
|
|
|
|
|
|
|
// Do this regardless of iRunCount to prevent a silly bug where one might use an older
|
|
|
|
// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
|
|
|
|
// even if said newer version is >= the upgrade found online.
|
|
|
|
if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
|
2013-11-26 13:04:29 +00:00
|
|
|
upgradeMessage = "";
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
// Check for new version on every 10 runs.
|
2013-11-26 13:04:29 +00:00
|
|
|
// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
|
|
|
|
// splash screen quickly), but then we'll just show the notification next time instead, we store the
|
|
|
|
// upgrade number in the ini.
|
2013-12-12 21:30:06 +00:00
|
|
|
if (iRunCount % 10 == 0 && bCheckForNewVersion) {
|
2013-12-10 12:14:32 +00:00
|
|
|
std::shared_ptr<http::Download> dl = g_DownloadManager.StartDownloadWithCallback(
|
2013-11-26 13:04:29 +00:00
|
|
|
"http://www.ppsspp.org/version.json", "", &DownloadCompletedCallback);
|
2013-12-10 12:14:32 +00:00
|
|
|
dl->SetHidden(true);
|
2013-11-26 13:04:29 +00:00
|
|
|
}
|
|
|
|
|
2013-09-15 23:01:46 +00:00
|
|
|
INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
|
2013-08-16 17:34:44 +00:00
|
|
|
bSaveSettings = true;
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
LoadStandardControllerIni();
|
2016-08-27 18:38:05 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
//so this is all the way down here to overwrite the controller settings
|
|
|
|
//sadly it won't benefit from all the "version conversion" going on up-above
|
|
|
|
//but these configs shouldn't contain older versions anyhow
|
2017-03-06 10:44:35 +00:00
|
|
|
if (bGameSpecific) {
|
2019-07-18 04:28:21 +00:00
|
|
|
loadGameConfig(gameId_, gameIdTitle_);
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
2013-08-16 17:34:44 +00:00
|
|
|
|
2013-04-13 19:24:07 +00:00
|
|
|
CleanRecent();
|
2014-09-14 10:59:27 +00:00
|
|
|
|
2017-04-29 19:48:06 +00:00
|
|
|
// Set a default MAC, and correct if it's an old format.
|
2014-11-25 19:58:03 +00:00
|
|
|
if (sMACAddress.length() != 17)
|
2014-11-13 15:56:08 +00:00
|
|
|
sMACAddress = CreateRandMAC();
|
2015-02-09 22:10:57 +00:00
|
|
|
|
|
|
|
if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
|
|
|
|
g_Config.iRenderingMode = FB_BUFFERED_MODE;
|
|
|
|
}
|
2015-11-03 17:34:33 +00:00
|
|
|
|
|
|
|
// Override ppsspp.ini JIT value to prevent crashing
|
2017-03-02 11:36:54 +00:00
|
|
|
if (DefaultCpuCore() != (int)CPUCore::JIT && g_Config.iCpuCore == (int)CPUCore::JIT) {
|
2015-11-03 17:34:33 +00:00
|
|
|
jitForcedOff = true;
|
2017-03-02 11:36:54 +00:00
|
|
|
g_Config.iCpuCore = (int)CPUCore::INTERPRETER;
|
2015-11-03 17:34:33 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2019-02-23 09:49:49 +00:00
|
|
|
void Config::Save(const char *saveReason) {
|
2015-11-03 17:34:33 +00:00
|
|
|
if (jitForcedOff) {
|
|
|
|
// if JIT has been forced off, we don't want to screw up the user's ppsspp.ini
|
2017-03-02 11:36:54 +00:00
|
|
|
g_Config.iCpuCore = (int)CPUCore::JIT;
|
2015-11-03 17:34:33 +00:00
|
|
|
}
|
2013-01-04 09:26:14 +00:00
|
|
|
if (iniFilename_.size() && g_Config.bSaveSettings) {
|
2019-07-14 22:04:09 +00:00
|
|
|
saveGameConfig(gameId_, gameIdTitle_);
|
2014-12-14 19:33:20 +00:00
|
|
|
|
2013-04-13 19:24:07 +00:00
|
|
|
CleanRecent();
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile iniFile;
|
2013-01-04 09:26:14 +00:00
|
|
|
if (!iniFile.Load(iniFilename_.c_str())) {
|
2018-03-24 11:51:54 +00:00
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't read ini '%s'", iniFilename_.c_str());
|
2013-01-04 09:26:14 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-06-01 17:01:43 +00:00
|
|
|
// Need to do this somewhere...
|
|
|
|
bFirstRun = false;
|
2014-02-04 11:58:37 +00:00
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
IterateSettings(iniFile, [&](IniFile::Section *section, ConfigSetting *setting) {
|
|
|
|
if (!bGameSpecific || !setting->perGame_) {
|
|
|
|
setting->Set(section);
|
2014-02-09 23:46:49 +00:00
|
|
|
}
|
2016-01-06 07:01:49 +00:00
|
|
|
});
|
2013-11-29 13:20:37 +00:00
|
|
|
|
2013-08-30 17:48:56 +00:00
|
|
|
IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
|
|
|
|
recent->Set("MaxRecent", iMaxRecent);
|
2013-11-29 13:20:37 +00:00
|
|
|
|
2013-09-08 05:31:22 +00:00
|
|
|
for (int i = 0; i < iMaxRecent; i++) {
|
2013-08-30 17:48:56 +00:00
|
|
|
char keyName[64];
|
2014-09-13 22:14:11 +00:00
|
|
|
snprintf(keyName, sizeof(keyName), "FileName%d", i);
|
2013-09-08 05:31:22 +00:00
|
|
|
if (i < (int)recentIsos.size()) {
|
2013-09-05 16:45:41 +00:00
|
|
|
recent->Set(keyName, recentIsos[i]);
|
2013-09-08 05:31:22 +00:00
|
|
|
} else {
|
2013-09-05 16:45:41 +00:00
|
|
|
recent->Delete(keyName); // delete the nonexisting FileName
|
2013-11-29 13:20:37 +00:00
|
|
|
}
|
2013-08-30 17:48:56 +00:00
|
|
|
}
|
2013-03-01 16:51:01 +00:00
|
|
|
|
2013-12-08 06:39:35 +00:00
|
|
|
IniFile::Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
|
|
|
|
pinnedPaths->Clear();
|
|
|
|
for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
|
|
|
|
char keyName[64];
|
2013-12-30 00:08:06 +00:00
|
|
|
snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
|
2013-12-08 06:39:35 +00:00
|
|
|
pinnedPaths->Set(keyName, vPinnedPaths[i]);
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
2013-12-12 13:52:46 +00:00
|
|
|
control->Delete("DPadRadius");
|
2013-11-26 13:04:29 +00:00
|
|
|
|
2017-03-06 10:44:35 +00:00
|
|
|
IniFile::Section *log = iniFile.GetOrCreateSection(logSectionName);
|
2017-04-15 23:30:37 +00:00
|
|
|
if (LogManager::GetInstance())
|
|
|
|
LogManager::GetInstance()->SaveConfig(log);
|
2017-03-06 10:44:35 +00:00
|
|
|
|
2013-01-04 09:26:14 +00:00
|
|
|
if (!iniFile.Save(iniFilename_.c_str())) {
|
2019-02-23 09:49:49 +00:00
|
|
|
ERROR_LOG(LOADER, "Error saving config (%s)- can't write ini '%s'", saveReason, iniFilename_.c_str());
|
2017-12-04 17:36:19 +00:00
|
|
|
System_SendMessage("toast", "Failed to save settings!\nCheck permissions, or try to restart the device.");
|
2013-01-04 09:26:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-02-23 09:49:49 +00:00
|
|
|
INFO_LOG(LOADER, "Config saved (%s): '%s'", saveReason, iniFilename_.c_str());
|
2013-08-16 17:34:44 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
|
|
|
|
{
|
|
|
|
IniFile controllerIniFile;
|
|
|
|
if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
|
2018-03-24 11:51:54 +00:00
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't read ini '%s'", controllerIniFilename_.c_str());
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
|
|
|
KeyMap::SaveToIni(controllerIniFile);
|
|
|
|
if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
|
2018-03-24 11:51:54 +00:00
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't write ini '%s'", controllerIniFilename_.c_str());
|
2014-12-14 19:33:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
|
2013-08-16 17:34:44 +00:00
|
|
|
}
|
2012-11-04 10:54:45 +00:00
|
|
|
} else {
|
2013-01-04 09:26:14 +00:00
|
|
|
INFO_LOG(LOADER, "Not saving config");
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
2015-11-03 17:34:33 +00:00
|
|
|
if (jitForcedOff) {
|
|
|
|
// force JIT off again just in case Config::Save() is called without exiting PPSSPP
|
2017-03-02 11:36:54 +00:00
|
|
|
g_Config.iCpuCore = (int)CPUCore::INTERPRETER;
|
2015-11-03 17:34:33 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
2013-03-24 19:03:42 +00:00
|
|
|
|
2013-11-26 13:04:29 +00:00
|
|
|
// Use for debugging the version check without messing with the server
|
|
|
|
#if 0
|
|
|
|
#define PPSSPP_GIT_VERSION "v0.0.1-gaaaaaaaaa"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void Config::DownloadCompletedCallback(http::Download &download) {
|
|
|
|
if (download.ResultCode() != 200) {
|
2017-03-12 16:24:46 +00:00
|
|
|
ERROR_LOG(LOADER, "Failed to download %s: %d", download.url().c_str(), download.ResultCode());
|
2013-11-26 19:10:35 +00:00
|
|
|
return;
|
2013-11-26 13:04:29 +00:00
|
|
|
}
|
|
|
|
std::string data;
|
|
|
|
download.buffer().TakeAll(&data);
|
2013-11-26 19:10:35 +00:00
|
|
|
if (data.empty()) {
|
|
|
|
ERROR_LOG(LOADER, "Version check: Empty data from server!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-12 22:05:00 +00:00
|
|
|
json::JsonReader reader(data.c_str(), data.size());
|
|
|
|
const json::JsonGet root = reader.root();
|
2016-04-09 16:20:31 +00:00
|
|
|
if (!root) {
|
|
|
|
ERROR_LOG(LOADER, "Failed to parse json");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-15 18:24:10 +00:00
|
|
|
std::string version = root.getString("version", "");
|
2013-11-26 13:04:29 +00:00
|
|
|
|
|
|
|
const char *gitVer = PPSSPP_GIT_VERSION;
|
|
|
|
Version installed(gitVer);
|
|
|
|
Version upgrade(version);
|
|
|
|
Version dismissed(g_Config.dismissedVersion);
|
|
|
|
|
|
|
|
if (!installed.IsValid()) {
|
|
|
|
ERROR_LOG(LOADER, "Version check: Local version string invalid. Build problems? %s", PPSSPP_GIT_VERSION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!upgrade.IsValid()) {
|
|
|
|
ERROR_LOG(LOADER, "Version check: Invalid server version: %s", version.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (installed >= upgrade) {
|
|
|
|
INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message");
|
|
|
|
g_Config.upgradeMessage = "";
|
|
|
|
g_Config.upgradeVersion = upgrade.ToString();
|
|
|
|
g_Config.dismissedVersion = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (installed < upgrade && dismissed != upgrade) {
|
|
|
|
g_Config.upgradeMessage = "New version of PPSSPP available!";
|
|
|
|
g_Config.upgradeVersion = upgrade.ToString();
|
|
|
|
g_Config.dismissedVersion = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Config::DismissUpgrade() {
|
|
|
|
g_Config.dismissedVersion = g_Config.upgradeVersion;
|
|
|
|
}
|
|
|
|
|
2013-03-24 19:03:42 +00:00
|
|
|
void Config::AddRecent(const std::string &file) {
|
2014-06-29 03:21:36 +00:00
|
|
|
// Don't bother with this if the user disabled recents (it's -1).
|
|
|
|
if (iMaxRecent <= 0)
|
|
|
|
return;
|
|
|
|
|
2018-08-18 17:22:55 +00:00
|
|
|
// We'll add it back below. This makes sure it's at the front, and only once.
|
|
|
|
RemoveRecent(file);
|
2018-08-12 15:24:33 +00:00
|
|
|
|
2018-08-18 17:22:55 +00:00
|
|
|
const std::string filename = File::ResolvePath(file);
|
2017-02-21 10:22:28 +00:00
|
|
|
recentIsos.insert(recentIsos.begin(), filename);
|
2013-07-06 09:09:08 +00:00
|
|
|
if ((int)recentIsos.size() > iMaxRecent)
|
2013-05-16 00:51:15 +00:00
|
|
|
recentIsos.resize(iMaxRecent);
|
2013-03-24 19:03:42 +00:00
|
|
|
}
|
2013-04-13 19:24:07 +00:00
|
|
|
|
2018-08-12 15:24:33 +00:00
|
|
|
void Config::RemoveRecent(const std::string &file) {
|
|
|
|
// Don't bother with this if the user disabled recents (it's -1).
|
|
|
|
if (iMaxRecent <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const std::string filename = File::ResolvePath(file);
|
2018-08-14 19:26:42 +00:00
|
|
|
for (auto iter = recentIsos.begin(); iter != recentIsos.end();) {
|
|
|
|
const std::string recent = File::ResolvePath(*iter);
|
2018-08-12 15:24:33 +00:00
|
|
|
if (filename == recent) {
|
2018-08-14 19:26:42 +00:00
|
|
|
// Note that the increment-erase idiom doesn't work with vectors.
|
|
|
|
iter = recentIsos.erase(iter);
|
|
|
|
} else {
|
|
|
|
iter++;
|
2018-08-12 15:24:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-13 19:24:07 +00:00
|
|
|
void Config::CleanRecent() {
|
|
|
|
std::vector<std::string> cleanedRecent;
|
|
|
|
for (size_t i = 0; i < recentIsos.size(); i++) {
|
2014-12-01 07:54:22 +00:00
|
|
|
FileLoader *loader = ConstructFileLoader(recentIsos[i]);
|
2016-07-04 07:27:49 +00:00
|
|
|
if (loader->ExistsFast()) {
|
2014-12-01 07:54:22 +00:00
|
|
|
// Make sure we don't have any redundant items.
|
|
|
|
auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), recentIsos[i]);
|
|
|
|
if (duplicate == cleanedRecent.end()) {
|
2013-11-20 15:36:58 +00:00
|
|
|
cleanedRecent.push_back(recentIsos[i]);
|
2013-09-04 22:04:24 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-01 07:54:22 +00:00
|
|
|
delete loader;
|
2013-04-13 19:24:07 +00:00
|
|
|
}
|
|
|
|
recentIsos = cleanedRecent;
|
2013-04-15 00:23:57 +00:00
|
|
|
}
|
2013-08-28 20:23:16 +00:00
|
|
|
|
2013-10-12 23:02:03 +00:00
|
|
|
void Config::SetDefaultPath(const std::string &defaultPath) {
|
|
|
|
defaultPath_ = defaultPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Config::AddSearchPath(const std::string &path) {
|
|
|
|
searchPath_.push_back(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string Config::FindConfigFile(const std::string &baseFilename) {
|
|
|
|
// Don't search for an absolute path.
|
|
|
|
if (baseFilename.size() > 1 && baseFilename[0] == '/') {
|
|
|
|
return baseFilename;
|
|
|
|
}
|
2013-10-12 23:41:53 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
if (baseFilename.size() > 3 && baseFilename[1] == ':' && (baseFilename[2] == '/' || baseFilename[2] == '\\')) {
|
|
|
|
return baseFilename;
|
|
|
|
}
|
|
|
|
#endif
|
2013-10-12 23:02:03 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < searchPath_.size(); ++i) {
|
|
|
|
std::string filename = searchPath_[i] + baseFilename;
|
|
|
|
if (File::Exists(filename)) {
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string filename = defaultPath_.empty() ? baseFilename : defaultPath_ + baseFilename;
|
|
|
|
if (!File::Exists(filename)) {
|
|
|
|
std::string path;
|
|
|
|
SplitPath(filename, &path, NULL, NULL);
|
2014-12-30 18:05:36 +00:00
|
|
|
if (createdPath_ != path) {
|
|
|
|
File::CreateFullPath(path);
|
|
|
|
createdPath_ = path;
|
|
|
|
}
|
2013-10-12 23:02:03 +00:00
|
|
|
}
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2013-08-28 20:23:16 +00:00
|
|
|
void Config::RestoreDefaults() {
|
2016-01-06 07:01:49 +00:00
|
|
|
if (bGameSpecific) {
|
2014-12-30 18:05:36 +00:00
|
|
|
deleteGameConfig(gameId_);
|
|
|
|
createGameConfig(gameId_);
|
2016-01-06 07:01:49 +00:00
|
|
|
} else {
|
2014-12-19 13:52:44 +00:00
|
|
|
if (File::Exists(iniFilename_))
|
|
|
|
File::Delete(iniFilename_);
|
|
|
|
recentIsos.clear();
|
|
|
|
currentDirectory = "";
|
|
|
|
}
|
2013-08-28 20:23:16 +00:00
|
|
|
Load();
|
|
|
|
}
|
2013-12-12 13:52:46 +00:00
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
bool Config::hasGameConfig(const std::string &pGameId) {
|
2014-12-14 19:33:20 +00:00
|
|
|
std::string fullIniFilePath = getGameConfigFile(pGameId);
|
2015-09-07 21:20:31 +00:00
|
|
|
return File::Exists(fullIniFilePath);
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
|
|
|
|
2019-07-14 22:04:09 +00:00
|
|
|
void Config::changeGameSpecific(const std::string &pGameId, const std::string &title) {
|
2019-02-23 09:49:49 +00:00
|
|
|
Save("changeGameSpecific");
|
2014-12-30 18:05:36 +00:00
|
|
|
gameId_ = pGameId;
|
2019-07-14 22:04:09 +00:00
|
|
|
gameIdTitle_ = title;
|
2014-12-14 19:33:20 +00:00
|
|
|
bGameSpecific = !pGameId.empty();
|
|
|
|
}
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
bool Config::createGameConfig(const std::string &pGameId) {
|
2014-12-14 19:33:20 +00:00
|
|
|
std::string fullIniFilePath = getGameConfigFile(pGameId);
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
if (hasGameConfig(pGameId)) {
|
2014-12-14 19:33:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
File::CreateEmptyFile(fullIniFilePath);
|
2014-12-19 01:12:31 +00:00
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
bool Config::deleteGameConfig(const std::string& pGameId) {
|
2014-12-14 19:33:20 +00:00
|
|
|
std::string fullIniFilePath = getGameConfigFile(pGameId);
|
|
|
|
|
|
|
|
File::Delete(fullIniFilePath);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
std::string Config::getGameConfigFile(const std::string &pGameId) {
|
2014-12-14 19:33:20 +00:00
|
|
|
std::string iniFileName = pGameId + "_ppsspp.ini";
|
|
|
|
std::string iniFileNameFull = FindConfigFile(iniFileName);
|
|
|
|
|
|
|
|
return iniFileNameFull;
|
|
|
|
}
|
|
|
|
|
2019-07-14 22:04:09 +00:00
|
|
|
bool Config::saveGameConfig(const std::string &pGameId, const std::string &title) {
|
2016-01-06 07:01:49 +00:00
|
|
|
if (pGameId.empty()) {
|
2014-12-14 19:33:20 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-19 01:12:31 +00:00
|
|
|
std::string fullIniFilePath = getGameConfigFile(pGameId);
|
2014-12-14 19:33:20 +00:00
|
|
|
|
|
|
|
IniFile iniFile;
|
|
|
|
|
2019-07-14 22:04:09 +00:00
|
|
|
IniFile::Section *top = iniFile.GetOrCreateSection("");
|
|
|
|
top->AddComment(StringFromFormat("Game config for %s - %s", pGameId.c_str(), title.c_str()));
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
|
|
|
if (setting->perGame_) {
|
|
|
|
setting->Set(section);
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
2016-01-06 07:01:49 +00:00
|
|
|
});
|
2014-12-14 19:33:20 +00:00
|
|
|
|
|
|
|
KeyMap::SaveToIni(iniFile);
|
|
|
|
iniFile.Save(fullIniFilePath);
|
|
|
|
|
2014-12-20 17:10:18 +00:00
|
|
|
return true;
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
|
|
|
|
2019-07-18 04:28:21 +00:00
|
|
|
bool Config::loadGameConfig(const std::string &pGameId, const std::string &title) {
|
2014-12-14 19:33:20 +00:00
|
|
|
std::string iniFileNameFull = getGameConfigFile(pGameId);
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
if (!hasGameConfig(pGameId)) {
|
2014-12-14 19:33:20 +00:00
|
|
|
INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-07-18 04:28:21 +00:00
|
|
|
changeGameSpecific(pGameId, title);
|
2014-12-14 19:33:20 +00:00
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(iniFileNameFull);
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
|
|
|
if (setting->perGame_) {
|
|
|
|
setting->Get(section);
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
2016-01-06 07:01:49 +00:00
|
|
|
});
|
|
|
|
|
2014-12-14 19:33:20 +00:00
|
|
|
KeyMap::LoadFromIni(iniFile);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
void Config::unloadGameConfig() {
|
|
|
|
if (bGameSpecific){
|
2014-12-14 19:33:20 +00:00
|
|
|
changeGameSpecific();
|
2016-01-06 07:02:19 +00:00
|
|
|
|
|
|
|
IniFile iniFile;
|
|
|
|
iniFile.Load(iniFilename_);
|
|
|
|
|
|
|
|
// Reload game specific settings back to standard.
|
|
|
|
IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) {
|
|
|
|
if (setting->perGame_) {
|
|
|
|
setting->Get(section);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
LoadStandardControllerIni();
|
2014-12-14 19:33:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-06 07:01:49 +00:00
|
|
|
void Config::LoadStandardControllerIni() {
|
|
|
|
IniFile controllerIniFile;
|
|
|
|
if (!controllerIniFile.Load(controllerIniFilename_)) {
|
|
|
|
ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
|
|
|
|
KeyMap::RestoreDefault();
|
|
|
|
} else {
|
|
|
|
// Continue anyway to initialize the config. It will just restore the defaults.
|
|
|
|
KeyMap::LoadFromIni(controllerIniFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-12 13:52:46 +00:00
|
|
|
void Config::ResetControlLayout() {
|
2018-06-17 05:14:41 +00:00
|
|
|
auto reset = [](ConfigTouchPos &pos) {
|
|
|
|
pos.x = defaultTouchPosShow.x;
|
|
|
|
pos.y = defaultTouchPosShow.y;
|
|
|
|
pos.scale = defaultTouchPosShow.scale;
|
|
|
|
};
|
|
|
|
reset(g_Config.touchActionButtonCenter);
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fActionButtonSpacing = 1.0f;
|
2018-06-17 05:14:41 +00:00
|
|
|
reset(g_Config.touchDpad);
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fDpadSpacing = 1.0f;
|
2018-06-17 05:14:41 +00:00
|
|
|
reset(g_Config.touchStartKey);
|
|
|
|
reset(g_Config.touchSelectKey);
|
|
|
|
reset(g_Config.touchUnthrottleKey);
|
|
|
|
reset(g_Config.touchLKey);
|
|
|
|
reset(g_Config.touchRKey);
|
|
|
|
reset(g_Config.touchAnalogStick);
|
2019-07-18 01:16:46 +00:00
|
|
|
reset(g_Config.touchRightAnalogStick);
|
2018-06-17 05:14:41 +00:00
|
|
|
reset(g_Config.touchCombo0);
|
|
|
|
reset(g_Config.touchCombo1);
|
|
|
|
reset(g_Config.touchCombo2);
|
|
|
|
reset(g_Config.touchCombo3);
|
|
|
|
reset(g_Config.touchCombo4);
|
2018-06-17 06:00:21 +00:00
|
|
|
reset(g_Config.touchSpeed1Key);
|
|
|
|
reset(g_Config.touchSpeed2Key);
|
2020-01-28 07:52:18 +00:00
|
|
|
reset(g_Config.touchRapidFireKey);
|
2013-12-08 06:39:35 +00:00
|
|
|
}
|
2014-02-10 01:15:00 +00:00
|
|
|
|
|
|
|
void Config::GetReportingInfo(UrlEncoder &data) {
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
|
|
|
|
const std::string prefix = std::string("config.") + sections[i].section;
|
|
|
|
for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
|
|
|
|
setting->Report(data, prefix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-17 01:42:31 +00:00
|
|
|
|
|
|
|
bool Config::IsPortrait() const {
|
2018-06-17 02:20:23 +00:00
|
|
|
return (iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180) && iRenderingMode != FB_NON_BUFFERED_MODE;
|
2018-06-17 01:42:31 +00:00
|
|
|
}
|