#pragma once
#include <string>
#include <string_view>
#include <map>
#include <vector>
#include "ppsspp_config.h"
#include "Common/CommonTypes.h"
#include "Common/File/Path.h"
#include "Common/Math/geom2d.h"
#include "Core/ConfigValues.h"
extern const char *PPSSPP_GIT_VERSION;
namespace http {
class Request;
class RequestManager;
}
struct UrlEncoder;
class Section;
class IniFile;
class PlayTimeTracker {
public:
struct PlayTime {
int totalTimePlayed;
double startTime;
uint64_t lastTimePlayed;
};
void Start(std::string_view gameId);
void Stop(std::string_view gameId);
void Reset(std::string_view gameId);
void Load(const Section *section);
void Save(Section *section);
bool GetPlayedTimeString(std::string_view, std::string *str) const;
private:
std::map<std::string, PlayTime, std::less<>> tracker_;
};
struct ConfigSetting;
struct ConfigSectionMeta {
ConfigBlock *configBlock;
const ConfigSetting *settings;
size_t settingsCount;
std::string_view section;
std::string_view fallbackSectionName;
};
struct DisplayLayoutConfig : public ConfigBlock {
int iDisplayFilter = SCALE_LINEAR;
bool bDisplayStretch = false;
float fDisplayOffsetX = 0.5f;
float fDisplayOffsetY = 0.5f;
float fDisplayScale = 1.0f;
bool bDisplayIntegerScale = false;
float fDisplayAspectRatio = 1.0f;
int iInternalScreenRotation = ROTATION_LOCKED_HORIZONTAL;
bool bRotateControlsWithScreen = true;
bool bIgnoreScreenInsets = true;
bool bEnableCardboardVR = false;
int iCardboardScreenSize = 50;
int iCardboardXShift = 0;
int iCardboardYShift = 0;
bool bImmersiveMode = false;
bool InternalRotationIsPortrait() const;
bool CanResetToDefault() const override { return true; }
bool ResetToDefault(std::string_view blockName) override;
size_t Size() const override { return sizeof(DisplayLayoutConfig); }
};
struct TouchControlConfig : public ConfigBlock {
constexpr TouchControlConfig() {
touchRightAnalogStick.show = false;
for (size_t i = 0; i < CUSTOM_BUTTON_COUNT; i++) {
touchCustom[i].show = false;
}
}
ConfigTouchPos touchActionButtonCenter;
float fActionButtonSpacing = 1.0f;
ConfigTouchPos touchDpad;
float fDpadSpacing = 1.0f;
ConfigTouchPos touchStartKey;
ConfigTouchPos touchSelectKey;
ConfigTouchPos touchFastForwardKey;
ConfigTouchPos touchLKey;
ConfigTouchPos touchRKey;
ConfigTouchPos touchAnalogStick;
ConfigTouchPos touchRightAnalogStick;
ConfigTouchPos touchPauseKey;
enum { CUSTOM_BUTTON_COUNT = 20 };
ConfigTouchPos touchCustom[CUSTOM_BUTTON_COUNT];
float fLeftStickHeadScale = 1.0f;
float fRightStickHeadScale = 1.0f;
bool bHideStickBackground = false;
bool bShowTouchCircle = true;
bool bShowTouchCross = true;
bool bShowTouchTriangle = true;
bool bShowTouchSquare = true;
void ResetLayout();
bool CanResetToDefault() const override { return true; }
bool ResetToDefault(std::string_view blockName) override;
size_t Size() const override { return sizeof(TouchControlConfig); }
};
struct GestureControlConfig : public ConfigBlock {
bool bGestureControlEnabled = false;
int iSwipeUp = 0;
int iSwipeDown = 0;
int iSwipeLeft = 0;
int iSwipeRight = 0;
float fSwipeSensitivity = 1.0f;
float fSwipeSmoothing = 0.5f;
int iDoubleTapGesture = 0;
bool bAnalogGesture = false;
float fAnalogGestureSensitivity = 1.0f;
bool CanResetToDefault() const override { return true; }
bool ResetToDefault(std::string_view blockName) override;
size_t Size() const override { return sizeof(GestureControlConfig); }
};
struct Config : public ConfigBlock {
public:
~Config();
void Init();
size_t Size() const override { return sizeof(Config); }
bool bSaveSettings;
bool bFirstRun;
bool bUpdatedInstanceCounter = false;
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;
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 bShrinkIfWindowSmall;
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 bRemoteDebuggerLocal;
bool bRemoteTab;
bool bMemStickInserted;
int iMemStickSizeGB;
bool bLoadPlugins;
int iAskForExitConfirmationAfterSeconds;
int iUIScaleFactor;
int iDisableHLE;
int iForceEnableHLE;
int iScreenRotation;
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 bVSync;
bool bLowLatencyPresent;
bool bSoftwareRendering;
bool bSoftwareRenderingJit;
bool bHardwareTransform;
bool bSoftwareSkinning;
bool bVendorBugChecksEnabled;
bool bUseGeometryShader;
bool bSkipBufferEffects;
bool bDisableRangeCulling;
int iDepthRasterMode;
int iTexFiltering;
bool bSmart2DTexFiltering;
DisplayLayoutConfig displayLayoutLandscape;
DisplayLayoutConfig displayLayoutPortrait;
bool bDisplayCropTo16x9;
bool bSustainedPerformanceMode;
bool bShowImDebugger;
int iFrameSkip;
bool bAutoFrameSkip;
int iWindowX;
int iWindowY;
int iWindowWidth;
int iWindowHeight;
int iWindowSizeState;
bool bShowMenuBar;
float fUITint;
float fUISaturation;
bool bTextureBackoffCache;
bool bVertexDecoderJit;
int iAppSwitchMode;
bool bFullScreen;
bool bFullScreenMulti;
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;
int iSaveStateSlotCount;
bool bEnableCheats;
bool bReloadCheats;
bool bEnablePlugins;
int iCwCheatRefreshIntervalMs;
float fCwCheatScrollPosition;
float fGameListScrollPosition;
float fHomebrewScrollPosition;
float fRemoteScrollPosition;
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 iAudioBufferSize;
bool bFillAudioGaps;
int iAudioPlaybackMode;
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 bTiltInputEnabled;
bool bGridView1;
bool bGridView2;
bool bGridView3;
bool bGridView4;
int iRightAnalogUp;
int iRightAnalogDown;
int iRightAnalogLeft;
int iRightAnalogRight;
int iRightAnalogPress;
bool bRightAnalogCustom;
bool bRightAnalogDisableDiagonal;
GestureControlConfig gestureControls[2];
bool bShowTouchControls = false;
bool bDisableDpadDiagonals;
bool bGamepadOnlyFocused;
int iTouchButtonStyle;
int iTouchButtonOpacity;
int iTouchButtonHideSeconds;
bool bTouchSnapToGrid;
int iTouchSnapGridSize;
bool bAutoCenterTouchAnalog;
bool bStickyTouchDPad;
bool bTouchGliding;
TouchControlConfig touchControlsLandscape;
TouchControlConfig touchControlsPortrait;
ConfigCustomButton CustomButton[TouchControlConfig::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 sProAdhocServer;
bool bUseServerRelay;
std::vector<std::string> proAdhocServerList;
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 sQuickChat[5];
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;
std::string sAchievementsHost;
Path currentDirectory;
Path defaultCurrentDirectory;
Path memStickDirectory;
Path flash0Directory;
Path internalDataDirectory;
Path appCacheDirectory;
Path mountRoot;
void Load(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
bool Save(const char *saveReason);
void Reload();
void RestoreDefaults(RestoreSettingsBits whatToRestore, bool log = false);
bool CreateGameConfig(std::string_view gameId);
bool DeleteGameConfig(std::string_view gameId);
bool LoadGameConfig(const std::string &gameId);
bool SaveGameConfig(const std::string &pGameId, std::string_view titleForComment);
void UnloadGameConfig();
bool HasGameConfig(std::string_view gameId);
bool IsGameSpecific() const { return !gameId_.empty(); }
void SetSearchPath(const Path &path);
void UpdateIniLocation(const char *iniFileName = nullptr, const char *controllerIniFilename = nullptr);
void GetReportingInfo(UrlEncoder &data) const;
int NextValidBackend();
bool IsBackendEnabled(GPUBackend backend);
bool LoadAppendedConfig();
void SetAppendedConfigIni(const Path &path) { appendedConfigFileName_ = path; }
void UpdateAfterSettingAutoFrameSkip();
void NotifyUpdatedCpuCore();
PlayTimeTracker &TimeTracker() { return playTimeTracker_; }
const DisplayLayoutConfig &GetDisplayLayoutConfig(DeviceOrientation orientation) const {
return orientation == DeviceOrientation::Portrait ? displayLayoutPortrait : displayLayoutLandscape;
}
DisplayLayoutConfig &GetDisplayLayoutConfig(DeviceOrientation orientation) {
return orientation == DeviceOrientation::Portrait ? displayLayoutPortrait : displayLayoutLandscape;
}
const TouchControlConfig &GetTouchControlsConfig(DeviceOrientation orientation) const {
return orientation == DeviceOrientation::Portrait ? touchControlsPortrait : touchControlsLandscape;
}
TouchControlConfig &GetTouchControlsConfig(DeviceOrientation orientation) {
return orientation == DeviceOrientation::Portrait ? touchControlsPortrait : touchControlsLandscape;
}
static int GetDefaultValueInt(int *configSetting);
void DoNotSaveSetting(void *configSetting) {
settingsNotToSave_.push_back(configSetting);
}
private:
void LoadStandardControllerIni();
void PostLoadCleanup();
void PreSaveCleanup();
void PostSaveCleanup();
friend struct ConfigSetting;
static std::map<const void *, std::pair<const ConfigBlock *, const ConfigSetting *>> &getPtrLUT();
void ReadAllSettings(const IniFile &iniFile);
bool inReload_ = false;
std::string gameId_;
PlayTimeTracker playTimeTracker_;
Path iniFilename_;
Path controllerIniFilename_;
Path searchPath_;
Path appendedConfigFileName_;
std::vector<std::string> appendedConfigUpdatedGames_;
std::vector<void *> settingsNotToSave_;
bool ShouldSaveSetting(const void *configSetting) const;
};
std::string CreateRandMAC();
extern http::RequestManager g_DownloadManager;
extern Config g_Config;