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/.
|
|
|
|
|
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 "ext/vjson/json.h"
|
|
|
|
#include "file/ini_file.h"
|
|
|
|
#include "i18n/i18n.h"
|
|
|
|
#include "gfx_es2/gpu_features.h"
|
|
|
|
#include "net/http_client.h"
|
|
|
|
#include "util/text/parsers.h"
|
|
|
|
|
|
|
|
#include "Common/CPUDetect.h"
|
2013-07-06 18:44:34 +00:00
|
|
|
#include "Common/KeyMap.h"
|
2013-04-13 19:24:07 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2013-10-12 23:02:03 +00:00
|
|
|
#include "Common/StringUtils.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
#include "Config.h"
|
2013-01-20 09:50:05 +00:00
|
|
|
#include "HLE/sceUtility.h"
|
2013-11-26 13:04:29 +00:00
|
|
|
|
2013-11-26 17:02:29 +00:00
|
|
|
#ifndef USING_QT_UI
|
2013-11-26 13:04:29 +00:00
|
|
|
extern const char *PPSSPP_GIT_VERSION;
|
2013-11-26 17:02:29 +00:00
|
|
|
#endif
|
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
|
|
|
|
2013-04-23 05:38:28 +00:00
|
|
|
#ifdef IOS
|
2013-12-01 19:28:20 +00:00
|
|
|
extern bool iosCanUseJit;
|
2013-04-23 05:38:28 +00:00
|
|
|
#endif
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
struct ConfigSetting {
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
TYPE_TERMINATOR,
|
|
|
|
TYPE_BOOL,
|
|
|
|
TYPE_INT,
|
2014-02-10 01:08:40 +00:00
|
|
|
TYPE_FLOAT,
|
2014-02-09 23:46:49 +00:00
|
|
|
TYPE_STRING,
|
|
|
|
};
|
|
|
|
union Value
|
|
|
|
{
|
|
|
|
bool b;
|
|
|
|
int i;
|
2014-02-10 01:08:40 +00:00
|
|
|
float f;
|
2014-02-09 23:46:49 +00:00
|
|
|
const char *s;
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
typedef bool (*BoolDefaultCallback)();
|
|
|
|
typedef int (*IntDefaultCallback)();
|
|
|
|
typedef float (*FloatDefaultCallback)();
|
|
|
|
typedef const char *(*StringDefaultCallback)();
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting(bool v)
|
2014-02-10 01:08:40 +00:00
|
|
|
: ini_(""), type_(TYPE_TERMINATOR), report_(false), save_(false), cb_(NULL) {
|
2014-02-09 23:46:49 +00:00
|
|
|
ptr_ = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigSetting(const char *ini, bool *v, bool def, bool save = true)
|
2014-02-10 01:08:40 +00:00
|
|
|
: ini_(ini), type_(TYPE_BOOL), report_(false), save_(save), cb_(NULL) {
|
2014-02-09 23:46:49 +00:00
|
|
|
ptr_ = (void *)v;
|
|
|
|
default_.b = def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigSetting(const char *ini, int *v, int def, bool save = true)
|
2014-02-10 01:08:40 +00:00
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save), cb_(NULL) {
|
2014-02-09 23:46:49 +00:00
|
|
|
ptr_ = (void *)v;
|
|
|
|
default_.i = def;
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting(const char *ini, float *v, float def, bool save = true)
|
|
|
|
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save), cb_(NULL) {
|
|
|
|
ptr_ = (void *)v;
|
|
|
|
default_.f = def;
|
|
|
|
}
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting(const char *ini, std::string *v, const char *def, bool save = true)
|
2014-02-10 01:08:40 +00:00
|
|
|
: ini_(ini), type_(TYPE_STRING), report_(false), save_(save), cb_(NULL) {
|
2014-02-09 23:46:49 +00:00
|
|
|
ptr_ = (void *)v;
|
|
|
|
default_.s = def;
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting(const char *ini, bool *v, BoolDefaultCallback def, bool save = true)
|
|
|
|
: ini_(ini), type_(TYPE_BOOL), report_(false), save_(save) {
|
|
|
|
ptr_ = (void *)v;
|
|
|
|
cb_ = (void *)def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, bool save = true)
|
|
|
|
: ini_(ini), type_(TYPE_INT), report_(false), save_(save) {
|
|
|
|
ptr_ = (void *)v;
|
|
|
|
cb_ = (void *)def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigSetting(const char *ini, float *v, FloatDefaultCallback def, bool save = true)
|
|
|
|
: ini_(ini), type_(TYPE_FLOAT), report_(false), save_(save) {
|
|
|
|
ptr_ = (void *)v;
|
|
|
|
cb_ = (void *)def;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfigSetting(const char *ini, std::string *v, StringDefaultCallback def, bool save = true)
|
|
|
|
: ini_(ini), type_(TYPE_STRING), report_(false), save_(save) {
|
|
|
|
ptr_ = (void *)v;
|
|
|
|
cb_ = (void *)def;
|
|
|
|
}
|
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
bool HasMore() {
|
|
|
|
return type_ != TYPE_TERMINATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Get(IniFile::Section *section) {
|
|
|
|
switch (type_) {
|
|
|
|
case TYPE_BOOL:
|
2014-02-10 01:08:40 +00:00
|
|
|
if (cb_) {
|
|
|
|
default_.b = ((BoolDefaultCallback)cb_)();
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
return section->Get(ini_, (bool *)ptr_, default_.b);
|
|
|
|
case TYPE_INT:
|
2014-02-10 01:08:40 +00:00
|
|
|
if (cb_) {
|
|
|
|
default_.i = ((IntDefaultCallback)cb_)();
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
return section->Get(ini_, (int *)ptr_, default_.i);
|
2014-02-10 01:08:40 +00:00
|
|
|
case TYPE_FLOAT:
|
|
|
|
if (cb_) {
|
|
|
|
default_.f = ((FloatDefaultCallback)cb_)();
|
|
|
|
}
|
|
|
|
return section->Get(ini_, (float *)ptr_, default_.f);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_STRING:
|
2014-02-10 01:08:40 +00:00
|
|
|
if (cb_) {
|
|
|
|
default_.s = ((StringDefaultCallback)cb_)();
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
return section->Get(ini_, (std::string *)ptr_, default_.s);
|
|
|
|
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:
|
|
|
|
return section->Set(ini_, *(bool *)ptr_);
|
|
|
|
case TYPE_INT:
|
|
|
|
return section->Set(ini_, *(int *)ptr_);
|
2014-02-10 01:08:40 +00:00
|
|
|
case TYPE_FLOAT:
|
|
|
|
return section->Set(ini_, *(float *)ptr_);
|
2014-02-09 23:46:49 +00:00
|
|
|
case TYPE_STRING:
|
|
|
|
return section->Set(ini_, *(std::string *)ptr_);
|
|
|
|
default:
|
|
|
|
_dbg_assert_msg_(LOADER, false, "Unexpected ini setting type");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *ini_;
|
|
|
|
Type type_;
|
|
|
|
bool report_;
|
|
|
|
bool save_;
|
|
|
|
void *ptr_;
|
|
|
|
Value default_;
|
2014-02-10 01:08:40 +00:00
|
|
|
void *cb_;
|
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>
|
|
|
|
ReportedConfigSetting(const char *ini, T1 *v, T2 def, bool save = true)
|
2014-02-09 23:46:49 +00:00
|
|
|
: ConfigSetting(ini, v, def, save) {
|
|
|
|
report_ = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
const char *DefaultLangRegion() {
|
|
|
|
static std::string defaultLangRegion = "en_US";
|
|
|
|
if (g_Config.bFirstRun) {
|
|
|
|
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
|
|
|
|
if (i18nrepo.IniExists(langRegion))
|
|
|
|
defaultLangRegion = langRegion;
|
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
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static int DefaultNumWorkers() {
|
|
|
|
return cpu_info.num_cores;
|
|
|
|
}
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static bool DefaultJit() {
|
|
|
|
#ifdef IOS
|
|
|
|
return iosCanUseJit;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
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),
|
|
|
|
ConfigSetting("IgnoreBadMemAccess", &g_Config.bIgnoreBadMemAccess, true),
|
|
|
|
ConfigSetting("CurrentDirectory", &g_Config.currentDirectory, ""),
|
|
|
|
ConfigSetting("ShowDebuggerOnLoad", &g_Config.bShowDebuggerOnLoad, false),
|
|
|
|
ConfigSetting("HomebrewStore", &g_Config.bHomebrewStore, false, false),
|
|
|
|
ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true),
|
2014-02-10 01:08:40 +00:00
|
|
|
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion),
|
2014-02-09 23:46:49 +00:00
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers),
|
2014-02-09 23:46:49 +00:00
|
|
|
ConfigSetting("EnableAutoLoad", &g_Config.bEnableAutoLoad, false),
|
|
|
|
ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false),
|
|
|
|
ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false),
|
|
|
|
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0),
|
|
|
|
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0),
|
|
|
|
|
|
|
|
ConfigSetting("GridView1", &g_Config.bGridView1, true),
|
|
|
|
ConfigSetting("GridView2", &g_Config.bGridView2, true),
|
|
|
|
ConfigSetting("GridView3", &g_Config.bGridView3, false),
|
|
|
|
|
|
|
|
// "default" means let emulator decide, "" means disable.
|
|
|
|
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default"),
|
|
|
|
ConfigSetting("AutoSaveSymbolMap", &g_Config.bAutoSaveSymbolMap, false),
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, 1),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#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),
|
|
|
|
ConfigSetting("PauseOnLostFocus", &g_Config.bPauseOnLostFocus, false),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
static ConfigSetting cpuSettings[] = {
|
|
|
|
ReportedConfigSetting("Jit", &g_Config.bJit, &DefaultJit),
|
|
|
|
ReportedConfigSetting("SeparateCPUThread", &g_Config.bSeparateCPUThread, false),
|
|
|
|
ConfigSetting("AtomicAudioLocks", &g_Config.bAtomicAudioLocks, false),
|
|
|
|
|
|
|
|
ReportedConfigSetting("SeparateIOThread", &g_Config.bSeparateIOThread, true),
|
|
|
|
ConfigSetting("FastMemoryAccess", &g_Config.bFastMemory, true),
|
|
|
|
ReportedConfigSetting("CPUSpeed", &g_Config.iLockedCPUSpeed, 0),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int DefaultRenderingMode() {
|
|
|
|
if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
|
|
|
|
return 0; // Non-buffered
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int DefaultInternalResolution() {
|
|
|
|
// Auto on Windows, 2x on large screens, 1x elsewhere.
|
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return pixel_xres >= 1024 ? 2 : 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool DefaultPartialStretch() {
|
|
|
|
#ifdef BLACKBERRY
|
|
|
|
return pixel_xres < 1.3 * pixel_yres;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool DefaultTimerHack() {
|
|
|
|
// Has been in use on Symbian since v0.7. Preferred option.
|
|
|
|
#ifdef __SYMBIAN32__
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static ConfigSetting graphicsSettings[] = {
|
|
|
|
ConfigSetting("ShowFPSCounter", &g_Config.iShowFPSCounter, 0),
|
|
|
|
ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, &DefaultRenderingMode),
|
|
|
|
ConfigSetting("SoftwareRendering", &g_Config.bSoftwareRendering, false),
|
|
|
|
ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true),
|
|
|
|
ReportedConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true),
|
|
|
|
ReportedConfigSetting("TextureFiltering", &g_Config.iTexFiltering, 1),
|
|
|
|
ReportedConfigSetting("InternalResolution", &g_Config.iInternalResolution, &DefaultInternalResolution),
|
|
|
|
ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0),
|
|
|
|
ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false),
|
|
|
|
ReportedConfigSetting("FrameRate", &g_Config.iFpsLimit, 0),
|
|
|
|
#ifdef _WIN32
|
|
|
|
ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, false),
|
|
|
|
#else
|
|
|
|
ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, true),
|
|
|
|
#endif
|
|
|
|
ReportedConfigSetting("ForceMaxEmulatedFPS", &g_Config.iForceMaxEmulatedFPS, 60),
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 0),
|
|
|
|
#else
|
|
|
|
ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 8),
|
|
|
|
#endif
|
|
|
|
ReportedConfigSetting("VertexCache", &g_Config.bVertexCache, true),
|
|
|
|
ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false),
|
|
|
|
ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false),
|
|
|
|
ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultJit, false),
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
ConfigSetting("FullScreen", &g_Config.bFullScreen, false),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// TODO: Replace these settings with a list of options
|
|
|
|
ConfigSetting("PartialStretch", &g_Config.bPartialStretch, &DefaultPartialStretch),
|
|
|
|
ConfigSetting("StretchToDisplay", &g_Config.bStretchToDisplay, false),
|
|
|
|
ConfigSetting("SmallDisplay", &g_Config.bSmallDisplay, false),
|
|
|
|
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false),
|
|
|
|
|
|
|
|
ConfigSetting("TrueColor", &g_Config.bTrueColor, true),
|
|
|
|
|
|
|
|
ReportedConfigSetting("MipMap", &g_Config.bMipMap, true),
|
|
|
|
|
|
|
|
ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1),
|
|
|
|
ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0),
|
|
|
|
ReportedConfigSetting("TexDeposterize", &g_Config.bTexDeposterize, false),
|
|
|
|
ConfigSetting("VSyncInterval", &g_Config.bVSync, false),
|
|
|
|
ReportedConfigSetting("DisableStencilTest", &g_Config.bDisableStencilTest, false),
|
|
|
|
ReportedConfigSetting("AlwaysDepthWrite", &g_Config.bAlwaysDepthWrite, false),
|
|
|
|
|
|
|
|
// Not really a graphics setting...
|
|
|
|
ReportedConfigSetting("TimerHack", &g_Config.bTimerHack, &DefaultTimerHack),
|
|
|
|
ReportedConfigSetting("LowQualitySplineBezier", &g_Config.bLowQualitySplineBezier, false),
|
|
|
|
ReportedConfigSetting("PostShader", &g_Config.sPostShaderName, "Off"),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting soundSettings[] = {
|
|
|
|
ConfigSetting("Enable", &g_Config.bEnableSound, true),
|
|
|
|
ConfigSetting("VolumeBGM", &g_Config.iBGMVolume, 7),
|
|
|
|
ConfigSetting("VolumeSFX", &g_Config.iSFXVolume, 7),
|
|
|
|
ConfigSetting("LowLatency", &g_Config.bLowLatencyAudio, false),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool DefaultShowTouchControls() {
|
|
|
|
#if defined(MOBILE_DEVICE)
|
|
|
|
std::string name = System_GetProperty(SYSPROP_NAME);
|
|
|
|
if (KeyMap::HasBuiltinController(name)) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static const float defaultControlScale = 1.15f;
|
|
|
|
|
|
|
|
static ConfigSetting controlSettings[] = {
|
|
|
|
ConfigSetting("HapticFeedback", &g_Config.bHapticFeedback, true),
|
|
|
|
ConfigSetting("ShowTouchCross", &g_Config.bShowTouchCross, true),
|
|
|
|
ConfigSetting("ShowTouchCircle", &g_Config.bShowTouchCircle, true),
|
|
|
|
ConfigSetting("ShowTouchSquare", &g_Config.bShowTouchSquare, true),
|
|
|
|
ConfigSetting("ShowTouchTriangle", &g_Config.bShowTouchTriangle, true),
|
|
|
|
ConfigSetting("ShowTouchStart", &g_Config.bShowTouchStart, true),
|
|
|
|
ConfigSetting("ShowTouchSelect", &g_Config.bShowTouchSelect, true),
|
|
|
|
ConfigSetting("ShowTouchLTrigger", &g_Config.bShowTouchLTrigger, true),
|
|
|
|
ConfigSetting("ShowTouchRTrigger", &g_Config.bShowTouchRTrigger, true),
|
|
|
|
ConfigSetting("ShowAnalogStick", &g_Config.bShowTouchAnalogStick, true),
|
|
|
|
ConfigSetting("ShowTouchDpad", &g_Config.bShowTouchDpad, true),
|
|
|
|
ConfigSetting("ShowTouchUnthrottle", &g_Config.bShowTouchUnthrottle, true),
|
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
ConfigSetting("IgnoreWindowsKey", &g_Config.bIgnoreWindowsKey, false),
|
|
|
|
#endif
|
|
|
|
ConfigSetting("ShowTouchControls", &g_Config.bShowTouchControls, &DefaultShowTouchControls),
|
|
|
|
// ConfigSetting("KeyMapping", &g_Config.iMappingMap, 0),
|
|
|
|
|
|
|
|
#ifdef MOBILE_DEVICE
|
|
|
|
ConfigSetting("TiltBaseX", &g_Config.fTiltBaseX, 0.0f),
|
|
|
|
ConfigSetting("TiltBaseY", &g_Config.fTiltBaseY, 0.0f),
|
|
|
|
ConfigSetting("InvertTiltX", &g_Config.bInvertTiltX, false),
|
|
|
|
ConfigSetting("InvertTiltY", &g_Config.bInvertTiltY, true),
|
|
|
|
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100),
|
|
|
|
ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 100),
|
|
|
|
ConfigSetting("DeadzoneRadius", &g_Config.fDeadzoneRadius, 0.2f),
|
|
|
|
ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false),
|
|
|
|
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1),
|
|
|
|
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65),
|
|
|
|
|
|
|
|
// -1.0f means uninitialized, set in GamepadEmu::CreatePadLayout().
|
|
|
|
ConfigSetting("ActionButtonSpacing2", &g_Config.fActionButtonSpacing, 1.0f),
|
|
|
|
ConfigSetting("ActionButtonCenterX", &g_Config.fActionButtonCenterX, -1.0f),
|
|
|
|
ConfigSetting("ActionButtonCenterY", &g_Config.fActionButtonCenterY, -1.0f),
|
|
|
|
ConfigSetting("ActionButtonScale", &g_Config.fActionButtonScale, defaultControlScale),
|
|
|
|
ConfigSetting("DPadX", &g_Config.fDpadX, -1.0f),
|
|
|
|
ConfigSetting("DPadY", &g_Config.fDpadY, -1.0f),
|
|
|
|
|
|
|
|
// Note: these will be overwritten if DPadRadius is set.
|
|
|
|
ConfigSetting("DPadScale", &g_Config.fDpadScale, defaultControlScale),
|
|
|
|
ConfigSetting("DPadSpacing", &g_Config.fDpadSpacing, 1.0f),
|
|
|
|
ConfigSetting("StartKeyX", &g_Config.fStartKeyX, -1.0f),
|
|
|
|
ConfigSetting("StartKeyY", &g_Config.fStartKeyY, -1.0f),
|
|
|
|
ConfigSetting("StartKeyScale", &g_Config.fStartKeyScale, defaultControlScale),
|
|
|
|
ConfigSetting("SelectKeyX", &g_Config.fSelectKeyX, -1.0f),
|
|
|
|
ConfigSetting("SelectKeyY", &g_Config.fSelectKeyY, -1.0f),
|
|
|
|
ConfigSetting("SelectKeyScale", &g_Config.fSelectKeyScale, defaultControlScale),
|
|
|
|
ConfigSetting("UnthrottleKeyX", &g_Config.fUnthrottleKeyX, -1.0f),
|
|
|
|
ConfigSetting("UnthrottleKeyY", &g_Config.fUnthrottleKeyY, -1.0f),
|
|
|
|
ConfigSetting("UnthrottleKeyScale", &g_Config.fUnthrottleKeyScale, defaultControlScale),
|
|
|
|
ConfigSetting("LKeyX", &g_Config.fLKeyX, -1.0f),
|
|
|
|
ConfigSetting("LKeyY", &g_Config.fLKeyY, -1.0f),
|
|
|
|
ConfigSetting("LKeyScale", &g_Config.fLKeyScale, defaultControlScale),
|
|
|
|
ConfigSetting("RKeyX", &g_Config.fRKeyX, -1.0f),
|
|
|
|
ConfigSetting("RKeyY", &g_Config.fRKeyY, -1.0f),
|
|
|
|
ConfigSetting("RKeyScale", &g_Config.fRKeyScale, defaultControlScale),
|
|
|
|
ConfigSetting("AnalogStickX", &g_Config.fAnalogStickX, -1.0f),
|
|
|
|
ConfigSetting("AnalogStickY", &g_Config.fAnalogStickY, -1.0f),
|
|
|
|
ConfigSetting("AnalogStickScale", &g_Config.fAnalogStickScale, defaultControlScale),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting networkSettings[] = {
|
|
|
|
ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int DefaultPSPModel() {
|
|
|
|
// TODO: Can probably default this on, but not sure about its memory differences.
|
|
|
|
#if !defined(_M_X64) && !defined(_WIN32) && !defined(__SYMBIAN32__)
|
|
|
|
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[] = {
|
|
|
|
ReportedConfigSetting("PSPModel", &g_Config.iPSPModel, &DefaultPSPModel),
|
|
|
|
ReportedConfigSetting("PSPFirmwareVersion", &g_Config.iFirmwareVersion, PSP_DEFAULT_FIRMWARE),
|
|
|
|
ConfigSetting("NickName", &g_Config.sNickName, "PPSSPP"),
|
|
|
|
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "localhost"),
|
|
|
|
ConfigSetting("MacAddress", &g_Config.localMacAddress, "01:02:03:04:05:06"),
|
|
|
|
ReportedConfigSetting("Language", &g_Config.iLanguage, &DefaultSystemParamLanguage),
|
|
|
|
ConfigSetting("TimeFormat", &g_Config.iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR),
|
|
|
|
ConfigSetting("DateFormat", &g_Config.iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD),
|
|
|
|
ConfigSetting("TimeZone", &g_Config.iTimeZone, 0),
|
|
|
|
ConfigSetting("DayLightSavings", &g_Config.bDayLightSavings, (bool)PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD),
|
|
|
|
ReportedConfigSetting("ButtonPreference", &g_Config.iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS),
|
|
|
|
ConfigSetting("LockParentalLevel", &g_Config.iLockParentalLevel, 0),
|
|
|
|
ConfigSetting("WlanAdhocChannel", &g_Config.iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC),
|
|
|
|
#if defined(USING_WIN_UI)
|
|
|
|
ConfigSetting("BypassOSKWithKeyboard", &g_Config.bBypassOSKWithKeyboard, false),
|
|
|
|
#endif
|
|
|
|
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool)PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF),
|
|
|
|
ReportedConfigSetting("EncryptSave", &g_Config.bEncryptSave, true),
|
|
|
|
|
|
|
|
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),
|
|
|
|
ConfigSetting("ShowBottomTabTitles",&g_Config.bShowBottomTabTitles,true),
|
|
|
|
ConfigSetting("ShowDeveloperMenu", &g_Config.bShowDeveloperMenu, false),
|
|
|
|
ConfigSetting("SkipDeadbeefFilling", &g_Config.bSkipDeadbeefFilling, false),
|
|
|
|
ConfigSetting("FuncHashMap", &g_Config.bFuncHashMap, false),
|
|
|
|
|
|
|
|
ConfigSetting(false),
|
|
|
|
};
|
|
|
|
|
|
|
|
static ConfigSetting speedHackSettings[] = {
|
|
|
|
ReportedConfigSetting("PrescaleUV", &g_Config.bPrescaleUV, false),
|
|
|
|
ReportedConfigSetting("DisableAlphaTest", &g_Config.bDisableAlphaTest, false),
|
|
|
|
|
|
|
|
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),
|
|
|
|
};
|
|
|
|
|
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},
|
|
|
|
{"SpeedHacks", speedHackSettings},
|
|
|
|
{"JIT", jitSettings},
|
|
|
|
{"Upgrade", upgradeSettings},
|
2014-02-09 23:46:49 +00:00
|
|
|
};
|
|
|
|
|
2013-06-17 18:28:22 +00:00
|
|
|
Config::Config() { }
|
|
|
|
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) {
|
2013-10-12 23:02:03 +00:00
|
|
|
iniFilename_ = FindConfigFile(iniFileName != NULL ? iniFileName : "ppsspp.ini");
|
|
|
|
controllerIniFilename_ = FindConfigFile(controllerIniFilename != NULL ? 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;
|
|
|
|
|
|
|
|
IniFile iniFile;
|
2013-09-15 16:50:42 +00:00
|
|
|
if (!iniFile.Load(iniFilename_)) {
|
2013-09-15 23:01:46 +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
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
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) {
|
|
|
|
setting->Get(section);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-26 09:24:31 +00:00
|
|
|
iRunCount++;
|
2013-10-25 16:44:19 +00:00
|
|
|
if (!File::Exists(currentDirectory))
|
|
|
|
currentDirectory = "";
|
|
|
|
|
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)
|
|
|
|
if (iMaxRecent == 0)
|
|
|
|
iMaxRecent = 30;
|
|
|
|
|
|
|
|
recentIsos.clear();
|
2014-02-10 01:08:40 +00:00
|
|
|
for (int i = 0; i < iMaxRecent; i++) {
|
2013-08-30 17:48:56 +00:00
|
|
|
char keyName[64];
|
|
|
|
std::string fileName;
|
|
|
|
|
2014-02-10 01:08:40 +00:00
|
|
|
sprintf(keyName, "FileName%d", i);
|
|
|
|
if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
|
2013-09-05 16:45:41 +00:00
|
|
|
recentIsos.push_back(fileName);
|
|
|
|
}
|
2013-08-30 17:48:56 +00:00
|
|
|
}
|
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) {
|
|
|
|
vPinnedPaths.push_back(it->second);
|
2013-12-08 06:39:35 +00:00
|
|
|
}
|
|
|
|
|
2013-07-17 20:27:05 +00:00
|
|
|
if (iAnisotropyLevel > 4) {
|
|
|
|
iAnisotropyLevel = 4;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
// MIGRATION: For users who had the old static touch layout, aren't I nice?
|
2014-02-10 01:08:40 +00:00
|
|
|
if (fDpadX > 1.0 || fDpadY > 1.0) { // Likely the rest are too!
|
2013-11-05 04:52:31 +00:00
|
|
|
fActionButtonCenterX /= dp_xres;
|
|
|
|
fActionButtonCenterY /= dp_yres;
|
|
|
|
fDpadX /= dp_xres;
|
|
|
|
fDpadY /= dp_yres;
|
|
|
|
fStartKeyX /= dp_xres;
|
|
|
|
fStartKeyY /= dp_yres;
|
|
|
|
fSelectKeyX /= dp_xres;
|
|
|
|
fSelectKeyY /= dp_yres;
|
|
|
|
fUnthrottleKeyX /= dp_xres;
|
|
|
|
fUnthrottleKeyY /= dp_yres;
|
|
|
|
fLKeyX /= dp_xres;
|
|
|
|
fLKeyY /= dp_yres;
|
|
|
|
fRKeyX /= dp_xres;
|
|
|
|
fRKeyY /= dp_yres;
|
|
|
|
fAnalogStickX /= dp_xres;
|
|
|
|
fAnalogStickY /= dp_yres;
|
|
|
|
}
|
2013-11-26 13:04:29 +00:00
|
|
|
|
|
|
|
if (dismissedVersion == upgradeVersion) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
IniFile controllerIniFile;
|
2013-09-15 16:50:42 +00:00
|
|
|
if (!controllerIniFile.Load(controllerIniFilename_)) {
|
2013-09-15 23:01:46 +00:00
|
|
|
ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
|
2013-08-20 14:06:43 +00:00
|
|
|
KeyMap::RestoreDefault();
|
|
|
|
} else {
|
|
|
|
// Continue anyway to initialize the config. It will just restore the defaults.
|
|
|
|
KeyMap::LoadFromIni(controllerIniFile);
|
2013-08-16 17:34:44 +00:00
|
|
|
}
|
|
|
|
|
2013-04-13 19:24:07 +00:00
|
|
|
CleanRecent();
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-08-20 14:06:43 +00:00
|
|
|
void Config::Save() {
|
2013-01-04 09:26:14 +00:00
|
|
|
if (iniFilename_.size() && g_Config.bSaveSettings) {
|
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())) {
|
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't read ini %s", iniFilename_.c_str());
|
|
|
|
}
|
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
|
|
|
|
2014-02-09 23:46:49 +00:00
|
|
|
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) {
|
|
|
|
setting->Set(section);
|
|
|
|
}
|
|
|
|
}
|
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];
|
|
|
|
sprintf(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
|
|
|
|
2013-01-04 09:26:14 +00:00
|
|
|
if (!iniFile.Save(iniFilename_.c_str())) {
|
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
INFO_LOG(LOADER, "Config saved: %s", iniFilename_.c_str());
|
2013-08-16 17:34:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
IniFile controllerIniFile;
|
|
|
|
if (!controllerIniFile.Load(controllerIniFilename_.c_str())) {
|
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't read ini %s", controllerIniFilename_.c_str());
|
|
|
|
}
|
2013-08-20 14:06:43 +00:00
|
|
|
KeyMap::SaveToIni(controllerIniFile);
|
2013-08-16 17:34:44 +00:00
|
|
|
if (!controllerIniFile.Save(controllerIniFilename_.c_str())) {
|
|
|
|
ERROR_LOG(LOADER, "Error saving config - can't write ini %s", controllerIniFilename_.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
INFO_LOG(LOADER, "Controller config saved: %s", controllerIniFilename_.c_str());
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
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) {
|
|
|
|
ERROR_LOG(LOADER, "Failed to download version.json");
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:04:29 +00:00
|
|
|
JsonReader reader(data.c_str(), data.size());
|
|
|
|
const json_value *root = reader.root();
|
|
|
|
std::string version = root->getString("version", "");
|
|
|
|
|
|
|
|
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) {
|
2013-11-23 17:11:33 +00:00
|
|
|
for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) {
|
2013-11-19 12:46:33 +00:00
|
|
|
#ifdef _WIN32
|
2013-11-23 17:11:33 +00:00
|
|
|
if (!strcmpIgnore((*str).c_str(), file.c_str(), "\\", "/")) {
|
2013-11-19 12:46:33 +00:00
|
|
|
#else
|
2013-11-23 17:11:33 +00:00
|
|
|
if (!strcmp((*str).c_str(), file.c_str())) {
|
2013-11-19 12:46:33 +00:00
|
|
|
#endif
|
2013-03-24 19:03:42 +00:00
|
|
|
recentIsos.erase(str);
|
|
|
|
recentIsos.insert(recentIsos.begin(), file);
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
recentIsos.insert(recentIsos.begin(), file);
|
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
|
|
|
|
|
|
|
void Config::CleanRecent() {
|
|
|
|
std::vector<std::string> cleanedRecent;
|
|
|
|
for (size_t i = 0; i < recentIsos.size(); i++) {
|
2013-11-20 15:36:58 +00:00
|
|
|
if (File::Exists(recentIsos[i])) {
|
2013-09-04 22:04:24 +00:00
|
|
|
// clean the redundant recent games' list.
|
2013-11-20 15:36:58 +00:00
|
|
|
if (cleanedRecent.size()==0) { // add first one
|
|
|
|
cleanedRecent.push_back(recentIsos[i]);
|
2013-09-04 22:04:24 +00:00
|
|
|
}
|
2013-11-20 15:36:58 +00:00
|
|
|
for (size_t j = 0; j < cleanedRecent.size();j++) {
|
|
|
|
if (cleanedRecent[j] == recentIsos[i])
|
2013-09-04 22:04:24 +00:00
|
|
|
break; // skip if found redundant
|
2013-11-20 15:36:58 +00:00
|
|
|
if (j == cleanedRecent.size() - 1){ // add if no redundant found
|
2013-09-04 22:04:24 +00:00
|
|
|
cleanedRecent.push_back(recentIsos[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
File::CreateFullPath(path);
|
|
|
|
}
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2013-08-28 20:23:16 +00:00
|
|
|
void Config::RestoreDefaults() {
|
2013-10-12 23:05:00 +00:00
|
|
|
if(File::Exists(iniFilename_))
|
|
|
|
File::Delete(iniFilename_);
|
2013-08-28 20:23:16 +00:00
|
|
|
recentIsos.clear();
|
|
|
|
currentDirectory = "";
|
|
|
|
Load();
|
|
|
|
}
|
2013-12-12 13:52:46 +00:00
|
|
|
|
|
|
|
void Config::ResetControlLayout() {
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fActionButtonScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fActionButtonSpacing = 1.0f;
|
|
|
|
g_Config.fActionButtonCenterX = -1.0;
|
|
|
|
g_Config.fActionButtonCenterY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fDpadScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fDpadSpacing = 1.0f;
|
|
|
|
g_Config.fDpadX = -1.0;
|
|
|
|
g_Config.fDpadY = -1.0;
|
|
|
|
g_Config.fStartKeyX = -1.0;
|
|
|
|
g_Config.fStartKeyY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fStartKeyScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fSelectKeyX = -1.0;
|
|
|
|
g_Config.fSelectKeyY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fSelectKeyScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fUnthrottleKeyX = -1.0;
|
|
|
|
g_Config.fUnthrottleKeyY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fUnthrottleKeyScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fLKeyX = -1.0;
|
|
|
|
g_Config.fLKeyY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fLKeyScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fRKeyX = -1.0;
|
|
|
|
g_Config.fRKeyY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fRKeyScale = defaultControlScale;
|
2013-12-12 13:52:46 +00:00
|
|
|
g_Config.fAnalogStickX = -1.0;
|
|
|
|
g_Config.fAnalogStickY = -1.0;
|
2014-02-10 01:08:40 +00:00
|
|
|
g_Config.fAnalogStickScale = defaultControlScale;
|
2013-12-08 06:39:35 +00:00
|
|
|
}
|