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.h
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
#pragma once
19
20
#include <string>
21
#include <map>
22
#include <vector>
23
24
#include "ppsspp_config.h"
25
26
#include "Common/CommonTypes.h"
27
#include "Common/File/Path.h"
28
#include "Core/ConfigValues.h"
29
30
extern const char *PPSSPP_GIT_VERSION;
31
32
namespace http {
33
class Request;
34
class RequestManager;
35
}
36
37
struct UrlEncoder;
38
struct ConfigPrivate;
39
40
class Section;
41
42
class PlayTimeTracker {
43
public:
44
struct PlayTime {
45
int totalTimePlayed;
46
double startTime; // time_now_d() time
47
uint64_t lastTimePlayed; // UTC Unix time for portability.
48
};
49
50
// It's OK to call these redundantly.
51
void Start(const std::string &gameId);
52
void Stop(const std::string &gameId);
53
54
void Load(const Section *section);
55
void Save(Section *section);
56
57
bool GetPlayedTimeString(const std::string &gameId, std::string *str) const;
58
59
private:
60
std::map<std::string, PlayTime> tracker_;
61
};
62
63
struct Config {
64
public:
65
Config();
66
~Config();
67
68
// Whether to save the config on close.
69
bool bSaveSettings;
70
bool bFirstRun;
71
bool bGameSpecific = false;
72
bool bUpdatedInstanceCounter = false;
73
74
int iRunCount; // To be used to for example check for updates every 10 runs and things like that.
75
76
bool bAutoRun; // start immediately
77
bool bBrowse; // when opening the emulator, immediately show a file browser
78
79
// General
80
bool bScreenshotsAsPNG;
81
bool bUseFFV1;
82
bool bDumpFrames;
83
bool bDumpVideoOutput;
84
bool bDumpAudio;
85
bool bSaveLoadResetsAVdumping;
86
bool bEnableLogging;
87
bool bDumpDecryptedEboot;
88
bool bFullscreenOnDoubleclick;
89
90
// These four are Win UI only
91
bool bPauseOnLostFocus;
92
bool bTopMost;
93
bool bIgnoreWindowsKey;
94
bool bRestartRequired;
95
96
std::string sFont;
97
98
bool bPauseWhenMinimized;
99
100
bool bPauseExitsEmulator;
101
bool bPauseMenuExitsEmulator;
102
103
bool bRunBehindPauseMenu;
104
105
// Core
106
bool bIgnoreBadMemAccess;
107
108
bool bFastMemory;
109
int iCpuCore;
110
bool bCheckForNewVersion;
111
bool bForceLagSync;
112
bool bFuncReplacements;
113
bool bHideSlowWarnings;
114
bool bHideStateWarnings;
115
bool bPreloadFunctions;
116
uint32_t uJitDisableFlags;
117
118
bool bDisableHTTPS;
119
120
bool bSeparateSASThread;
121
int iIOTimingMethod;
122
int iLockedCPUSpeed;
123
bool bAutoSaveSymbolMap;
124
bool bCacheFullIsoInRam;
125
int iRemoteISOPort;
126
std::string sLastRemoteISOServer;
127
int iLastRemoteISOPort;
128
bool bRemoteISOManual;
129
bool bRemoteShareOnStartup;
130
std::string sRemoteISOSubdir;
131
std::string sRemoteISOSharedDir;
132
int iRemoteISOShareType;
133
bool bRemoteDebuggerOnStartup;
134
bool bRemoteTab;
135
bool bMemStickInserted;
136
int iMemStickSizeGB;
137
bool bLoadPlugins;
138
139
int iScreenRotation; // The rotation angle of the PPSSPP UI. Only supported on Android and possibly other mobile platforms.
140
int iInternalScreenRotation; // The internal screen rotation angle. Useful for vertical SHMUPs and similar.
141
142
std::string sReportHost;
143
std::vector<std::string> vPinnedPaths;
144
std::string sLanguageIni;
145
146
std::string sIgnoreCompatSettings;
147
148
bool bDiscordPresence; // Enables setting the Discord presence to the current game (or menu)
149
150
// GFX
151
int iGPUBackend;
152
std::string sCustomDriver;
153
std::string sFailedGPUBackends;
154
std::string sDisabledGPUBackends;
155
// We have separate device parameters for each backend so it doesn't get erased if you switch backends.
156
// If not set, will use the "best" device.
157
std::string sVulkanDevice;
158
std::string sD3D11Device; // Windows only
159
std::string sCameraDevice;
160
std::string sMicDevice;
161
bool bCameraMirrorHorizontal;
162
int iDisplayFramerateMode; // enum DisplayFramerateMode. Android-only.
163
int iDisplayRefreshRate = 60;
164
165
bool bSoftwareRendering;
166
bool bSoftwareRenderingJit;
167
bool bHardwareTransform; // only used in the GLES backend
168
bool bSoftwareSkinning;
169
bool bVendorBugChecksEnabled;
170
bool bUseGeometryShader;
171
172
// Speedhacks (more will be moved here):
173
bool bSkipBufferEffects;
174
bool bDisableRangeCulling;
175
176
int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality
177
bool bSmart2DTexFiltering;
178
179
bool bDisplayStretch; // Automatically matches the aspect ratio of the window.
180
int iDisplayFilter; // 1 = linear, 2 = nearest
181
float fDisplayOffsetX;
182
float fDisplayOffsetY;
183
float fDisplayScale; // Relative to the most constraining axis (x or y).
184
bool bDisplayIntegerScale; // Snaps scaling to integer scale factors in raw pixels.
185
bool bDisplayCropTo16x9; // Crops to 16:9 if the resolution is very close.
186
float fDisplayAspectRatio; // Stored relative to the PSP's native ratio, so 1.0 is the normal pixel aspect ratio.
187
188
bool bImmersiveMode; // Mode on Android Kitkat 4.4 and later that hides the back button etc.
189
bool bSustainedPerformanceMode; // Android: Slows clocks down to avoid overheating/speed fluctuations.
190
bool bIgnoreScreenInsets; // Android: Center screen disregarding insets if this is enabled.
191
bool bVSync;
192
193
int iFrameSkip;
194
int iFrameSkipType;
195
int iFastForwardMode; // See FastForwardMode in ConfigValues.h.
196
bool bAutoFrameSkip;
197
198
bool bEnableCardboardVR; // Cardboard Master Switch
199
int iCardboardScreenSize; // Screen Size (in %)
200
int iCardboardXShift; // X-Shift of Screen (in %)
201
int iCardboardYShift; // Y-Shift of Screen (in %)
202
203
int iWindowX;
204
int iWindowY;
205
int iWindowWidth; // Windows and other windowed environments
206
int iWindowHeight;
207
bool bShowMenuBar; // Windows-only
208
209
float fUITint;
210
float fUISaturation;
211
212
bool bTextureBackoffCache;
213
bool bVertexDecoderJit;
214
int iAppSwitchMode;
215
bool bFullScreen;
216
bool bFullScreenMulti;
217
int iForceFullScreen = -1; // -1 = nope, 0 = force off, 1 = force on (not saved.)
218
int iInternalResolution; // 0 = Auto (native), 1 = 1x (480x272), 2 = 2x, 3 = 3x, 4 = 4x and so on.
219
int iAnisotropyLevel; // 0 - 5, powers of 2: 0 = 1x = no aniso
220
int iMultiSampleLevel;
221
int bHighQualityDepth;
222
bool bReplaceTextures;
223
bool bSaveNewTextures;
224
bool bIgnoreTextureFilenames;
225
int iTexScalingLevel; // 0 = auto, 1 = off, 2 = 2x, ..., 5 = 5x
226
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
227
bool bTexDeposterize;
228
bool bTexHardwareScaling;
229
int iFpsLimit1;
230
int iFpsLimit2;
231
int iAnalogFpsLimit;
232
int iMaxRecent;
233
int iCurrentStateSlot;
234
int iRewindSnapshotInterval;
235
bool bUISound;
236
bool bEnableStateUndo;
237
std::string sStateLoadUndoGame;
238
std::string sStateUndoLastSaveGame;
239
int iStateUndoLastSaveSlot;
240
int iAutoLoadSaveState; // 0 = off, 1 = oldest, 2 = newest, >2 = slot number + 3
241
bool bEnableCheats;
242
bool bReloadCheats;
243
bool bEnablePlugins;
244
int iCwCheatRefreshIntervalMs;
245
float fCwCheatScrollPosition;
246
float fGameListScrollPosition;
247
int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive
248
int iSkipGPUReadbackMode; // 0 = off, 1 = skip, 2 = to texture
249
int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High
250
bool bHardwareTessellation;
251
bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times.
252
bool bUberShaderVertex;
253
bool bUberShaderFragment;
254
255
std::vector<std::string> vPostShaderNames; // Off for chain end (only Off for no shader)
256
std::map<std::string, float> mPostShaderSetting;
257
258
// Note that this is separate from VR stereo, though it'll share some code paths.
259
bool bStereoRendering;
260
// There can only be one, unlike regular post shaders.
261
std::string sStereoToMonoShader;
262
263
bool bShaderChainRequires60FPS;
264
std::string sTextureShaderName;
265
bool bGfxDebugOutput;
266
int iInflightFrames;
267
bool bRenderDuplicateFrames;
268
bool bRenderMultiThreading;
269
270
// HW debug
271
bool bShowGPOLEDs;
272
273
// Sound
274
bool bEnableSound;
275
int iAudioBackend;
276
int iGlobalVolume;
277
int iReverbVolume;
278
int iAltSpeedVolume;
279
int iAchievementSoundVolume;
280
bool bExtraAudioBuffering; // For bluetooth
281
std::string sAudioDevice;
282
bool bAutoAudioDevice;
283
bool bUseNewAtrac;
284
285
// iOS only for now
286
bool bAudioMixWithOthers;
287
bool bAudioRespectSilentMode;
288
289
// UI
290
bool bShowDebuggerOnLoad;
291
int iShowStatusFlags;
292
bool bShowRegionOnGameIcon;
293
bool bShowIDOnGameIcon;
294
float fGameGridScale;
295
bool bShowOnScreenMessages;
296
int iBackgroundAnimation; // enum BackgroundAnimation
297
bool bTransparentBackground;
298
299
std::string sThemeName;
300
301
// These aren't saved, just for instant debugging.
302
bool bLogFrameDrops;
303
304
// Analog stick tilting
305
// This is the held base angle (from the horizon), that we compute the tilt relative from.
306
float fTiltBaseAngleY;
307
// Inverts the direction of the x axes and y axes for the purposes of tilt input.
308
bool bInvertTiltX;
309
bool bInvertTiltY;
310
// The sensitivity of the tilt in the X and Y directions, separately.
311
int iTiltSensitivityX;
312
int iTiltSensitivityY;
313
// The deadzone radius of the tilt. Only used in the analog mapping.
314
float fTiltAnalogDeadzoneRadius;
315
float fTiltInverseDeadzone; // An inverse deadzone for the output, counteracting excessive deadzones applied by games. See #17483.
316
bool bTiltCircularDeadzone;
317
// Type of tilt input currently selected: Defined in TiltEventProcessor.h
318
// 0 - no tilt, 1 - analog stick, 2 - D-Pad, 3 - Action Buttons (Tri, Cross, Square, Circle)
319
int iTiltInputType;
320
321
// The three tabs.
322
bool bGridView1;
323
bool bGridView2;
324
bool bGridView3;
325
326
// Right analog binding
327
int iRightAnalogUp;
328
int iRightAnalogDown;
329
int iRightAnalogLeft;
330
int iRightAnalogRight;
331
int iRightAnalogPress;
332
bool bRightAnalogCustom;
333
bool bRightAnalogDisableDiagonal;
334
335
// Motion gesture controller
336
bool bGestureControlEnabled;
337
int iSwipeUp;
338
int iSwipeDown;
339
int iSwipeLeft;
340
int iSwipeRight;
341
float fSwipeSensitivity;
342
float fSwipeSmoothing;
343
int iDoubleTapGesture;
344
bool bAnalogGesture;
345
float fAnalogGestureSensibility;
346
347
// Disable diagonals
348
bool bDisableDpadDiagonals;
349
bool bGamepadOnlyFocused;
350
// Control Style
351
int iTouchButtonStyle;
352
int iTouchButtonOpacity;
353
int iTouchButtonHideSeconds;
354
355
// Snap touch control position
356
bool bTouchSnapToGrid;
357
int iTouchSnapGridSize;
358
359
// Floating analog stick (recenters on thumb on press).
360
bool bAutoCenterTouchAnalog;
361
362
// Sticky D-pad (can't glide off it)
363
bool bStickyTouchDPad;
364
365
//space between PSP buttons
366
//the PSP button's center (triangle, circle, square, cross)
367
ConfigTouchPos touchActionButtonCenter;
368
float fActionButtonSpacing;
369
//radius of the D-pad (PSP cross)
370
// int iDpadRadius;
371
//the D-pad (PSP cross) position
372
ConfigTouchPos touchDpad;
373
float fDpadSpacing;
374
ConfigTouchPos touchStartKey;
375
ConfigTouchPos touchSelectKey;
376
ConfigTouchPos touchFastForwardKey;
377
ConfigTouchPos touchLKey;
378
ConfigTouchPos touchRKey;
379
ConfigTouchPos touchAnalogStick;
380
ConfigTouchPos touchRightAnalogStick;
381
382
enum { CUSTOM_BUTTON_COUNT = 20 };
383
384
ConfigTouchPos touchCustom[CUSTOM_BUTTON_COUNT];
385
386
float fLeftStickHeadScale;
387
float fRightStickHeadScale;
388
bool bHideStickBackground;
389
390
// Controls Visibility
391
bool bShowTouchControls;
392
393
bool bShowTouchCircle;
394
bool bShowTouchCross;
395
bool bShowTouchTriangle;
396
bool bShowTouchSquare;
397
398
ConfigCustomButton CustomButton[CUSTOM_BUTTON_COUNT];
399
400
// Ignored on iOS and other platforms that lack pause.
401
bool bShowTouchPause;
402
403
bool bHapticFeedback;
404
405
// We also use the XInput settings as analog settings on other platforms like Android.
406
float fAnalogDeadzone;
407
float fAnalogInverseDeadzone;
408
float fAnalogSensitivity;
409
// convert analog stick circle to square
410
bool bAnalogIsCircular;
411
// Auto rotation speed
412
float fAnalogAutoRotSpeed;
413
414
// Sets up how much the analog limiter button restricts digital->analog input.
415
float fAnalogLimiterDeadzone;
416
417
// Trigger configuration
418
float fAnalogTriggerThreshold;
419
420
// Sets whether combo mapping is enabled.
421
bool bAllowMappingCombos;
422
bool bStrictComboOrder;
423
424
bool bMouseControl;
425
bool bMapMouse; // Workaround for mapping screen:|
426
bool bMouseConfine; // Trap inside the window.
427
float fMouseSensitivity;
428
float fMouseSmoothing;
429
int iMouseWheelUpDelayMs;
430
431
bool bSystemControls;
432
int iRapidFireInterval;
433
434
// Use the hardware scaler to scale up the image to save fillrate. Similar to Windows' window size, really.
435
int iAndroidHwScale; // 0 = device resolution. 1 = 480x272 (extended to correct aspect), 2 = 960x544 etc.
436
437
// Risky JIT optimizations
438
bool bDiscardRegsOnJRRA;
439
440
// SystemParam
441
std::string sNickName;
442
std::string sMACAddress;
443
int iLanguage;
444
int iTimeFormat;
445
int iDateFormat;
446
int iTimeZone;
447
bool bDayLightSavings;
448
int iButtonPreference;
449
int iLockParentalLevel;
450
bool bEncryptSave;
451
bool bSavedataUpgrade;
452
453
// Networking
454
std::string proAdhocServer;
455
bool bEnableWlan;
456
bool bEnableAdhocServer;
457
bool bEnableUPnP;
458
bool bUPnPUseOriginalPort;
459
bool bForcedFirstConnect;
460
int iPortOffset;
461
int iMinTimeout;
462
int iWlanAdhocChannel;
463
bool bWlanPowerSave;
464
bool bEnableNetworkChat;
465
//for chat position , moveable buttons is better than this
466
int iChatButtonPosition;
467
int iChatScreenPosition;
468
469
bool bEnableQuickChat;
470
std::string sQuickChat0;
471
std::string sQuickChat1;
472
std::string sQuickChat2;
473
std::string sQuickChat3;
474
std::string sQuickChat4;
475
476
int iPSPModel;
477
int iFirmwareVersion;
478
bool bBypassOSKWithKeyboard;
479
480
// Virtual reality
481
bool bEnableVR;
482
bool bEnable6DoF;
483
bool bEnableStereo;
484
bool bEnableImmersiveVR;
485
bool bForce72Hz;
486
bool bForceVR;
487
bool bManualForceVR;
488
bool bPassthrough;
489
bool bRescaleHUD;
490
float fCameraDistance;
491
float fCameraHeight;
492
float fCameraSide;
493
float fCameraPitch;
494
float fCanvasDistance;
495
float fCanvas3DDistance;
496
float fFieldOfViewPercentage;
497
float fHeadUpDisplayScale;
498
499
// Debugger
500
int iDisasmWindowX;
501
int iDisasmWindowY;
502
int iDisasmWindowW;
503
int iDisasmWindowH;
504
int iGEWindowX;
505
int iGEWindowY;
506
int iGEWindowW;
507
int iGEWindowH;
508
uint32_t uGETabsLeft;
509
uint32_t uGETabsRight;
510
uint32_t uGETabsTopRight;
511
int iConsoleWindowX;
512
int iConsoleWindowY;
513
int iFontWidth;
514
int iFontHeight;
515
bool bDisplayStatusBar;
516
bool bShowBottomTabTitles;
517
bool bShowDeveloperMenu;
518
519
// Double edged sword: much easier debugging, but not accurate.
520
bool bSkipDeadbeefFilling;
521
522
bool bFuncHashMap;
523
std::string sSkipFuncHashMap;
524
bool bDebugMemInfoDetailed;
525
526
// Volatile development settings
527
// Overlays
528
int iDebugOverlay;
529
530
bool bGpuLogProfiler; // Controls the Vulkan logging profiler (profiles textures uploads etc).
531
532
// Retro Achievement settings
533
// Copied from Duckstation, we might want to remove some.
534
bool bAchievementsEnable;
535
bool bAchievementsHardcoreMode;
536
bool bAchievementsEncoreMode;
537
bool bAchievementsUnofficial;
538
bool bAchievementsSoundEffects;
539
bool bAchievementsLogBadMemReads;
540
bool bAchievementsSaveStateInHardcoreMode;
541
bool bAchievementsEnableRAIntegration;
542
543
// Positioning of the various notifications
544
int iAchievementsLeaderboardTrackerPos;
545
int iAchievementsLeaderboardStartedOrFailedPos;
546
int iAchievementsLeaderboardSubmittedPos;
547
int iAchievementsProgressPos;
548
int iAchievementsChallengePos;
549
int iAchievementsUnlockedPos;
550
551
// Customizations
552
std::string sAchievementsUnlockAudioFile;
553
std::string sAchievementsLeaderboardSubmitAudioFile;
554
555
// Achivements login info. Note that password is NOT stored, only a login token.
556
// Still, we may wanna store it more securely than in PPSSPP.ini, especially on Android.
557
std::string sAchievementsUserName;
558
std::string sAchievementsToken; // Not saved, to be used if you want to manually make your RA login persistent. See Native_SaveSecret for the normal case.
559
560
// Various directories. Autoconfigured, not read from ini.
561
Path currentDirectory; // The directory selected in the game browsing window.
562
Path defaultCurrentDirectory; // Platform dependent, initialized at startup.
563
564
Path memStickDirectory;
565
Path flash0Directory;
566
Path internalDataDirectory;
567
Path appCacheDirectory;
568
569
// Data for upgrade prompt
570
std::string upgradeMessage; // The actual message from the server is currently not used, need a translation mechanism. So this just acts as a flag.
571
std::string upgradeVersion;
572
std::string dismissedVersion;
573
574
void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
575
bool Save(const char *saveReason);
576
void Reload();
577
void RestoreDefaults(RestoreSettingsBits whatToRestore);
578
579
//per game config managment, should maybe be in it's own class
580
void changeGameSpecific(const std::string &gameId = "", const std::string &title = "");
581
bool createGameConfig(const std::string &game_id);
582
bool deleteGameConfig(const std::string& pGameId);
583
bool loadGameConfig(const std::string &game_id, const std::string &title);
584
bool saveGameConfig(const std::string &pGameId, const std::string &title);
585
void unloadGameConfig();
586
Path getGameConfigFile(const std::string &gameId);
587
bool hasGameConfig(const std::string &game_id);
588
589
void SetSearchPath(const Path &path);
590
const Path FindConfigFile(const std::string &baseFilename);
591
592
void UpdateIniLocation(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
593
594
// Utility functions for "recent" management
595
void AddRecent(const std::string &file);
596
void RemoveRecent(const std::string &file);
597
void CleanRecent();
598
599
static void DownloadCompletedCallback(http::Request &download);
600
void DismissUpgrade();
601
602
void ResetControlLayout();
603
604
void GetReportingInfo(UrlEncoder &data);
605
606
bool IsPortrait() const;
607
int NextValidBackend();
608
bool IsBackendEnabled(GPUBackend backend);
609
610
bool UseFullScreen() const {
611
if (iForceFullScreen != -1)
612
return iForceFullScreen == 1;
613
return bFullScreen;
614
}
615
616
std::vector<std::string> RecentIsos() const;
617
bool HasRecentIsos() const;
618
void ClearRecentIsos();
619
620
const std::map<std::string, std::pair<std::string, int>, std::less<>> &GetLangValuesMapping();
621
bool LoadAppendedConfig();
622
void SetAppendedConfigIni(const Path &path);
623
void UpdateAfterSettingAutoFrameSkip();
624
void NotifyUpdatedCpuCore();
625
626
// Applies the Auto setting if set. Returns an enum value from PSP_SYSTEMPARAM_LANGUAGE_*.
627
int GetPSPLanguage();
628
629
PlayTimeTracker &TimeTracker() { return playTimeTracker_; }
630
631
protected:
632
void LoadStandardControllerIni();
633
void LoadLangValuesMapping();
634
635
void PostLoadCleanup(bool gameSpecific);
636
void PreSaveCleanup(bool gameSpecific);
637
void PostSaveCleanup(bool gameSpecific);
638
639
private:
640
bool reload_ = false;
641
std::string gameId_;
642
std::string gameIdTitle_;
643
std::vector<std::string> recentIsos;
644
std::map<std::string, std::pair<std::string, int>, std::less<>> langValuesMapping_;
645
PlayTimeTracker playTimeTracker_;
646
Path iniFilename_;
647
Path controllerIniFilename_;
648
Path searchPath_;
649
Path appendedConfigFileName_;
650
// A set make more sense, but won't have many entry, and I dont want to include the whole std::set header here
651
std::vector<std::string> appendedConfigUpdatedGames_;
652
ConfigPrivate *private_ = nullptr;
653
};
654
655
std::string CreateRandMAC();
656
657
// TODO: Find a better place for this.
658
extern http::RequestManager g_DownloadManager;
659
extern Config g_Config;
660
661
662