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-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-04-18 09:58:54 +00:00
|
|
|
#include "file/ini_file.h"
|
2013-09-04 10:07:42 +00:00
|
|
|
#include "i18n/i18n.h"
|
2013-10-25 09:45:41 +00:00
|
|
|
#include "gfx_es2/gpu_features.h"
|
2013-01-20 09:50:05 +00:00
|
|
|
#include "HLE/sceUtility.h"
|
2013-05-01 12:08:01 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
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
|
|
|
|
extern bool isJailed;
|
|
|
|
#endif
|
|
|
|
|
2013-06-17 18:28:22 +00:00
|
|
|
Config::Config() { }
|
|
|
|
Config::~Config() { }
|
2012-11-01 15:19:01 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
IniFile::Section *general = iniFile.GetOrCreateSection("General");
|
|
|
|
|
|
|
|
general->Get("FirstRun", &bFirstRun, true);
|
2013-07-27 23:55:57 +00:00
|
|
|
general->Get("Enable Logging", &bEnableLogging, true);
|
2013-01-04 09:26:14 +00:00
|
|
|
general->Get("AutoRun", &bAutoRun, true);
|
2013-02-17 19:39:31 +00:00
|
|
|
general->Get("Browse", &bBrowse, false);
|
2012-11-01 15:19:01 +00:00
|
|
|
general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
|
|
|
|
general->Get("CurrentDirectory", ¤tDirectory, "");
|
2013-08-19 23:46:06 +00:00
|
|
|
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
|
2013-09-04 10:07:42 +00:00
|
|
|
|
2013-10-25 16:44:19 +00:00
|
|
|
if (!File::Exists(currentDirectory))
|
|
|
|
currentDirectory = "";
|
|
|
|
|
2013-09-04 10:07:42 +00:00
|
|
|
std::string defaultLangRegion = "en_US";
|
|
|
|
if (bFirstRun) {
|
|
|
|
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
|
|
|
|
if (i18nrepo.IniExists(langRegion))
|
|
|
|
defaultLangRegion = langRegion;
|
|
|
|
// TODO: Be smart about same language, different country
|
|
|
|
}
|
|
|
|
|
2013-09-16 23:47:25 +00:00
|
|
|
general->Get("Language", &sLanguageIni, defaultLangRegion.c_str());
|
2013-05-01 12:08:01 +00:00
|
|
|
general->Get("NumWorkerThreads", &iNumWorkerThreads, cpu_info.num_cores);
|
2013-11-01 23:11:20 +00:00
|
|
|
general->Get("EnableAutoLoad", &bEnableAutoLoad, false);
|
2013-05-23 11:10:39 +00:00
|
|
|
general->Get("EnableCheats", &bEnableCheats, false);
|
2013-07-07 22:10:23 +00:00
|
|
|
general->Get("ScreenshotsAsPNG", &bScreenshotsAsPNG, false);
|
2013-07-21 11:31:46 +00:00
|
|
|
general->Get("StateSlot", &iCurrentStateSlot, 0);
|
2013-11-03 01:33:23 +00:00
|
|
|
general->Get("RewindFlipFrequency", &iRewindFlipFrequency, 0);
|
2013-08-18 20:30:34 +00:00
|
|
|
general->Get("GridView1", &bGridView1, true);
|
|
|
|
general->Get("GridView2", &bGridView2, true);
|
|
|
|
general->Get("GridView3", &bGridView3, true);
|
2013-05-23 11:10:39 +00:00
|
|
|
|
2013-03-01 16:51:01 +00:00
|
|
|
// "default" means let emulator decide, "" means disable.
|
2013-08-21 13:53:45 +00:00
|
|
|
general->Get("ReportingHost", &sReportHost, "default");
|
2013-03-24 19:03:42 +00:00
|
|
|
general->Get("Recent", recentIsos);
|
2013-03-31 04:42:43 +00:00
|
|
|
general->Get("AutoSaveSymbolMap", &bAutoSaveSymbolMap, false);
|
2013-06-10 21:45:12 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
general->Get("TopMost", &bTopMost);
|
2013-10-15 11:10:14 +00:00
|
|
|
general->Get("WindowX", &iWindowX, -1); // -1 tells us to center the window.
|
|
|
|
general->Get("WindowY", &iWindowY, -1);
|
2013-09-10 22:19:34 +00:00
|
|
|
general->Get("WindowWidth", &iWindowWidth, 0); // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
|
|
|
|
general->Get("WindowHeight", &iWindowHeight, 0);
|
2013-10-11 11:53:25 +00:00
|
|
|
general->Get("PauseOnLostFocus", &bPauseOnLostFocus, false);
|
2013-06-10 21:45:12 +00:00
|
|
|
#endif
|
2013-03-30 16:49:02 +00:00
|
|
|
|
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();
|
|
|
|
for (int i = 0; i < iMaxRecent; i++)
|
|
|
|
{
|
|
|
|
char keyName[64];
|
|
|
|
std::string fileName;
|
|
|
|
|
|
|
|
sprintf(keyName,"FileName%d",i);
|
2013-09-05 16:45:41 +00:00
|
|
|
if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) {
|
|
|
|
// just skip it to get the next key
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recentIsos.push_back(fileName);
|
|
|
|
}
|
2013-08-30 17:48:56 +00:00
|
|
|
}
|
2012-12-21 15:49:02 +00:00
|
|
|
|
2012-11-23 11:42:35 +00:00
|
|
|
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
2013-04-23 05:38:28 +00:00
|
|
|
#ifdef IOS
|
2013-05-08 13:22:45 +00:00
|
|
|
cpu->Get("Jit", &bJit, !isJailed);
|
2013-04-23 05:38:28 +00:00
|
|
|
#else
|
2013-02-16 08:49:33 +00:00
|
|
|
cpu->Get("Jit", &bJit, true);
|
2013-04-23 05:38:28 +00:00
|
|
|
#endif
|
2013-08-08 08:09:43 +00:00
|
|
|
cpu->Get("SeparateCPUThread", &bSeparateCPUThread, false);
|
2013-10-15 06:06:37 +00:00
|
|
|
cpu->Get("AtomicAudioLocks", &bAtomicAudioLocks, false);
|
2013-10-25 09:45:41 +00:00
|
|
|
|
2013-08-21 19:06:02 +00:00
|
|
|
#ifdef __SYMBIAN32__
|
2013-08-12 15:54:25 +00:00
|
|
|
cpu->Get("SeparateIOThread", &bSeparateIOThread, false);
|
2013-08-21 19:06:02 +00:00
|
|
|
#else
|
|
|
|
cpu->Get("SeparateIOThread", &bSeparateIOThread, true);
|
|
|
|
#endif
|
2013-02-24 21:22:01 +00:00
|
|
|
cpu->Get("FastMemory", &bFastMemory, false);
|
2013-08-18 17:51:40 +00:00
|
|
|
cpu->Get("CPUSpeed", &iLockedCPUSpeed, 0);
|
2012-11-23 11:42:35 +00:00
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
2013-06-19 05:08:29 +00:00
|
|
|
graphics->Get("ShowFPSCounter", &iShowFPSCounter, false);
|
2013-10-25 09:45:41 +00:00
|
|
|
|
|
|
|
int renderingModeDefault = 1; // Buffered
|
|
|
|
if (System_GetProperty(SYSPROP_NAME) == "samsung:GT-S5360") {
|
|
|
|
renderingModeDefault = 0; // Non-buffered
|
|
|
|
}
|
|
|
|
|
|
|
|
graphics->Get("RenderingMode", &iRenderingMode, renderingModeDefault);
|
2013-08-16 19:48:30 +00:00
|
|
|
graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
|
2013-01-02 20:00:10 +00:00
|
|
|
graphics->Get("HardwareTransform", &bHardwareTransform, true);
|
2013-07-18 08:26:29 +00:00
|
|
|
graphics->Get("TextureFiltering", &iTexFiltering, 1);
|
2013-09-10 22:19:34 +00:00
|
|
|
// Auto on Windows, 1x elsewhere. Maybe change to 2x on large screens?
|
|
|
|
#ifdef _WIN32
|
|
|
|
graphics->Get("InternalResolution", &iInternalResolution, 0);
|
|
|
|
#else
|
|
|
|
graphics->Get("InternalResolution", &iInternalResolution, 1);
|
|
|
|
#endif
|
|
|
|
|
2013-05-02 14:48:28 +00:00
|
|
|
graphics->Get("FrameSkip", &iFrameSkip, 0);
|
2013-07-05 19:19:56 +00:00
|
|
|
graphics->Get("FrameRate", &iFpsLimit, 0);
|
2013-09-20 12:51:46 +00:00
|
|
|
#ifdef _WIN32
|
2013-09-20 05:57:46 +00:00
|
|
|
graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, false);
|
2013-09-20 12:51:46 +00:00
|
|
|
#else
|
|
|
|
graphics->Get("FrameSkipUnthrottle", &bFrameSkipUnthrottle, true);
|
|
|
|
#endif
|
2013-08-21 19:06:02 +00:00
|
|
|
graphics->Get("ForceMaxEmulatedFPS", &iForceMaxEmulatedFPS, 60);
|
2013-02-11 18:03:11 +00:00
|
|
|
#ifdef USING_GLES2
|
2013-05-02 14:48:28 +00:00
|
|
|
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
|
2013-02-11 18:03:11 +00:00
|
|
|
#else
|
2013-05-02 14:48:28 +00:00
|
|
|
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
|
2013-02-11 18:03:11 +00:00
|
|
|
#endif
|
2013-07-17 20:27:05 +00:00
|
|
|
if (iAnisotropyLevel > 4) {
|
|
|
|
iAnisotropyLevel = 4;
|
|
|
|
}
|
2013-01-26 16:26:07 +00:00
|
|
|
graphics->Get("VertexCache", &bVertexCache, true);
|
2013-07-05 19:19:56 +00:00
|
|
|
#ifdef _WIN32
|
2013-05-08 13:22:45 +00:00
|
|
|
graphics->Get("FullScreen", &bFullScreen, false);
|
2013-07-05 19:19:56 +00:00
|
|
|
#endif
|
2013-06-21 05:40:52 +00:00
|
|
|
#ifdef BLACKBERRY
|
2013-05-08 13:22:45 +00:00
|
|
|
graphics->Get("PartialStretch", &bPartialStretch, pixel_xres == pixel_yres);
|
|
|
|
#endif
|
2013-02-13 17:21:21 +00:00
|
|
|
graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
|
2013-02-19 18:07:42 +00:00
|
|
|
graphics->Get("TrueColor", &bTrueColor, true);
|
2013-04-11 15:05:48 +00:00
|
|
|
graphics->Get("MipMap", &bMipMap, true);
|
2013-05-01 21:55:34 +00:00
|
|
|
graphics->Get("TexScalingLevel", &iTexScalingLevel, 1);
|
2013-05-03 08:29:29 +00:00
|
|
|
graphics->Get("TexScalingType", &iTexScalingType, 0);
|
2013-05-03 14:21:46 +00:00
|
|
|
graphics->Get("TexDeposterize", &bTexDeposterize, false);
|
2013-07-20 14:03:52 +00:00
|
|
|
graphics->Get("VSyncInterval", &bVSync, false);
|
2013-09-05 12:51:17 +00:00
|
|
|
graphics->Get("DisableStencilTest", &bDisableStencilTest, false);
|
|
|
|
graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false);
|
2013-09-24 09:14:04 +00:00
|
|
|
graphics->Get("LowQualitySplineBezier", &bLowQualitySplineBezier, false);
|
2013-10-30 21:44:01 +00:00
|
|
|
graphics->Get("WipeFramebufferAlpha", &bWipeFramebufferAlpha, false);
|
2013-10-12 00:05:55 +00:00
|
|
|
graphics->Get("PostShader", &sPostShaderName, "Off");
|
2013-04-30 01:46:27 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Get("Enable", &bEnableSound, true);
|
2013-07-25 21:51:45 +00:00
|
|
|
sound->Get("VolumeBGM", &iBGMVolume, 7);
|
2013-08-09 12:04:13 +00:00
|
|
|
sound->Get("VolumeSFX", &iSFXVolume, 7);
|
2013-08-24 00:16:10 +00:00
|
|
|
sound->Get("LowLatency", &bLowLatencyAudio, false);
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
2013-10-10 14:44:12 +00:00
|
|
|
control->Get("HapticFeedback", &bHapticFeedback, true);
|
2013-10-20 02:40:52 +00:00
|
|
|
control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
|
2013-10-20 03:59:57 +00:00
|
|
|
control->Get("ShowTouchCross", &bShowTouchCross, true);
|
|
|
|
control->Get("ShowTouchCircle", &bShowTouchCircle, true);
|
|
|
|
control->Get("ShowTouchSquare", &bShowTouchSquare, true);
|
|
|
|
control->Get("ShowTouchTriangle", &bShowTouchTriangle, true);
|
|
|
|
control->Get("ShowTouchStart", &bShowTouchStart, true);
|
2013-10-20 16:02:19 +00:00
|
|
|
control->Get("ShowTouchSelect", &bShowTouchSelect, true);
|
2013-10-20 03:59:57 +00:00
|
|
|
control->Get("ShowTouchLTrigger", &bShowTouchLTrigger, true);
|
|
|
|
control->Get("ShowTouchRTrigger", &bShowTouchRTrigger, true);
|
|
|
|
control->Get("ShowAnalogStick", &bShowTouchAnalogStick, true);
|
2013-10-20 16:02:19 +00:00
|
|
|
control->Get("ShowTouchDpad", &bShowTouchDpad, true);
|
2013-10-20 03:59:57 +00:00
|
|
|
control->Get("ShowTouchUnthrottle", &bShowTouchUnthrottle, true);
|
2013-10-20 02:40:52 +00:00
|
|
|
|
2013-10-12 07:19:02 +00:00
|
|
|
#if defined(USING_GLES2)
|
2013-09-04 09:29:38 +00:00
|
|
|
std::string name = System_GetProperty(SYSPROP_NAME);
|
2013-09-07 09:05:27 +00:00
|
|
|
if (KeyMap::HasBuiltinController(name)) {
|
2013-08-20 13:40:19 +00:00
|
|
|
control->Get("ShowTouchControls", &bShowTouchControls, false);
|
|
|
|
} else {
|
|
|
|
control->Get("ShowTouchControls", &bShowTouchControls, true);
|
|
|
|
}
|
2013-01-14 15:13:53 +00:00
|
|
|
#else
|
2013-07-05 19:19:56 +00:00
|
|
|
control->Get("ShowTouchControls", &bShowTouchControls, false);
|
2013-01-14 15:13:53 +00:00
|
|
|
#endif
|
2013-07-06 17:08:59 +00:00
|
|
|
// control->Get("KeyMapping",iMappingMap);
|
2013-09-29 19:45:06 +00:00
|
|
|
#ifdef USING_GLES2
|
2013-03-10 12:21:36 +00:00
|
|
|
control->Get("AccelerometerToAnalogHoriz", &bAccelerometerToAnalogHoriz, false);
|
2013-10-29 09:21:47 +00:00
|
|
|
|
2013-10-27 17:58:47 +00:00
|
|
|
control->Get("TiltBaseX", &fTiltBaseX, 0);
|
|
|
|
control->Get("TiltBaseY", &fTiltBaseY, 0);
|
|
|
|
control->Get("InvertTiltX", &bInvertTiltX, false);
|
|
|
|
control->Get("InvertTiltY", &bInvertTiltY, true);
|
|
|
|
control->Get("TiltSensitivityX", &iTiltSensitivityX, 100);
|
|
|
|
control->Get("TiltSensitivityY", &iTiltSensitivityY, 100);
|
2013-10-28 11:13:42 +00:00
|
|
|
control->Get("DeadzoneRadius", &fDeadzoneRadius, 0.35);
|
2013-10-27 17:58:47 +00:00
|
|
|
|
2013-09-29 19:45:06 +00:00
|
|
|
#endif
|
|
|
|
control->Get("TouchButtonOpacity", &iTouchButtonOpacity, 65);
|
2013-06-18 09:37:34 +00:00
|
|
|
control->Get("ButtonScale", &fButtonScale, 1.15);
|
2013-10-09 20:15:56 +00:00
|
|
|
//set these to -1 if not initialized. initializing these
|
|
|
|
//requires pixel coordinates which is not known right now.
|
|
|
|
//will be initialized in GamepadEmu::CreatePadLayout
|
|
|
|
control->Get("ActionButtonSpacing", &iActionButtonSpacing, -1);
|
2013-11-05 04:52:31 +00:00
|
|
|
control->Get("ActionButtonCenterX", &fActionButtonCenterX, -1.0);
|
|
|
|
control->Get("ActionButtonCenterY", &fActionButtonCenterY, -1.0);
|
2013-10-09 20:15:56 +00:00
|
|
|
control->Get("DPadRadius", &iDpadRadius, -1);
|
2013-11-05 04:52:31 +00:00
|
|
|
control->Get("DPadX", &fDpadX, -1.0);
|
|
|
|
control->Get("DPadY", &fDpadY, -1.0);
|
|
|
|
control->Get("StartKeyX", &fStartKeyX, -1.0);
|
|
|
|
control->Get("StartKeyY", &fStartKeyY, -1.0);
|
|
|
|
control->Get("SelectKeyX", &fSelectKeyX, -1.0);
|
|
|
|
control->Get("SelectKeyY", &fSelectKeyY, -1.0);
|
|
|
|
control->Get("UnthrottleKeyX", &fUnthrottleKeyX, -1.0);
|
|
|
|
control->Get("UnthrottleKeyY", &fUnthrottleKeyY, -1.0);
|
|
|
|
control->Get("LKeyX", &fLKeyX, -1.0);
|
|
|
|
control->Get("LKeyY", &fLKeyY, -1.0);
|
|
|
|
control->Get("RKeyX", &fRKeyX, -1.0);
|
|
|
|
control->Get("RKeyY", &fRKeyY, -1.0);
|
|
|
|
control->Get("AnalogStickX", &fAnalogStickX, -1.0);
|
|
|
|
control->Get("AnalogStickY", &fAnalogStickY, -1.0);
|
|
|
|
|
|
|
|
// MIGRATION: For users who had the old static touch layout, aren't I nice?
|
|
|
|
if (fDpadX > 1.0 || fDpadY > 1.0) // Likely the rest are too!
|
|
|
|
{
|
|
|
|
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-10-09 20:15:56 +00:00
|
|
|
|
2013-01-20 09:50:05 +00:00
|
|
|
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
2013-07-05 19:19:56 +00:00
|
|
|
pspConfig->Get("NickName", &sNickName, "PPSSPP");
|
2013-09-16 22:08:09 +00:00
|
|
|
pspConfig->Get("Language", &iLanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
|
2013-06-19 05:08:29 +00:00
|
|
|
pspConfig->Get("TimeFormat", &iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Get("DateFormat", &iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD);
|
|
|
|
pspConfig->Get("TimeZone", &iTimeZone, 0);
|
|
|
|
pspConfig->Get("DayLightSavings", &bDayLightSavings, PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD);
|
2013-06-19 05:08:29 +00:00
|
|
|
pspConfig->Get("ButtonPreference", &iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS);
|
2013-04-20 16:01:03 +00:00
|
|
|
pspConfig->Get("LockParentalLevel", &iLockParentalLevel, 0);
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Get("WlanAdhocChannel", &iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC);
|
2013-08-06 01:32:19 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
pspConfig->Get("BypassOSKWithKeyboard", &bBypassOSKWithKeyboard, false);
|
|
|
|
#endif
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Get("WlanPowerSave", &bWlanPowerSave, PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF);
|
2013-01-28 23:11:02 +00:00
|
|
|
pspConfig->Get("EncryptSave", &bEncryptSave, true);
|
2013-01-20 09:50:05 +00:00
|
|
|
|
2013-06-26 07:15:16 +00:00
|
|
|
IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
|
|
|
|
debugConfig->Get("DisasmWindowX", &iDisasmWindowX, -1);
|
|
|
|
debugConfig->Get("DisasmWindowY", &iDisasmWindowY, -1);
|
|
|
|
debugConfig->Get("DisasmWindowW", &iDisasmWindowW, -1);
|
|
|
|
debugConfig->Get("DisasmWindowH", &iDisasmWindowH, -1);
|
2013-09-28 14:04:56 +00:00
|
|
|
debugConfig->Get("GEWindowX", &iGEWindowX, -1);
|
|
|
|
debugConfig->Get("GEWindowY", &iGEWindowY, -1);
|
|
|
|
debugConfig->Get("GEWindowW", &iGEWindowW, -1);
|
|
|
|
debugConfig->Get("GEWindowH", &iGEWindowH, -1);
|
2013-06-26 07:32:49 +00:00
|
|
|
debugConfig->Get("ConsoleWindowX", &iConsoleWindowX, -1);
|
|
|
|
debugConfig->Get("ConsoleWindowY", &iConsoleWindowY, -1);
|
2013-07-09 09:17:57 +00:00
|
|
|
debugConfig->Get("FontWidth", &iFontWidth, 8);
|
|
|
|
debugConfig->Get("FontHeight", &iFontHeight, 12);
|
2013-07-30 15:06:37 +00:00
|
|
|
debugConfig->Get("DisplayStatusBar", &bDisplayStatusBar, true);
|
2013-09-30 19:42:05 +00:00
|
|
|
debugConfig->Get("ShowBottomTabTitles",&bShowBottomTabTitles,true);
|
2013-09-07 18:54:11 +00:00
|
|
|
debugConfig->Get("ShowDeveloperMenu", &bShowDeveloperMenu, false);
|
2013-10-30 06:02:05 +00:00
|
|
|
debugConfig->Get("SkipDeadbeefFilling", &bSkipDeadbeefFilling, false);
|
2013-06-26 07:15:16 +00:00
|
|
|
|
2013-10-08 20:59:40 +00:00
|
|
|
IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks");
|
|
|
|
speedhacks->Get("PrescaleUV", &bPrescaleUV, false);
|
2013-10-22 11:00:19 +00:00
|
|
|
speedhacks->Get("DisableAlphaTest", &bDisableAlphaTest, false);
|
2013-07-27 21:21:48 +00:00
|
|
|
|
2013-11-08 11:30:31 +00:00
|
|
|
IniFile::Section *jitConfig = iniFile.GetOrCreateSection("JIT");
|
|
|
|
jitConfig->Get("DiscardRegsOnJRRA", &bDiscardRegsOnJRRA, false);
|
|
|
|
|
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
|
|
|
|
|
|
|
IniFile::Section *general = iniFile.GetOrCreateSection("General");
|
2013-06-01 17:01:43 +00:00
|
|
|
|
|
|
|
// Need to do this somewhere...
|
|
|
|
bFirstRun = false;
|
2012-11-01 15:19:01 +00:00
|
|
|
general->Set("FirstRun", bFirstRun);
|
2013-07-27 23:55:57 +00:00
|
|
|
general->Set("Enable Logging", bEnableLogging);
|
2012-11-01 15:19:01 +00:00
|
|
|
general->Set("AutoRun", bAutoRun);
|
2013-02-17 19:39:31 +00:00
|
|
|
general->Set("Browse", bBrowse);
|
2012-11-01 15:19:01 +00:00
|
|
|
general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
|
|
|
|
general->Set("CurrentDirectory", currentDirectory);
|
2012-12-04 16:04:24 +00:00
|
|
|
general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
|
2013-08-21 16:52:21 +00:00
|
|
|
general->Set("ReportingHost", sReportHost);
|
2013-03-31 04:42:43 +00:00
|
|
|
general->Set("AutoSaveSymbolMap", bAutoSaveSymbolMap);
|
2013-06-10 21:45:12 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
general->Set("TopMost", bTopMost);
|
2013-07-05 19:19:56 +00:00
|
|
|
general->Set("WindowX", iWindowX);
|
|
|
|
general->Set("WindowY", iWindowY);
|
2013-09-10 22:19:34 +00:00
|
|
|
general->Set("WindowWidth", iWindowWidth);
|
|
|
|
general->Set("WindowHeight", iWindowHeight);
|
2013-10-11 11:53:25 +00:00
|
|
|
general->Set("PauseOnLostFocus", bPauseOnLostFocus);
|
2013-06-10 21:45:12 +00:00
|
|
|
#endif
|
2013-09-16 23:47:25 +00:00
|
|
|
general->Set("Language", sLanguageIni);
|
2013-05-01 12:08:01 +00:00
|
|
|
general->Set("NumWorkerThreads", iNumWorkerThreads);
|
2013-10-30 17:16:27 +00:00
|
|
|
general->Set("EnableAutoLoad", bEnableAutoLoad);
|
2013-05-23 11:10:39 +00:00
|
|
|
general->Set("EnableCheats", bEnableCheats);
|
2013-07-07 22:36:25 +00:00
|
|
|
general->Set("ScreenshotsAsPNG", bScreenshotsAsPNG);
|
2013-07-21 11:31:46 +00:00
|
|
|
general->Set("StateSlot", iCurrentStateSlot);
|
2013-11-03 01:33:23 +00:00
|
|
|
general->Set("RewindFlipFrequency", iRewindFlipFrequency);
|
2013-08-18 20:30:34 +00:00
|
|
|
general->Set("GridView1", bGridView1);
|
|
|
|
general->Set("GridView2", bGridView2);
|
|
|
|
general->Set("GridView3", bGridView3);
|
2013-08-30 17:48:56 +00:00
|
|
|
|
|
|
|
IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
|
|
|
|
recent->Set("MaxRecent", iMaxRecent);
|
|
|
|
|
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-08-30 17:48:56 +00:00
|
|
|
}
|
2013-03-01 16:51:01 +00:00
|
|
|
|
2012-11-23 11:42:35 +00:00
|
|
|
IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU");
|
2013-02-16 08:49:33 +00:00
|
|
|
cpu->Set("Jit", bJit);
|
2013-08-08 08:09:43 +00:00
|
|
|
cpu->Set("SeparateCPUThread", bSeparateCPUThread);
|
2013-10-15 06:06:37 +00:00
|
|
|
cpu->Set("AtomicAudioLocks", bAtomicAudioLocks);
|
2013-08-11 18:51:36 +00:00
|
|
|
cpu->Set("SeparateIOThread", bSeparateIOThread);
|
2012-12-21 15:49:02 +00:00
|
|
|
cpu->Set("FastMemory", bFastMemory);
|
2013-06-12 21:15:45 +00:00
|
|
|
cpu->Set("CPUSpeed", iLockedCPUSpeed);
|
2012-11-23 11:42:35 +00:00
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
2013-06-19 05:08:29 +00:00
|
|
|
graphics->Set("ShowFPSCounter", iShowFPSCounter);
|
2013-07-21 15:17:42 +00:00
|
|
|
graphics->Set("RenderingMode", iRenderingMode);
|
2013-08-16 19:48:30 +00:00
|
|
|
graphics->Set("SoftwareRendering", bSoftwareRendering);
|
2012-12-21 10:08:54 +00:00
|
|
|
graphics->Set("HardwareTransform", bHardwareTransform);
|
2013-06-30 06:48:50 +00:00
|
|
|
graphics->Set("TextureFiltering", iTexFiltering);
|
2013-09-10 22:19:34 +00:00
|
|
|
graphics->Set("InternalResolution", iInternalResolution);
|
2013-05-02 14:48:28 +00:00
|
|
|
graphics->Set("FrameSkip", iFrameSkip);
|
2013-05-11 14:03:33 +00:00
|
|
|
graphics->Set("FrameRate", iFpsLimit);
|
2013-09-17 06:36:09 +00:00
|
|
|
graphics->Set("FrameSkipUnthrottle", bFrameSkipUnthrottle);
|
2013-06-30 07:02:33 +00:00
|
|
|
graphics->Set("ForceMaxEmulatedFPS", iForceMaxEmulatedFPS);
|
2013-05-02 14:48:28 +00:00
|
|
|
graphics->Set("AnisotropyLevel", iAnisotropyLevel);
|
2013-01-19 16:05:08 +00:00
|
|
|
graphics->Set("VertexCache", bVertexCache);
|
2013-07-05 19:19:56 +00:00
|
|
|
#ifdef _WIN32
|
2013-01-27 13:05:09 +00:00
|
|
|
graphics->Set("FullScreen", bFullScreen);
|
2013-07-05 19:19:56 +00:00
|
|
|
#endif
|
2013-06-21 05:40:52 +00:00
|
|
|
#ifdef BLACKBERRY
|
2013-05-08 13:22:45 +00:00
|
|
|
graphics->Set("PartialStretch", bPartialStretch);
|
|
|
|
#endif
|
2013-02-13 17:21:21 +00:00
|
|
|
graphics->Set("StretchToDisplay", bStretchToDisplay);
|
2013-02-19 18:07:42 +00:00
|
|
|
graphics->Set("TrueColor", bTrueColor);
|
2013-04-02 23:33:14 +00:00
|
|
|
graphics->Set("MipMap", bMipMap);
|
2013-05-01 21:55:34 +00:00
|
|
|
graphics->Set("TexScalingLevel", iTexScalingLevel);
|
|
|
|
graphics->Set("TexScalingType", iTexScalingType);
|
2013-05-03 14:21:46 +00:00
|
|
|
graphics->Set("TexDeposterize", bTexDeposterize);
|
2013-07-20 14:03:52 +00:00
|
|
|
graphics->Set("VSyncInterval", bVSync);
|
2013-09-05 12:51:17 +00:00
|
|
|
graphics->Set("DisableStencilTest", bDisableStencilTest);
|
|
|
|
graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite);
|
2013-09-24 09:14:04 +00:00
|
|
|
graphics->Set("LowQualitySplineBezier", bLowQualitySplineBezier);
|
2013-10-12 00:05:55 +00:00
|
|
|
graphics->Set("PostShader", sPostShaderName);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Set("Enable", bEnableSound);
|
2013-07-25 21:51:45 +00:00
|
|
|
sound->Set("VolumeBGM", iBGMVolume);
|
2013-08-09 12:04:13 +00:00
|
|
|
sound->Set("VolumeSFX", iSFXVolume);
|
2013-08-24 00:16:10 +00:00
|
|
|
sound->Set("LowLatency", bLowLatencyAudio);
|
2013-07-05 19:19:56 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
2013-10-10 14:44:12 +00:00
|
|
|
control->Set("HapticFeedback", bHapticFeedback);
|
2012-12-01 22:20:08 +00:00
|
|
|
control->Set("ShowTouchControls", bShowTouchControls);
|
2013-10-20 02:40:52 +00:00
|
|
|
control->Set("ShowTouchCross", bShowTouchCross);
|
|
|
|
control->Set("ShowTouchCircle", bShowTouchCircle);
|
|
|
|
control->Set("ShowTouchSquare", bShowTouchSquare);
|
|
|
|
control->Set("ShowTouchTriangle", bShowTouchTriangle);
|
|
|
|
control->Set("ShowTouchStart", bShowTouchStart);
|
|
|
|
control->Set("ShowTouchSelect", bShowTouchSelect);
|
|
|
|
control->Set("ShowTouchLTrigger", bShowTouchLTrigger);
|
|
|
|
control->Set("ShowTouchRTrigger", bShowTouchRTrigger);
|
|
|
|
control->Set("ShowAnalogStick", bShowTouchAnalogStick);
|
|
|
|
control->Set("ShowTouchUnthrottle", bShowTouchUnthrottle);
|
2013-10-20 16:02:19 +00:00
|
|
|
control->Set("ShowTouchDpad", bShowTouchDpad);
|
2013-10-20 02:40:52 +00:00
|
|
|
|
2013-07-06 17:08:59 +00:00
|
|
|
// control->Set("KeyMapping",iMappingMap);
|
2013-09-29 19:45:06 +00:00
|
|
|
#ifdef USING_GLES2
|
2013-03-10 12:21:36 +00:00
|
|
|
control->Set("AccelerometerToAnalogHoriz", bAccelerometerToAnalogHoriz);
|
2013-10-27 17:58:47 +00:00
|
|
|
control->Set("TiltBaseX", fTiltBaseX);
|
|
|
|
control->Set("TiltBaseY", fTiltBaseY);
|
|
|
|
control->Set("InvertTiltX", bInvertTiltX);
|
|
|
|
control->Set("InvertTiltY", bInvertTiltY);
|
|
|
|
control->Set("TiltSensitivityX", iTiltSensitivityX);
|
|
|
|
control->Set("TiltSensitivityY", iTiltSensitivityY);
|
2013-10-28 11:13:42 +00:00
|
|
|
control->Set("DeadzoneRadius", fDeadzoneRadius);
|
2013-09-29 19:45:06 +00:00
|
|
|
#endif
|
2013-06-17 18:28:22 +00:00
|
|
|
control->Set("TouchButtonOpacity", iTouchButtonOpacity);
|
2013-06-18 09:37:34 +00:00
|
|
|
control->Set("ButtonScale", fButtonScale);
|
2013-10-09 20:15:56 +00:00
|
|
|
control->Set("ActionButtonSpacing", iActionButtonSpacing);
|
2013-11-05 04:52:31 +00:00
|
|
|
control->Set("ActionButtonCenterX", fActionButtonCenterX);
|
|
|
|
control->Set("ActionButtonCenterY", fActionButtonCenterY);
|
2013-10-09 20:15:56 +00:00
|
|
|
control->Set("DPadRadius", iDpadRadius);
|
2013-11-05 04:52:31 +00:00
|
|
|
control->Set("DPadX", fDpadX);
|
|
|
|
control->Set("DPadY", fDpadY);
|
|
|
|
control->Set("StartKeyX", fStartKeyX);
|
|
|
|
control->Set("StartKeyY", fStartKeyY);
|
|
|
|
control->Set("SelectKeyX", fSelectKeyX);
|
|
|
|
control->Set("SelectKeyY", fSelectKeyY);
|
|
|
|
control->Set("UnthrottleKeyX", fUnthrottleKeyX);
|
|
|
|
control->Set("UnthrottleKeyY", fUnthrottleKeyY);
|
|
|
|
control->Set("LKeyX", fLKeyX);
|
|
|
|
control->Set("LKeyY", fLKeyY);
|
|
|
|
control->Set("RKeyX", fRKeyX);
|
|
|
|
control->Set("RKeyY", fRKeyY);
|
|
|
|
control->Set("AnalogStickX", fAnalogStickX);
|
|
|
|
control->Set("AnalogStickY", fAnalogStickY);
|
2013-10-09 20:15:56 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-01-20 09:50:05 +00:00
|
|
|
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Set("NickName", sNickName.c_str());
|
2013-09-16 22:08:09 +00:00
|
|
|
pspConfig->Set("Language", iLanguage);
|
2013-06-19 05:08:29 +00:00
|
|
|
pspConfig->Set("TimeFormat", iTimeFormat);
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Set("DateFormat", iDateFormat);
|
|
|
|
pspConfig->Set("TimeZone", iTimeZone);
|
|
|
|
pspConfig->Set("DayLightSavings", bDayLightSavings);
|
2013-06-19 05:08:29 +00:00
|
|
|
pspConfig->Set("ButtonPreference", iButtonPreference);
|
2013-04-20 16:01:03 +00:00
|
|
|
pspConfig->Set("LockParentalLevel", iLockParentalLevel);
|
2013-04-19 18:59:24 +00:00
|
|
|
pspConfig->Set("WlanAdhocChannel", iWlanAdhocChannel);
|
|
|
|
pspConfig->Set("WlanPowerSave", bWlanPowerSave);
|
2013-01-28 23:11:02 +00:00
|
|
|
pspConfig->Set("EncryptSave", bEncryptSave);
|
2013-08-06 01:32:19 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
pspConfig->Set("BypassOSKWithKeyboard", bBypassOSKWithKeyboard);
|
|
|
|
#endif
|
2013-01-20 09:50:05 +00:00
|
|
|
|
2013-06-26 07:15:16 +00:00
|
|
|
IniFile::Section *debugConfig = iniFile.GetOrCreateSection("Debugger");
|
|
|
|
debugConfig->Set("DisasmWindowX", iDisasmWindowX);
|
|
|
|
debugConfig->Set("DisasmWindowY", iDisasmWindowY);
|
|
|
|
debugConfig->Set("DisasmWindowW", iDisasmWindowW);
|
|
|
|
debugConfig->Set("DisasmWindowH", iDisasmWindowH);
|
2013-09-28 14:04:56 +00:00
|
|
|
debugConfig->Set("GEWindowX", iGEWindowX);
|
|
|
|
debugConfig->Set("GEWindowY", iGEWindowY);
|
|
|
|
debugConfig->Set("GEWindowW", iGEWindowW);
|
|
|
|
debugConfig->Set("GEWindowH", iGEWindowH);
|
2013-06-26 07:32:49 +00:00
|
|
|
debugConfig->Set("ConsoleWindowX", iConsoleWindowX);
|
|
|
|
debugConfig->Set("ConsoleWindowY", iConsoleWindowY);
|
2013-07-09 09:17:57 +00:00
|
|
|
debugConfig->Set("FontWidth", iFontWidth);
|
|
|
|
debugConfig->Set("FontHeight", iFontHeight);
|
2013-07-30 15:06:37 +00:00
|
|
|
debugConfig->Set("DisplayStatusBar", bDisplayStatusBar);
|
2013-09-30 19:42:05 +00:00
|
|
|
debugConfig->Set("ShowBottomTabTitles",bShowBottomTabTitles);
|
2013-09-07 18:54:11 +00:00
|
|
|
debugConfig->Set("ShowDeveloperMenu", bShowDeveloperMenu);
|
2013-10-30 06:02:05 +00:00
|
|
|
debugConfig->Set("SkipDeadbeefFilling", bSkipDeadbeefFilling);
|
2013-09-07 18:54:11 +00:00
|
|
|
|
2013-10-08 20:59:40 +00:00
|
|
|
IniFile::Section *speedhacks = iniFile.GetOrCreateSection("SpeedHacks");
|
|
|
|
speedhacks->Set("PrescaleUV", bPrescaleUV);
|
2013-10-22 11:00:19 +00:00
|
|
|
speedhacks->Set("DisableAlphaTest", bDisableAlphaTest);
|
2013-10-08 20:59:40 +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
|
|
|
|
|
|
|
void Config::AddRecent(const std::string &file) {
|
|
|
|
for (auto str = recentIsos.begin(); str != recentIsos.end(); str++) {
|
|
|
|
if (*str == file) {
|
|
|
|
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-09-04 22:04:24 +00:00
|
|
|
if (File::Exists(recentIsos[i])){
|
|
|
|
// clean the redundant recent games' list.
|
|
|
|
if (cleanedRecent.size()==0){ // add first one
|
|
|
|
cleanedRecent.push_back(recentIsos[i]);
|
|
|
|
}
|
|
|
|
for (size_t j=0; j<cleanedRecent.size();j++){
|
2013-09-05 16:45:41 +00:00
|
|
|
if (cleanedRecent[j]==recentIsos[i])
|
2013-09-04 22:04:24 +00:00
|
|
|
break; // skip if found redundant
|
|
|
|
if (j==cleanedRecent.size()-1){ // add if no redundant found
|
|
|
|
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();
|
|
|
|
}
|