CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/Config.cpp
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include <algorithm>
19
#include <cstdlib>
20
#include <ctime>
21
#include <mutex>
22
#include <set>
23
#include <sstream>
24
#include <thread>
25
26
#include "ppsspp_config.h"
27
28
#include "Common/GPU/OpenGL/GLFeatures.h"
29
#include "Common/Net/HTTPClient.h"
30
#include "Common/Net/URL.h"
31
32
#include "Common/Log.h"
33
#include "Common/TimeUtil.h"
34
#include "Common/Thread/ThreadUtil.h"
35
#include "Common/Data/Format/IniFile.h"
36
#include "Common/Data/Format/JSONReader.h"
37
#include "Common/Data/Text/I18n.h"
38
#include "Common/Data/Text/Parsers.h"
39
#include "Common/CPUDetect.h"
40
#include "Common/File/FileUtil.h"
41
#include "Common/File/VFS/VFS.h"
42
#include "Common/Log/LogManager.h"
43
#include "Common/OSVersion.h"
44
#include "Common/System/Display.h"
45
#include "Common/System/System.h"
46
#include "Common/StringUtils.h"
47
#include "Common/Thread/ThreadUtil.h"
48
#include "Common/GPU/Vulkan/VulkanLoader.h"
49
#include "Common/VR/PPSSPPVR.h"
50
#include "Common/System/OSD.h"
51
#include "Core/Config.h"
52
#include "Core/ConfigSettings.h"
53
#include "Core/ConfigValues.h"
54
#include "Core/Loaders.h"
55
#include "Core/KeyMap.h"
56
#include "Core/HLE/sceUtility.h"
57
#include "Core/Instance.h"
58
#include "GPU/Common/FramebufferManagerCommon.h"
59
60
// TODO: Find a better place for this.
61
http::RequestManager g_DownloadManager;
62
63
Config g_Config;
64
65
static bool jitForcedOff;
66
67
// Not in Config.h because it's #included a lot.
68
struct ConfigPrivate {
69
std::mutex recentIsosLock;
70
std::mutex recentIsosThreadLock;
71
std::thread recentIsosThread;
72
bool recentIsosThreadPending = false;
73
74
void ResetRecentIsosThread();
75
void SetRecentIsosThread(std::function<void()> f);
76
};
77
78
#ifdef _DEBUG
79
static const char * const logSectionName = "LogDebug";
80
#else
81
static const char * const logSectionName = "Log";
82
#endif
83
84
static bool TryUpdateSavedPath(Path *path);
85
86
std::string GPUBackendToString(GPUBackend backend) {
87
switch (backend) {
88
case GPUBackend::OPENGL:
89
return "OPENGL";
90
case GPUBackend::DIRECT3D9:
91
return "DIRECT3D9";
92
case GPUBackend::DIRECT3D11:
93
return "DIRECT3D11";
94
case GPUBackend::VULKAN:
95
return "VULKAN";
96
}
97
// Intentionally not a default so we get a warning.
98
return "INVALID";
99
}
100
101
GPUBackend GPUBackendFromString(std::string_view backend) {
102
if (!equalsNoCase(backend, "OPENGL") || backend == "0")
103
return GPUBackend::OPENGL;
104
if (!equalsNoCase(backend, "DIRECT3D9") || backend == "1")
105
return GPUBackend::DIRECT3D9;
106
if (!equalsNoCase(backend, "DIRECT3D11") || backend == "2")
107
return GPUBackend::DIRECT3D11;
108
if (!equalsNoCase(backend, "VULKAN") || backend == "3")
109
return GPUBackend::VULKAN;
110
return GPUBackend::OPENGL;
111
}
112
113
const char *DefaultLangRegion() {
114
// Unfortunate default. There's no need to use bFirstRun, since this is only a default.
115
static std::string defaultLangRegion = "en_US";
116
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
117
if (g_i18nrepo.IniExists(langRegion)) {
118
defaultLangRegion = langRegion;
119
} else if (langRegion.length() >= 3) {
120
// Don't give up. Let's try a fuzzy match - so nl_BE can match nl_NL.
121
IniFile mapping;
122
mapping.LoadFromVFS(g_VFS, "langregion.ini");
123
std::vector<std::string> keys;
124
mapping.GetKeys("LangRegionNames", keys);
125
126
for (std::string key : keys) {
127
if (startsWithNoCase(key, langRegion)) {
128
// Exact submatch, or different case. Let's use it.
129
defaultLangRegion = key;
130
break;
131
} else if (startsWithNoCase(key, langRegion.substr(0, 3))) {
132
// Best so far.
133
defaultLangRegion = key;
134
}
135
}
136
}
137
138
return defaultLangRegion.c_str();
139
}
140
141
std::string CreateRandMAC() {
142
std::stringstream randStream;
143
srand(time(nullptr));
144
for (int i = 0; i < 6; i++) {
145
u32 value = rand() % 256;
146
if (i == 0) {
147
// Making sure the 1st 2-bits on the 1st byte of OUI are zero to prevent issue with some games (ie. Gran Turismo)
148
value &= 0xfc;
149
}
150
if (value <= 15)
151
randStream << '0' << std::hex << value;
152
else
153
randStream << std::hex << value;
154
if (i < 5) {
155
randStream << ':'; //we need a : between every octet
156
}
157
}
158
return randStream.str();
159
}
160
161
static int DefaultCpuCore() {
162
#if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) || PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(RISCV64)
163
if (System_GetPropertyBool(SYSPROP_CAN_JIT))
164
return (int)CPUCore::JIT;
165
return (int)CPUCore::IR_INTERPRETER;
166
#else
167
return (int)CPUCore::IR_INTERPRETER;
168
#endif
169
}
170
171
static bool DefaultCodeGen() {
172
#if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) || PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(RISCV64)
173
return true;
174
#else
175
return false;
176
#endif
177
}
178
179
static bool DefaultVSync() {
180
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(UWP)
181
// Previously we didn't allow turning off vsync/FIFO on Android. Let's set the default accordingly.
182
return true;
183
#else
184
return false;
185
#endif
186
}
187
188
static bool DefaultEnableStateUndo() {
189
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(IOS)
190
// Off on mobile to save disk space.
191
return false;
192
#endif
193
return true;
194
}
195
196
static float DefaultUISaturation() {
197
return IsVREnabled() ? 1.5f : 1.0f;
198
}
199
200
static const ConfigSetting generalSettings[] = {
201
ConfigSetting("FirstRun", &g_Config.bFirstRun, true, CfgFlag::DEFAULT),
202
ConfigSetting("RunCount", &g_Config.iRunCount, 0, CfgFlag::DEFAULT),
203
ConfigSetting("Enable Logging", &g_Config.bEnableLogging, true, CfgFlag::DEFAULT),
204
ConfigSetting("AutoRun", &g_Config.bAutoRun, true, CfgFlag::DEFAULT),
205
ConfigSetting("Browse", &g_Config.bBrowse, false, CfgFlag::DEFAULT),
206
ConfigSetting("IgnoreBadMemAccess", &g_Config.bIgnoreBadMemAccess, true, CfgFlag::DEFAULT),
207
ConfigSetting("CurrentDirectory", &g_Config.currentDirectory, "", CfgFlag::DEFAULT),
208
ConfigSetting("ShowDebuggerOnLoad", &g_Config.bShowDebuggerOnLoad, false, CfgFlag::DEFAULT),
209
ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true, CfgFlag::DEFAULT),
210
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion, CfgFlag::DEFAULT),
211
ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, CfgFlag::PER_GAME),
212
ConfigSetting("DiscordPresence", &g_Config.bDiscordPresence, true, CfgFlag::DEFAULT), // Or maybe it makes sense to have it per-game? Race conditions abound...
213
ConfigSetting("UISound", &g_Config.bUISound, false, CfgFlag::DEFAULT),
214
215
ConfigSetting("DisableHTTPS", &g_Config.bDisableHTTPS, false, CfgFlag::DONT_SAVE),
216
ConfigSetting("AutoLoadSaveState", &g_Config.iAutoLoadSaveState, 0, CfgFlag::PER_GAME),
217
ConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
218
ConfigSetting("EnablePlugins", &g_Config.bEnablePlugins, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
219
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshIntervalMs, 77, CfgFlag::PER_GAME),
220
ConfigSetting("CwCheatScrollPosition", &g_Config.fCwCheatScrollPosition, 0.0f, CfgFlag::PER_GAME),
221
ConfigSetting("GameListScrollPosition", &g_Config.fGameListScrollPosition, 0.0f, CfgFlag::DEFAULT),
222
ConfigSetting("DebugOverlay", &g_Config.iDebugOverlay, 0, CfgFlag::DONT_SAVE),
223
224
ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, CfgFlag::PER_GAME),
225
ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false, CfgFlag::DEFAULT),
226
ConfigSetting("DumpFrames", &g_Config.bDumpFrames, false, CfgFlag::DEFAULT),
227
ConfigSetting("DumpVideoOutput", &g_Config.bDumpVideoOutput, false, CfgFlag::DEFAULT),
228
ConfigSetting("DumpAudio", &g_Config.bDumpAudio, false, CfgFlag::DEFAULT),
229
ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false, CfgFlag::DEFAULT),
230
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, CfgFlag::PER_GAME),
231
ConfigSetting("EnableStateUndo", &g_Config.bEnableStateUndo, &DefaultEnableStateUndo, CfgFlag::PER_GAME),
232
ConfigSetting("StateLoadUndoGame", &g_Config.sStateLoadUndoGame, "NA", CfgFlag::DEFAULT),
233
ConfigSetting("StateUndoLastSaveGame", &g_Config.sStateUndoLastSaveGame, "NA", CfgFlag::DEFAULT),
234
ConfigSetting("StateUndoLastSaveSlot", &g_Config.iStateUndoLastSaveSlot, -5, CfgFlag::DEFAULT), // Start with an "invalid" value
235
ConfigSetting("RewindSnapshotInterval", &g_Config.iRewindSnapshotInterval, 0, CfgFlag::PER_GAME),
236
237
ConfigSetting("ShowOnScreenMessage", &g_Config.bShowOnScreenMessages, true, CfgFlag::DEFAULT),
238
ConfigSetting("ShowRegionOnGameIcon", &g_Config.bShowRegionOnGameIcon, false, CfgFlag::DEFAULT),
239
ConfigSetting("ShowIDOnGameIcon", &g_Config.bShowIDOnGameIcon, false, CfgFlag::DEFAULT),
240
ConfigSetting("GameGridScale", &g_Config.fGameGridScale, 1.0, CfgFlag::DEFAULT),
241
ConfigSetting("GridView1", &g_Config.bGridView1, true, CfgFlag::DEFAULT),
242
ConfigSetting("GridView2", &g_Config.bGridView2, true, CfgFlag::DEFAULT),
243
ConfigSetting("GridView3", &g_Config.bGridView3, false, CfgFlag::DEFAULT),
244
ConfigSetting("RightAnalogUp", &g_Config.iRightAnalogUp, 0, CfgFlag::PER_GAME),
245
ConfigSetting("RightAnalogDown", &g_Config.iRightAnalogDown, 0, CfgFlag::PER_GAME),
246
ConfigSetting("RightAnalogLeft", &g_Config.iRightAnalogLeft, 0, CfgFlag::PER_GAME),
247
ConfigSetting("RightAnalogRight", &g_Config.iRightAnalogRight, 0, CfgFlag::PER_GAME),
248
ConfigSetting("RightAnalogPress", &g_Config.iRightAnalogPress, 0, CfgFlag::PER_GAME),
249
ConfigSetting("RightAnalogCustom", &g_Config.bRightAnalogCustom, false, CfgFlag::PER_GAME),
250
ConfigSetting("RightAnalogDisableDiagonal", &g_Config.bRightAnalogDisableDiagonal, false, CfgFlag::PER_GAME),
251
ConfigSetting("SwipeUp", &g_Config.iSwipeUp, 0, CfgFlag::PER_GAME),
252
ConfigSetting("SwipeDown", &g_Config.iSwipeDown, 0, CfgFlag::PER_GAME),
253
ConfigSetting("SwipeLeft", &g_Config.iSwipeLeft, 0, CfgFlag::PER_GAME),
254
ConfigSetting("SwipeRight", &g_Config.iSwipeRight, 0, CfgFlag::PER_GAME),
255
ConfigSetting("SwipeSensitivity", &g_Config.fSwipeSensitivity, 1.0f, CfgFlag::PER_GAME),
256
ConfigSetting("SwipeSmoothing", &g_Config.fSwipeSmoothing, 0.3f, CfgFlag::PER_GAME),
257
ConfigSetting("DoubleTapGesture", &g_Config.iDoubleTapGesture, 0, CfgFlag::PER_GAME),
258
ConfigSetting("GestureControlEnabled", &g_Config.bGestureControlEnabled, false, CfgFlag::PER_GAME),
259
260
// "default" means let emulator decide, "" means disable.
261
ConfigSetting("ReportingHost", &g_Config.sReportHost, "default", CfgFlag::DEFAULT),
262
ConfigSetting("AutoSaveSymbolMap", &g_Config.bAutoSaveSymbolMap, false, CfgFlag::PER_GAME),
263
ConfigSetting("CacheFullIsoInRam", &g_Config.bCacheFullIsoInRam, false, CfgFlag::PER_GAME),
264
ConfigSetting("RemoteISOPort", &g_Config.iRemoteISOPort, 0, CfgFlag::DEFAULT),
265
ConfigSetting("LastRemoteISOServer", &g_Config.sLastRemoteISOServer, "", CfgFlag::DEFAULT),
266
ConfigSetting("LastRemoteISOPort", &g_Config.iLastRemoteISOPort, 0, CfgFlag::DEFAULT),
267
ConfigSetting("RemoteISOManualConfig", &g_Config.bRemoteISOManual, false, CfgFlag::DEFAULT),
268
ConfigSetting("RemoteShareOnStartup", &g_Config.bRemoteShareOnStartup, false, CfgFlag::DEFAULT),
269
ConfigSetting("RemoteISOSubdir", &g_Config.sRemoteISOSubdir, "/", CfgFlag::DEFAULT),
270
ConfigSetting("RemoteDebuggerOnStartup", &g_Config.bRemoteDebuggerOnStartup, false, CfgFlag::DEFAULT),
271
ConfigSetting("RemoteTab", &g_Config.bRemoteTab, false, CfgFlag::DEFAULT),
272
ConfigSetting("RemoteISOSharedDir", &g_Config.sRemoteISOSharedDir, "", CfgFlag::DEFAULT),
273
ConfigSetting("RemoteISOShareType", &g_Config.iRemoteISOShareType, (int)RemoteISOShareType::RECENT, CfgFlag::DEFAULT),
274
275
#ifdef __ANDROID__
276
ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, ROTATION_AUTO_HORIZONTAL),
277
#endif
278
ConfigSetting("InternalScreenRotation", &g_Config.iInternalScreenRotation, ROTATION_LOCKED_HORIZONTAL, CfgFlag::PER_GAME),
279
280
ConfigSetting("BackgroundAnimation", &g_Config.iBackgroundAnimation, 1, CfgFlag::DEFAULT),
281
ConfigSetting("TransparentBackground", &g_Config.bTransparentBackground, true, CfgFlag::DEFAULT),
282
ConfigSetting("UITint", &g_Config.fUITint, 0.0, CfgFlag::DEFAULT),
283
ConfigSetting("UISaturation", &g_Config.fUISaturation, &DefaultUISaturation, CfgFlag::DEFAULT),
284
285
#if defined(USING_WIN_UI)
286
ConfigSetting("TopMost", &g_Config.bTopMost, false, CfgFlag::DEFAULT),
287
ConfigSetting("PauseOnLostFocus", &g_Config.bPauseOnLostFocus, false, CfgFlag::PER_GAME),
288
#endif
289
290
#if !defined(MOBILE_DEVICE)
291
ConfigSetting("WindowX", &g_Config.iWindowX, -1, CfgFlag::DEFAULT), // -1 tells us to center the window.
292
ConfigSetting("WindowY", &g_Config.iWindowY, -1, CfgFlag::DEFAULT),
293
ConfigSetting("WindowWidth", &g_Config.iWindowWidth, 0, CfgFlag::DEFAULT), // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
294
ConfigSetting("WindowHeight", &g_Config.iWindowHeight, 0, CfgFlag::DEFAULT),
295
#endif
296
297
ConfigSetting("PauseWhenMinimized", &g_Config.bPauseWhenMinimized, false, CfgFlag::PER_GAME),
298
ConfigSetting("PauseExitsEmulator", &g_Config.bPauseExitsEmulator, false, CfgFlag::DONT_SAVE),
299
ConfigSetting("PauseMenuExitsEmulator", &g_Config.bPauseMenuExitsEmulator, false, CfgFlag::DONT_SAVE),
300
301
ConfigSetting("DumpDecryptedEboots", &g_Config.bDumpDecryptedEboot, false, CfgFlag::PER_GAME),
302
ConfigSetting("FullscreenOnDoubleclick", &g_Config.bFullscreenOnDoubleclick, true, CfgFlag::DONT_SAVE),
303
ConfigSetting("ShowMenuBar", &g_Config.bShowMenuBar, true, CfgFlag::DEFAULT),
304
305
ConfigSetting("MemStickInserted", &g_Config.bMemStickInserted, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
306
ConfigSetting("LoadPlugins", &g_Config.bLoadPlugins, true, CfgFlag::PER_GAME),
307
308
ConfigSetting("IgnoreCompatSettings", &g_Config.sIgnoreCompatSettings, "", CfgFlag::PER_GAME | CfgFlag::REPORT),
309
310
ConfigSetting("RunBehindPauseMenu", &g_Config.bRunBehindPauseMenu, false, CfgFlag::DEFAULT),
311
312
ConfigSetting("ShowGPOLEDs", &g_Config.bShowGPOLEDs, false, CfgFlag::PER_GAME),
313
};
314
315
static bool DefaultSasThread() {
316
return cpu_info.num_cores > 1;
317
}
318
319
static const ConfigSetting achievementSettings[] = {
320
// Core settings
321
ConfigSetting("AchievementsEnable", &g_Config.bAchievementsEnable, true, CfgFlag::DEFAULT),
322
ConfigSetting("AchievementsEnableRAIntegration", &g_Config.bAchievementsEnableRAIntegration, false, CfgFlag::DEFAULT),
323
ConfigSetting("AchievementsChallengeMode", &g_Config.bAchievementsHardcoreMode, true, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
324
ConfigSetting("AchievementsEncoreMode", &g_Config.bAchievementsEncoreMode, false, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
325
ConfigSetting("AchievementsUnofficial", &g_Config.bAchievementsUnofficial, false, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
326
ConfigSetting("AchievementsLogBadMemReads", &g_Config.bAchievementsLogBadMemReads, false, CfgFlag::DEFAULT),
327
ConfigSetting("AchievementsSaveStateInHardcoreMode", &g_Config.bAchievementsSaveStateInHardcoreMode, false, CfgFlag::DEFAULT),
328
329
// Achievements login info. Note that password is NOT stored, only a login token.
330
// And that login token is stored separately from the ini, see NativeSaveSecret, but it can also be loaded
331
// from the ini if manually entered (useful when testing various builds on Android).
332
ConfigSetting("AchievementsToken", &g_Config.sAchievementsToken, "", CfgFlag::DONT_SAVE),
333
ConfigSetting("AchievementsUserName", &g_Config.sAchievementsUserName, "", CfgFlag::DEFAULT),
334
335
// Customizations
336
ConfigSetting("AchievementsSoundEffects", &g_Config.bAchievementsSoundEffects, true, CfgFlag::DEFAULT),
337
ConfigSetting("AchievementsUnlockAudioFile", &g_Config.sAchievementsUnlockAudioFile, "", CfgFlag::DEFAULT),
338
ConfigSetting("AchievementsLeaderboardSubmitAudioFile", &g_Config.sAchievementsLeaderboardSubmitAudioFile, "", CfgFlag::DEFAULT),
339
340
ConfigSetting("AchievementsLeaderboardTrackerPos", &g_Config.iAchievementsLeaderboardTrackerPos, (int)ScreenEdgePosition::TOP_LEFT, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
341
ConfigSetting("AchievementsLeaderboardStartedOrFailedPos", &g_Config.iAchievementsLeaderboardStartedOrFailedPos, (int)ScreenEdgePosition::TOP_LEFT, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
342
ConfigSetting("AchievementsLeaderboardSubmittedPos", &g_Config.iAchievementsLeaderboardSubmittedPos, (int)ScreenEdgePosition::TOP_LEFT, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
343
ConfigSetting("AchievementsProgressPos", &g_Config.iAchievementsProgressPos, (int)ScreenEdgePosition::TOP_LEFT, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
344
ConfigSetting("AchievementsChallengePos", &g_Config.iAchievementsChallengePos, (int)ScreenEdgePosition::TOP_LEFT, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
345
ConfigSetting("AchievementsUnlockedPos", &g_Config.iAchievementsUnlockedPos, (int)ScreenEdgePosition::TOP_CENTER, CfgFlag::PER_GAME | CfgFlag::DEFAULT),
346
};
347
348
static const ConfigSetting cpuSettings[] = {
349
ConfigSetting("CPUCore", &g_Config.iCpuCore, &DefaultCpuCore, CfgFlag::PER_GAME | CfgFlag::REPORT),
350
ConfigSetting("SeparateSASThread", &g_Config.bSeparateSASThread, &DefaultSasThread, CfgFlag::PER_GAME | CfgFlag::REPORT),
351
ConfigSetting("IOTimingMethod", &g_Config.iIOTimingMethod, IOTIMING_FAST, CfgFlag::PER_GAME | CfgFlag::REPORT),
352
ConfigSetting("FastMemoryAccess", &g_Config.bFastMemory, true, CfgFlag::PER_GAME),
353
ConfigSetting("FunctionReplacements", &g_Config.bFuncReplacements, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
354
ConfigSetting("HideSlowWarnings", &g_Config.bHideSlowWarnings, false, CfgFlag::DEFAULT),
355
ConfigSetting("HideStateWarnings", &g_Config.bHideStateWarnings, false, CfgFlag::DEFAULT),
356
ConfigSetting("PreloadFunctions", &g_Config.bPreloadFunctions, false, CfgFlag::PER_GAME),
357
ConfigSetting("JitDisableFlags", &g_Config.uJitDisableFlags, (uint32_t)0, CfgFlag::PER_GAME),
358
ConfigSetting("CPUSpeed", &g_Config.iLockedCPUSpeed, 0, CfgFlag::PER_GAME | CfgFlag::REPORT),
359
};
360
361
static int DefaultInternalResolution() {
362
// Auto on Windows and Linux, 2x on large screens and iOS, 1x elsewhere.
363
#if defined(USING_WIN_UI) || defined(USING_QT_UI)
364
return 0;
365
#elif PPSSPP_PLATFORM(IOS)
366
return 2;
367
#else
368
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_VR) {
369
return 4;
370
}
371
int longestDisplaySide = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES));
372
int scale = longestDisplaySide >= 1000 ? 2 : 1;
373
INFO_LOG(Log::G3D, "Longest display side: %d pixels. Choosing scale %d", longestDisplaySide, scale);
374
return scale;
375
#endif
376
}
377
378
static int DefaultFastForwardMode() {
379
#if PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)
380
return (int)FastForwardMode::SKIP_FLIP;
381
#else
382
return (int)FastForwardMode::CONTINUOUS;
383
#endif
384
}
385
386
static int DefaultAndroidHwScale() {
387
#if PPSSPP_PLATFORM(ANDROID)
388
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19 || System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
389
// Arbitrary cutoff at Kitkat - modern devices are usually powerful enough that hw scaling
390
// doesn't really help very much and mostly causes problems. See #11151
391
return 0;
392
}
393
394
// Get the real resolution as passed in during startup, not dp_xres and stuff
395
int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
396
int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);
397
398
if (xres <= 960) {
399
// Smaller than the PSP*2, let's go native.
400
return 0;
401
} else if (xres <= 480 * 3) { // 720p xres
402
// Small-ish screen, we should default to 2x
403
return 2 + 1;
404
} else {
405
// Large or very large screen. Default to 3x psp resolution.
406
return 3 + 1;
407
}
408
return 0;
409
#else
410
return 1;
411
#endif
412
}
413
414
// See issue 14439. Should possibly even block these devices from selecting VK.
415
const char * const vulkanDefaultBlacklist[] = {
416
"Sony:BRAVIA VH1",
417
};
418
419
static int DefaultGPUBackend() {
420
if (IsVREnabled()) {
421
return (int)GPUBackend::OPENGL;
422
}
423
424
#if PPSSPP_PLATFORM(WINDOWS)
425
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
426
if (IsWin8OrHigher()) {
427
return (int)GPUBackend::DIRECT3D11;
428
}
429
#elif PPSSPP_PLATFORM(ANDROID)
430
// Check blacklist.
431
for (size_t i = 0; i < ARRAY_SIZE(vulkanDefaultBlacklist); i++) {
432
if (System_GetProperty(SYSPROP_NAME) == vulkanDefaultBlacklist[i]) {
433
return (int)GPUBackend::OPENGL;
434
}
435
}
436
437
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer, and only
438
// on ARM64 and x86-64. Drivers before, and on other archs, are generally too
439
// unreliable to default to (with some exceptions, of course).
440
#if PPSSPP_ARCH(64BIT)
441
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 27) {
442
return (int)GPUBackend::VULKAN;
443
}
444
#else
445
// There are some newer devices that benefit from Vulkan as default, but are 32-bit. Example: Redmi 9A.
446
// Let's only allow the very newest generation though.
447
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 30) {
448
return (int)GPUBackend::VULKAN;
449
}
450
#endif
451
452
#elif PPSSPP_PLATFORM(MAC)
453
454
#if PPSSPP_ARCH(ARM64)
455
return (int)GPUBackend::VULKAN;
456
#else
457
// On Intel (generally older Macs) default to OpenGL.
458
return (int)GPUBackend::OPENGL;
459
#endif
460
461
#elif PPSSPP_PLATFORM(IOS_APP_STORE)
462
return (int)GPUBackend::VULKAN;
463
#endif
464
465
// TODO: On some additional Linux platforms, we should also default to Vulkan.
466
return (int)GPUBackend::OPENGL;
467
}
468
469
int Config::NextValidBackend() {
470
std::vector<std::string> split;
471
std::set<GPUBackend> failed;
472
473
SplitString(sFailedGPUBackends, ',', split);
474
for (const auto &str : split) {
475
if (!str.empty() && str != "ALL") {
476
failed.insert(GPUBackendFromString(str));
477
}
478
}
479
480
// Count these as "failed" too so we don't pick them.
481
SplitString(sDisabledGPUBackends, ',', split);
482
for (const auto &str : split) {
483
if (!str.empty()) {
484
failed.insert(GPUBackendFromString(str));
485
}
486
}
487
488
if (failed.count((GPUBackend)iGPUBackend)) {
489
ERROR_LOG(Log::Loader, "Graphics backend failed for %d, trying another", iGPUBackend);
490
491
#if !PPSSPP_PLATFORM(UWP)
492
if (!failed.count(GPUBackend::VULKAN) && VulkanMayBeAvailable()) {
493
return (int)GPUBackend::VULKAN;
494
}
495
#endif
496
#if PPSSPP_PLATFORM(WINDOWS)
497
if (!failed.count(GPUBackend::DIRECT3D11) && IsWin7OrHigher()) {
498
return (int)GPUBackend::DIRECT3D11;
499
}
500
#endif
501
#if PPSSPP_API(ANY_GL)
502
if (!failed.count(GPUBackend::OPENGL)) {
503
return (int)GPUBackend::OPENGL;
504
}
505
#endif
506
#if PPSSPP_API(D3D9)
507
if (!failed.count(GPUBackend::DIRECT3D9)) {
508
return (int)GPUBackend::DIRECT3D9;
509
}
510
#endif
511
512
// They've all failed. Let them try the default - or on Android, OpenGL.
513
sFailedGPUBackends += ",ALL";
514
ERROR_LOG(Log::Loader, "All graphics backends failed");
515
#if PPSSPP_PLATFORM(ANDROID)
516
return (int)GPUBackend::OPENGL;
517
#else
518
return DefaultGPUBackend();
519
#endif
520
}
521
522
return iGPUBackend;
523
}
524
525
bool Config::IsBackendEnabled(GPUBackend backend) {
526
std::vector<std::string> split;
527
528
SplitString(sDisabledGPUBackends, ',', split);
529
for (const auto &str : split) {
530
if (str.empty())
531
continue;
532
auto match = GPUBackendFromString(str);
533
if (match == backend)
534
return false;
535
}
536
537
#if PPSSPP_PLATFORM(UWP)
538
if (backend != GPUBackend::DIRECT3D11)
539
return false;
540
#elif PPSSPP_PLATFORM(SWITCH)
541
if (backend != GPUBackend::OPENGL)
542
return false;
543
#elif PPSSPP_PLATFORM(WINDOWS)
544
if (backend == GPUBackend::DIRECT3D11 && !IsVistaOrHigher())
545
return false;
546
#else
547
if (backend == GPUBackend::DIRECT3D11 || backend == GPUBackend::DIRECT3D9)
548
return false;
549
#endif
550
551
#if !PPSSPP_API(ANY_GL)
552
if (backend == GPUBackend::OPENGL)
553
return false;
554
#endif
555
if (backend == GPUBackend::VULKAN && !VulkanMayBeAvailable())
556
return false;
557
return true;
558
}
559
560
template <typename T, std::string (*FTo)(T), T (*FFrom)(std::string_view)>
561
struct ConfigTranslator {
562
static std::string To(int v) {
563
return StringFromInt(v) + " (" + FTo(T(v)) + ")";
564
}
565
566
static int From(const std::string &v) {
567
int result;
568
if (TryParse(v, &result)) {
569
return result;
570
}
571
return (int)FFrom(v);
572
}
573
};
574
575
typedef ConfigTranslator<GPUBackend, GPUBackendToString, GPUBackendFromString> GPUBackendTranslator;
576
577
static int FastForwardModeFromString(const std::string &s) {
578
if (!strcasecmp(s.c_str(), "CONTINUOUS"))
579
return (int)FastForwardMode::CONTINUOUS;
580
if (!strcasecmp(s.c_str(), "SKIP_FLIP"))
581
return (int)FastForwardMode::SKIP_FLIP;
582
return DefaultFastForwardMode();
583
}
584
585
static std::string FastForwardModeToString(int v) {
586
switch (FastForwardMode(v)) {
587
case FastForwardMode::CONTINUOUS:
588
return "CONTINUOUS";
589
case FastForwardMode::SKIP_FLIP:
590
return "SKIP_FLIP";
591
}
592
return "CONTINUOUS";
593
}
594
595
static const ConfigSetting graphicsSettings[] = {
596
ConfigSetting("EnableCardboardVR", &g_Config.bEnableCardboardVR, false, CfgFlag::PER_GAME),
597
ConfigSetting("CardboardScreenSize", &g_Config.iCardboardScreenSize, 50, CfgFlag::PER_GAME),
598
ConfigSetting("CardboardXShift", &g_Config.iCardboardXShift, 0, CfgFlag::PER_GAME),
599
ConfigSetting("CardboardYShift", &g_Config.iCardboardYShift, 0, CfgFlag::PER_GAME),
600
ConfigSetting("iShowStatusFlags", &g_Config.iShowStatusFlags, 0, CfgFlag::PER_GAME),
601
ConfigSetting("GraphicsBackend", &g_Config.iGPUBackend, &DefaultGPUBackend, &GPUBackendTranslator::To, &GPUBackendTranslator::From, CfgFlag::DEFAULT | CfgFlag::REPORT),
602
#if PPSSPP_PLATFORM(ANDROID) && PPSSPP_ARCH(ARM64)
603
ConfigSetting("CustomDriver", &g_Config.sCustomDriver, "", CfgFlag::DEFAULT),
604
#endif
605
ConfigSetting("FailedGraphicsBackends", &g_Config.sFailedGPUBackends, "", CfgFlag::DEFAULT),
606
ConfigSetting("DisabledGraphicsBackends", &g_Config.sDisabledGPUBackends, "", CfgFlag::DEFAULT),
607
ConfigSetting("VulkanDevice", &g_Config.sVulkanDevice, "", CfgFlag::DEFAULT),
608
#ifdef _WIN32
609
ConfigSetting("D3D11Device", &g_Config.sD3D11Device, "", CfgFlag::DEFAULT),
610
#endif
611
ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", CfgFlag::DEFAULT),
612
ConfigSetting("CameraMirrorHorizontal", &g_Config.bCameraMirrorHorizontal, false, CfgFlag::DEFAULT),
613
ConfigSetting("AndroidFramerateMode", &g_Config.iDisplayFramerateMode, 1, CfgFlag::DEFAULT),
614
ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, CfgFlag::DONT_SAVE),
615
ConfigSetting("UseGeometryShader", &g_Config.bUseGeometryShader, false, CfgFlag::PER_GAME),
616
ConfigSetting("SkipBufferEffects", &g_Config.bSkipBufferEffects, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
617
ConfigSetting("DisableRangeCulling", &g_Config.bDisableRangeCulling, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
618
ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, CfgFlag::PER_GAME),
619
ConfigSetting("SoftwareRendererJit", &g_Config.bSoftwareRenderingJit, true, CfgFlag::PER_GAME),
620
ConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
621
ConfigSetting("SoftwareSkinning", &g_Config.bSoftwareSkinning, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
622
ConfigSetting("TextureFiltering", &g_Config.iTexFiltering, 1, CfgFlag::PER_GAME | CfgFlag::REPORT),
623
ConfigSetting("Smart2DTexFiltering", &g_Config.bSmart2DTexFiltering, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
624
ConfigSetting("InternalResolution", &g_Config.iInternalResolution, &DefaultInternalResolution, CfgFlag::PER_GAME | CfgFlag::REPORT),
625
ConfigSetting("AndroidHwScale", &g_Config.iAndroidHwScale, &DefaultAndroidHwScale, CfgFlag::DEFAULT),
626
ConfigSetting("HighQualityDepth", &g_Config.bHighQualityDepth, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
627
ConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0, CfgFlag::PER_GAME | CfgFlag::REPORT),
628
ConfigSetting("FrameSkipType", &g_Config.iFrameSkipType, 0, CfgFlag::PER_GAME | CfgFlag::REPORT),
629
ConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, IsVREnabled(), CfgFlag::PER_GAME | CfgFlag::REPORT),
630
ConfigSetting("StereoRendering", &g_Config.bStereoRendering, false, CfgFlag::PER_GAME),
631
ConfigSetting("StereoToMonoShader", &g_Config.sStereoToMonoShader, "RedBlue", CfgFlag::PER_GAME),
632
ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, CfgFlag::PER_GAME),
633
ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, CfgFlag::PER_GAME),
634
ConfigSetting("AnalogFrameRate", &g_Config.iAnalogFpsLimit, 240, CfgFlag::PER_GAME),
635
ConfigSetting("UnthrottlingMode", &g_Config.iFastForwardMode, &DefaultFastForwardMode, &FastForwardModeToString, &FastForwardModeFromString, CfgFlag::PER_GAME),
636
#if defined(USING_WIN_UI)
637
ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, CfgFlag::DONT_SAVE),
638
#endif
639
640
// Most low-performance (and many high performance) mobile GPUs do not support aniso anyway so defaulting to 4 is fine.
641
ConfigSetting("AnisotropyLevel", &g_Config.iAnisotropyLevel, 4, CfgFlag::PER_GAME),
642
ConfigSetting("MultiSampleLevel", &g_Config.iMultiSampleLevel, 0, CfgFlag::PER_GAME), // Number of samples is 1 << iMultiSampleLevel
643
644
ConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
645
ConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, CfgFlag::DONT_SAVE | CfgFlag::REPORT),
646
647
#ifndef MOBILE_DEVICE
648
ConfigSetting("FullScreen", &g_Config.bFullScreen, false, CfgFlag::DEFAULT),
649
ConfigSetting("FullScreenMulti", &g_Config.bFullScreenMulti, false, CfgFlag::DEFAULT),
650
#endif
651
652
#if PPSSPP_PLATFORM(IOS)
653
ConfigSetting("AppSwitchMode", &g_Config.iAppSwitchMode, (int)AppSwitchMode::DOUBLE_SWIPE_INDICATOR, CfgFlag::DEFAULT),
654
#endif
655
656
ConfigSetting("BufferFiltering", &g_Config.iDisplayFilter, SCALE_LINEAR, CfgFlag::PER_GAME),
657
ConfigSetting("DisplayOffsetX", &g_Config.fDisplayOffsetX, 0.5f, CfgFlag::PER_GAME),
658
ConfigSetting("DisplayOffsetY", &g_Config.fDisplayOffsetY, 0.5f, CfgFlag::PER_GAME),
659
ConfigSetting("DisplayScale", &g_Config.fDisplayScale, 1.0f, CfgFlag::PER_GAME),
660
ConfigSetting("DisplayIntegerScale", &g_Config.bDisplayIntegerScale, false, CfgFlag::PER_GAME),
661
ConfigSetting("DisplayAspectRatio", &g_Config.fDisplayAspectRatio, 1.0f, CfgFlag::PER_GAME),
662
ConfigSetting("DisplayStretch", &g_Config.bDisplayStretch, false, CfgFlag::PER_GAME),
663
ConfigSetting("DisplayCropTo16x9", &g_Config.bDisplayCropTo16x9, true, CfgFlag::PER_GAME),
664
665
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, true, CfgFlag::PER_GAME),
666
ConfigSetting("SustainedPerformanceMode", &g_Config.bSustainedPerformanceMode, false, CfgFlag::PER_GAME),
667
ConfigSetting("IgnoreScreenInsets", &g_Config.bIgnoreScreenInsets, true, CfgFlag::DEFAULT),
668
669
ConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
670
ConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
671
ConfigSetting("IgnoreTextureFilenames", &g_Config.bIgnoreTextureFilenames, false, CfgFlag::PER_GAME),
672
673
ConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, CfgFlag::PER_GAME | CfgFlag::REPORT),
674
ConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, CfgFlag::PER_GAME | CfgFlag::REPORT),
675
ConfigSetting("TexDeposterize", &g_Config.bTexDeposterize, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
676
ConfigSetting("TexHardwareScaling", &g_Config.bTexHardwareScaling, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
677
ConfigSetting("VSync", &g_Config.bVSync, &DefaultVSync, CfgFlag::PER_GAME),
678
ConfigSetting("BloomHack", &g_Config.iBloomHack, 0, CfgFlag::PER_GAME | CfgFlag::REPORT),
679
680
// Not really a graphics setting...
681
ConfigSetting("SplineBezierQuality", &g_Config.iSplineBezierQuality, 2, CfgFlag::PER_GAME | CfgFlag::REPORT),
682
ConfigSetting("HardwareTessellation", &g_Config.bHardwareTessellation, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
683
ConfigSetting("TextureShader", &g_Config.sTextureShaderName, "Off", CfgFlag::PER_GAME),
684
ConfigSetting("ShaderChainRequires60FPS", &g_Config.bShaderChainRequires60FPS, false, CfgFlag::PER_GAME),
685
686
ConfigSetting("SkipGPUReadbackMode", &g_Config.iSkipGPUReadbackMode, false, CfgFlag::PER_GAME | CfgFlag::REPORT),
687
688
ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, CfgFlag::DONT_SAVE),
689
ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, CfgFlag::DEFAULT),
690
691
ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, CfgFlag::DEFAULT),
692
ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, CfgFlag::PER_GAME),
693
694
ConfigSetting("MultiThreading", &g_Config.bRenderMultiThreading, true, CfgFlag::DEFAULT),
695
696
ConfigSetting("ShaderCache", &g_Config.bShaderCache, true, CfgFlag::DONT_SAVE), // Doesn't save. Ini-only.
697
ConfigSetting("GpuLogProfiler", &g_Config.bGpuLogProfiler, false, CfgFlag::DEFAULT),
698
699
ConfigSetting("UberShaderVertex", &g_Config.bUberShaderVertex, true, CfgFlag::DEFAULT),
700
ConfigSetting("UberShaderFragment", &g_Config.bUberShaderFragment, true, CfgFlag::DEFAULT),
701
702
ConfigSetting("DisplayRefreshRate", &g_Config.iDisplayRefreshRate, g_Config.iDisplayRefreshRate, CfgFlag::PER_GAME),
703
};
704
705
static const ConfigSetting soundSettings[] = {
706
ConfigSetting("Enable", &g_Config.bEnableSound, true, CfgFlag::PER_GAME),
707
ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, CfgFlag::PER_GAME),
708
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, CfgFlag::DEFAULT),
709
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_FULL, CfgFlag::PER_GAME),
710
ConfigSetting("ReverbVolume", &g_Config.iReverbVolume, VOLUME_FULL, CfgFlag::PER_GAME),
711
ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, CfgFlag::PER_GAME),
712
ConfigSetting("AchievementSoundVolume", &g_Config.iAchievementSoundVolume, 6, CfgFlag::PER_GAME),
713
ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", CfgFlag::DEFAULT),
714
ConfigSetting("AutoAudioDevice", &g_Config.bAutoAudioDevice, true, CfgFlag::DEFAULT),
715
ConfigSetting("AudioMixWithOthers", &g_Config.bAudioMixWithOthers, true, CfgFlag::DEFAULT),
716
ConfigSetting("AudioRespectSilentMode", &g_Config.bAudioRespectSilentMode, false, CfgFlag::DEFAULT),
717
ConfigSetting("UseNewAtrac", &g_Config.bUseNewAtrac, false, CfgFlag::DEFAULT),
718
};
719
720
static bool DefaultShowTouchControls() {
721
int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
722
if (deviceType == DEVICE_TYPE_MOBILE) {
723
std::string name = System_GetProperty(SYSPROP_NAME);
724
if (KeyMap::HasBuiltinController(name)) {
725
return false;
726
} else {
727
return true;
728
}
729
} else if (deviceType == DEVICE_TYPE_TV) {
730
return false;
731
} else if (deviceType == DEVICE_TYPE_DESKTOP) {
732
return false;
733
} else if (deviceType == DEVICE_TYPE_VR) {
734
return false;
735
} else {
736
return false;
737
}
738
}
739
740
static const float defaultControlScale = 1.15f;
741
static const ConfigTouchPos defaultTouchPosShow = { -1.0f, -1.0f, defaultControlScale, true };
742
static const ConfigTouchPos defaultTouchPosHide = { -1.0f, -1.0f, defaultControlScale, false };
743
744
static const ConfigSetting controlSettings[] = {
745
ConfigSetting("HapticFeedback", &g_Config.bHapticFeedback, false, CfgFlag::PER_GAME),
746
ConfigSetting("ShowTouchCross", &g_Config.bShowTouchCross, true, CfgFlag::PER_GAME),
747
ConfigSetting("ShowTouchCircle", &g_Config.bShowTouchCircle, true, CfgFlag::PER_GAME),
748
ConfigSetting("ShowTouchSquare", &g_Config.bShowTouchSquare, true, CfgFlag::PER_GAME),
749
ConfigSetting("ShowTouchTriangle", &g_Config.bShowTouchTriangle, true, CfgFlag::PER_GAME),
750
751
ConfigSetting("Custom0Mapping", "Custom0Image", "Custom0Shape", "Custom0Toggle", "Custom0Repeat", &g_Config.CustomButton[0], {0, 0, 0, false, false}, CfgFlag::PER_GAME),
752
ConfigSetting("Custom1Mapping", "Custom1Image", "Custom1Shape", "Custom1Toggle", "Custom1Repeat", &g_Config.CustomButton[1], {0, 1, 0, false, false}, CfgFlag::PER_GAME),
753
ConfigSetting("Custom2Mapping", "Custom2Image", "Custom2Shape", "Custom2Toggle", "Custom2Repeat", &g_Config.CustomButton[2], {0, 2, 0, false, false}, CfgFlag::PER_GAME),
754
ConfigSetting("Custom3Mapping", "Custom3Image", "Custom3Shape", "Custom3Toggle", "Custom3Repeat", &g_Config.CustomButton[3], {0, 3, 0, false, false}, CfgFlag::PER_GAME),
755
ConfigSetting("Custom4Mapping", "Custom4Image", "Custom4Shape", "Custom4Toggle", "Custom4Repeat", &g_Config.CustomButton[4], {0, 4, 0, false, false}, CfgFlag::PER_GAME),
756
ConfigSetting("Custom5Mapping", "Custom5Image", "Custom5Shape", "Custom5Toggle", "Custom5Repeat", &g_Config.CustomButton[5], {0, 0, 1, false, false}, CfgFlag::PER_GAME),
757
ConfigSetting("Custom6Mapping", "Custom6Image", "Custom6Shape", "Custom6Toggle", "Custom6Repeat", &g_Config.CustomButton[6], {0, 1, 1, false, false}, CfgFlag::PER_GAME),
758
ConfigSetting("Custom7Mapping", "Custom7Image", "Custom7Shape", "Custom7Toggle", "Custom7Repeat", &g_Config.CustomButton[7], {0, 2, 1, false, false}, CfgFlag::PER_GAME),
759
ConfigSetting("Custom8Mapping", "Custom8Image", "Custom8Shape", "Custom8Toggle", "Custom8Repeat", &g_Config.CustomButton[8], {0, 3, 1, false, false}, CfgFlag::PER_GAME),
760
ConfigSetting("Custom9Mapping", "Custom9Image", "Custom9Shape", "Custom9Toggle", "Custom9Repeat", &g_Config.CustomButton[9], {0, 4, 1, false, false}, CfgFlag::PER_GAME),
761
ConfigSetting("Custom10Mapping", "Custom10Image", "Custom10Shape", "Custom10Toggle", "Custom10Repeat", &g_Config.CustomButton[10], {0, 0, 2, false, false}, CfgFlag::PER_GAME),
762
ConfigSetting("Custom11Mapping", "Custom11Image", "Custom11Shape", "Custom11Toggle", "Custom11Repeat", &g_Config.CustomButton[11], {0, 1, 2, false, false}, CfgFlag::PER_GAME),
763
ConfigSetting("Custom12Mapping", "Custom12Image", "Custom12Shape", "Custom12Toggle", "Custom12Repeat", &g_Config.CustomButton[12], {0, 2, 2, false, false}, CfgFlag::PER_GAME),
764
ConfigSetting("Custom13Mapping", "Custom13Image", "Custom13Shape", "Custom13Toggle", "Custom13Repeat", &g_Config.CustomButton[13], {0, 3, 2, false, false}, CfgFlag::PER_GAME),
765
ConfigSetting("Custom14Mapping", "Custom14Image", "Custom14Shape", "Custom14Toggle", "Custom14Repeat", &g_Config.CustomButton[14], {0, 4, 2, false, false}, CfgFlag::PER_GAME),
766
ConfigSetting("Custom15Mapping", "Custom15Image", "Custom15Shape", "Custom15Toggle", "Custom15Repeat", &g_Config.CustomButton[15], {0, 0, 9, false, false}, CfgFlag::PER_GAME),
767
ConfigSetting("Custom16Mapping", "Custom16Image", "Custom16Shape", "Custom16Toggle", "Custom16Repeat", &g_Config.CustomButton[16], {0, 1, 9, false, false}, CfgFlag::PER_GAME),
768
ConfigSetting("Custom17Mapping", "Custom17Image", "Custom17Shape", "Custom17Toggle", "Custom17Repeat", &g_Config.CustomButton[17], {0, 2, 9, false, false}, CfgFlag::PER_GAME),
769
ConfigSetting("Custom18Mapping", "Custom18Image", "Custom18Shape", "Custom18Toggle", "Custom18Repeat", &g_Config.CustomButton[18], {0, 3, 9, false, false}, CfgFlag::PER_GAME),
770
ConfigSetting("Custom19Mapping", "Custom19Image", "Custom19Shape", "Custom19Toggle", "Custom19Repeat", &g_Config.CustomButton[19], {0, 4, 9, false, false}, CfgFlag::PER_GAME),
771
// Combo keys are something else, but I don't want to break the config backwards compatibility so these will stay wrongly named.
772
ConfigSetting("fcombo0X", "fcombo0Y", "comboKeyScale0", "ShowComboKey0", &g_Config.touchCustom[0], defaultTouchPosHide, CfgFlag::PER_GAME),
773
ConfigSetting("fcombo1X", "fcombo1Y", "comboKeyScale1", "ShowComboKey1", &g_Config.touchCustom[1], defaultTouchPosHide, CfgFlag::PER_GAME),
774
ConfigSetting("fcombo2X", "fcombo2Y", "comboKeyScale2", "ShowComboKey2", &g_Config.touchCustom[2], defaultTouchPosHide, CfgFlag::PER_GAME),
775
ConfigSetting("fcombo3X", "fcombo3Y", "comboKeyScale3", "ShowComboKey3", &g_Config.touchCustom[3], defaultTouchPosHide, CfgFlag::PER_GAME),
776
ConfigSetting("fcombo4X", "fcombo4Y", "comboKeyScale4", "ShowComboKey4", &g_Config.touchCustom[4], defaultTouchPosHide, CfgFlag::PER_GAME),
777
ConfigSetting("fcombo5X", "fcombo5Y", "comboKeyScale5", "ShowComboKey5", &g_Config.touchCustom[5], defaultTouchPosHide, CfgFlag::PER_GAME),
778
ConfigSetting("fcombo6X", "fcombo6Y", "comboKeyScale6", "ShowComboKey6", &g_Config.touchCustom[6], defaultTouchPosHide, CfgFlag::PER_GAME),
779
ConfigSetting("fcombo7X", "fcombo7Y", "comboKeyScale7", "ShowComboKey7", &g_Config.touchCustom[7], defaultTouchPosHide, CfgFlag::PER_GAME),
780
ConfigSetting("fcombo8X", "fcombo8Y", "comboKeyScale8", "ShowComboKey8", &g_Config.touchCustom[8], defaultTouchPosHide, CfgFlag::PER_GAME),
781
ConfigSetting("fcombo9X", "fcombo9Y", "comboKeyScale9", "ShowComboKey9", &g_Config.touchCustom[9], defaultTouchPosHide, CfgFlag::PER_GAME),
782
ConfigSetting("fcombo10X", "fcombo10Y", "comboKeyScale10", "ShowComboKey10", &g_Config.touchCustom[10], defaultTouchPosHide, CfgFlag::PER_GAME),
783
ConfigSetting("fcombo11X", "fcombo11Y", "comboKeyScale11", "ShowComboKey11", &g_Config.touchCustom[11], defaultTouchPosHide, CfgFlag::PER_GAME),
784
ConfigSetting("fcombo12X", "fcombo12Y", "comboKeyScale12", "ShowComboKey12", &g_Config.touchCustom[12], defaultTouchPosHide, CfgFlag::PER_GAME),
785
ConfigSetting("fcombo13X", "fcombo13Y", "comboKeyScale13", "ShowComboKey13", &g_Config.touchCustom[13], defaultTouchPosHide, CfgFlag::PER_GAME),
786
ConfigSetting("fcombo14X", "fcombo14Y", "comboKeyScale14", "ShowComboKey14", &g_Config.touchCustom[14], defaultTouchPosHide, CfgFlag::PER_GAME),
787
ConfigSetting("fcombo15X", "fcombo15Y", "comboKeyScale15", "ShowComboKey15", &g_Config.touchCustom[15], defaultTouchPosHide, CfgFlag::PER_GAME),
788
ConfigSetting("fcombo16X", "fcombo16Y", "comboKeyScale16", "ShowComboKey16", &g_Config.touchCustom[16], defaultTouchPosHide, CfgFlag::PER_GAME),
789
ConfigSetting("fcombo17X", "fcombo17Y", "comboKeyScale17", "ShowComboKey17", &g_Config.touchCustom[17], defaultTouchPosHide, CfgFlag::PER_GAME),
790
ConfigSetting("fcombo18X", "fcombo18Y", "comboKeyScale18", "ShowComboKey18", &g_Config.touchCustom[18], defaultTouchPosHide, CfgFlag::PER_GAME),
791
ConfigSetting("fcombo19X", "fcombo19Y", "comboKeyScale19", "ShowComboKey19", &g_Config.touchCustom[19], defaultTouchPosHide, CfgFlag::PER_GAME),
792
793
#if defined(_WIN32)
794
// A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes
795
// sense to default this to on.
796
ConfigSetting("ShowTouchPause", &g_Config.bShowTouchPause, true, CfgFlag::DEFAULT),
797
#else
798
ConfigSetting("ShowTouchPause", &g_Config.bShowTouchPause, false, CfgFlag::DEFAULT),
799
#endif
800
#if defined(USING_WIN_UI)
801
ConfigSetting("IgnoreWindowsKey", &g_Config.bIgnoreWindowsKey, false, CfgFlag::PER_GAME),
802
#endif
803
804
ConfigSetting("ShowTouchControls", &g_Config.bShowTouchControls, &DefaultShowTouchControls, CfgFlag::PER_GAME),
805
806
// ConfigSetting("KeyMapping", &g_Config.iMappingMap, 0),
807
808
#ifdef MOBILE_DEVICE
809
ConfigSetting("TiltBaseAngleY", &g_Config.fTiltBaseAngleY, 0.9f, CfgFlag::PER_GAME),
810
ConfigSetting("TiltInvertX", &g_Config.bInvertTiltX, false, CfgFlag::PER_GAME),
811
ConfigSetting("TiltInvertY", &g_Config.bInvertTiltY, false, CfgFlag::PER_GAME),
812
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 60, CfgFlag::PER_GAME),
813
ConfigSetting("TiltSensitivityY", &g_Config.iTiltSensitivityY, 60, CfgFlag::PER_GAME),
814
ConfigSetting("TiltAnalogDeadzoneRadius", &g_Config.fTiltAnalogDeadzoneRadius, 0.0f, CfgFlag::PER_GAME),
815
ConfigSetting("TiltInverseDeadzone", &g_Config.fTiltInverseDeadzone, 0.0f, CfgFlag::PER_GAME),
816
ConfigSetting("TiltCircularDeadzone", &g_Config.bTiltCircularDeadzone, true, CfgFlag::PER_GAME),
817
ConfigSetting("TiltInputType", &g_Config.iTiltInputType, 0, CfgFlag::PER_GAME),
818
#endif
819
820
ConfigSetting("DisableDpadDiagonals", &g_Config.bDisableDpadDiagonals, false, CfgFlag::PER_GAME),
821
ConfigSetting("GamepadOnlyFocused", &g_Config.bGamepadOnlyFocused, false, CfgFlag::PER_GAME),
822
ConfigSetting("TouchButtonStyle", &g_Config.iTouchButtonStyle, 1, CfgFlag::PER_GAME),
823
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, CfgFlag::PER_GAME),
824
ConfigSetting("TouchButtonHideSeconds", &g_Config.iTouchButtonHideSeconds, 20, CfgFlag::PER_GAME),
825
ConfigSetting("AutoCenterTouchAnalog", &g_Config.bAutoCenterTouchAnalog, false, CfgFlag::PER_GAME),
826
ConfigSetting("StickyTouchDPad", &g_Config.bStickyTouchDPad, false, CfgFlag::PER_GAME),
827
828
// Snap touch control position
829
ConfigSetting("TouchSnapToGrid", &g_Config.bTouchSnapToGrid, false, CfgFlag::PER_GAME),
830
ConfigSetting("TouchSnapGridSize", &g_Config.iTouchSnapGridSize, 64, CfgFlag::PER_GAME),
831
832
// -1.0f means uninitialized, set in GamepadEmu::CreatePadLayout().
833
ConfigSetting("ActionButtonSpacing2", &g_Config.fActionButtonSpacing, 1.0f, CfgFlag::PER_GAME),
834
ConfigSetting("ActionButtonCenterX", "ActionButtonCenterY", "ActionButtonScale", nullptr, &g_Config.touchActionButtonCenter, defaultTouchPosShow, CfgFlag::PER_GAME),
835
ConfigSetting("DPadX", "DPadY", "DPadScale", "ShowTouchDpad", &g_Config.touchDpad, defaultTouchPosShow, CfgFlag::PER_GAME),
836
837
// Note: these will be overwritten if DPadRadius is set.
838
ConfigSetting("DPadSpacing", &g_Config.fDpadSpacing, 1.0f, CfgFlag::PER_GAME),
839
ConfigSetting("StartKeyX", "StartKeyY", "StartKeyScale", "ShowTouchStart", &g_Config.touchStartKey, defaultTouchPosShow, CfgFlag::PER_GAME),
840
ConfigSetting("SelectKeyX", "SelectKeyY", "SelectKeyScale", "ShowTouchSelect", &g_Config.touchSelectKey, defaultTouchPosShow, CfgFlag::PER_GAME),
841
ConfigSetting("UnthrottleKeyX", "UnthrottleKeyY", "UnthrottleKeyScale", "ShowTouchUnthrottle", &g_Config.touchFastForwardKey, defaultTouchPosShow, CfgFlag::PER_GAME),
842
ConfigSetting("LKeyX", "LKeyY", "LKeyScale", "ShowTouchLTrigger", &g_Config.touchLKey, defaultTouchPosShow, CfgFlag::PER_GAME),
843
ConfigSetting("RKeyX", "RKeyY", "RKeyScale", "ShowTouchRTrigger", &g_Config.touchRKey, defaultTouchPosShow, CfgFlag::PER_GAME),
844
ConfigSetting("AnalogStickX", "AnalogStickY", "AnalogStickScale", "ShowAnalogStick", &g_Config.touchAnalogStick, defaultTouchPosShow, CfgFlag::PER_GAME),
845
ConfigSetting("RightAnalogStickX", "RightAnalogStickY", "RightAnalogStickScale", "ShowRightAnalogStick", &g_Config.touchRightAnalogStick, defaultTouchPosHide, CfgFlag::PER_GAME),
846
847
ConfigSetting("AnalogDeadzone", &g_Config.fAnalogDeadzone, 0.15f, CfgFlag::PER_GAME),
848
ConfigSetting("AnalogInverseDeadzone", &g_Config.fAnalogInverseDeadzone, 0.0f, CfgFlag::PER_GAME),
849
ConfigSetting("AnalogSensitivity", &g_Config.fAnalogSensitivity, 1.1f, CfgFlag::PER_GAME),
850
ConfigSetting("AnalogIsCircular", &g_Config.bAnalogIsCircular, false, CfgFlag::PER_GAME),
851
ConfigSetting("AnalogAutoRotSpeed", &g_Config.fAnalogAutoRotSpeed, 8.0f, CfgFlag::PER_GAME),
852
853
ConfigSetting("AnalogLimiterDeadzone", &g_Config.fAnalogLimiterDeadzone, 0.6f, CfgFlag::DEFAULT),
854
ConfigSetting("AnalogTriggerThreshold", &g_Config.fAnalogTriggerThreshold, 0.75f, CfgFlag::DEFAULT),
855
856
ConfigSetting("AllowMappingCombos", &g_Config.bAllowMappingCombos, false, CfgFlag::DEFAULT),
857
ConfigSetting("StrictComboOrder", &g_Config.bStrictComboOrder, false, CfgFlag::DEFAULT),
858
859
ConfigSetting("LeftStickHeadScale", &g_Config.fLeftStickHeadScale, 1.0f, CfgFlag::PER_GAME),
860
ConfigSetting("RightStickHeadScale", &g_Config.fRightStickHeadScale, 1.0f, CfgFlag::PER_GAME),
861
ConfigSetting("HideStickBackground", &g_Config.bHideStickBackground, false, CfgFlag::PER_GAME),
862
863
ConfigSetting("UseMouse", &g_Config.bMouseControl, false, CfgFlag::PER_GAME),
864
ConfigSetting("MapMouse", &g_Config.bMapMouse, false, CfgFlag::PER_GAME),
865
ConfigSetting("ConfineMap", &g_Config.bMouseConfine, false, CfgFlag::PER_GAME),
866
ConfigSetting("MouseSensitivity", &g_Config.fMouseSensitivity, 0.1f, CfgFlag::PER_GAME),
867
ConfigSetting("MouseSmoothing", &g_Config.fMouseSmoothing, 0.9f, CfgFlag::PER_GAME),
868
ConfigSetting("MouseWheelUpDelayMs", &g_Config.iMouseWheelUpDelayMs, 80, CfgFlag::PER_GAME),
869
870
ConfigSetting("SystemControls", &g_Config.bSystemControls, true, CfgFlag::DEFAULT),
871
ConfigSetting("RapidFileInterval", &g_Config.iRapidFireInterval, 5, CfgFlag::DEFAULT),
872
873
ConfigSetting("AnalogGesture", &g_Config.bAnalogGesture, false, CfgFlag::PER_GAME),
874
ConfigSetting("AnalogGestureSensibility", &g_Config.fAnalogGestureSensibility, 1.0f, CfgFlag::PER_GAME),
875
};
876
877
static const ConfigSetting networkSettings[] = {
878
ConfigSetting("EnableWlan", &g_Config.bEnableWlan, false, CfgFlag::PER_GAME),
879
ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, CfgFlag::PER_GAME),
880
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "socom.cc", CfgFlag::PER_GAME),
881
ConfigSetting("PortOffset", &g_Config.iPortOffset, 10000, CfgFlag::PER_GAME),
882
ConfigSetting("MinTimeout", &g_Config.iMinTimeout, 0, CfgFlag::PER_GAME),
883
ConfigSetting("ForcedFirstConnect", &g_Config.bForcedFirstConnect, false, CfgFlag::PER_GAME),
884
ConfigSetting("EnableUPnP", &g_Config.bEnableUPnP, false, CfgFlag::PER_GAME),
885
ConfigSetting("UPnPUseOriginalPort", &g_Config.bUPnPUseOriginalPort, false, CfgFlag::PER_GAME),
886
887
ConfigSetting("EnableNetworkChat", &g_Config.bEnableNetworkChat, false, CfgFlag::PER_GAME),
888
ConfigSetting("ChatButtonPosition", &g_Config.iChatButtonPosition, (int)ScreenEdgePosition::BOTTOM_LEFT, CfgFlag::PER_GAME),
889
ConfigSetting("ChatScreenPosition", &g_Config.iChatScreenPosition, (int)ScreenEdgePosition::BOTTOM_LEFT, CfgFlag::PER_GAME),
890
ConfigSetting("EnableQuickChat", &g_Config.bEnableQuickChat, true, CfgFlag::PER_GAME),
891
ConfigSetting("QuickChat1", &g_Config.sQuickChat0, "Quick Chat 1", CfgFlag::PER_GAME),
892
ConfigSetting("QuickChat2", &g_Config.sQuickChat1, "Quick Chat 2", CfgFlag::PER_GAME),
893
ConfigSetting("QuickChat3", &g_Config.sQuickChat2, "Quick Chat 3", CfgFlag::PER_GAME),
894
ConfigSetting("QuickChat4", &g_Config.sQuickChat3, "Quick Chat 4", CfgFlag::PER_GAME),
895
ConfigSetting("QuickChat5", &g_Config.sQuickChat4, "Quick Chat 5", CfgFlag::PER_GAME),
896
};
897
898
static const ConfigSetting systemParamSettings[] = {
899
ConfigSetting("PSPModel", &g_Config.iPSPModel, PSP_MODEL_SLIM, CfgFlag::PER_GAME | CfgFlag::REPORT),
900
ConfigSetting("PSPFirmwareVersion", &g_Config.iFirmwareVersion, PSP_DEFAULT_FIRMWARE, CfgFlag::PER_GAME | CfgFlag::REPORT),
901
ConfigSetting("NickName", &g_Config.sNickName, "PPSSPP", CfgFlag::PER_GAME),
902
ConfigSetting("MacAddress", &g_Config.sMACAddress, "", CfgFlag::PER_GAME),
903
ConfigSetting("GameLanguage", &g_Config.iLanguage, -1, CfgFlag::PER_GAME | CfgFlag::REPORT),
904
ConfigSetting("ParamTimeFormat", &g_Config.iTimeFormat, PSP_SYSTEMPARAM_TIME_FORMAT_24HR, CfgFlag::PER_GAME),
905
ConfigSetting("ParamDateFormat", &g_Config.iDateFormat, PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD, CfgFlag::PER_GAME),
906
ConfigSetting("TimeZone", &g_Config.iTimeZone, 0, CfgFlag::PER_GAME),
907
ConfigSetting("DayLightSavings", &g_Config.bDayLightSavings, (bool) PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD, CfgFlag::PER_GAME),
908
ConfigSetting("ButtonPreference", &g_Config.iButtonPreference, PSP_SYSTEMPARAM_BUTTON_CROSS, CfgFlag::PER_GAME | CfgFlag::REPORT),
909
ConfigSetting("LockParentalLevel", &g_Config.iLockParentalLevel, 0, CfgFlag::PER_GAME),
910
ConfigSetting("WlanAdhocChannel", &g_Config.iWlanAdhocChannel, PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC, CfgFlag::PER_GAME),
911
#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH)
912
ConfigSetting("BypassOSKWithKeyboard", &g_Config.bBypassOSKWithKeyboard, false, CfgFlag::PER_GAME),
913
#endif
914
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, CfgFlag::PER_GAME),
915
ConfigSetting("EncryptSave", &g_Config.bEncryptSave, true, CfgFlag::PER_GAME | CfgFlag::REPORT),
916
ConfigSetting("SavedataUpgradeVersion", &g_Config.bSavedataUpgrade, true, CfgFlag::DEFAULT),
917
ConfigSetting("MemStickSize", &g_Config.iMemStickSizeGB, 16, CfgFlag::DEFAULT),
918
};
919
920
static const ConfigSetting debuggerSettings[] = {
921
ConfigSetting("DisasmWindowX", &g_Config.iDisasmWindowX, -1, CfgFlag::DEFAULT),
922
ConfigSetting("DisasmWindowY", &g_Config.iDisasmWindowY, -1, CfgFlag::DEFAULT),
923
ConfigSetting("DisasmWindowW", &g_Config.iDisasmWindowW, -1, CfgFlag::DEFAULT),
924
ConfigSetting("DisasmWindowH", &g_Config.iDisasmWindowH, -1, CfgFlag::DEFAULT),
925
ConfigSetting("GEWindowX", &g_Config.iGEWindowX, -1, CfgFlag::DEFAULT),
926
ConfigSetting("GEWindowY", &g_Config.iGEWindowY, -1, CfgFlag::DEFAULT),
927
ConfigSetting("GEWindowW", &g_Config.iGEWindowW, -1, CfgFlag::DEFAULT),
928
ConfigSetting("GEWindowH", &g_Config.iGEWindowH, -1, CfgFlag::DEFAULT),
929
ConfigSetting("GEWindowTabsBL", &g_Config.uGETabsLeft, (uint32_t)0, CfgFlag::DEFAULT),
930
ConfigSetting("GEWindowTabsBR", &g_Config.uGETabsRight, (uint32_t)0, CfgFlag::DEFAULT),
931
ConfigSetting("GEWindowTabsTR", &g_Config.uGETabsTopRight, (uint32_t)0, CfgFlag::DEFAULT),
932
ConfigSetting("ConsoleWindowX", &g_Config.iConsoleWindowX, -1, CfgFlag::DEFAULT),
933
ConfigSetting("ConsoleWindowY", &g_Config.iConsoleWindowY, -1, CfgFlag::DEFAULT),
934
ConfigSetting("FontWidth", &g_Config.iFontWidth, 8, CfgFlag::DEFAULT),
935
ConfigSetting("FontHeight", &g_Config.iFontHeight, 12, CfgFlag::DEFAULT),
936
ConfigSetting("DisplayStatusBar", &g_Config.bDisplayStatusBar, true, CfgFlag::DEFAULT),
937
ConfigSetting("ShowBottomTabTitles",&g_Config.bShowBottomTabTitles, true, CfgFlag::DEFAULT),
938
ConfigSetting("ShowDeveloperMenu", &g_Config.bShowDeveloperMenu, false, CfgFlag::DEFAULT),
939
ConfigSetting("SkipDeadbeefFilling", &g_Config.bSkipDeadbeefFilling, false, CfgFlag::DEFAULT),
940
ConfigSetting("FuncHashMap", &g_Config.bFuncHashMap, false, CfgFlag::DEFAULT),
941
ConfigSetting("SkipFuncHashMap", &g_Config.sSkipFuncHashMap, "", CfgFlag::DEFAULT),
942
ConfigSetting("MemInfoDetailed", &g_Config.bDebugMemInfoDetailed, false, CfgFlag::DEFAULT),
943
};
944
945
static const ConfigSetting jitSettings[] = {
946
ConfigSetting("DiscardRegsOnJRRA", &g_Config.bDiscardRegsOnJRRA, false, CfgFlag::DONT_SAVE | CfgFlag::REPORT),
947
};
948
949
static const ConfigSetting upgradeSettings[] = {
950
ConfigSetting("UpgradeMessage", &g_Config.upgradeMessage, "", CfgFlag::DEFAULT),
951
ConfigSetting("UpgradeVersion", &g_Config.upgradeVersion, "", CfgFlag::DEFAULT),
952
ConfigSetting("DismissedVersion", &g_Config.dismissedVersion, "", CfgFlag::DEFAULT),
953
};
954
955
static const ConfigSetting themeSettings[] = {
956
ConfigSetting("ThemeName", &g_Config.sThemeName, "Default", CfgFlag::DEFAULT),
957
};
958
959
960
static const ConfigSetting vrSettings[] = {
961
ConfigSetting("VREnable", &g_Config.bEnableVR, true, CfgFlag::PER_GAME),
962
ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, false, CfgFlag::PER_GAME),
963
ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false, CfgFlag::PER_GAME),
964
ConfigSetting("VRForce72Hz", &g_Config.bForce72Hz, true, CfgFlag::PER_GAME),
965
ConfigSetting("VRForce", &g_Config.bForceVR, false, CfgFlag::DEFAULT),
966
ConfigSetting("VRImmersiveMode", &g_Config.bEnableImmersiveVR, true, CfgFlag::PER_GAME),
967
ConfigSetting("VRManualForceVR", &g_Config.bManualForceVR, false, CfgFlag::PER_GAME),
968
ConfigSetting("VRPassthrough", &g_Config.bPassthrough, false, CfgFlag::PER_GAME),
969
ConfigSetting("VRRescaleHUD", &g_Config.bRescaleHUD, true, CfgFlag::PER_GAME),
970
ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f, CfgFlag::PER_GAME),
971
ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f, CfgFlag::PER_GAME),
972
ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f, CfgFlag::PER_GAME),
973
ConfigSetting("VRCameraPitch", &g_Config.fCameraPitch, 0.0f, CfgFlag::PER_GAME),
974
ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 12.0f, CfgFlag::DEFAULT),
975
ConfigSetting("VRCanvas3DDistance", &g_Config.fCanvas3DDistance, 3.0f, CfgFlag::DEFAULT),
976
ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f, CfgFlag::PER_GAME),
977
ConfigSetting("VRHeadUpDisplayScale", &g_Config.fHeadUpDisplayScale, 0.3f, CfgFlag::PER_GAME),
978
};
979
980
static const ConfigSectionSettings sections[] = {
981
{"General", generalSettings, ARRAY_SIZE(generalSettings)},
982
{"CPU", cpuSettings, ARRAY_SIZE(cpuSettings)},
983
{"Graphics", graphicsSettings, ARRAY_SIZE(graphicsSettings)},
984
{"Sound", soundSettings, ARRAY_SIZE(soundSettings)},
985
{"Control", controlSettings, ARRAY_SIZE(controlSettings)},
986
{"Network", networkSettings, ARRAY_SIZE(networkSettings)},
987
{"SystemParam", systemParamSettings, ARRAY_SIZE(systemParamSettings)},
988
{"Debugger", debuggerSettings, ARRAY_SIZE(debuggerSettings)},
989
{"JIT", jitSettings, ARRAY_SIZE(jitSettings)},
990
{"Upgrade", upgradeSettings, ARRAY_SIZE(upgradeSettings)},
991
{"Theme", themeSettings, ARRAY_SIZE(themeSettings)},
992
{"VR", vrSettings, ARRAY_SIZE(vrSettings)},
993
{"Achievements", achievementSettings, ARRAY_SIZE(achievementSettings)},
994
};
995
996
const size_t numSections = ARRAY_SIZE(sections);
997
998
static void IterateSettings(IniFile &iniFile, std::function<void(Section *section, const ConfigSetting &setting)> func) {
999
for (size_t i = 0; i < numSections; ++i) {
1000
Section *section = iniFile.GetOrCreateSection(sections[i].section);
1001
for (size_t j = 0; j < sections[i].settingsCount; j++) {
1002
func(section, sections[i].settings[j]);
1003
}
1004
}
1005
}
1006
1007
static void IterateSettings(std::function<void(const ConfigSetting &setting)> func) {
1008
for (size_t i = 0; i < numSections; ++i) {
1009
for (size_t j = 0; j < sections[i].settingsCount; j++) {
1010
func(sections[i].settings[j]);
1011
}
1012
}
1013
}
1014
1015
void ConfigPrivate::ResetRecentIsosThread() {
1016
std::lock_guard<std::mutex> guard(recentIsosThreadLock);
1017
if (recentIsosThreadPending && recentIsosThread.joinable())
1018
recentIsosThread.join();
1019
}
1020
1021
void ConfigPrivate::SetRecentIsosThread(std::function<void()> f) {
1022
std::lock_guard<std::mutex> guard(recentIsosThreadLock);
1023
if (recentIsosThreadPending && recentIsosThread.joinable())
1024
recentIsosThread.join();
1025
recentIsosThread = std::thread(f);
1026
recentIsosThreadPending = true;
1027
}
1028
1029
Config::Config() {
1030
private_ = new ConfigPrivate();
1031
}
1032
1033
Config::~Config() {
1034
if (bUpdatedInstanceCounter) {
1035
ShutdownInstanceCounter();
1036
}
1037
private_->ResetRecentIsosThread();
1038
delete private_;
1039
}
1040
1041
void Config::LoadLangValuesMapping() {
1042
IniFile mapping;
1043
mapping.LoadFromVFS(g_VFS, "langregion.ini");
1044
std::vector<std::string> keys;
1045
mapping.GetKeys("LangRegionNames", keys);
1046
1047
std::map<std::string, int> langCodeMapping;
1048
langCodeMapping["JAPANESE"] = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE;
1049
langCodeMapping["ENGLISH"] = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
1050
langCodeMapping["FRENCH"] = PSP_SYSTEMPARAM_LANGUAGE_FRENCH;
1051
langCodeMapping["SPANISH"] = PSP_SYSTEMPARAM_LANGUAGE_SPANISH;
1052
langCodeMapping["GERMAN"] = PSP_SYSTEMPARAM_LANGUAGE_GERMAN;
1053
langCodeMapping["ITALIAN"] = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN;
1054
langCodeMapping["DUTCH"] = PSP_SYSTEMPARAM_LANGUAGE_DUTCH;
1055
langCodeMapping["PORTUGUESE"] = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE;
1056
langCodeMapping["RUSSIAN"] = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN;
1057
langCodeMapping["KOREAN"] = PSP_SYSTEMPARAM_LANGUAGE_KOREAN;
1058
langCodeMapping["CHINESE_TRADITIONAL"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL;
1059
langCodeMapping["CHINESE_SIMPLIFIED"] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED;
1060
1061
const Section *langRegionNames = mapping.GetOrCreateSection("LangRegionNames");
1062
const Section *systemLanguage = mapping.GetOrCreateSection("SystemLanguage");
1063
1064
for (size_t i = 0; i < keys.size(); i++) {
1065
std::string langName;
1066
langRegionNames->Get(keys[i].c_str(), &langName, "ERROR");
1067
std::string langCode;
1068
systemLanguage->Get(keys[i].c_str(), &langCode, "ENGLISH");
1069
int iLangCode = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
1070
if (langCodeMapping.find(langCode) != langCodeMapping.end())
1071
iLangCode = langCodeMapping[langCode];
1072
langValuesMapping_[keys[i]] = std::make_pair(langName, iLangCode);
1073
}
1074
}
1075
1076
const std::map<std::string, std::pair<std::string, int>, std::less<>> &Config::GetLangValuesMapping() {
1077
if (langValuesMapping_.empty()) {
1078
LoadLangValuesMapping();
1079
}
1080
return langValuesMapping_;
1081
}
1082
1083
void Config::Reload() {
1084
reload_ = true;
1085
Load();
1086
reload_ = false;
1087
}
1088
1089
// Call this if you change the search path (such as when changing memstick directory. can't
1090
// really think of any other legit uses).
1091
void Config::UpdateIniLocation(const char *iniFileName, const char *controllerIniFilename) {
1092
const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0;
1093
const char *ppssppIniFilename = IsVREnabled() ? "ppssppvr.ini" : "ppsspp.ini";
1094
iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : ppssppIniFilename);
1095
const bool useControllerIniFilename = controllerIniFilename != nullptr && strlen(controllerIniFilename) > 0;
1096
const char *controlsIniFilename = IsVREnabled() ? "controlsvr.ini" : "controls.ini";
1097
controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : controlsIniFilename);
1098
}
1099
1100
bool Config::LoadAppendedConfig() {
1101
IniFile iniFile;
1102
if (!iniFile.Load(appendedConfigFileName_)) {
1103
ERROR_LOG(Log::Loader, "Failed to read appended config '%s'.", appendedConfigFileName_.c_str());
1104
return false;
1105
}
1106
1107
IterateSettings(iniFile, [&iniFile](Section *section, const ConfigSetting &setting) {
1108
if (iniFile.Exists(section->name().c_str(), setting.iniKey_))
1109
setting.Get(section);
1110
});
1111
1112
INFO_LOG(Log::Loader, "Loaded appended config '%s'.", appendedConfigFileName_.c_str());
1113
1114
Save("Loaded appended config"); // Let's prevent reset
1115
return true;
1116
}
1117
1118
void Config::SetAppendedConfigIni(const Path &path) {
1119
appendedConfigFileName_ = path;
1120
}
1121
1122
void Config::UpdateAfterSettingAutoFrameSkip() {
1123
if (bAutoFrameSkip && iFrameSkip == 0) {
1124
iFrameSkip = 1;
1125
}
1126
1127
if (bAutoFrameSkip && bSkipBufferEffects) {
1128
bSkipBufferEffects = false;
1129
}
1130
}
1131
1132
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
1133
double startTime = time_now_d();
1134
1135
if (!bUpdatedInstanceCounter) {
1136
InitInstanceCounter();
1137
bUpdatedInstanceCounter = true;
1138
}
1139
1140
g_DownloadManager.SetUserAgent(StringFromFormat("PPSSPP/%s", PPSSPP_GIT_VERSION));
1141
1142
UpdateIniLocation(iniFileName, controllerIniFilename);
1143
1144
INFO_LOG(Log::Loader, "Loading config: %s", iniFilename_.c_str());
1145
bSaveSettings = true;
1146
1147
IniFile iniFile;
1148
if (!iniFile.Load(iniFilename_)) {
1149
ERROR_LOG(Log::Loader, "Failed to read '%s'. Setting config to default.", iniFilename_.c_str());
1150
// Continue anyway to initialize the config.
1151
}
1152
1153
IterateSettings(iniFile, [](Section *section, const ConfigSetting &setting) {
1154
setting.Get(section);
1155
});
1156
1157
iRunCount++;
1158
1159
// For iOS, issue #19211
1160
TryUpdateSavedPath(&currentDirectory);
1161
1162
// This check is probably not really necessary here anyway, you can always
1163
// press Home or Browse if you're in a bad directory.
1164
if (!File::Exists(currentDirectory))
1165
currentDirectory = defaultCurrentDirectory;
1166
1167
Section *log = iniFile.GetOrCreateSection(logSectionName);
1168
1169
bool debugDefaults = false;
1170
#ifdef _DEBUG
1171
debugDefaults = true;
1172
#endif
1173
LogManager::GetInstance()->LoadConfig(log, debugDefaults);
1174
1175
Section *recent = iniFile.GetOrCreateSection("Recent");
1176
recent->Get("MaxRecent", &iMaxRecent, 60);
1177
1178
// Fix issue from switching from uint (hex in .ini) to int (dec)
1179
// -1 is okay, though. We'll just ignore recent stuff if it is.
1180
if (iMaxRecent == 0)
1181
iMaxRecent = 60;
1182
1183
// Fix JIT setting if no longer available.
1184
if (!System_GetPropertyBool(SYSPROP_CAN_JIT)) {
1185
if (iCpuCore == (int)CPUCore::JIT || iCpuCore == (int)CPUCore::JIT_IR) {
1186
WARN_LOG(Log::Loader, "Forcing JIT off due to unavailablility");
1187
iCpuCore = (int)CPUCore::IR_INTERPRETER;
1188
}
1189
}
1190
1191
if (iMaxRecent > 0) {
1192
private_->ResetRecentIsosThread();
1193
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1194
recentIsos.clear();
1195
for (int i = 0; i < iMaxRecent; i++) {
1196
char keyName[64];
1197
std::string fileName;
1198
1199
snprintf(keyName, sizeof(keyName), "FileName%d", i);
1200
if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
1201
recentIsos.push_back(fileName);
1202
}
1203
}
1204
}
1205
1206
// Time tracking
1207
Section *playTime = iniFile.GetOrCreateSection("PlayTime");
1208
playTimeTracker_.Load(playTime);
1209
1210
auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
1211
vPinnedPaths.clear();
1212
for (const auto &[_, value] : pinnedPaths) {
1213
// Unpin paths that are deleted automatically.
1214
const std::string &path = value;
1215
if (startsWith(path, "http://") || startsWith(path, "https://") || File::Exists(Path(path))) {
1216
vPinnedPaths.push_back(File::ResolvePath(path));
1217
}
1218
}
1219
1220
// Default values for post process shaders
1221
bool postShadersInitialized = iniFile.HasSection("PostShaderList");
1222
Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList");
1223
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
1224
if (IsVREnabled() && !postShadersInitialized) {
1225
postShaderChain->Set("PostShader1", "ColorCorrection");
1226
postShaderSetting->Set("ColorCorrectionSettingCurrentValue1", 1.0f);
1227
postShaderSetting->Set("ColorCorrectionSettingCurrentValue2", 1.5f);
1228
postShaderSetting->Set("ColorCorrectionSettingCurrentValue3", 1.1f);
1229
postShaderSetting->Set("ColorCorrectionSettingCurrentValue4", 1.0f);
1230
}
1231
1232
// Load post process shader values
1233
mPostShaderSetting.clear();
1234
for (const auto &[key, value] : postShaderSetting->ToMap()) {
1235
mPostShaderSetting[key] = std::stof(value);
1236
}
1237
1238
// Load post process shader names
1239
vPostShaderNames.clear();
1240
for (const auto& it : postShaderChain->ToMap()) {
1241
if (it.second != "Off")
1242
vPostShaderNames.push_back(it.second);
1243
}
1244
1245
// Check for an old dpad setting
1246
Section *control = iniFile.GetOrCreateSection("Control");
1247
float f;
1248
control->Get("DPadRadius", &f, 0.0f);
1249
if (f > 0.0f) {
1250
ResetControlLayout();
1251
}
1252
1253
// Force JIT setting to a valid value for the current system configuration.
1254
if (!System_GetPropertyBool(SYSPROP_CAN_JIT)) {
1255
if (g_Config.iCpuCore == (int)CPUCore::JIT || g_Config.iCpuCore == (int)CPUCore::JIT_IR) {
1256
g_Config.iCpuCore = (int)CPUCore::IR_INTERPRETER;
1257
}
1258
}
1259
1260
const char *gitVer = PPSSPP_GIT_VERSION;
1261
Version installed(gitVer);
1262
Version upgrade(upgradeVersion);
1263
const bool versionsValid = installed.IsValid() && upgrade.IsValid();
1264
1265
// Do this regardless of iRunCount to prevent a silly bug where one might use an older
1266
// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
1267
// even if said newer version is >= the upgrade found online.
1268
if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
1269
upgradeMessage.clear();
1270
}
1271
1272
// Check for new version on every 10 runs.
1273
// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
1274
// splash screen quickly), but then we'll just show the notification next time instead, we store the
1275
// upgrade number in the ini.
1276
if (iRunCount % 10 == 0 && bCheckForNewVersion) {
1277
const char *versionUrl = "http://www.ppsspp.org/version.json";
1278
const char *acceptMime = "application/json, text/*; q=0.9, */*; q=0.8";
1279
g_DownloadManager.StartDownloadWithCallback(versionUrl, Path(), http::ProgressBarMode::NONE, &DownloadCompletedCallback, "version", acceptMime);
1280
}
1281
1282
INFO_LOG(Log::Loader, "Loading controller config: %s", controllerIniFilename_.c_str());
1283
bSaveSettings = true;
1284
1285
LoadStandardControllerIni();
1286
1287
//so this is all the way down here to overwrite the controller settings
1288
//sadly it won't benefit from all the "version conversion" going on up-above
1289
//but these configs shouldn't contain older versions anyhow
1290
if (bGameSpecific) {
1291
loadGameConfig(gameId_, gameIdTitle_);
1292
}
1293
1294
CleanRecent();
1295
1296
PostLoadCleanup(false);
1297
1298
INFO_LOG(Log::Loader, "Config loaded: '%s' (%0.1f ms)", iniFilename_.c_str(), (time_now_d() - startTime) * 1000.0);
1299
}
1300
1301
bool Config::Save(const char *saveReason) {
1302
double startTime = time_now_d();
1303
if (!IsFirstInstance()) {
1304
// TODO: Should we allow saving config if started from a different directory?
1305
// How do we tell?
1306
WARN_LOG(Log::Loader, "Not saving config - secondary instances don't.");
1307
1308
// Don't want to retry or something.
1309
return true;
1310
}
1311
1312
if (!iniFilename_.empty() && g_Config.bSaveSettings) {
1313
saveGameConfig(gameId_, gameIdTitle_);
1314
1315
PreSaveCleanup(false);
1316
1317
CleanRecent();
1318
IniFile iniFile;
1319
if (!iniFile.Load(iniFilename_)) {
1320
WARN_LOG(Log::Loader, "Likely saving config for first time - couldn't read ini '%s'", iniFilename_.c_str());
1321
}
1322
1323
// Need to do this somewhere...
1324
bFirstRun = false;
1325
1326
IterateSettings(iniFile, [&](Section *section, const ConfigSetting &setting) {
1327
if (!bGameSpecific || !setting.PerGame()) {
1328
setting.Set(section);
1329
}
1330
});
1331
1332
Section *recent = iniFile.GetOrCreateSection("Recent");
1333
recent->Set("MaxRecent", iMaxRecent);
1334
1335
private_->ResetRecentIsosThread();
1336
for (int i = 0; i < iMaxRecent; i++) {
1337
char keyName[64];
1338
snprintf(keyName, sizeof(keyName), "FileName%d", i);
1339
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1340
if (i < (int)recentIsos.size()) {
1341
recent->Set(keyName, recentIsos[i]);
1342
} else {
1343
recent->Delete(keyName); // delete the nonexisting FileName
1344
}
1345
}
1346
1347
Section *pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths");
1348
pinnedPaths->Clear();
1349
for (size_t i = 0; i < vPinnedPaths.size(); ++i) {
1350
char keyName[64];
1351
snprintf(keyName, sizeof(keyName), "Path%d", (int)i);
1352
pinnedPaths->Set(keyName, vPinnedPaths[i]);
1353
}
1354
1355
if (!bGameSpecific) {
1356
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
1357
postShaderSetting->Clear();
1358
for (const auto &[k, v] : mPostShaderSetting) {
1359
postShaderSetting->Set(k.c_str(), v);
1360
}
1361
Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList");
1362
postShaderChain->Clear();
1363
for (size_t i = 0; i < vPostShaderNames.size(); ++i) {
1364
char keyName[64];
1365
snprintf(keyName, sizeof(keyName), "PostShader%d", (int)i+1);
1366
postShaderChain->Set(keyName, vPostShaderNames[i]);
1367
}
1368
}
1369
1370
Section *control = iniFile.GetOrCreateSection("Control");
1371
control->Delete("DPadRadius");
1372
1373
Section *log = iniFile.GetOrCreateSection(logSectionName);
1374
if (LogManager::GetInstance())
1375
LogManager::GetInstance()->SaveConfig(log);
1376
1377
// Time tracking
1378
Section *playTime = iniFile.GetOrCreateSection("PlayTime");
1379
playTimeTracker_.Save(playTime);
1380
1381
if (!iniFile.Save(iniFilename_)) {
1382
ERROR_LOG(Log::Loader, "Error saving config (%s) - can't write ini '%s'", saveReason, iniFilename_.c_str());
1383
return false;
1384
}
1385
INFO_LOG(Log::Loader, "Config saved (%s): '%s' (%0.1f ms)", saveReason, iniFilename_.c_str(), (time_now_d() - startTime) * 1000.0);
1386
1387
if (!bGameSpecific) //otherwise we already did this in saveGameConfig()
1388
{
1389
IniFile controllerIniFile;
1390
if (!controllerIniFile.Load(controllerIniFilename_)) {
1391
ERROR_LOG(Log::Loader, "Error saving controller config - can't read ini first '%s'", controllerIniFilename_.c_str());
1392
}
1393
KeyMap::SaveToIni(controllerIniFile);
1394
if (!controllerIniFile.Save(controllerIniFilename_)) {
1395
ERROR_LOG(Log::Loader, "Error saving config - can't write ini '%s'", controllerIniFilename_.c_str());
1396
return false;
1397
}
1398
INFO_LOG(Log::Loader, "Controller config saved: %s", controllerIniFilename_.c_str());
1399
}
1400
1401
PostSaveCleanup(false);
1402
} else {
1403
INFO_LOG(Log::Loader, "Not saving config");
1404
}
1405
1406
return true;
1407
}
1408
1409
void Config::PostLoadCleanup(bool gameSpecific) {
1410
// Override ppsspp.ini JIT value to prevent crashing
1411
jitForcedOff = DefaultCpuCore() != (int)CPUCore::JIT && (g_Config.iCpuCore == (int)CPUCore::JIT || g_Config.iCpuCore == (int)CPUCore::JIT_IR);
1412
if (jitForcedOff) {
1413
g_Config.iCpuCore = (int)CPUCore::IR_INTERPRETER;
1414
}
1415
1416
// This caps the exponent 4 (so 16x.)
1417
if (iAnisotropyLevel > 4) {
1418
iAnisotropyLevel = 4;
1419
}
1420
1421
// Set a default MAC, and correct if it's an old format.
1422
if (sMACAddress.length() != 17)
1423
sMACAddress = CreateRandMAC();
1424
1425
if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) {
1426
g_Config.bSkipBufferEffects = false;
1427
}
1428
1429
// Automatically silence secondary instances. Could be an option I guess, but meh.
1430
if (PPSSPP_ID > 1) {
1431
g_Config.iGlobalVolume = 0;
1432
}
1433
1434
// Automatically switch away from deprecated setting value.
1435
if (iTexScalingLevel <= 0) {
1436
iTexScalingLevel = 1;
1437
}
1438
1439
// Remove a legacy value.
1440
if (g_Config.sCustomDriver == "Default") {
1441
g_Config.sCustomDriver = "";
1442
}
1443
}
1444
1445
void Config::PreSaveCleanup(bool gameSpecific) {
1446
if (jitForcedOff) {
1447
// If we forced jit off and it's still set to IR, change it back to jit.
1448
if (g_Config.iCpuCore == (int)CPUCore::IR_INTERPRETER)
1449
g_Config.iCpuCore = (int)CPUCore::JIT;
1450
}
1451
}
1452
1453
void Config::PostSaveCleanup(bool gameSpecific) {
1454
if (jitForcedOff) {
1455
// Force JIT off again just in case Config::Save() is called without exiting PPSSPP.
1456
if (g_Config.iCpuCore == (int)CPUCore::JIT)
1457
g_Config.iCpuCore = (int)CPUCore::IR_INTERPRETER;
1458
}
1459
}
1460
1461
void Config::NotifyUpdatedCpuCore() {
1462
if (jitForcedOff && g_Config.iCpuCore == (int)CPUCore::IR_INTERPRETER) {
1463
// No longer forced off, the user set it to IR jit.
1464
jitForcedOff = false;
1465
}
1466
}
1467
1468
// Use for debugging the version check without messing with the server
1469
#if 0
1470
#define PPSSPP_GIT_VERSION "v0.0.1-gaaaaaaaaa"
1471
#endif
1472
1473
void Config::DownloadCompletedCallback(http::Request &download) {
1474
if (download.ResultCode() != 200) {
1475
ERROR_LOG(Log::Loader, "Failed to download %s: %d", download.url().c_str(), download.ResultCode());
1476
return;
1477
}
1478
std::string data;
1479
download.buffer().TakeAll(&data);
1480
if (data.empty()) {
1481
ERROR_LOG(Log::Loader, "Version check: Empty data from server!");
1482
return;
1483
}
1484
1485
json::JsonReader reader(data.c_str(), data.size());
1486
const json::JsonGet root = reader.root();
1487
if (!root) {
1488
ERROR_LOG(Log::Loader, "Failed to parse json");
1489
return;
1490
}
1491
1492
std::string version;
1493
root.getString("version", &version);
1494
1495
const char *gitVer = PPSSPP_GIT_VERSION;
1496
Version installed(gitVer);
1497
Version upgrade(version);
1498
Version dismissed(g_Config.dismissedVersion);
1499
1500
if (!installed.IsValid()) {
1501
ERROR_LOG(Log::Loader, "Version check: Local version string invalid. Build problems? %s", PPSSPP_GIT_VERSION);
1502
return;
1503
}
1504
if (!upgrade.IsValid()) {
1505
ERROR_LOG(Log::Loader, "Version check: Invalid server version: %s", version.c_str());
1506
return;
1507
}
1508
1509
if (installed >= upgrade) {
1510
INFO_LOG(Log::Loader, "Version check: Already up to date, erasing any upgrade message");
1511
g_Config.upgradeMessage.clear();
1512
g_Config.upgradeVersion = upgrade.ToString();
1513
g_Config.dismissedVersion.clear();
1514
return;
1515
}
1516
1517
if (installed < upgrade && dismissed != upgrade) {
1518
g_Config.upgradeMessage = "New version of PPSSPP available!";
1519
g_Config.upgradeVersion = upgrade.ToString();
1520
g_Config.dismissedVersion.clear();
1521
}
1522
}
1523
1524
void Config::DismissUpgrade() {
1525
g_Config.dismissedVersion = g_Config.upgradeVersion;
1526
}
1527
1528
void Config::AddRecent(const std::string &file) {
1529
// Don't bother with this if the user disabled recents (it's -1).
1530
if (iMaxRecent <= 0)
1531
return;
1532
1533
// We'll add it back below. This makes sure it's at the front, and only once.
1534
RemoveRecent(file);
1535
1536
private_->ResetRecentIsosThread();
1537
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1538
const std::string filename = File::ResolvePath(file);
1539
recentIsos.insert(recentIsos.begin(), filename);
1540
if ((int)recentIsos.size() > iMaxRecent)
1541
recentIsos.resize(iMaxRecent);
1542
}
1543
1544
void Config::RemoveRecent(const std::string &file) {
1545
// Don't bother with this if the user disabled recents (it's -1).
1546
if (iMaxRecent <= 0)
1547
return;
1548
1549
private_->ResetRecentIsosThread();
1550
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1551
1552
const std::string filename = File::ResolvePath(file);
1553
auto iter = std::remove_if(recentIsos.begin(), recentIsos.end(), [filename](const auto &str) {
1554
const std::string recent = File::ResolvePath(str);
1555
return filename == recent;
1556
});
1557
// remove_if is weird.
1558
recentIsos.erase(iter, recentIsos.end());
1559
}
1560
1561
// On iOS, the path to the app documents directory changes on each launch.
1562
// Example path:
1563
// /var/mobile/Containers/Data/Application/0E0E89DE-8D8E-485A-860C-700D8BC87B86/Documents/PSP/GAME/SuicideBarbie
1564
// The GUID part changes on each launch.
1565
static bool TryUpdateSavedPath(Path *path) {
1566
#if PPSSPP_PLATFORM(IOS)
1567
INFO_LOG(Log::Loader, "Original path: %s", path->c_str());
1568
std::string pathStr = path->ToString();
1569
1570
const std::string_view applicationRoot = "/var/mobile/Containers/Data/Application/";
1571
if (startsWith(pathStr, applicationRoot)) {
1572
size_t documentsPos = pathStr.find("/Documents/");
1573
if (documentsPos == std::string::npos) {
1574
return false;
1575
}
1576
std::string memstick = g_Config.memStickDirectory.ToString();
1577
size_t memstickDocumentsPos = memstick.find("/Documents"); // Note: No trailing slash, or we won't find it.
1578
*path = Path(memstick.substr(0, memstickDocumentsPos) + pathStr.substr(documentsPos));
1579
return true;
1580
} else {
1581
// Path can't be auto-updated.
1582
return false;
1583
}
1584
#else
1585
return false;
1586
#endif
1587
}
1588
1589
void Config::CleanRecent() {
1590
private_->SetRecentIsosThread([this] {
1591
SetCurrentThreadName("RecentISOs");
1592
1593
AndroidJNIThreadContext jniContext; // destructor detaches
1594
1595
double startTime = time_now_d();
1596
1597
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1598
std::vector<std::string> cleanedRecent;
1599
if (recentIsos.empty()) {
1600
INFO_LOG(Log::Loader, "No recents list found.");
1601
}
1602
1603
for (size_t i = 0; i < recentIsos.size(); i++) {
1604
bool exists = false;
1605
Path path = Path(recentIsos[i]);
1606
switch (path.Type()) {
1607
case PathType::CONTENT_URI:
1608
case PathType::NATIVE:
1609
exists = File::Exists(path);
1610
if (!exists) {
1611
if (TryUpdateSavedPath(&path)) {
1612
exists = File::Exists(path);
1613
INFO_LOG(Log::Loader, "Exists=%d when checking updated path: %s", exists, path.c_str());
1614
}
1615
}
1616
break;
1617
default:
1618
FileLoader *loader = ConstructFileLoader(path);
1619
exists = loader->ExistsFast();
1620
delete loader;
1621
break;
1622
}
1623
1624
if (exists) {
1625
std::string pathStr = path.ToString();
1626
// Make sure we don't have any redundant items.
1627
auto duplicate = std::find(cleanedRecent.begin(), cleanedRecent.end(), pathStr);
1628
if (duplicate == cleanedRecent.end()) {
1629
cleanedRecent.push_back(pathStr);
1630
}
1631
} else {
1632
DEBUG_LOG(Log::Loader, "Removed %s from recent. errno=%d", path.c_str(), errno);
1633
}
1634
}
1635
1636
double recentTime = time_now_d() - startTime;
1637
if (recentTime > 0.1) {
1638
INFO_LOG(Log::System, "CleanRecent took %0.2f", recentTime);
1639
}
1640
recentIsos = cleanedRecent;
1641
});
1642
}
1643
1644
std::vector<std::string> Config::RecentIsos() const {
1645
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1646
return recentIsos;
1647
}
1648
1649
bool Config::HasRecentIsos() const {
1650
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1651
return !recentIsos.empty();
1652
}
1653
1654
void Config::ClearRecentIsos() {
1655
private_->ResetRecentIsosThread();
1656
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
1657
recentIsos.clear();
1658
}
1659
1660
void Config::SetSearchPath(const Path &searchPath) {
1661
searchPath_ = searchPath;
1662
}
1663
1664
const Path Config::FindConfigFile(const std::string &baseFilename) {
1665
// Don't search for an absolute path.
1666
if (baseFilename.size() > 1 && baseFilename[0] == '/') {
1667
return Path(baseFilename);
1668
}
1669
#ifdef _WIN32
1670
if (baseFilename.size() > 3 && baseFilename[1] == ':' && (baseFilename[2] == '/' || baseFilename[2] == '\\')) {
1671
return Path(baseFilename);
1672
}
1673
#endif
1674
1675
Path filename = searchPath_ / baseFilename;
1676
if (File::Exists(filename)) {
1677
return filename;
1678
}
1679
1680
// Make sure at least the directory it's supposed to be in exists.
1681
Path path = filename.NavigateUp();
1682
// This check is just to avoid logging.
1683
if (!File::Exists(path)) {
1684
File::CreateFullPath(path);
1685
}
1686
return filename;
1687
}
1688
1689
void Config::RestoreDefaults(RestoreSettingsBits whatToRestore) {
1690
if (bGameSpecific) {
1691
// TODO: This should be possible to do in a cleaner way.
1692
deleteGameConfig(gameId_);
1693
createGameConfig(gameId_);
1694
Load();
1695
} else {
1696
if (whatToRestore & RestoreSettingsBits::SETTINGS) {
1697
IterateSettings([](const ConfigSetting &setting) {
1698
setting.RestoreToDefault();
1699
});
1700
}
1701
1702
if (whatToRestore & RestoreSettingsBits::CONTROLS) {
1703
KeyMap::RestoreDefault();
1704
}
1705
1706
if (whatToRestore & RestoreSettingsBits::RECENT) {
1707
ClearRecentIsos();
1708
currentDirectory = defaultCurrentDirectory;
1709
}
1710
}
1711
}
1712
1713
bool Config::hasGameConfig(const std::string &pGameId) {
1714
Path fullIniFilePath = getGameConfigFile(pGameId);
1715
return File::Exists(fullIniFilePath);
1716
}
1717
1718
void Config::changeGameSpecific(const std::string &pGameId, const std::string &title) {
1719
if (!reload_)
1720
Save("changeGameSpecific");
1721
gameId_ = pGameId;
1722
gameIdTitle_ = title;
1723
bGameSpecific = !pGameId.empty();
1724
}
1725
1726
bool Config::createGameConfig(const std::string &pGameId) {
1727
Path fullIniFilePath = getGameConfigFile(pGameId);
1728
1729
if (hasGameConfig(pGameId)) {
1730
return false;
1731
}
1732
1733
File::CreateEmptyFile(fullIniFilePath);
1734
return true;
1735
}
1736
1737
bool Config::deleteGameConfig(const std::string& pGameId) {
1738
Path fullIniFilePath = Path(getGameConfigFile(pGameId));
1739
1740
File::Delete(fullIniFilePath);
1741
return true;
1742
}
1743
1744
Path Config::getGameConfigFile(const std::string &pGameId) {
1745
const char *ppssppIniFilename = IsVREnabled() ? "_ppssppvr.ini" : "_ppsspp.ini";
1746
std::string iniFileName = pGameId + ppssppIniFilename;
1747
Path iniFileNameFull = FindConfigFile(iniFileName);
1748
1749
return iniFileNameFull;
1750
}
1751
1752
bool Config::saveGameConfig(const std::string &pGameId, const std::string &title) {
1753
if (pGameId.empty()) {
1754
return false;
1755
}
1756
1757
Path fullIniFilePath = getGameConfigFile(pGameId);
1758
1759
IniFile iniFile;
1760
1761
Section *top = iniFile.GetOrCreateSection("");
1762
top->AddComment(StringFromFormat("Game config for %s - %s", pGameId.c_str(), title.c_str()));
1763
1764
PreSaveCleanup(true);
1765
1766
IterateSettings(iniFile, [](Section *section, const ConfigSetting &setting) {
1767
if (setting.PerGame()) {
1768
setting.Set(section);
1769
}
1770
});
1771
1772
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
1773
postShaderSetting->Clear();
1774
for (const auto &[k, v] : mPostShaderSetting) {
1775
postShaderSetting->Set(k.c_str(), v);
1776
}
1777
1778
Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList");
1779
postShaderChain->Clear();
1780
for (size_t i = 0; i < vPostShaderNames.size(); ++i) {
1781
char keyName[64];
1782
snprintf(keyName, sizeof(keyName), "PostShader%d", (int)i+1);
1783
postShaderChain->Set(keyName, vPostShaderNames[i]);
1784
}
1785
1786
KeyMap::SaveToIni(iniFile);
1787
iniFile.Save(fullIniFilePath);
1788
1789
PostSaveCleanup(true);
1790
return true;
1791
}
1792
1793
bool Config::loadGameConfig(const std::string &pGameId, const std::string &title) {
1794
Path iniFileNameFull = getGameConfigFile(pGameId);
1795
1796
if (!hasGameConfig(pGameId)) {
1797
DEBUG_LOG(Log::Loader, "No game-specific settings found in %s. Using global defaults.", iniFileNameFull.c_str());
1798
return false;
1799
}
1800
1801
changeGameSpecific(pGameId, title);
1802
IniFile iniFile;
1803
iniFile.Load(iniFileNameFull);
1804
1805
auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
1806
mPostShaderSetting.clear();
1807
for (const auto &[k, v] : postShaderSetting) {
1808
float value = 0.0f;
1809
if (sscanf(v.c_str(), "%f", &value)) {
1810
mPostShaderSetting[k] = value;
1811
} else {
1812
WARN_LOG(Log::Loader, "Invalid float value string for param %s: '%s'", k.c_str(), v.c_str());
1813
}
1814
}
1815
1816
auto postShaderChain = iniFile.GetOrCreateSection("PostShaderList")->ToMap();
1817
vPostShaderNames.clear();
1818
for (const auto &[_, v] : postShaderChain) {
1819
if (v != "Off")
1820
vPostShaderNames.push_back(v);
1821
}
1822
1823
IterateSettings(iniFile, [](Section *section, const ConfigSetting &setting) {
1824
if (setting.PerGame()) {
1825
setting.Get(section);
1826
}
1827
});
1828
1829
KeyMap::LoadFromIni(iniFile);
1830
1831
if (!appendedConfigFileName_.ToString().empty() &&
1832
std::find(appendedConfigUpdatedGames_.begin(), appendedConfigUpdatedGames_.end(), pGameId) == appendedConfigUpdatedGames_.end()) {
1833
1834
LoadAppendedConfig();
1835
appendedConfigUpdatedGames_.push_back(pGameId);
1836
}
1837
1838
PostLoadCleanup(true);
1839
return true;
1840
}
1841
1842
void Config::unloadGameConfig() {
1843
if (bGameSpecific) {
1844
changeGameSpecific();
1845
1846
IniFile iniFile;
1847
iniFile.Load(iniFilename_);
1848
1849
// Reload game specific settings back to standard.
1850
IterateSettings(iniFile, [](Section *section, const ConfigSetting &setting) {
1851
if (setting.PerGame()) {
1852
setting.Get(section);
1853
}
1854
});
1855
1856
auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
1857
mPostShaderSetting.clear();
1858
for (const auto &[k, v] : postShaderSetting) {
1859
mPostShaderSetting[k] = std::stof(v);
1860
}
1861
1862
auto postShaderChain = iniFile.GetOrCreateSection("PostShaderList")->ToMap();
1863
vPostShaderNames.clear();
1864
for (const auto &[k, v] : postShaderChain) {
1865
if (v != "Off")
1866
vPostShaderNames.push_back(v);
1867
}
1868
1869
LoadStandardControllerIni();
1870
PostLoadCleanup(true);
1871
}
1872
}
1873
1874
void Config::LoadStandardControllerIni() {
1875
IniFile controllerIniFile;
1876
if (!controllerIniFile.Load(controllerIniFilename_)) {
1877
ERROR_LOG(Log::Loader, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
1878
KeyMap::RestoreDefault();
1879
} else {
1880
// Continue anyway to initialize the config. It will just restore the defaults.
1881
KeyMap::LoadFromIni(controllerIniFile);
1882
}
1883
}
1884
1885
void Config::ResetControlLayout() {
1886
auto reset = [](ConfigTouchPos &pos) {
1887
pos.x = defaultTouchPosShow.x;
1888
pos.y = defaultTouchPosShow.y;
1889
pos.scale = defaultTouchPosShow.scale;
1890
};
1891
reset(g_Config.touchActionButtonCenter);
1892
g_Config.fActionButtonSpacing = 1.0f;
1893
reset(g_Config.touchDpad);
1894
g_Config.fDpadSpacing = 1.0f;
1895
reset(g_Config.touchStartKey);
1896
reset(g_Config.touchSelectKey);
1897
reset(g_Config.touchFastForwardKey);
1898
reset(g_Config.touchLKey);
1899
reset(g_Config.touchRKey);
1900
reset(g_Config.touchAnalogStick);
1901
reset(g_Config.touchRightAnalogStick);
1902
for (int i = 0; i < CUSTOM_BUTTON_COUNT; i++) {
1903
reset(g_Config.touchCustom[i]);
1904
}
1905
g_Config.fLeftStickHeadScale = 1.0f;
1906
g_Config.fRightStickHeadScale = 1.0f;
1907
}
1908
1909
void Config::GetReportingInfo(UrlEncoder &data) {
1910
for (size_t i = 0; i < numSections; ++i) {
1911
const std::string prefix = std::string("config.") + sections[i].section;
1912
for (size_t j = 0; j < sections[i].settingsCount; j++) {
1913
sections[i].settings[j].ReportSetting(data, prefix);
1914
}
1915
}
1916
}
1917
1918
bool Config::IsPortrait() const {
1919
return (iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180) && !bSkipBufferEffects;
1920
}
1921
1922
int Config::GetPSPLanguage() {
1923
if (g_Config.iLanguage == -1) {
1924
const auto &langValuesMapping = GetLangValuesMapping();
1925
auto iter = langValuesMapping.find(g_Config.sLanguageIni);
1926
if (iter != langValuesMapping.end()) {
1927
return iter->second.second;
1928
} else {
1929
// Fallback to English
1930
return PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
1931
}
1932
} else {
1933
return g_Config.iLanguage;
1934
}
1935
}
1936
1937
void PlayTimeTracker::Start(const std::string &gameId) {
1938
if (gameId.empty()) {
1939
return;
1940
}
1941
INFO_LOG(Log::System, "GameTimeTracker::Start(%s)", gameId.c_str());
1942
1943
auto iter = tracker_.find(std::string(gameId));
1944
if (iter != tracker_.end()) {
1945
if (iter->second.startTime == 0.0) {
1946
iter->second.lastTimePlayed = time_now_unix_utc();
1947
iter->second.startTime = time_now_d();
1948
}
1949
return;
1950
}
1951
1952
PlayTime playTime;
1953
playTime.lastTimePlayed = time_now_unix_utc();
1954
playTime.totalTimePlayed = 0.0;
1955
playTime.startTime = time_now_d();
1956
tracker_[gameId] = playTime;
1957
}
1958
1959
void PlayTimeTracker::Stop(const std::string &gameId) {
1960
if (gameId.empty()) {
1961
return;
1962
}
1963
1964
INFO_LOG(Log::System, "GameTimeTracker::Stop(%s)", gameId.c_str());
1965
1966
auto iter = tracker_.find(std::string(gameId));
1967
if (iter != tracker_.end()) {
1968
if (iter->second.startTime != 0.0) {
1969
iter->second.totalTimePlayed += time_now_d() - iter->second.startTime;
1970
iter->second.startTime = 0.0;
1971
}
1972
iter->second.lastTimePlayed = time_now_unix_utc();
1973
return;
1974
}
1975
1976
// Shouldn't happen, ignore this case.
1977
WARN_LOG(Log::System, "GameTimeTracker::Stop called without corresponding GameTimeTracker::Start");
1978
}
1979
1980
void PlayTimeTracker::Load(const Section *section) {
1981
tracker_.clear();
1982
1983
auto map = section->ToMap();
1984
1985
for (const auto &iter : map) {
1986
const std::string &value = iter.second;
1987
// Parse the string.
1988
PlayTime gameTime{};
1989
if (2 == sscanf(value.c_str(), "%d,%llu", &gameTime.totalTimePlayed, (long long *)&gameTime.lastTimePlayed)) {
1990
tracker_[iter.first.c_str()] = gameTime;
1991
}
1992
}
1993
}
1994
1995
void PlayTimeTracker::Save(Section *section) {
1996
for (auto iter : tracker_) {
1997
std::string formatted = StringFromFormat("%d,%llu", iter.second.totalTimePlayed, iter.second.lastTimePlayed);
1998
section->Set(iter.first.c_str(), formatted);
1999
}
2000
}
2001
2002
bool PlayTimeTracker::GetPlayedTimeString(const std::string &gameId, std::string *str) const {
2003
auto ga = GetI18NCategory(I18NCat::GAME);
2004
2005
auto iter = tracker_.find(gameId);
2006
if (iter == tracker_.end()) {
2007
return false;
2008
}
2009
2010
int totalSeconds = iter->second.totalTimePlayed;
2011
int seconds = totalSeconds % 60;
2012
totalSeconds /= 60;
2013
int minutes = totalSeconds % 60;
2014
totalSeconds /= 60;
2015
int hours = totalSeconds;
2016
2017
*str = ApplySafeSubstitutions(ga->T("Time Played: %1h %2m %3s"), hours, minutes, seconds);
2018
return true;
2019
}
2020
2021