#pragma once
#include <string>
#include <map>
#include <vector>
#include "ppsspp_config.h"
#include "Common/CommonTypes.h"
#include "Common/File/Path.h"
#include "Core/ConfigValues.h"
extern const char *PPSSPP_GIT_VERSION;
namespace http {
class Request;
class RequestManager;
}
struct UrlEncoder;
class Section;
class PlayTimeTracker {
public:
struct PlayTime {
int totalTimePlayed;
double startTime;
uint64_t lastTimePlayed;
};
void Start(const std::string &gameId);
void Stop(const std::string &gameId);
void Load(const Section *section);
void Save(Section *section);
bool GetPlayedTimeString(const std::string &gameId, std::string *str) const;
private:
std::map<std::string, PlayTime> tracker_;
};
struct Config {
public:
Config();
~Config();
bool bSaveSettings;
bool bFirstRun;
bool bGameSpecific = false;
bool bUpdatedInstanceCounter = false;
bool bBrowse;
int iRunCount;
bool bAutoRun;
bool bBreakOnFrameTimeout;
bool bScreenshotsAsPNG;
bool bUseFFV1;
bool bDumpFrames;
bool bDumpVideoOutput;
bool bDumpAudio;
bool bSaveLoadResetsAVdumping;
bool bEnableLogging;
bool bEnableFileLogging;
int iLogOutputTypes;
int iDumpFileTypes;
bool bFullscreenOnDoubleclick;
bool bPauseOnLostFocus;
bool bTopMost;
bool bIgnoreWindowsKey;
bool bRestartRequired;
std::string sFont;
bool bPauseWhenMinimized;
bool bPauseExitsEmulator;
bool bPauseMenuExitsEmulator;
bool bRunBehindPauseMenu;
bool bIgnoreBadMemAccess;
bool bFastMemory;
int iCpuCore;
bool bCheckForNewVersion;
bool bForceLagSync;
bool bFuncReplacements;
bool bHideSlowWarnings;
bool bHideStateWarnings;
uint32_t uJitDisableFlags;
bool bDisableHTTPS;
bool bSeparateSASThread;
int iIOTimingMethod;
int iLockedCPUSpeed;
bool bAutoSaveSymbolMap;
bool bCompressSymbols;
bool bCacheFullIsoInRam;
int iRemoteISOPort;
std::string sLastRemoteISOServer;
int iLastRemoteISOPort;
bool bRemoteISOManual;
bool bRemoteShareOnStartup;
std::string sRemoteISOSubdir;
std::string sRemoteISOSharedDir;
int iRemoteISOShareType;
bool bRemoteDebuggerOnStartup;
bool bRemoteTab;
bool bMemStickInserted;
int iMemStickSizeGB;
bool bLoadPlugins;
int iAskForExitConfirmationAfterSeconds;
int iUIScaleFactor;
int iDisableHLE;
int iForceEnableHLE;
int iScreenRotation;
int iInternalScreenRotation;
std::string sReportHost;
std::vector<std::string> vPinnedPaths;
std::string sLanguageIni;
std::string sIgnoreCompatSettings;
bool bDiscordRichPresence;
int iGPUBackend;
std::string sCustomDriver;
std::string sFailedGPUBackends;
std::string sDisabledGPUBackends;
std::string sVulkanDevice;
std::string sD3D11Device;
std::string sCameraDevice;
std::string sMicDevice;
bool bCameraMirrorHorizontal;
int iDisplayFramerateMode;
int iDisplayRefreshRate = 60;
bool bSoftwareRendering;
bool bSoftwareRenderingJit;
bool bHardwareTransform;
bool bSoftwareSkinning;
bool bVendorBugChecksEnabled;
bool bUseGeometryShader;
bool bSkipBufferEffects;
bool bDisableRangeCulling;
int iDepthRasterMode;
int iTexFiltering;
bool bSmart2DTexFiltering;
bool bDisplayStretch;
int iDisplayFilter;
float fDisplayOffsetX;
float fDisplayOffsetY;
float fDisplayScale;
bool bDisplayIntegerScale;
bool bDisplayCropTo16x9;
float fDisplayAspectRatio;
bool bImmersiveMode;
bool bSustainedPerformanceMode;
bool bIgnoreScreenInsets;
bool bVSync;
bool bShowImDebugger;
int iFrameSkip;
int iFrameSkipType;
int iFastForwardMode;
bool bAutoFrameSkip;
bool bEnableCardboardVR;
int iCardboardScreenSize;
int iCardboardXShift;
int iCardboardYShift;
int iWindowX;
int iWindowY;
int iWindowWidth;
int iWindowHeight;
bool bShowMenuBar;
float fUITint;
float fUISaturation;
bool bTextureBackoffCache;
bool bVertexDecoderJit;
int iAppSwitchMode;
bool bFullScreen;
bool bFullScreenMulti;
int iForceFullScreen = -1;
int iInternalResolution;
int iAnisotropyLevel;
int iMultiSampleLevel;
int bHighQualityDepth;
bool bReplaceTextures;
bool bSaveNewTextures;
int iReplacementTextureLoadSpeed;
bool bIgnoreTextureFilenames;
int iTexScalingLevel;
int iTexScalingType;
bool bTexDeposterize;
bool bTexHardwareScaling;
int iFpsLimit1;
int iFpsLimit2;
int iAnalogFpsLimit;
int iMaxRecent;
int iCurrentStateSlot;
int iRewindSnapshotInterval;
bool bUISound;
bool bEnableStateUndo;
std::string sStateLoadUndoGame;
std::string sStateUndoLastSaveGame;
int iStateUndoLastSaveSlot;
int iAutoLoadSaveState;
bool bEnableCheats;
bool bReloadCheats;
bool bEnablePlugins;
int iCwCheatRefreshIntervalMs;
float fCwCheatScrollPosition;
float fGameListScrollPosition;
int iBloomHack;
int iSkipGPUReadbackMode;
int iSplineBezierQuality;
bool bHardwareTessellation;
bool bShaderCache;
bool bUberShaderVertex;
bool bUberShaderFragment;
int iDefaultTab;
int iScreenshotMode;
bool bVulkanDisableImplicitLayers;
bool bForceFfmpegForAudioDec;
std::vector<std::string> vPostShaderNames;
std::map<std::string, float> mPostShaderSetting;
bool bStereoRendering;
std::string sStereoToMonoShader;
bool bShaderChainRequires60FPS;
std::string sTextureShaderName;
bool bGfxDebugOutput;
int iInflightFrames;
bool bRenderDuplicateFrames;
bool bRenderMultiThreading;
bool bShowGPOLEDs;
bool bEnableSound;
int iSDLAudioBufferSize;
int iLegacyGameVolume;
int iLegacyReverbVolume;
int iLegacyAchievementVolume;
int iGameVolume;
int iReverbVolume;
int iUIVolume;
int iGamePreviewVolume;
int iAchievementVolume;
int iAltSpeedVolume;
bool bExtraAudioBuffering;
std::string sAudioDevice;
bool bAutoAudioDevice;
bool bUseOldAtrac;
bool bAudioMixWithOthers;
bool bAudioRespectSilentMode;
bool bShowDebuggerOnLoad;
int iShowStatusFlags;
bool bShowRegionOnGameIcon;
bool bShowIDOnGameIcon;
float fGameGridScale;
int iBackgroundAnimation;
bool bTransparentBackground;
std::string sThemeName;
bool bLogFrameDrops;
float fTiltBaseAngleY;
bool bInvertTiltX;
bool bInvertTiltY;
int iTiltSensitivityX;
int iTiltSensitivityY;
float fTiltAnalogDeadzoneRadius;
float fTiltInverseDeadzone;
bool bTiltCircularDeadzone;
int iTiltInputType;
bool bGridView1;
bool bGridView2;
bool bGridView3;
int iRightAnalogUp;
int iRightAnalogDown;
int iRightAnalogLeft;
int iRightAnalogRight;
int iRightAnalogPress;
bool bRightAnalogCustom;
bool bRightAnalogDisableDiagonal;
bool bGestureControlEnabled;
int iSwipeUp;
int iSwipeDown;
int iSwipeLeft;
int iSwipeRight;
float fSwipeSensitivity;
float fSwipeSmoothing;
int iDoubleTapGesture;
bool bAnalogGesture;
float fAnalogGestureSensibility;
bool bDisableDpadDiagonals;
bool bGamepadOnlyFocused;
int iTouchButtonStyle;
int iTouchButtonOpacity;
int iTouchButtonHideSeconds;
bool bTouchSnapToGrid;
int iTouchSnapGridSize;
bool bAutoCenterTouchAnalog;
bool bStickyTouchDPad;
bool bTouchGliding;
ConfigTouchPos touchActionButtonCenter;
float fActionButtonSpacing;
ConfigTouchPos touchDpad;
float fDpadSpacing;
ConfigTouchPos touchStartKey;
ConfigTouchPos touchSelectKey;
ConfigTouchPos touchFastForwardKey;
ConfigTouchPos touchLKey;
ConfigTouchPos touchRKey;
ConfigTouchPos touchAnalogStick;
ConfigTouchPos touchRightAnalogStick;
enum { CUSTOM_BUTTON_COUNT = 20 };
ConfigTouchPos touchCustom[CUSTOM_BUTTON_COUNT];
float fLeftStickHeadScale;
float fRightStickHeadScale;
bool bHideStickBackground;
bool bShowTouchControls;
bool bShowTouchCircle;
bool bShowTouchCross;
bool bShowTouchTriangle;
bool bShowTouchSquare;
ConfigCustomButton CustomButton[CUSTOM_BUTTON_COUNT];
bool bShowTouchPause;
bool bHapticFeedback;
float fAnalogDeadzone;
float fAnalogInverseDeadzone;
float fAnalogSensitivity;
bool bAnalogIsCircular;
float fAnalogAutoRotSpeed;
float fAnalogLimiterDeadzone;
float fAnalogTriggerThreshold;
bool bAllowMappingCombos;
bool bStrictComboOrder;
bool bMouseControl;
bool bMouseConfine;
float fMouseSensitivity;
float fMouseSmoothing;
int iMouseWheelUpDelayMs;
bool bSystemControls;
int iRapidFireInterval;
int iAndroidHwScale;
bool bDiscardRegsOnJRRA;
std::string sNickName;
std::string sMACAddress;
int iLanguage;
int iTimeFormat;
int iDateFormat;
int iTimeZone;
bool bDayLightSavings;
int iButtonPreference;
int iLockParentalLevel;
bool bEncryptSave;
bool bEnableAdhocServer;
std::string proAdhocServer;
std::string sInfrastructureDNSServer;
std::string sInfrastructureUsername;
bool bInfrastructureAutoDNS;
bool bAllowSavestateWhileConnected;
bool bAllowSpeedControlWhileConnected;
bool bEnableWlan;
std::map<std::string, std::string> mHostToAlias;
bool bEnableUPnP;
bool bUPnPUseOriginalPort;
bool bForcedFirstConnect;
int iPortOffset;
int iMinTimeout;
int iWlanAdhocChannel;
bool bWlanPowerSave;
bool bEnableNetworkChat;
bool bDontDownloadInfraJson;
int iChatButtonPosition;
int iChatScreenPosition;
bool bEnableQuickChat;
std::string sQuickChat0;
std::string sQuickChat1;
std::string sQuickChat2;
std::string sQuickChat3;
std::string sQuickChat4;
int iPSPModel;
int iFirmwareVersion;
bool bBypassOSKWithKeyboard;
bool bEnableVR;
bool bEnable6DoF;
bool bEnableStereo;
bool bEnableImmersiveVR;
bool bForce72Hz;
bool bForceVR;
bool bManualForceVR;
bool bPassthrough;
bool bRescaleHUD;
float fCameraDistance;
float fCameraHeight;
float fCameraSide;
float fCameraPitch;
float fCanvasDistance;
float fCanvas3DDistance;
float fFieldOfViewPercentage;
float fHeadUpDisplayScale;
int iDisasmWindowX;
int iDisasmWindowY;
int iDisasmWindowW;
int iDisasmWindowH;
int iGEWindowX;
int iGEWindowY;
int iGEWindowW;
int iGEWindowH;
uint32_t uGETabsLeft;
uint32_t uGETabsRight;
uint32_t uGETabsTopRight;
int iConsoleWindowX;
int iConsoleWindowY;
int iFontWidth;
int iFontHeight;
bool bDisplayStatusBar;
bool bShowBottomTabTitles;
bool bShowDeveloperMenu;
bool bSkipDeadbeefFilling;
bool bFuncHashMap;
std::string sSkipFuncHashMap;
bool bDebugMemInfoDetailed;
int iDebugOverlay;
bool bGpuLogProfiler;
bool bAchievementsEnable;
bool bAchievementsHardcoreMode;
bool bAchievementsEncoreMode;
bool bAchievementsUnofficial;
bool bAchievementsSoundEffects;
bool bAchievementsLogBadMemReads;
bool bAchievementsSaveStateInHardcoreMode;
bool bAchievementsEnableRAIntegration;
int iNotificationPos;
int iAchievementsLeaderboardTrackerPos;
int iAchievementsLeaderboardStartedOrFailedPos;
int iAchievementsLeaderboardSubmittedPos;
int iAchievementsProgressPos;
int iAchievementsChallengePos;
int iAchievementsUnlockedPos;
std::string sAchievementsUnlockAudioFile;
std::string sAchievementsLeaderboardSubmitAudioFile;
std::string sAchievementsUserName;
std::string sAchievementsToken;
Path currentDirectory;
Path defaultCurrentDirectory;
Path memStickDirectory;
Path flash0Directory;
Path internalDataDirectory;
Path appCacheDirectory;
void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
bool Save(const char *saveReason);
void Reload();
void RestoreDefaults(RestoreSettingsBits whatToRestore);
void changeGameSpecific(const std::string &gameId = "", const std::string &title = "");
bool createGameConfig(const std::string &game_id);
bool deleteGameConfig(const std::string& pGameId);
bool loadGameConfig(const std::string &game_id, const std::string &title);
bool saveGameConfig(const std::string &pGameId, const std::string &title);
void unloadGameConfig();
Path getGameConfigFile(const std::string &gameId, bool *exists);
bool hasGameConfig(const std::string &game_id);
void SetSearchPath(const Path &path);
const Path FindConfigFile(const std::string &baseFilename, bool *exists);
void UpdateIniLocation(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
void ResetControlLayout();
void GetReportingInfo(UrlEncoder &data) const;
bool IsPortrait() const;
int NextValidBackend();
bool IsBackendEnabled(GPUBackend backend);
bool UseFullScreen() const {
if (iForceFullScreen != -1)
return iForceFullScreen == 1;
return bFullScreen;
}
const std::map<std::string, std::pair<std::string, int>, std::less<>> &GetLangValuesMapping();
bool LoadAppendedConfig();
void SetAppendedConfigIni(const Path &path);
void UpdateAfterSettingAutoFrameSkip();
void NotifyUpdatedCpuCore();
int GetPSPLanguage();
PlayTimeTracker &TimeTracker() { return playTimeTracker_; }
protected:
void LoadStandardControllerIni();
void LoadLangValuesMapping();
void PostLoadCleanup(bool gameSpecific);
void PreSaveCleanup(bool gameSpecific);
void PostSaveCleanup(bool gameSpecific);
private:
bool reload_ = false;
std::string gameId_;
std::string gameIdTitle_;
std::map<std::string, std::pair<std::string, int>, std::less<>> langValuesMapping_;
PlayTimeTracker playTimeTracker_;
Path iniFilename_;
Path controllerIniFilename_;
Path searchPath_;
Path appendedConfigFileName_;
std::vector<std::string> appendedConfigUpdatedGames_;
};
std::string CreateRandMAC();
bool TryUpdateSavedPath(Path *path);
extern http::RequestManager g_DownloadManager;
extern Config g_Config;