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/.
|
|
|
|
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
#include "IniFile.h"
|
2013-01-20 09:50:05 +00:00
|
|
|
#include "HLE/sceUtility.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
SState g_State;
|
|
|
|
CConfig g_Config;
|
|
|
|
|
|
|
|
CConfig::CConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CConfig::~CConfig()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CConfig::Load(const char *iniFileName)
|
|
|
|
{
|
|
|
|
iniFilename_ = iniFileName;
|
2013-01-04 09:26:14 +00:00
|
|
|
INFO_LOG(LOADER, "Loading config: %s", iniFileName);
|
2012-11-01 15:19:01 +00:00
|
|
|
bSaveSettings = true;
|
|
|
|
|
|
|
|
IniFile iniFile;
|
2013-01-04 09:26:14 +00:00
|
|
|
if (!iniFile.Load(iniFileName)) {
|
|
|
|
ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFileName);
|
|
|
|
// Continue anyway to initialize the config.
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *general = iniFile.GetOrCreateSection("General");
|
|
|
|
|
|
|
|
bSpeedLimit = false;
|
|
|
|
general->Get("FirstRun", &bFirstRun, true);
|
|
|
|
general->Get("AutoLoadLast", &bAutoLoadLast, false);
|
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("ConfirmOnQuit", &bConfirmOnQuit, false);
|
|
|
|
general->Get("IgnoreBadMemAccess", &bIgnoreBadMemAccess, true);
|
|
|
|
general->Get("CurrentDirectory", ¤tDirectory, "");
|
2012-12-04 16:04:24 +00:00
|
|
|
general->Get("ShowDebuggerOnLoad", &bShowDebuggerOnLoad, false);
|
2012-12-21 15:49:02 +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->Get("Jit", &bJit, true);
|
|
|
|
cpu->Get("FastMemory", &bFastMemory, true);
|
2012-11-23 11:42:35 +00:00
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
|
|
|
graphics->Get("ShowFPSCounter", &bShowFPSCounter, false);
|
|
|
|
graphics->Get("DisplayFramebuffer", &bDisplayFramebuffer, false);
|
|
|
|
graphics->Get("WindowZoom", &iWindowZoom, 1);
|
|
|
|
graphics->Get("BufferedRendering", &bBufferedRendering, true);
|
2013-01-02 20:00:10 +00:00
|
|
|
graphics->Get("HardwareTransform", &bHardwareTransform, true);
|
2012-12-28 15:23:42 +00:00
|
|
|
graphics->Get("LinearFiltering", &bLinearFiltering, false);
|
2013-01-26 23:15:39 +00:00
|
|
|
graphics->Get("SSAA", &SSAntiAliasing, 0);
|
2013-01-20 20:52:54 +00:00
|
|
|
graphics->Get("VBO", &bUseVBO, false);
|
2013-02-11 18:03:11 +00:00
|
|
|
#ifdef USING_GLES2
|
|
|
|
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0);
|
|
|
|
#else
|
|
|
|
graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8);
|
|
|
|
#endif
|
2013-01-12 00:23:24 +00:00
|
|
|
graphics->Get("DisableG3DLog", &bDisableG3DLog, false);
|
2013-01-26 16:26:07 +00:00
|
|
|
graphics->Get("VertexCache", &bVertexCache, true);
|
2013-01-27 13:05:09 +00:00
|
|
|
graphics->Get("FullScreen", &bFullScreen, false);
|
2013-02-13 17:21:21 +00:00
|
|
|
graphics->Get("StretchToDisplay", &bStretchToDisplay, false);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Get("Enable", &bEnableSound, true);
|
|
|
|
|
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
|
|
|
control->Get("ShowStick", &bShowAnalogStick, false);
|
2013-01-14 15:13:53 +00:00
|
|
|
control->Get("ShowTouchControls", &bShowTouchControls,
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
true);
|
|
|
|
#else
|
|
|
|
false);
|
|
|
|
#endif
|
2013-01-26 16:26:07 +00:00
|
|
|
control->Get("LargeControls", &bLargeControls, false);
|
2013-02-01 23:36:35 +00:00
|
|
|
control->Get("KeyMapping",iMappingMap);
|
2012-12-19 14:14:41 +00:00
|
|
|
|
2013-01-20 09:50:05 +00:00
|
|
|
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
|
|
|
pspConfig->Get("Language", &ilanguage, PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
|
2013-01-21 13:35:31 +00:00
|
|
|
pspConfig->Get("TimeFormat", &itimeformat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR);
|
2013-01-28 23:11:02 +00:00
|
|
|
pspConfig->Get("EncryptSave", &bEncryptSave, true);
|
2013-01-20 09:50:05 +00:00
|
|
|
|
2012-12-19 14:14:41 +00:00
|
|
|
// Ephemeral settings
|
|
|
|
bDrawWireframe = false;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CConfig::Save()
|
|
|
|
{
|
2013-01-04 09:26:14 +00:00
|
|
|
if (iniFilename_.size() && g_Config.bSaveSettings) {
|
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");
|
|
|
|
general->Set("FirstRun", bFirstRun);
|
|
|
|
general->Set("AutoLoadLast", bAutoLoadLast);
|
|
|
|
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("ConfirmOnQuit", bConfirmOnQuit);
|
|
|
|
general->Set("IgnoreBadMemAccess", bIgnoreBadMemAccess);
|
|
|
|
general->Set("CurrentDirectory", currentDirectory);
|
2012-12-04 16:04:24 +00:00
|
|
|
general->Set("ShowDebuggerOnLoad", bShowDebuggerOnLoad);
|
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);
|
2012-12-21 15:49:02 +00:00
|
|
|
cpu->Set("FastMemory", bFastMemory);
|
2012-11-23 11:42:35 +00:00
|
|
|
|
2012-11-20 09:59:23 +00:00
|
|
|
IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics");
|
|
|
|
graphics->Set("ShowFPSCounter", bShowFPSCounter);
|
|
|
|
graphics->Set("DisplayFramebuffer", bDisplayFramebuffer);
|
|
|
|
graphics->Set("WindowZoom", iWindowZoom);
|
|
|
|
graphics->Set("BufferedRendering", bBufferedRendering);
|
2012-12-21 10:08:54 +00:00
|
|
|
graphics->Set("HardwareTransform", bHardwareTransform);
|
2012-12-28 15:23:42 +00:00
|
|
|
graphics->Set("LinearFiltering", bLinearFiltering);
|
2013-01-26 23:15:39 +00:00
|
|
|
graphics->Set("SSAA", SSAntiAliasing);
|
2013-01-10 11:51:18 +00:00
|
|
|
graphics->Set("VBO", bUseVBO);
|
2013-02-11 12:48:07 +00:00
|
|
|
graphics->Set("AnisotropyLevel", iAnisotropyLevel);
|
2013-01-12 00:23:24 +00:00
|
|
|
graphics->Set("DisableG3DLog", bDisableG3DLog);
|
2013-01-19 16:05:08 +00:00
|
|
|
graphics->Set("VertexCache", bVertexCache);
|
2013-01-27 13:05:09 +00:00
|
|
|
graphics->Set("FullScreen", bFullScreen);
|
2013-02-13 17:21:21 +00:00
|
|
|
graphics->Set("StretchToDisplay", bStretchToDisplay);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
IniFile::Section *sound = iniFile.GetOrCreateSection("Sound");
|
|
|
|
sound->Set("Enable", bEnableSound);
|
|
|
|
|
|
|
|
IniFile::Section *control = iniFile.GetOrCreateSection("Control");
|
|
|
|
control->Set("ShowStick", bShowAnalogStick);
|
2012-12-01 22:20:08 +00:00
|
|
|
control->Set("ShowTouchControls", bShowTouchControls);
|
2013-01-26 16:26:07 +00:00
|
|
|
control->Set("LargeControls", bLargeControls);
|
2013-02-01 23:36:35 +00:00
|
|
|
control->Set("KeyMapping",iMappingMap);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-01-20 09:50:05 +00:00
|
|
|
IniFile::Section *pspConfig = iniFile.GetOrCreateSection("SystemParam");
|
|
|
|
pspConfig->Set("Language", ilanguage);
|
2013-01-21 13:35:31 +00:00
|
|
|
pspConfig->Set("TimeFormat", itimeformat);
|
2013-01-28 23:11:02 +00:00
|
|
|
pspConfig->Set("EncryptSave", bEncryptSave);
|
2013-01-20 09:50:05 +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());
|
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
|
|
|
}
|
|
|
|
}
|