2012-11-01 15:19:01 +00:00
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
2012-11-04 22:01:49 +00:00
// the Free Software Foundation, version 2.0 or later versions.
2012-11-01 15:19:01 +00:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
2016-10-12 09:32:24 +00:00
# include <algorithm>
2014-06-19 19:38:54 +00:00
# include <cstdlib>
# include <ctime>
2022-07-12 05:01:06 +00:00
# include <mutex>
2018-09-01 20:57:20 +00:00
# include <set>
2020-08-10 12:31:31 +00:00
# include <sstream>
2022-07-12 05:01:06 +00:00
# include <thread>
2014-06-19 19:38:54 +00:00
2020-08-29 15:45:50 +00:00
# include "ppsspp_config.h"
2020-10-04 07:29:36 +00:00
2020-10-04 21:24:14 +00:00
# include "Common/GPU/OpenGL/GLFeatures.h"
2020-10-04 18:48:47 +00:00
# include "Common/Net/HTTPClient.h"
# include "Common/Net/URL.h"
2013-11-26 13:04:29 +00:00
2020-10-04 07:29:36 +00:00
# include "Common/Log.h"
2021-11-13 21:47:29 +00:00
# include "Common/TimeUtil.h"
2023-01-03 18:01:51 +00:00
# include "Common/Thread/ThreadUtil.h"
2020-10-04 07:29:36 +00:00
# include "Common/Data/Format/IniFile.h"
# include "Common/Data/Format/JSONReader.h"
# include "Common/Data/Text/I18n.h"
# include "Common/Data/Text/Parsers.h"
2013-11-26 13:04:29 +00:00
# include "Common/CPUDetect.h"
2020-10-04 18:48:47 +00:00
# include "Common/File/FileUtil.h"
2023-03-07 09:02:59 +00:00
# include "Common/File/VFS/VFS.h"
2017-03-06 10:44:35 +00:00
# include "Common/LogManager.h"
2017-12-11 07:46:36 +00:00
# include "Common/OSVersion.h"
2020-10-04 08:30:18 +00:00
# include "Common/System/Display.h"
# include "Common/System/System.h"
2017-12-11 07:46:36 +00:00
# include "Common/StringUtils.h"
2023-01-03 18:01:51 +00:00
# include "Common/Thread/ThreadUtil.h"
2020-10-04 21:24:14 +00:00
# include "Common/GPU/Vulkan/VulkanLoader.h"
2022-08-27 15:33:37 +00:00
# include "Common/VR/PPSSPPVR.h"
2023-07-31 21:13:52 +00:00
# include "Common/System/OSD.h"
2014-12-01 07:54:22 +00:00
# include "Core/Config.h"
2023-04-05 09:44:11 +00:00
# include "Core/ConfigSettings.h"
2018-06-17 01:42:31 +00:00
# include "Core/ConfigValues.h"
2014-12-01 07:54:22 +00:00
# include "Core/Loaders.h"
2020-10-03 22:25:21 +00:00
# include "Core/KeyMap.h"
2017-12-11 07:46:36 +00:00
# include "Core/HLE/sceUtility.h"
2020-07-20 09:38:39 +00:00
# include "Core/Instance.h"
2020-08-03 21:17:22 +00:00
# include "GPU/Common/FramebufferManagerCommon.h"
2013-11-26 13:04:29 +00:00
// TODO: Find a better place for this.
2023-07-20 09:25:27 +00:00
http : : RequestManager g_DownloadManager ;
2012-11-01 15:19:01 +00:00
2013-03-24 19:03:42 +00:00
Config g_Config ;
2012-11-01 15:19:01 +00:00
2023-02-07 05:07:32 +00:00
static bool jitForcedOff ;
2015-11-03 17:34:33 +00:00
2022-07-12 06:46:09 +00:00
// Not in Config.h because it's #included a lot.
struct ConfigPrivate {
std : : mutex recentIsosLock ;
std : : mutex recentIsosThreadLock ;
std : : thread recentIsosThread ;
bool recentIsosThreadPending = false ;
void ResetRecentIsosThread ( ) ;
void SetRecentIsosThread ( std : : function < void ( ) > f ) ;
} ;
2015-11-03 17:34:33 +00:00
2017-03-06 10:44:35 +00:00
# ifdef _DEBUG
static const char * logSectionName = " LogDebug " ;
# else
static const char * logSectionName = " Log " ;
# endif
2014-02-10 01:08:40 +00:00
const char * DefaultLangRegion ( ) {
2015-12-26 03:15:03 +00:00
// Unfortunate default. There's no need to use bFirstRun, since this is only a default.
2014-02-10 01:08:40 +00:00
static std : : string defaultLangRegion = " en_US " ;
2015-12-26 03:15:03 +00:00
std : : string langRegion = System_GetProperty ( SYSPROP_LANGREGION ) ;
2023-04-07 08:20:00 +00:00
if ( g_i18nrepo . IniExists ( langRegion ) ) {
2015-12-26 03:15:03 +00:00
defaultLangRegion = langRegion ;
} else if ( langRegion . length ( ) > = 3 ) {
// Don't give up. Let's try a fuzzy match - so nl_BE can match nl_NL.
IniFile mapping ;
2023-03-07 09:02:59 +00:00
mapping . LoadFromVFS ( g_VFS , " langregion.ini " ) ;
2015-12-26 03:15:03 +00:00
std : : vector < std : : string > keys ;
mapping . GetKeys ( " LangRegionNames " , keys ) ;
for ( std : : string key : keys ) {
if ( startsWithNoCase ( key , langRegion ) ) {
// Exact submatch, or different case. Let's use it.
defaultLangRegion = key ;
break ;
} else if ( startsWithNoCase ( key , langRegion . substr ( 0 , 3 ) ) ) {
// Best so far.
defaultLangRegion = key ;
}
}
2014-02-09 23:46:49 +00:00
}
2014-02-10 01:08:40 +00:00
return defaultLangRegion . c_str ( ) ;
}
2014-02-09 23:46:49 +00:00
2017-04-29 19:48:06 +00:00
std : : string CreateRandMAC ( ) {
2014-06-29 21:41:33 +00:00
std : : stringstream randStream ;
2014-11-25 19:58:03 +00:00
srand ( time ( nullptr ) ) ;
for ( int i = 0 ; i < 6 ; i + + ) {
u32 value = rand ( ) % 256 ;
2020-09-02 14:42:16 +00:00
if ( i = = 0 ) {
// Making sure the 1st 2-bits on the 1st byte of OUI are zero to prevent issue with some games (ie. Gran Turismo)
value & = 0xfc ;
}
2014-11-25 19:58:03 +00:00
if ( value < = 15 )
2014-11-13 15:57:16 +00:00
randStream < < ' 0 ' < < std : : hex < < value ;
2014-11-13 14:13:57 +00:00
else
randStream < < std : : hex < < value ;
2014-11-25 19:58:03 +00:00
if ( i < 5 ) {
2014-06-29 23:08:45 +00:00
randStream < < ' : ' ; //we need a : between every octet
}
}
2017-04-29 19:48:06 +00:00
return randStream . str ( ) ;
2014-06-29 21:41:33 +00:00
}
2016-05-07 23:43:27 +00:00
static int DefaultCpuCore ( ) {
2023-07-23 21:20:57 +00:00
# if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) || PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(RISCV64)
2023-02-07 05:07:32 +00:00
if ( System_GetPropertyBool ( SYSPROP_CAN_JIT ) )
return ( int ) CPUCore : : JIT ;
2023-08-21 01:36:06 +00:00
return ( int ) CPUCore : : IR_INTERPRETER ;
2016-05-07 23:43:27 +00:00
# else
2023-08-21 01:36:06 +00:00
return ( int ) CPUCore : : IR_INTERPRETER ;
2016-05-07 23:43:27 +00:00
# endif
}
static bool DefaultCodeGen ( ) {
2023-07-23 21:20:57 +00:00
# if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) || PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(RISCV64)
2014-02-10 01:08:40 +00:00
return true ;
2014-11-13 15:41:30 +00:00
# else
return false ;
2014-02-10 01:08:40 +00:00
# endif
}
2014-02-09 23:46:49 +00:00
2023-08-13 11:33:38 +00:00
static bool DefaultVSync ( ) {
# if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(UWP)
// Previously we didn't allow turning off vsync/FIFO on Android. Let's set the default accordingly.
return true ;
# else
return false ;
# endif
}
2018-03-18 06:13:20 +00:00
static bool DefaultEnableStateUndo ( ) {
# ifdef MOBILE_DEVICE
// Off on mobile to save disk space.
return false ;
# endif
return true ;
}
2022-12-10 20:57:02 +00:00
static float DefaultUISaturation ( ) {
2022-12-11 11:35:52 +00:00
return IsVREnabled ( ) ? 1.5f : 1.0f ;
2022-12-10 20:57:02 +00:00
}
2023-02-01 09:27:15 +00:00
static const ConfigSetting generalSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " FirstRun " , & g_Config . bFirstRun , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RunCount " , & g_Config . iRunCount , 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " Enable Logging " , & g_Config . bEnableLogging , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AutoRun " , & g_Config . bAutoRun , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " Browse " , & g_Config . bBrowse , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " IgnoreBadMemAccess " , & g_Config . bIgnoreBadMemAccess , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " CurrentDirectory " , & g_Config . currentDirectory , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ShowDebuggerOnLoad " , & g_Config . bShowDebuggerOnLoad , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " CheckForNewVersion " , & g_Config . bCheckForNewVersion , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " Language " , & g_Config . sLanguageIni , & DefaultLangRegion , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ForceLagSync2 " , & g_Config . bForceLagSync , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DiscordPresence " , & g_Config . bDiscordPresence , true , CfgFlag : : DEFAULT ) , // Or maybe it makes sense to have it per-game? Race conditions abound...
ConfigSetting ( " UISound " , & g_Config . bUISound , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AutoLoadSaveState " , & g_Config . iAutoLoadSaveState , 0 , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " EnableCheats " , & g_Config . bEnableCheats , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " CwCheatRefreshRate " , & g_Config . iCwCheatRefreshRate , 77 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " CwCheatScrollPosition " , & g_Config . fCwCheatScrollPosition , 0.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " GameListScrollPosition " , & g_Config . fGameListScrollPosition , 0.0f , CfgFlag : : DEFAULT ) ,
2023-08-03 14:19:18 +00:00
ConfigSetting ( " DebugOverlay " , & g_Config . iDebugOverlay , 0 , CfgFlag : : DONT_SAVE ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ScreenshotsAsPNG " , & g_Config . bScreenshotsAsPNG , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " UseFFV1 " , & g_Config . bUseFFV1 , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DumpFrames " , & g_Config . bDumpFrames , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DumpVideoOutput " , & g_Config . bDumpVideoOutput , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DumpAudio " , & g_Config . bDumpAudio , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " SaveLoadResetsAVdumping " , & g_Config . bSaveLoadResetsAVdumping , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " StateSlot " , & g_Config . iCurrentStateSlot , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " EnableStateUndo " , & g_Config . bEnableStateUndo , & DefaultEnableStateUndo , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " StateLoadUndoGame " , & g_Config . sStateLoadUndoGame , " NA " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " StateUndoLastSaveGame " , & g_Config . sStateUndoLastSaveGame , " NA " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " StateUndoLastSaveSlot " , & g_Config . iStateUndoLastSaveSlot , - 5 , CfgFlag : : DEFAULT ) , // Start with an "invalid" value
ConfigSetting ( " RewindSnapshotInterval " , & g_Config . iRewindSnapshotInterval , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShowOnScreenMessage " , & g_Config . bShowOnScreenMessages , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ShowRegionOnGameIcon " , & g_Config . bShowRegionOnGameIcon , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ShowIDOnGameIcon " , & g_Config . bShowIDOnGameIcon , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GameGridScale " , & g_Config . fGameGridScale , 1.0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GridView1 " , & g_Config . bGridView1 , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GridView2 " , & g_Config . bGridView2 , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GridView3 " , & g_Config . bGridView3 , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RightAnalogUp " , & g_Config . iRightAnalogUp , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogDown " , & g_Config . iRightAnalogDown , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogLeft " , & g_Config . iRightAnalogLeft , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogRight " , & g_Config . iRightAnalogRight , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogPress " , & g_Config . iRightAnalogPress , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogCustom " , & g_Config . bRightAnalogCustom , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogDisableDiagonal " , & g_Config . bRightAnalogDisableDiagonal , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeUp " , & g_Config . iSwipeUp , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeDown " , & g_Config . iSwipeDown , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeLeft " , & g_Config . iSwipeLeft , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeRight " , & g_Config . iSwipeRight , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeSensitivity " , & g_Config . fSwipeSensitivity , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SwipeSmoothing " , & g_Config . fSwipeSmoothing , 0.3f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DoubleTapGesture " , & g_Config . iDoubleTapGesture , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " GestureControlEnabled " , & g_Config . bGestureControlEnabled , false , CfgFlag : : PER_GAME ) ,
2014-02-09 23:46:49 +00:00
// "default" means let emulator decide, "" means disable.
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ReportingHost " , & g_Config . sReportHost , " default " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AutoSaveSymbolMap " , & g_Config . bAutoSaveSymbolMap , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " CacheFullIsoInRam " , & g_Config . bCacheFullIsoInRam , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RemoteISOPort " , & g_Config . iRemoteISOPort , 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " LastRemoteISOServer " , & g_Config . sLastRemoteISOServer , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " LastRemoteISOPort " , & g_Config . iLastRemoteISOPort , 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RemoteISOManualConfig " , & g_Config . bRemoteISOManual , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RemoteShareOnStartup " , & g_Config . bRemoteShareOnStartup , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RemoteISOSubdir " , & g_Config . sRemoteISOSubdir , " / " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RemoteDebuggerOnStartup " , & g_Config . bRemoteDebuggerOnStartup , false , CfgFlag : : DEFAULT ) ,
2014-02-09 23:46:49 +00:00
2016-10-12 09:13:16 +00:00
# ifdef __ANDROID__
2019-02-23 16:17:40 +00:00
ConfigSetting ( " ScreenRotation " , & g_Config . iScreenRotation , ROTATION_AUTO_HORIZONTAL ) ,
2014-02-09 23:46:49 +00:00
# endif
2023-04-05 14:23:31 +00:00
ConfigSetting ( " InternalScreenRotation " , & g_Config . iInternalScreenRotation , ROTATION_LOCKED_HORIZONTAL , CfgFlag : : PER_GAME ) ,
2014-02-09 23:46:49 +00:00
2023-04-05 14:23:31 +00:00
ConfigSetting ( " BackgroundAnimation " , & g_Config . iBackgroundAnimation , 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " TransparentBackground " , & g_Config . bTransparentBackground , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " UITint " , & g_Config . fUITint , 0.0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " UISaturation " , & g_Config . fUISaturation , & DefaultUISaturation , CfgFlag : : DEFAULT ) ,
2021-03-23 22:41:16 +00:00
2014-02-09 23:46:49 +00:00
# if defined(USING_WIN_UI)
2023-04-05 14:23:31 +00:00
ConfigSetting ( " TopMost " , & g_Config . bTopMost , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " PauseOnLostFocus " , & g_Config . bPauseOnLostFocus , false , CfgFlag : : PER_GAME ) ,
2023-03-28 12:25:30 +00:00
# endif
# if !defined(MOBILE_DEVICE)
2023-04-05 14:23:31 +00:00
ConfigSetting ( " WindowX " , & g_Config . iWindowX , - 1 , CfgFlag : : DEFAULT ) , // -1 tells us to center the window.
ConfigSetting ( " WindowY " , & g_Config . iWindowY , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " WindowWidth " , & g_Config . iWindowWidth , 0 , CfgFlag : : DEFAULT ) , // 0 will be automatically reset later (need to do the AdjustWindowRect dance).
ConfigSetting ( " WindowHeight " , & g_Config . iWindowHeight , 0 , CfgFlag : : DEFAULT ) ,
2014-02-09 23:46:49 +00:00
# endif
2023-03-28 12:25:30 +00:00
2023-04-05 14:23:31 +00:00
ConfigSetting ( " PauseWhenMinimized " , & g_Config . bPauseWhenMinimized , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DumpDecryptedEboots " , & g_Config . bDumpDecryptedEboot , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " FullscreenOnDoubleclick " , & g_Config . bFullscreenOnDoubleclick , true , CfgFlag : : DONT_SAVE ) ,
ConfigSetting ( " ShowMenuBar " , & g_Config . bShowMenuBar , true , CfgFlag : : DEFAULT ) ,
2016-07-04 04:09:17 +00:00
2023-04-05 14:27:44 +00:00
ConfigSetting ( " MemStickInserted " , & g_Config . bMemStickInserted , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " EnablePlugins " , & g_Config . bLoadPlugins , true , CfgFlag : : PER_GAME ) ,
2016-08-06 04:27:53 +00:00
2023-04-05 14:27:44 +00:00
ConfigSetting ( " IgnoreCompatSettings " , & g_Config . sIgnoreCompatSettings , " " , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2014-02-09 23:46:49 +00:00
} ;
2015-11-15 19:27:40 +00:00
static bool DefaultSasThread ( ) {
return cpu_info . num_cores > 1 ;
}
2023-06-15 20:17:27 +00:00
static const ConfigSetting achievementSettings [ ] = {
2023-07-16 10:15:44 +00:00
// Core settings
2023-06-16 14:29:44 +00:00
ConfigSetting ( " AchievementsEnable " , & g_Config . bAchievementsEnable , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsChallengeMode " , & g_Config . bAchievementsChallengeMode , false , CfgFlag : : DEFAULT ) ,
2023-07-02 22:14:23 +00:00
ConfigSetting ( " AchievementsEncoreMode " , & g_Config . bAchievementsEncoreMode , false , CfgFlag : : DEFAULT ) ,
2023-07-03 20:17:07 +00:00
ConfigSetting ( " AchievementsUnofficial " , & g_Config . bAchievementsUnofficial , false , CfgFlag : : DEFAULT ) ,
2023-06-20 21:59:58 +00:00
ConfigSetting ( " AchievementsLogBadMemReads " , & g_Config . bAchievementsLogBadMemReads , false , CfgFlag : : DEFAULT ) ,
2023-06-16 14:29:44 +00:00
// Achievements login info. Note that password is NOT stored, only a login token.
2023-06-27 21:31:15 +00:00
// And that login token is stored separately from the ini, see NativeSaveSecret, but it can also be loaded
// from the ini if manually entered (useful when testing various builds on Android).
2023-06-26 08:01:20 +00:00
ConfigSetting ( " AchievementsToken " , & g_Config . sAchievementsToken , " " , CfgFlag : : DONT_SAVE ) ,
2023-06-27 21:31:15 +00:00
ConfigSetting ( " AchievementsUserName " , & g_Config . sAchievementsUserName , " " , CfgFlag : : DEFAULT ) ,
2023-07-16 10:15:44 +00:00
// Customizations
2023-07-16 12:23:06 +00:00
ConfigSetting ( " AchievementsSoundEffects " , & g_Config . bAchievementsSoundEffects , true , CfgFlag : : DEFAULT ) ,
2023-07-16 10:15:44 +00:00
ConfigSetting ( " AchievementsUnlockAudioFile " , & g_Config . sAchievementsUnlockAudioFile , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsLeaderboardSubmitAudioFile " , & g_Config . sAchievementsLeaderboardSubmitAudioFile , " " , CfgFlag : : DEFAULT ) ,
2023-07-31 22:13:33 +00:00
ConfigSetting ( " AchievementsLeaderboardTrackerPos " , & g_Config . iAchievementsLeaderboardTrackerPos , ( int ) ScreenEdgePosition : : TOP_LEFT , CfgFlag : : DEFAULT ) ,
2023-08-01 10:52:09 +00:00
ConfigSetting ( " AchievementsLeaderboardStartedOrFailedPos " , & g_Config . iAchievementsLeaderboardStartedOrFailedPos , ( int ) ScreenEdgePosition : : TOP_LEFT , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsLeaderboardSubmittedPos " , & g_Config . iAchievementsLeaderboardSubmittedPos , ( int ) ScreenEdgePosition : : TOP_LEFT , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsProgressPos " , & g_Config . iAchievementsProgressPos , ( int ) ScreenEdgePosition : : TOP_LEFT , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsChallengePos " , & g_Config . iAchievementsChallengePos , ( int ) ScreenEdgePosition : : TOP_LEFT , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AchievementsUnlockedPos " , & g_Config . iAchievementsUnlockedPos , ( int ) ScreenEdgePosition : : TOP_CENTER , CfgFlag : : DEFAULT ) ,
2023-06-15 20:17:27 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting cpuSettings [ ] = {
2023-04-05 14:27:44 +00:00
ConfigSetting ( " CPUCore " , & g_Config . iCpuCore , & DefaultCpuCore , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " SeparateSASThread " , & g_Config . bSeparateSASThread , & DefaultSasThread , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " IOTimingMethod " , & g_Config . iIOTimingMethod , IOTIMING_FAST , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " FastMemoryAccess " , & g_Config . bFastMemory , true , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " FunctionReplacements " , & g_Config . bFuncReplacements , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " HideSlowWarnings " , & g_Config . bHideSlowWarnings , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " HideStateWarnings " , & g_Config . bHideStateWarnings , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " PreloadFunctions " , & g_Config . bPreloadFunctions , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " JitDisableFlags " , & g_Config . uJitDisableFlags , ( uint32_t ) 0 , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " CPUSpeed " , & g_Config . iLockedCPUSpeed , 0 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2014-02-10 01:08:40 +00:00
} ;
static int DefaultInternalResolution ( ) {
2020-07-03 22:16:36 +00:00
// Auto on Windows and Linux, 2x on large screens, 1x elsewhere.
# if defined(USING_WIN_UI) || defined(USING_QT_UI)
2014-02-10 01:08:40 +00:00
return 0 ;
# else
2022-12-02 19:57:50 +00:00
if ( System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_VR ) {
return 4 ;
}
2015-04-03 16:20:56 +00:00
int longestDisplaySide = std : : max ( System_GetPropertyInt ( SYSPROP_DISPLAY_XRES ) , System_GetPropertyInt ( SYSPROP_DISPLAY_YRES ) ) ;
2017-11-26 13:49:00 +00:00
int scale = longestDisplaySide > = 1000 ? 2 : 1 ;
2020-08-15 14:13:24 +00:00
INFO_LOG ( G3D , " Longest display side: %d pixels. Choosing scale %d " , longestDisplaySide , scale ) ;
2017-11-26 13:49:00 +00:00
return scale ;
2014-02-10 01:08:40 +00:00
# endif
}
2021-08-17 14:48:47 +00:00
static int DefaultFastForwardMode ( ) {
2020-07-19 09:03:46 +00:00
# if PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)
2021-08-17 14:48:47 +00:00
return ( int ) FastForwardMode : : SKIP_FLIP ;
2017-03-09 13:16:51 +00:00
# else
2021-08-17 14:48:47 +00:00
return ( int ) FastForwardMode : : CONTINUOUS ;
2017-03-09 13:16:51 +00:00
# endif
}
2023-05-17 07:37:15 +00:00
static int DefaultAndroidHwScale ( ) {
# ifdef __ANDROID__
if ( System_GetPropertyInt ( SYSPROP_SYSTEMVERSION ) > = 19 | | System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) = = DEVICE_TYPE_TV ) {
// Arbitrary cutoff at Kitkat - modern devices are usually powerful enough that hw scaling
// doesn't really help very much and mostly causes problems. See #11151
return 0 ;
}
// Get the real resolution as passed in during startup, not dp_xres and stuff
int xres = System_GetPropertyInt ( SYSPROP_DISPLAY_XRES ) ;
int yres = System_GetPropertyInt ( SYSPROP_DISPLAY_YRES ) ;
if ( xres < = 960 ) {
// Smaller than the PSP*2, let's go native.
return 0 ;
} else if ( xres < = 480 * 3 ) { // 720p xres
// Small-ish screen, we should default to 2x
return 2 + 1 ;
} else {
// Large or very large screen. Default to 3x psp resolution.
return 3 + 1 ;
}
return 0 ;
# else
return 1 ;
# endif
}
2021-08-21 20:18:25 +00:00
// See issue 14439. Should possibly even block these devices from selecting VK.
const char * const vulkanDefaultBlacklist [ ] = {
" Sony:BRAVIA VH1 " ,
} ;
2017-12-11 07:46:36 +00:00
static int DefaultGPUBackend ( ) {
2022-11-06 13:36:51 +00:00
if ( IsVREnabled ( ) ) {
2022-08-27 15:33:37 +00:00
return ( int ) GPUBackend : : OPENGL ;
}
2022-07-24 13:38:30 +00:00
2017-12-11 07:46:36 +00:00
# if PPSSPP_PLATFORM(WINDOWS)
// If no Vulkan, use Direct3D 11 on Windows 8+ (most importantly 10.)
if ( DoesVersionMatchWindows ( 6 , 2 , 0 , 0 , true ) ) {
2017-12-26 23:55:24 +00:00
return ( int ) GPUBackend : : DIRECT3D11 ;
2017-12-11 07:46:36 +00:00
}
2019-08-23 15:14:11 +00:00
# elif PPSSPP_PLATFORM(ANDROID)
2021-08-21 20:18:25 +00:00
// Check blacklist.
for ( size_t i = 0 ; i < ARRAY_SIZE ( vulkanDefaultBlacklist ) ; i + + ) {
if ( System_GetProperty ( SYSPROP_NAME ) = = vulkanDefaultBlacklist [ i ] ) {
return ( int ) GPUBackend : : OPENGL ;
}
}
2021-08-21 19:52:28 +00:00
// Default to Vulkan only on Oreo 8.1 (level 27) devices or newer, and only
// on ARM64 and x86-64. Drivers before, and on other archs, are generally too
// unreliable to default to (with some exceptions, of course).
# if PPSSPP_ARCH(64BIT)
2019-09-02 19:42:07 +00:00
if ( System_GetPropertyInt ( SYSPROP_SYSTEMVERSION ) > = 27 ) {
2019-08-23 15:14:11 +00:00
return ( int ) GPUBackend : : VULKAN ;
}
2023-08-18 13:12:34 +00:00
# else
// There are some newer devices that benefit from Vulkan as default, but are 32-bit. Example: Redmi 9A.
// Let's only allow the very newest generation though.
if ( System_GetPropertyInt ( SYSPROP_SYSTEMVERSION ) > = 30 ) {
return ( int ) GPUBackend : : VULKAN ;
}
2021-08-21 19:52:28 +00:00
# endif
2023-04-27 11:38:17 +00:00
# elif PPSSPP_PLATFORM(MAC)
# if PPSSPP_ARCH(ARM64)
return ( int ) GPUBackend : : VULKAN ;
# else
// On Intel (generally older Macs) default to OpenGL.
return ( int ) GPUBackend : : OPENGL ;
2019-08-24 07:56:19 +00:00
# endif
2023-04-27 11:38:17 +00:00
# endif
2019-08-23 15:14:11 +00:00
// TODO: On some additional Linux platforms, we should also default to Vulkan.
2017-12-26 23:55:24 +00:00
return ( int ) GPUBackend : : OPENGL ;
2017-12-11 07:46:36 +00:00
}
2018-09-01 20:57:20 +00:00
int Config : : NextValidBackend ( ) {
std : : vector < std : : string > split ;
2019-06-22 18:48:36 +00:00
std : : set < GPUBackend > failed ;
2018-09-01 20:57:20 +00:00
SplitString ( sFailedGPUBackends , ' , ' , split ) ;
for ( const auto & str : split ) {
if ( ! str . empty ( ) & & str ! = " ALL " ) {
2019-06-22 18:48:36 +00:00
failed . insert ( GPUBackendFromString ( str ) ) ;
}
}
// Count these as "failed" too so we don't pick them.
SplitString ( sDisabledGPUBackends , ' , ' , split ) ;
for ( const auto & str : split ) {
if ( ! str . empty ( ) ) {
failed . insert ( GPUBackendFromString ( str ) ) ;
2018-09-01 20:57:20 +00:00
}
}
2019-06-22 18:48:36 +00:00
if ( failed . count ( ( GPUBackend ) iGPUBackend ) ) {
2018-09-06 06:13:15 +00:00
ERROR_LOG ( LOADER , " Graphics backend failed for %d, trying another " , iGPUBackend ) ;
2022-08-22 02:00:10 +00:00
# if !PPSSPP_PLATFORM(UWP)
2019-06-22 18:48:36 +00:00
if ( ! failed . count ( GPUBackend : : VULKAN ) & & VulkanMayBeAvailable ( ) ) {
2018-09-01 20:57:20 +00:00
return ( int ) GPUBackend : : VULKAN ;
}
# endif
# if PPSSPP_PLATFORM(WINDOWS)
2019-06-22 18:48:36 +00:00
if ( ! failed . count ( GPUBackend : : DIRECT3D11 ) & & DoesVersionMatchWindows ( 6 , 1 , 0 , 0 , true ) ) {
2018-09-01 20:57:20 +00:00
return ( int ) GPUBackend : : DIRECT3D11 ;
}
# endif
2019-05-10 21:25:57 +00:00
# if PPSSPP_API(ANY_GL)
2019-06-22 18:48:36 +00:00
if ( ! failed . count ( GPUBackend : : OPENGL ) ) {
2018-09-01 20:57:20 +00:00
return ( int ) GPUBackend : : OPENGL ;
}
# endif
2019-05-11 04:36:28 +00:00
# if PPSSPP_API(D3D9)
2019-06-22 18:48:36 +00:00
if ( ! failed . count ( GPUBackend : : DIRECT3D9 ) ) {
2018-09-01 20:57:20 +00:00
return ( int ) GPUBackend : : DIRECT3D9 ;
}
# endif
2019-09-02 19:42:07 +00:00
// They've all failed. Let them try the default - or on Android, OpenGL.
2018-09-01 20:57:20 +00:00
sFailedGPUBackends + = " ,ALL " ;
2018-09-06 06:13:15 +00:00
ERROR_LOG ( LOADER , " All graphics backends failed " ) ;
2019-09-02 19:42:07 +00:00
# if PPSSPP_PLATFORM(ANDROID)
return ( int ) GPUBackend : : OPENGL ;
# else
2018-09-01 20:57:20 +00:00
return DefaultGPUBackend ( ) ;
2019-09-02 19:42:07 +00:00
# endif
2018-09-01 20:57:20 +00:00
}
return iGPUBackend ;
}
2019-06-22 18:48:36 +00:00
bool Config : : IsBackendEnabled ( GPUBackend backend , bool validate ) {
std : : vector < std : : string > split ;
SplitString ( sDisabledGPUBackends , ' , ' , split ) ;
for ( const auto & str : split ) {
if ( str . empty ( ) )
continue ;
auto match = GPUBackendFromString ( str ) ;
if ( match = = backend )
return false ;
}
2020-12-08 05:46:14 +00:00
# if PPSSPP_PLATFORM(UWP)
2019-06-22 18:48:36 +00:00
if ( backend ! = GPUBackend : : DIRECT3D11 )
return false ;
2022-08-22 02:00:10 +00:00
# elif PPSSPP_PLATFORM(SWITCH)
if ( backend ! = GPUBackend : : OPENGL )
return false ;
2019-06-22 18:48:36 +00:00
# elif PPSSPP_PLATFORM(WINDOWS)
if ( validate ) {
if ( backend = = GPUBackend : : DIRECT3D11 & & ! DoesVersionMatchWindows ( 6 , 0 , 0 , 0 , true ) )
return false ;
}
# else
if ( backend = = GPUBackend : : DIRECT3D11 | | backend = = GPUBackend : : DIRECT3D9 )
return false ;
# endif
# if !PPSSPP_API(ANY_GL)
if ( backend = = GPUBackend : : OPENGL )
return false ;
# endif
if ( validate ) {
if ( backend = = GPUBackend : : VULKAN & & ! VulkanMayBeAvailable ( ) )
return false ;
}
return true ;
}
2019-06-22 19:15:31 +00:00
template < typename T , std : : string ( * FTo ) ( T ) , T ( * FFrom ) ( const std : : string & ) >
struct ConfigTranslator {
static std : : string To ( int v ) {
2019-06-22 19:36:17 +00:00
return StringFromInt ( v ) + " ( " + FTo ( T ( v ) ) + " ) " ;
2019-06-22 19:15:31 +00:00
}
static int From ( const std : : string & v ) {
2019-06-22 19:36:17 +00:00
int result ;
if ( TryParse ( v , & result ) ) {
return result ;
}
2019-06-22 19:15:31 +00:00
return ( int ) FFrom ( v ) ;
}
} ;
typedef ConfigTranslator < GPUBackend , GPUBackendToString , GPUBackendFromString > GPUBackendTranslator ;
2021-08-17 14:48:47 +00:00
static int FastForwardModeFromString ( const std : : string & s ) {
2020-05-24 21:57:18 +00:00
if ( ! strcasecmp ( s . c_str ( ) , " CONTINUOUS " ) )
2021-08-17 14:48:47 +00:00
return ( int ) FastForwardMode : : CONTINUOUS ;
2020-05-24 21:57:18 +00:00
if ( ! strcasecmp ( s . c_str ( ) , " SKIP_FLIP " ) )
2021-08-17 14:48:47 +00:00
return ( int ) FastForwardMode : : SKIP_FLIP ;
return DefaultFastForwardMode ( ) ;
2020-05-24 21:57:18 +00:00
}
2021-08-17 14:48:47 +00:00
std : : string FastForwardModeToString ( int v ) {
switch ( FastForwardMode ( v ) ) {
case FastForwardMode : : CONTINUOUS :
2020-05-24 21:57:18 +00:00
return " CONTINUOUS " ;
2021-08-17 14:48:47 +00:00
case FastForwardMode : : SKIP_FLIP :
2020-05-24 21:57:18 +00:00
return " SKIP_FLIP " ;
}
return " CONTINUOUS " ;
}
2023-02-01 09:27:15 +00:00
static const ConfigSetting graphicsSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " EnableCardboardVR " , & g_Config . bEnableCardboardVR , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " CardboardScreenSize " , & g_Config . iCardboardScreenSize , 50 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " CardboardXShift " , & g_Config . iCardboardXShift , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " CardboardYShift " , & g_Config . iCardboardYShift , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " iShowStatusFlags " , & g_Config . iShowStatusFlags , 0 , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " GraphicsBackend " , & g_Config . iGPUBackend , & DefaultGPUBackend , & GPUBackendTranslator : : To , & GPUBackendTranslator : : From , CfgFlag : : DEFAULT | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " FailedGraphicsBackends " , & g_Config . sFailedGPUBackends , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DisabledGraphicsBackends " , & g_Config . sDisabledGPUBackends , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " VulkanDevice " , & g_Config . sVulkanDevice , " " , CfgFlag : : DEFAULT ) ,
2018-04-15 08:53:07 +00:00
# ifdef _WIN32
2023-04-05 14:23:31 +00:00
ConfigSetting ( " D3D11Device " , & g_Config . sD3D11Device , " " , CfgFlag : : DEFAULT ) ,
2020-01-14 09:15:11 +00:00
# endif
2023-04-05 14:23:31 +00:00
ConfigSetting ( " CameraDevice " , & g_Config . sCameraDevice , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " VendorBugChecksEnabled " , & g_Config . bVendorBugChecksEnabled , true , CfgFlag : : DONT_SAVE ) ,
ConfigSetting ( " UseGeometryShader " , & g_Config . bUseGeometryShader , false , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " SkipBufferEffects " , & g_Config . bSkipBufferEffects , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " SoftwareRenderer " , & g_Config . bSoftwareRendering , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SoftwareRendererJit " , & g_Config . bSoftwareRenderingJit , true , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " HardwareTransform " , & g_Config . bHardwareTransform , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " SoftwareSkinning " , & g_Config . bSoftwareSkinning , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " TextureFiltering " , & g_Config . iTexFiltering , 1 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " InternalResolution " , & g_Config . iInternalResolution , & DefaultInternalResolution , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-05-17 07:37:15 +00:00
ConfigSetting ( " AndroidHwScale " , & g_Config . iAndroidHwScale , & DefaultAndroidHwScale , CfgFlag : : DEFAULT ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " HighQualityDepth " , & g_Config . bHighQualityDepth , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " FrameSkip " , & g_Config . iFrameSkip , 0 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " FrameSkipType " , & g_Config . iFrameSkipType , 0 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " AutoFrameSkip " , & g_Config . bAutoFrameSkip , IsVREnabled ( ) , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " StereoRendering " , & g_Config . bStereoRendering , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " StereoToMonoShader " , & g_Config . sStereoToMonoShader , " RedBlue " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " FrameRate " , & g_Config . iFpsLimit1 , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " FrameRate2 " , & g_Config . iFpsLimit2 , - 1 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogFrameRate " , & g_Config . iAnalogFpsLimit , 240 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " UnthrottlingMode " , & g_Config . iFastForwardMode , & DefaultFastForwardMode , & FastForwardModeToString , & FastForwardModeFromString , CfgFlag : : PER_GAME ) ,
2017-05-21 15:24:40 +00:00
# if defined(USING_WIN_UI)
2023-04-05 14:23:31 +00:00
ConfigSetting ( " RestartRequired " , & g_Config . bRestartRequired , false , CfgFlag : : DONT_SAVE ) ,
2017-05-21 15:24:40 +00:00
# endif
2015-09-05 21:09:06 +00:00
2017-12-19 16:59:00 +00:00
// Most low-performance (and many high performance) mobile GPUs do not support aniso anyway so defaulting to 4 is fine.
2023-04-05 14:23:31 +00:00
ConfigSetting ( " AnisotropyLevel " , & g_Config . iAnisotropyLevel , 4 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MultiSampleLevel " , & g_Config . iMultiSampleLevel , 0 , CfgFlag : : PER_GAME ) , // Number of samples is 1 << iMultiSampleLevel
2017-12-19 16:59:00 +00:00
2023-04-05 14:27:44 +00:00
ConfigSetting ( " VertexDecCache " , & g_Config . bVertexCache , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " TextureBackoffCache " , & g_Config . bTextureBackoffCache , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " VertexDecJit " , & g_Config . bVertexDecoderJit , & DefaultCodeGen , CfgFlag : : DONT_SAVE | CfgFlag : : REPORT ) ,
2014-02-10 01:08:40 +00:00
2015-10-24 12:40:29 +00:00
# ifndef MOBILE_DEVICE
2023-04-05 14:23:31 +00:00
ConfigSetting ( " FullScreen " , & g_Config . bFullScreen , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " FullScreenMulti " , & g_Config . bFullScreenMulti , false , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
# endif
2023-04-05 14:23:31 +00:00
ConfigSetting ( " BufferFiltering " , & g_Config . iDisplayFilter , SCALE_LINEAR , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayOffsetX " , & g_Config . fDisplayOffsetX , 0.5f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayOffsetY " , & g_Config . fDisplayOffsetY , 0.5f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayScale " , & g_Config . fDisplayScale , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayIntegerScale " , & g_Config . bDisplayIntegerScale , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayAspectRatio " , & g_Config . fDisplayAspectRatio , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DisplayStretch " , & g_Config . bDisplayStretch , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ImmersiveMode " , & g_Config . bImmersiveMode , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SustainedPerformanceMode " , & g_Config . bSustainedPerformanceMode , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " IgnoreScreenInsets " , & g_Config . bIgnoreScreenInsets , true , CfgFlag : : DEFAULT ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " ReplaceTextures " , & g_Config . bReplaceTextures , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " SaveNewTextures " , & g_Config . bSaveNewTextures , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " IgnoreTextureFilenames " , & g_Config . bIgnoreTextureFilenames , false , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " TexScalingLevel " , & g_Config . iTexScalingLevel , 1 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " TexScalingType " , & g_Config . iTexScalingType , 0 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " TexDeposterize " , & g_Config . bTexDeposterize , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " TexHardwareScaling " , & g_Config . bTexHardwareScaling , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-08-13 11:33:38 +00:00
ConfigSetting ( " VSync " , & g_Config . bVSync , & DefaultVSync , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " BloomHack " , & g_Config . iBloomHack , 0 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2014-02-10 01:08:40 +00:00
// Not really a graphics setting...
2023-04-05 14:27:44 +00:00
ConfigSetting ( " SplineBezierQuality " , & g_Config . iSplineBezierQuality , 2 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " HardwareTessellation " , & g_Config . bHardwareTessellation , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " TextureShader " , & g_Config . sTextureShaderName , " Off " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShaderChainRequires60FPS " , & g_Config . bShaderChainRequires60FPS , false , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
2023-04-05 14:27:44 +00:00
ConfigSetting ( " SkipGPUReadbacks " , & g_Config . bSkipGPUReadbacks , false , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2014-05-25 08:18:14 +00:00
2023-04-05 14:23:31 +00:00
ConfigSetting ( " GfxDebugOutput " , & g_Config . bGfxDebugOutput , false , CfgFlag : : DONT_SAVE ) ,
ConfigSetting ( " LogFrameDrops " , & g_Config . bLogFrameDrops , false , CfgFlag : : DEFAULT ) ,
2016-07-04 04:09:17 +00:00
2023-04-05 14:23:31 +00:00
ConfigSetting ( " InflightFrames " , & g_Config . iInflightFrames , 3 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " RenderDuplicateFrames " , & g_Config . bRenderDuplicateFrames , false , CfgFlag : : PER_GAME ) ,
2020-03-01 07:40:55 +00:00
2023-07-23 17:20:55 +00:00
ConfigSetting ( " MultiThreading " , & g_Config . bRenderMultiThreading , true , CfgFlag : : DEFAULT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ShaderCache " , & g_Config . bShaderCache , true , CfgFlag : : DONT_SAVE ) , // Doesn't save. Ini-only.
ConfigSetting ( " GpuLogProfiler " , & g_Config . bGpuLogProfiler , false , CfgFlag : : DEFAULT ) ,
2023-08-17 18:16:04 +00:00
ConfigSetting ( " UberShaderVertex " , & g_Config . bUberShaderVertex , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " UberShaderFragment " , & g_Config . bUberShaderFragment , true , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting soundSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " Enable " , & g_Config . bEnableSound , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AudioBackend " , & g_Config . iAudioBackend , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ExtraAudioBuffering " , & g_Config . bExtraAudioBuffering , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GlobalVolume " , & g_Config . iGlobalVolume , VOLUME_FULL , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ReverbVolume " , & g_Config . iReverbVolume , VOLUME_FULL , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AltSpeedVolume " , & g_Config . iAltSpeedVolume , - 1 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AudioDevice " , & g_Config . sAudioDevice , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " AutoAudioDevice " , & g_Config . bAutoAudioDevice , true , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
static bool DefaultShowTouchControls ( ) {
2015-04-03 09:50:03 +00:00
int deviceType = System_GetPropertyInt ( SYSPROP_DEVICE_TYPE ) ;
if ( deviceType = = DEVICE_TYPE_MOBILE ) {
std : : string name = System_GetProperty ( SYSPROP_NAME ) ;
if ( KeyMap : : HasBuiltinController ( name ) ) {
return false ;
} else {
return true ;
}
} else if ( deviceType = = DEVICE_TYPE_TV ) {
return false ;
} else if ( deviceType = = DEVICE_TYPE_DESKTOP ) {
2014-02-10 01:08:40 +00:00
return false ;
2022-07-24 13:38:30 +00:00
} else if ( deviceType = = DEVICE_TYPE_VR ) {
return false ;
2014-02-10 01:08:40 +00:00
} else {
2015-04-03 09:50:03 +00:00
return false ;
2014-02-10 01:08:40 +00:00
}
}
static const float defaultControlScale = 1.15f ;
2018-06-17 05:14:41 +00:00
static const ConfigTouchPos defaultTouchPosShow = { - 1.0f , - 1.0f , defaultControlScale , true } ;
static const ConfigTouchPos defaultTouchPosHide = { - 1.0f , - 1.0f , defaultControlScale , false } ;
2014-02-10 01:08:40 +00:00
2023-02-01 09:27:15 +00:00
static const ConfigSetting controlSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " HapticFeedback " , & g_Config . bHapticFeedback , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShowTouchCross " , & g_Config . bShowTouchCross , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShowTouchCircle " , & g_Config . bShowTouchCircle , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShowTouchSquare " , & g_Config . bShowTouchSquare , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ShowTouchTriangle " , & g_Config . bShowTouchTriangle , true , CfgFlag : : PER_GAME ) ,
2023-06-20 07:30:38 +00:00
ConfigSetting ( " Custom0Mapping " , " Custom0Image " , " Custom0Shape " , " Custom0Toggle " , " Custom0Repeat " , & g_Config . CustomButton [ 0 ] , { 0 , 0 , 0 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom1Mapping " , " Custom1Image " , " Custom1Shape " , " Custom1Toggle " , " Custom1Repeat " , & g_Config . CustomButton [ 1 ] , { 0 , 1 , 0 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom2Mapping " , " Custom2Image " , " Custom2Shape " , " Custom2Toggle " , " Custom2Repeat " , & g_Config . CustomButton [ 2 ] , { 0 , 2 , 0 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom3Mapping " , " Custom3Image " , " Custom3Shape " , " Custom3Toggle " , " Custom3Repeat " , & g_Config . CustomButton [ 3 ] , { 0 , 3 , 0 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom4Mapping " , " Custom4Image " , " Custom4Shape " , " Custom4Toggle " , " Custom4Repeat " , & g_Config . CustomButton [ 4 ] , { 0 , 4 , 0 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom5Mapping " , " Custom5Image " , " Custom5Shape " , " Custom5Toggle " , " Custom5Repeat " , & g_Config . CustomButton [ 5 ] , { 0 , 0 , 1 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom6Mapping " , " Custom6Image " , " Custom6Shape " , " Custom6Toggle " , " Custom6Repeat " , & g_Config . CustomButton [ 6 ] , { 0 , 1 , 1 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom7Mapping " , " Custom7Image " , " Custom7Shape " , " Custom7Toggle " , " Custom7Repeat " , & g_Config . CustomButton [ 7 ] , { 0 , 2 , 1 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom8Mapping " , " Custom8Image " , " Custom8Shape " , " Custom8Toggle " , " Custom8Repeat " , & g_Config . CustomButton [ 8 ] , { 0 , 3 , 1 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom9Mapping " , " Custom9Image " , " Custom9Shape " , " Custom9Toggle " , " Custom9Repeat " , & g_Config . CustomButton [ 9 ] , { 0 , 4 , 1 , false , false } , CfgFlag : : PER_GAME ) ,
2023-06-20 08:42:31 +00:00
ConfigSetting ( " Custom10Mapping " , " Custom10Image " , " Custom10Shape " , " Custom10Toggle " , " Custom10Repeat " , & g_Config . CustomButton [ 10 ] , { 0 , 0 , 2 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom11Mapping " , " Custom11Image " , " Custom11Shape " , " Custom11Toggle " , " Custom11Repeat " , & g_Config . CustomButton [ 11 ] , { 0 , 1 , 2 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom12Mapping " , " Custom12Image " , " Custom12Shape " , " Custom12Toggle " , " Custom12Repeat " , & g_Config . CustomButton [ 12 ] , { 0 , 2 , 2 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom13Mapping " , " Custom13Image " , " Custom13Shape " , " Custom13Toggle " , " Custom13Repeat " , & g_Config . CustomButton [ 13 ] , { 0 , 3 , 2 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom14Mapping " , " Custom14Image " , " Custom14Shape " , " Custom14Toggle " , " Custom14Repeat " , & g_Config . CustomButton [ 14 ] , { 0 , 4 , 2 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom15Mapping " , " Custom15Image " , " Custom15Shape " , " Custom15Toggle " , " Custom15Repeat " , & g_Config . CustomButton [ 15 ] , { 0 , 0 , 9 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom16Mapping " , " Custom16Image " , " Custom16Shape " , " Custom16Toggle " , " Custom16Repeat " , & g_Config . CustomButton [ 16 ] , { 0 , 1 , 9 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom17Mapping " , " Custom17Image " , " Custom17Shape " , " Custom17Toggle " , " Custom17Repeat " , & g_Config . CustomButton [ 17 ] , { 0 , 2 , 9 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom18Mapping " , " Custom18Image " , " Custom18Shape " , " Custom18Toggle " , " Custom18Repeat " , & g_Config . CustomButton [ 18 ] , { 0 , 3 , 9 , false , false } , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " Custom19Mapping " , " Custom19Image " , " Custom19Shape " , " Custom19Toggle " , " Custom19Repeat " , & g_Config . CustomButton [ 19 ] , { 0 , 4 , 9 , false , false } , CfgFlag : : PER_GAME ) ,
// Combo keys are something else, but I don't want to break the config backwards compatibility so these will stay wrongly named.
2023-06-20 07:30:38 +00:00
ConfigSetting ( " fcombo0X " , " fcombo0Y " , " comboKeyScale0 " , " ShowComboKey0 " , & g_Config . touchCustom [ 0 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo1X " , " fcombo1Y " , " comboKeyScale1 " , " ShowComboKey1 " , & g_Config . touchCustom [ 1 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo2X " , " fcombo2Y " , " comboKeyScale2 " , " ShowComboKey2 " , & g_Config . touchCustom [ 2 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo3X " , " fcombo3Y " , " comboKeyScale3 " , " ShowComboKey3 " , & g_Config . touchCustom [ 3 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo4X " , " fcombo4Y " , " comboKeyScale4 " , " ShowComboKey4 " , & g_Config . touchCustom [ 4 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo5X " , " fcombo5Y " , " comboKeyScale5 " , " ShowComboKey5 " , & g_Config . touchCustom [ 5 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo6X " , " fcombo6Y " , " comboKeyScale6 " , " ShowComboKey6 " , & g_Config . touchCustom [ 6 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo7X " , " fcombo7Y " , " comboKeyScale7 " , " ShowComboKey7 " , & g_Config . touchCustom [ 7 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo8X " , " fcombo8Y " , " comboKeyScale8 " , " ShowComboKey8 " , & g_Config . touchCustom [ 8 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo9X " , " fcombo9Y " , " comboKeyScale9 " , " ShowComboKey9 " , & g_Config . touchCustom [ 9 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
2023-06-20 08:42:31 +00:00
ConfigSetting ( " fcombo10X " , " fcombo10Y " , " comboKeyScale10 " , " ShowComboKey10 " , & g_Config . touchCustom [ 10 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo11X " , " fcombo11Y " , " comboKeyScale11 " , " ShowComboKey11 " , & g_Config . touchCustom [ 11 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo12X " , " fcombo12Y " , " comboKeyScale12 " , " ShowComboKey12 " , & g_Config . touchCustom [ 12 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo13X " , " fcombo13Y " , " comboKeyScale13 " , " ShowComboKey13 " , & g_Config . touchCustom [ 13 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo14X " , " fcombo14Y " , " comboKeyScale14 " , " ShowComboKey14 " , & g_Config . touchCustom [ 14 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo15X " , " fcombo15Y " , " comboKeyScale15 " , " ShowComboKey15 " , & g_Config . touchCustom [ 15 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo16X " , " fcombo16Y " , " comboKeyScale16 " , " ShowComboKey16 " , & g_Config . touchCustom [ 16 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo17X " , " fcombo17Y " , " comboKeyScale17 " , " ShowComboKey17 " , & g_Config . touchCustom [ 17 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo18X " , " fcombo18Y " , " comboKeyScale18 " , " ShowComboKey18 " , & g_Config . touchCustom [ 18 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " fcombo19X " , " fcombo19Y " , " comboKeyScale19 " , " ShowComboKey19 " , & g_Config . touchCustom [ 19 ] , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
2020-02-12 14:48:49 +00:00
2014-06-23 22:45:24 +00:00
# if defined(_WIN32)
// A win32 user seeing touch controls is likely using PPSSPP on a tablet. There it makes
// sense to default this to on.
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ShowTouchPause " , & g_Config . bShowTouchPause , true , CfgFlag : : DEFAULT ) ,
2014-06-23 22:45:24 +00:00
# else
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ShowTouchPause " , & g_Config . bShowTouchPause , false , CfgFlag : : DEFAULT ) ,
2014-02-25 06:39:10 +00:00
# endif
2014-02-10 01:08:40 +00:00
# if defined(USING_WIN_UI)
2023-04-05 14:23:31 +00:00
ConfigSetting ( " IgnoreWindowsKey " , & g_Config . bIgnoreWindowsKey , false , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
# endif
2022-07-07 16:20:12 +00:00
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ShowTouchControls " , & g_Config . bShowTouchControls , & DefaultShowTouchControls , CfgFlag : : PER_GAME ) ,
2022-07-07 16:20:12 +00:00
2014-02-10 01:08:40 +00:00
// ConfigSetting("KeyMapping", &g_Config.iMappingMap, 0),
# ifdef MOBILE_DEVICE
2023-04-05 14:23:31 +00:00
ConfigSetting ( " TiltBaseAngleY " , & g_Config . fTiltBaseAngleY , 0.9f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TiltInvertX " , & g_Config . bInvertTiltX , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TiltInvertY " , & g_Config . bInvertTiltY , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TiltSensitivityX " , & g_Config . iTiltSensitivityX , 60 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TiltSensitivityY " , & g_Config . iTiltSensitivityY , 60 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TiltAnalogDeadzoneRadius " , & g_Config . fTiltAnalogDeadzoneRadius , 0.0f , CfgFlag : : PER_GAME ) ,
2023-05-22 08:13:57 +00:00
ConfigSetting ( " TiltInverseDeadzone " , & g_Config . fTiltInverseDeadzone , 0.0f , CfgFlag : : PER_GAME ) ,
2023-05-22 08:39:08 +00:00
ConfigSetting ( " TiltCircularInverseDeadzone " , & g_Config . bTiltCircularInverseDeadzone , true , CfgFlag : : PER_GAME ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " TiltInputType " , & g_Config . iTiltInputType , 0 , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
# endif
2023-04-05 14:23:31 +00:00
ConfigSetting ( " DisableDpadDiagonals " , & g_Config . bDisableDpadDiagonals , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " GamepadOnlyFocused " , & g_Config . bGamepadOnlyFocused , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TouchButtonStyle " , & g_Config . iTouchButtonStyle , 1 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TouchButtonOpacity " , & g_Config . iTouchButtonOpacity , 65 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TouchButtonHideSeconds " , & g_Config . iTouchButtonHideSeconds , 20 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AutoCenterTouchAnalog " , & g_Config . bAutoCenterTouchAnalog , false , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
2019-12-18 23:41:32 +00:00
// Snap touch control position
2023-04-05 14:23:31 +00:00
ConfigSetting ( " TouchSnapToGrid " , & g_Config . bTouchSnapToGrid , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TouchSnapGridSize " , & g_Config . iTouchSnapGridSize , 64 , CfgFlag : : PER_GAME ) ,
2019-12-18 23:41:32 +00:00
2014-02-10 01:08:40 +00:00
// -1.0f means uninitialized, set in GamepadEmu::CreatePadLayout().
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ActionButtonSpacing2 " , & g_Config . fActionButtonSpacing , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ActionButtonCenterX " , " ActionButtonCenterY " , " ActionButtonScale " , nullptr , & g_Config . touchActionButtonCenter , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DPadX " , " DPadY " , " DPadScale " , " ShowTouchDpad " , & g_Config . touchDpad , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
// Note: these will be overwritten if DPadRadius is set.
2023-04-05 14:23:31 +00:00
ConfigSetting ( " DPadSpacing " , & g_Config . fDpadSpacing , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " StartKeyX " , " StartKeyY " , " StartKeyScale " , " ShowTouchStart " , & g_Config . touchStartKey , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SelectKeyX " , " SelectKeyY " , " SelectKeyScale " , " ShowTouchSelect " , & g_Config . touchSelectKey , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " UnthrottleKeyX " , " UnthrottleKeyY " , " UnthrottleKeyScale " , " ShowTouchUnthrottle " , & g_Config . touchFastForwardKey , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " LKeyX " , " LKeyY " , " LKeyScale " , " ShowTouchLTrigger " , & g_Config . touchLKey , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RKeyX " , " RKeyY " , " RKeyScale " , " ShowTouchRTrigger " , & g_Config . touchRKey , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogStickX " , " AnalogStickY " , " AnalogStickScale " , " ShowAnalogStick " , & g_Config . touchAnalogStick , defaultTouchPosShow , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightAnalogStickX " , " RightAnalogStickY " , " RightAnalogStickScale " , " ShowRightAnalogStick " , & g_Config . touchRightAnalogStick , defaultTouchPosHide , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogDeadzone " , & g_Config . fAnalogDeadzone , 0.15f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogInverseDeadzone " , & g_Config . fAnalogInverseDeadzone , 0.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogSensitivity " , & g_Config . fAnalogSensitivity , 1.1f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogIsCircular " , & g_Config . bAnalogIsCircular , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " AnalogAutoRotSpeed " , & g_Config . fAnalogAutoRotSpeed , 8.0f , CfgFlag : : PER_GAME ) ,
2023-04-15 15:36:55 +00:00
ConfigSetting ( " AnalogLimiterDeadzone " , & g_Config . fAnalogLimiterDeadzone , 0.6f , CfgFlag : : DEFAULT ) ,
2023-04-05 14:23:31 +00:00
2023-07-07 08:33:27 +00:00
ConfigSetting ( " AllowMappingCombos " , & g_Config . bAllowMappingCombos , false , CfgFlag : : DEFAULT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " LeftStickHeadScale " , & g_Config . fLeftStickHeadScale , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " RightStickHeadScale " , & g_Config . fRightStickHeadScale , 1.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " HideStickBackground " , & g_Config . bHideStickBackground , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " UseMouse " , & g_Config . bMouseControl , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MapMouse " , & g_Config . bMapMouse , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ConfineMap " , & g_Config . bMouseConfine , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MouseSensitivity " , & g_Config . fMouseSensitivity , 0.1f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MouseSmoothing " , & g_Config . fMouseSmoothing , 0.9f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " SystemControls " , & g_Config . bSystemControls , true , CfgFlag : : DEFAULT ) ,
2023-07-23 09:49:25 +00:00
ConfigSetting ( " RapidFileInterval " , & g_Config . iRapidFireInterval , 5 , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting networkSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " EnableWlan " , & g_Config . bEnableWlan , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " EnableAdhocServer " , & g_Config . bEnableAdhocServer , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " proAdhocServer " , & g_Config . proAdhocServer , " socom.cc " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " PortOffset " , & g_Config . iPortOffset , 10000 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MinTimeout " , & g_Config . iMinTimeout , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ForcedFirstConnect " , & g_Config . bForcedFirstConnect , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " EnableUPnP " , & g_Config . bEnableUPnP , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " UPnPUseOriginalPort " , & g_Config . bUPnPUseOriginalPort , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " EnableNetworkChat " , & g_Config . bEnableNetworkChat , false , CfgFlag : : PER_GAME ) ,
2023-07-16 09:03:49 +00:00
ConfigSetting ( " ChatButtonPosition " , & g_Config . iChatButtonPosition , ( int ) ScreenEdgePosition : : BOTTOM_LEFT , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ChatScreenPosition " , & g_Config . iChatScreenPosition , ( int ) ScreenEdgePosition : : BOTTOM_LEFT , CfgFlag : : PER_GAME ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " EnableQuickChat " , & g_Config . bEnableQuickChat , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " QuickChat1 " , & g_Config . sQuickChat0 , " Quick Chat 1 " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " QuickChat2 " , & g_Config . sQuickChat1 , " Quick Chat 2 " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " QuickChat3 " , & g_Config . sQuickChat2 , " Quick Chat 3 " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " QuickChat4 " , & g_Config . sQuickChat3 , " Quick Chat 4 " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " QuickChat5 " , & g_Config . sQuickChat4 , " Quick Chat 5 " , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting systemParamSettings [ ] = {
2023-04-05 14:27:44 +00:00
ConfigSetting ( " PSPModel " , & g_Config . iPSPModel , PSP_MODEL_SLIM , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
ConfigSetting ( " PSPFirmwareVersion " , & g_Config . iFirmwareVersion , PSP_DEFAULT_FIRMWARE , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " NickName " , & g_Config . sNickName , " PPSSPP " , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " MacAddress " , & g_Config . sMACAddress , " " , CfgFlag : : PER_GAME ) ,
2023-07-23 09:05:08 +00:00
ConfigSetting ( " GameLanguage " , & g_Config . iLanguage , - 1 , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ParamTimeFormat " , & g_Config . iTimeFormat , PSP_SYSTEMPARAM_TIME_FORMAT_24HR , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " ParamDateFormat " , & g_Config . iDateFormat , PSP_SYSTEMPARAM_DATE_FORMAT_YYYYMMDD , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " TimeZone " , & g_Config . iTimeZone , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " DayLightSavings " , & g_Config . bDayLightSavings , ( bool ) PSP_SYSTEMPARAM_DAYLIGHTSAVINGS_STD , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " ButtonPreference " , & g_Config . iButtonPreference , PSP_SYSTEMPARAM_BUTTON_CROSS , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " LockParentalLevel " , & g_Config . iLockParentalLevel , 0 , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " WlanAdhocChannel " , & g_Config . iWlanAdhocChannel , PSP_SYSTEMPARAM_ADHOC_CHANNEL_AUTOMATIC , CfgFlag : : PER_GAME ) ,
2020-03-10 00:36:52 +00:00
# if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(ANDROID)
2023-04-05 14:23:31 +00:00
ConfigSetting ( " BypassOSKWithKeyboard " , & g_Config . bBypassOSKWithKeyboard , false , CfgFlag : : PER_GAME ) ,
2014-02-10 01:08:40 +00:00
# endif
2023-04-05 14:23:31 +00:00
ConfigSetting ( " WlanPowerSave " , & g_Config . bWlanPowerSave , ( bool ) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF , CfgFlag : : PER_GAME ) ,
2023-04-05 14:27:44 +00:00
ConfigSetting ( " EncryptSave " , & g_Config . bEncryptSave , true , CfgFlag : : PER_GAME | CfgFlag : : REPORT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " SavedataUpgradeVersion " , & g_Config . bSavedataUpgrade , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " MemStickSize " , & g_Config . iMemStickSizeGB , 16 , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting debuggerSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " DisasmWindowX " , & g_Config . iDisasmWindowX , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DisasmWindowY " , & g_Config . iDisasmWindowY , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DisasmWindowW " , & g_Config . iDisasmWindowW , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DisasmWindowH " , & g_Config . iDisasmWindowH , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowX " , & g_Config . iGEWindowX , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowY " , & g_Config . iGEWindowY , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowW " , & g_Config . iGEWindowW , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowH " , & g_Config . iGEWindowH , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowTabsBL " , & g_Config . uGETabsLeft , ( uint32_t ) 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowTabsBR " , & g_Config . uGETabsRight , ( uint32_t ) 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " GEWindowTabsTR " , & g_Config . uGETabsTopRight , ( uint32_t ) 0 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ConsoleWindowX " , & g_Config . iConsoleWindowX , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ConsoleWindowY " , & g_Config . iConsoleWindowY , - 1 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " FontWidth " , & g_Config . iFontWidth , 8 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " FontHeight " , & g_Config . iFontHeight , 12 , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DisplayStatusBar " , & g_Config . bDisplayStatusBar , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ShowBottomTabTitles " , & g_Config . bShowBottomTabTitles , true , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " ShowDeveloperMenu " , & g_Config . bShowDeveloperMenu , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " SkipDeadbeefFilling " , & g_Config . bSkipDeadbeefFilling , false , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " FuncHashMap " , & g_Config . bFuncHashMap , false , CfgFlag : : DEFAULT ) ,
2023-04-29 17:24:35 +00:00
ConfigSetting ( " SkipFuncHashMap " , & g_Config . sSkipFuncHashMap , " " , CfgFlag : : DEFAULT ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " MemInfoDetailed " , & g_Config . bDebugMemInfoDetailed , false , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting jitSettings [ ] = {
2023-04-05 14:27:44 +00:00
ConfigSetting ( " DiscardRegsOnJRRA " , & g_Config . bDiscardRegsOnJRRA , false , CfgFlag : : DONT_SAVE | CfgFlag : : REPORT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting upgradeSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " UpgradeMessage " , & g_Config . upgradeMessage , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " UpgradeVersion " , & g_Config . upgradeVersion , " " , CfgFlag : : DEFAULT ) ,
ConfigSetting ( " DismissedVersion " , & g_Config . dismissedVersion , " " , CfgFlag : : DEFAULT ) ,
2014-02-10 01:08:40 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSetting themeSettings [ ] = {
2023-04-05 14:23:31 +00:00
ConfigSetting ( " ThemeName " , & g_Config . sThemeName , " Default " , CfgFlag : : DEFAULT ) ,
2017-03-26 16:51:33 +00:00
} ;
2022-07-27 17:47:11 +00:00
2023-02-01 09:27:15 +00:00
static const ConfigSetting vrSettings [ ] = {
2023-05-27 08:50:15 +00:00
ConfigSetting ( " VREnable " , & g_Config . bEnableVR , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VREnable6DoF " , & g_Config . bEnable6DoF , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VREnableStereo " , & g_Config . bEnableStereo , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VREnableMotions " , & g_Config . bEnableMotions , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRForce72Hz " , & g_Config . bForce72Hz , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRManualForceVR " , & g_Config . bManualForceVR , false , CfgFlag : : PER_GAME ) ,
2023-06-17 19:55:47 +00:00
ConfigSetting ( " VRPassthrough " , & g_Config . bPassthrough , false , CfgFlag : : PER_GAME ) ,
2023-05-27 08:50:15 +00:00
ConfigSetting ( " VRRescaleHUD " , & g_Config . bRescaleHUD , true , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRCameraDistance " , & g_Config . fCameraDistance , 0.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRCameraHeight " , & g_Config . fCameraHeight , 0.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRCameraSide " , & g_Config . fCameraSide , 0.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRCameraPitch " , & g_Config . iCameraPitch , 0 , CfgFlag : : PER_GAME ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " VRCanvasDistance " , & g_Config . fCanvasDistance , 12.0f , CfgFlag : : DEFAULT ) ,
2023-07-12 17:33:29 +00:00
ConfigSetting ( " VRCanvas3DDistance " , & g_Config . fCanvas3DDistance , 3.0f , CfgFlag : : DEFAULT ) ,
2023-05-27 08:50:15 +00:00
ConfigSetting ( " VRFieldOfView " , & g_Config . fFieldOfViewPercentage , 100.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRHeadUpDisplayScale " , & g_Config . fHeadUpDisplayScale , 0.3f , CfgFlag : : PER_GAME ) ,
2023-04-05 14:23:31 +00:00
ConfigSetting ( " VRMotionLength " , & g_Config . fMotionLength , 0.5f , CfgFlag : : DEFAULT ) ,
2023-05-27 08:50:15 +00:00
ConfigSetting ( " VRHeadRotationScale " , & g_Config . fHeadRotationScale , 5.0f , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRHeadRotationEnabled " , & g_Config . bHeadRotationEnabled , false , CfgFlag : : PER_GAME ) ,
ConfigSetting ( " VRHeadRotationSmoothing " , & g_Config . bHeadRotationSmoothing , false , CfgFlag : : PER_GAME ) ,
2022-07-27 17:47:11 +00:00
} ;
2023-02-01 09:27:15 +00:00
static const ConfigSectionSettings sections [ ] = {
2023-02-01 09:45:03 +00:00
{ " General " , generalSettings , ARRAY_SIZE ( generalSettings ) } ,
{ " CPU " , cpuSettings , ARRAY_SIZE ( cpuSettings ) } ,
{ " Graphics " , graphicsSettings , ARRAY_SIZE ( graphicsSettings ) } ,
{ " Sound " , soundSettings , ARRAY_SIZE ( soundSettings ) } ,
{ " Control " , controlSettings , ARRAY_SIZE ( controlSettings ) } ,
{ " Network " , networkSettings , ARRAY_SIZE ( networkSettings ) } ,
{ " SystemParam " , systemParamSettings , ARRAY_SIZE ( systemParamSettings ) } ,
{ " Debugger " , debuggerSettings , ARRAY_SIZE ( debuggerSettings ) } ,
{ " JIT " , jitSettings , ARRAY_SIZE ( jitSettings ) } ,
{ " Upgrade " , upgradeSettings , ARRAY_SIZE ( upgradeSettings ) } ,
{ " Theme " , themeSettings , ARRAY_SIZE ( themeSettings ) } ,
{ " VR " , vrSettings , ARRAY_SIZE ( vrSettings ) } ,
2023-06-15 20:17:27 +00:00
{ " Achievements " , achievementSettings , ARRAY_SIZE ( achievementSettings ) } ,
2014-02-09 23:46:49 +00:00
} ;
2023-04-05 09:46:44 +00:00
const size_t numSections = ARRAY_SIZE ( sections ) ;
2023-02-01 09:27:15 +00:00
static void IterateSettings ( IniFile & iniFile , std : : function < void ( Section * section , const ConfigSetting & setting ) > func ) {
2023-04-05 09:46:44 +00:00
for ( size_t i = 0 ; i < numSections ; + + i ) {
2020-08-10 13:53:52 +00:00
Section * section = iniFile . GetOrCreateSection ( sections [ i ] . section ) ;
2023-02-01 09:45:03 +00:00
for ( size_t j = 0 ; j < sections [ i ] . settingsCount ; j + + ) {
func ( section , sections [ i ] . settings [ j ] ) ;
2016-01-06 07:01:49 +00:00
}
}
}
2023-02-01 10:01:48 +00:00
static void IterateSettings ( std : : function < void ( const ConfigSetting & setting ) > func ) {
2023-04-05 09:46:44 +00:00
for ( size_t i = 0 ; i < numSections ; + + i ) {
2023-02-01 10:01:48 +00:00
for ( size_t j = 0 ; j < sections [ i ] . settingsCount ; j + + ) {
func ( sections [ i ] . settings [ j ] ) ;
}
}
}
2022-07-12 06:46:09 +00:00
void ConfigPrivate : : ResetRecentIsosThread ( ) {
2022-07-12 05:01:06 +00:00
std : : lock_guard < std : : mutex > guard ( recentIsosThreadLock ) ;
2022-07-12 06:46:09 +00:00
if ( recentIsosThreadPending & & recentIsosThread . joinable ( ) )
2022-07-12 05:01:06 +00:00
recentIsosThread . join ( ) ;
}
2022-07-12 06:46:09 +00:00
void ConfigPrivate : : SetRecentIsosThread ( std : : function < void ( ) > f ) {
2022-07-12 05:01:06 +00:00
std : : lock_guard < std : : mutex > guard ( recentIsosThreadLock ) ;
2022-07-12 06:46:09 +00:00
if ( recentIsosThreadPending & & recentIsosThread . joinable ( ) )
2022-07-12 05:01:06 +00:00
recentIsosThread . join ( ) ;
recentIsosThread = std : : thread ( f ) ;
2022-07-12 06:46:09 +00:00
recentIsosThreadPending = true ;
2022-07-12 05:01:06 +00:00
}
2020-08-18 07:47:22 +00:00
Config : : Config ( ) {
2022-07-12 06:46:09 +00:00
private_ = new ConfigPrivate ( ) ;
2020-07-20 09:38:39 +00:00
}
Config : : ~ Config ( ) {
2020-08-18 07:47:22 +00:00
if ( bUpdatedInstanceCounter ) {
ShutdownInstanceCounter ( ) ;
}
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
delete private_ ;
2020-07-20 09:38:39 +00:00
}
2012-11-01 15:19:01 +00:00
2022-12-05 10:55:23 +00:00
void Config : : LoadLangValuesMapping ( ) {
2014-01-03 18:04:43 +00:00
IniFile mapping ;
2023-03-07 09:02:59 +00:00
mapping . LoadFromVFS ( g_VFS , " langregion.ini " ) ;
2014-01-03 18:04:43 +00:00
std : : vector < std : : string > keys ;
mapping . GetKeys ( " LangRegionNames " , keys ) ;
std : : map < std : : string , int > langCodeMapping ;
langCodeMapping [ " JAPANESE " ] = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE ;
langCodeMapping [ " ENGLISH " ] = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH ;
langCodeMapping [ " FRENCH " ] = PSP_SYSTEMPARAM_LANGUAGE_FRENCH ;
langCodeMapping [ " SPANISH " ] = PSP_SYSTEMPARAM_LANGUAGE_SPANISH ;
langCodeMapping [ " GERMAN " ] = PSP_SYSTEMPARAM_LANGUAGE_GERMAN ;
langCodeMapping [ " ITALIAN " ] = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN ;
langCodeMapping [ " DUTCH " ] = PSP_SYSTEMPARAM_LANGUAGE_DUTCH ;
langCodeMapping [ " PORTUGUESE " ] = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE ;
langCodeMapping [ " RUSSIAN " ] = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN ;
langCodeMapping [ " KOREAN " ] = PSP_SYSTEMPARAM_LANGUAGE_KOREAN ;
langCodeMapping [ " CHINESE_TRADITIONAL " ] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL ;
langCodeMapping [ " CHINESE_SIMPLIFIED " ] = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED ;
2022-12-05 11:07:07 +00:00
const Section * langRegionNames = mapping . GetOrCreateSection ( " LangRegionNames " ) ;
const Section * systemLanguage = mapping . GetOrCreateSection ( " SystemLanguage " ) ;
2014-01-03 18:04:43 +00:00
for ( size_t i = 0 ; i < keys . size ( ) ; i + + ) {
std : : string langName ;
langRegionNames - > Get ( keys [ i ] . c_str ( ) , & langName , " ERROR " ) ;
std : : string langCode ;
systemLanguage - > Get ( keys [ i ] . c_str ( ) , & langCode , " ENGLISH " ) ;
int iLangCode = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH ;
if ( langCodeMapping . find ( langCode ) ! = langCodeMapping . end ( ) )
iLangCode = langCodeMapping [ langCode ] ;
2022-12-05 10:55:23 +00:00
langValuesMapping_ [ keys [ i ] ] = std : : make_pair ( langName , iLangCode ) ;
}
}
const std : : map < std : : string , std : : pair < std : : string , int > > & Config : : GetLangValuesMapping ( ) {
if ( langValuesMapping_ . empty ( ) ) {
LoadLangValuesMapping ( ) ;
2014-01-03 18:04:43 +00:00
}
2022-12-05 10:55:23 +00:00
return langValuesMapping_ ;
2014-01-03 18:04:43 +00:00
}
2020-03-08 22:25:20 +00:00
void Config : : Reload ( ) {
reload_ = true ;
Load ( ) ;
reload_ = false ;
}
2021-05-29 20:55:43 +00:00
// Call this if you change the search path (such as when changing memstick directory. can't
// really think of any other legit uses).
void Config : : UpdateIniLocation ( const char * iniFileName , const char * controllerIniFilename ) {
2014-08-31 07:19:19 +00:00
const bool useIniFilename = iniFileName ! = nullptr & & strlen ( iniFileName ) > 0 ;
2022-12-07 20:40:13 +00:00
const char * ppssppIniFilename = IsVREnabled ( ) ? " ppssppvr.ini " : " ppsspp.ini " ;
iniFilename_ = FindConfigFile ( useIniFilename ? iniFileName : ppssppIniFilename ) ;
2021-05-29 20:55:43 +00:00
const bool useControllerIniFilename = controllerIniFilename ! = nullptr & & strlen ( controllerIniFilename ) > 0 ;
2022-12-07 20:40:13 +00:00
const char * controlsIniFilename = IsVREnabled ( ) ? " controlsvr.ini " : " controls.ini " ;
controllerIniFilename_ = FindConfigFile ( useControllerIniFilename ? controllerIniFilename : controlsIniFilename ) ;
2021-05-29 20:55:43 +00:00
}
2014-08-31 05:17:25 +00:00
2022-10-09 13:04:19 +00:00
bool Config : : LoadAppendedConfig ( ) {
IniFile iniFile ;
if ( ! iniFile . Load ( appendedConfigFileName_ ) ) {
ERROR_LOG ( LOADER , " Failed to read appended config '%s'. " , appendedConfigFileName_ . c_str ( ) ) ;
return false ;
}
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ & iniFile ] ( Section * section , const ConfigSetting & setting ) {
if ( iniFile . Exists ( section - > name ( ) . c_str ( ) , setting . iniKey_ ) )
setting . Get ( section ) ;
2022-10-09 13:04:19 +00:00
} ) ;
INFO_LOG ( LOADER , " Loaded appended config '%s'. " , appendedConfigFileName_ . c_str ( ) ) ;
Save ( " Loaded appended config " ) ; // Let's prevent reset
return true ;
}
void Config : : SetAppendedConfigIni ( const Path & path ) {
appendedConfigFileName_ = path ;
}
2023-02-14 16:11:32 +00:00
void Config : : UpdateAfterSettingAutoFrameSkip ( ) {
2023-02-06 19:17:27 +00:00
if ( bAutoFrameSkip & & iFrameSkip = = 0 ) {
iFrameSkip = 1 ;
}
if ( bAutoFrameSkip & & bSkipBufferEffects ) {
bSkipBufferEffects = false ;
}
}
2022-10-09 13:04:19 +00:00
2021-05-29 20:55:43 +00:00
void Config : : Load ( const char * iniFileName , const char * controllerIniFilename ) {
2020-08-18 07:47:22 +00:00
if ( ! bUpdatedInstanceCounter ) {
InitInstanceCounter ( ) ;
bUpdatedInstanceCounter = true ;
}
2023-07-14 13:24:34 +00:00
g_DownloadManager . SetUserAgent ( StringFromFormat ( " PPSSPP/%s " , PPSSPP_GIT_VERSION ) ) ;
2021-05-29 20:55:43 +00:00
UpdateIniLocation ( iniFileName , controllerIniFilename ) ;
2013-09-15 16:50:42 +00:00
2013-09-15 23:01:46 +00:00
INFO_LOG ( LOADER , " Loading config: %s " , iniFilename_ . c_str ( ) ) ;
2012-11-01 15:19:01 +00:00
bSaveSettings = true ;
IniFile iniFile ;
2022-12-17 16:44:40 +00:00
if ( ! iniFile . Load ( iniFilename_ ) ) {
2018-03-24 11:51:54 +00:00
ERROR_LOG ( LOADER , " Failed to read '%s'. Setting config to default. " , iniFilename_ . c_str ( ) ) ;
2013-01-04 09:26:14 +00:00
// Continue anyway to initialize the config.
}
2012-11-01 15:19:01 +00:00
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ ] ( Section * section , const ConfigSetting & setting ) {
setting . Get ( section ) ;
2016-01-06 07:01:49 +00:00
} ) ;
2014-02-09 23:46:49 +00:00
2013-11-26 09:24:31 +00:00
iRunCount + + ;
2021-04-24 16:36:25 +00:00
// This check is probably not really necessary here anyway, you can always
// press Home or Browse if you're in a bad directory.
if ( ! File : : Exists ( currentDirectory ) )
2021-05-29 22:20:41 +00:00
currentDirectory = defaultCurrentDirectory ;
2013-10-25 16:44:19 +00:00
2020-08-10 13:53:52 +00:00
Section * log = iniFile . GetOrCreateSection ( logSectionName ) ;
2017-03-06 10:44:35 +00:00
2021-06-06 08:50:58 +00:00
bool debugDefaults = false ;
2017-03-06 10:44:35 +00:00
# ifdef _DEBUG
debugDefaults = true ;
# endif
LogManager : : GetInstance ( ) - > LoadConfig ( log , debugDefaults ) ;
2020-08-10 13:53:52 +00:00
Section * recent = iniFile . GetOrCreateSection ( " Recent " ) ;
2021-08-09 07:22:55 +00:00
recent - > Get ( " MaxRecent " , & iMaxRecent , 60 ) ;
2013-10-25 09:45:41 +00:00
2013-08-30 17:48:56 +00:00
// Fix issue from switching from uint (hex in .ini) to int (dec)
2014-06-29 03:21:36 +00:00
// -1 is okay, though. We'll just ignore recent stuff if it is.
2015-09-23 17:29:39 +00:00
if ( iMaxRecent = = 0 )
2021-08-09 07:22:55 +00:00
iMaxRecent = 60 ;
2013-08-30 17:48:56 +00:00
2015-09-23 17:29:39 +00:00
if ( iMaxRecent > 0 ) {
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2015-09-23 17:29:39 +00:00
recentIsos . clear ( ) ;
for ( int i = 0 ; i < iMaxRecent ; i + + ) {
char keyName [ 64 ] ;
std : : string fileName ;
snprintf ( keyName , sizeof ( keyName ) , " FileName%d " , i ) ;
if ( recent - > Get ( keyName , & fileName , " " ) & & ! fileName . empty ( ) ) {
recentIsos . push_back ( fileName ) ;
}
}
}
2012-12-21 15:49:02 +00:00
2013-12-08 06:39:35 +00:00
auto pinnedPaths = iniFile . GetOrCreateSection ( " PinnedPaths " ) - > ToMap ( ) ;
vPinnedPaths . clear ( ) ;
2014-02-10 00:11:16 +00:00
for ( auto it = pinnedPaths . begin ( ) , end = pinnedPaths . end ( ) ; it ! = end ; + + it ) {
2018-09-05 04:53:20 +00:00
// Unpin paths that are deleted automatically.
2019-10-06 16:31:06 +00:00
const std : : string & path = it - > second ;
2021-05-09 13:02:46 +00:00
if ( startsWith ( path , " http:// " ) | | startsWith ( path , " https:// " ) | | File : : Exists ( Path ( path ) ) ) {
2019-10-06 16:31:06 +00:00
vPinnedPaths . push_back ( File : : ResolvePath ( path ) ) ;
2018-09-05 04:53:20 +00:00
}
2013-12-08 06:39:35 +00:00
}
2022-12-11 11:35:52 +00:00
// Default values for post process shaders
bool postShadersInitialized = iniFile . HasSection ( " PostShaderList " ) ;
Section * postShaderChain = iniFile . GetOrCreateSection ( " PostShaderList " ) ;
Section * postShaderSetting = iniFile . GetOrCreateSection ( " PostShaderSetting " ) ;
if ( IsVREnabled ( ) & & ! postShadersInitialized ) {
postShaderChain - > Set ( " PostShader1 " , " ColorCorrection " ) ;
2022-12-13 03:11:20 +00:00
postShaderSetting - > Set ( " ColorCorrectionSettingCurrentValue1 " , 1.0f ) ;
postShaderSetting - > Set ( " ColorCorrectionSettingCurrentValue2 " , 1.5f ) ;
postShaderSetting - > Set ( " ColorCorrectionSettingCurrentValue3 " , 1.1f ) ;
postShaderSetting - > Set ( " ColorCorrectionSettingCurrentValue4 " , 1.0f ) ;
2022-12-11 11:35:52 +00:00
}
// Load post process shader values
2020-05-15 22:52:38 +00:00
mPostShaderSetting . clear ( ) ;
2022-12-11 11:35:52 +00:00
for ( const auto & it : postShaderSetting - > ToMap ( ) ) {
2020-05-16 07:27:53 +00:00
mPostShaderSetting [ it . first ] = std : : stof ( it . second ) ;
2020-05-15 22:52:38 +00:00
}
2022-12-11 11:35:52 +00:00
// Load post process shader names
2020-05-18 09:17:45 +00:00
vPostShaderNames . clear ( ) ;
2022-12-11 11:35:52 +00:00
for ( const auto & it : postShaderChain - > ToMap ( ) ) {
2021-04-11 01:35:23 +00:00
if ( it . second ! = " Off " )
vPostShaderNames . push_back ( it . second ) ;
2020-05-18 09:17:45 +00:00
}
2013-12-12 13:52:46 +00:00
// Check for an old dpad setting
2020-08-10 13:53:52 +00:00
Section * control = iniFile . GetOrCreateSection ( " Control " ) ;
2013-12-12 13:52:46 +00:00
float f ;
control - > Get ( " DPadRadius " , & f , 0.0f ) ;
if ( f > 0.0f ) {
ResetControlLayout ( ) ;
}
2013-11-05 04:52:31 +00:00
2014-08-16 20:31:07 +00:00
const char * gitVer = PPSSPP_GIT_VERSION ;
Version installed ( gitVer ) ;
Version upgrade ( upgradeVersion ) ;
const bool versionsValid = installed . IsValid ( ) & & upgrade . IsValid ( ) ;
// Do this regardless of iRunCount to prevent a silly bug where one might use an older
// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
// even if said newer version is >= the upgrade found online.
if ( ( dismissedVersion = = upgradeVersion ) | | ( versionsValid & & ( installed > = upgrade ) ) ) {
2022-09-30 09:26:30 +00:00
upgradeMessage . clear ( ) ;
2013-11-26 13:04:29 +00:00
}
2014-02-10 01:08:40 +00:00
// Check for new version on every 10 runs.
2013-11-26 13:04:29 +00:00
// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
// splash screen quickly), but then we'll just show the notification next time instead, we store the
// upgrade number in the ini.
2013-12-12 21:30:06 +00:00
if ( iRunCount % 10 = = 0 & & bCheckForNewVersion ) {
2021-08-22 15:29:48 +00:00
const char * versionUrl = " http://www.ppsspp.org/version.json " ;
const char * acceptMime = " application/json, text/*; q=0.9, */*; q=0.8 " ;
2023-07-20 09:25:27 +00:00
g_DownloadManager . StartDownloadWithCallback ( versionUrl , Path ( ) , http : : ProgressBarMode : : NONE , & DownloadCompletedCallback , " version " , acceptMime ) ;
2013-11-26 13:04:29 +00:00
}
2013-09-15 23:01:46 +00:00
INFO_LOG ( LOADER , " Loading controller config: %s " , controllerIniFilename_ . c_str ( ) ) ;
2013-08-16 17:34:44 +00:00
bSaveSettings = true ;
2016-01-06 07:01:49 +00:00
LoadStandardControllerIni ( ) ;
2016-08-27 18:38:05 +00:00
2014-12-14 19:33:20 +00:00
//so this is all the way down here to overwrite the controller settings
//sadly it won't benefit from all the "version conversion" going on up-above
//but these configs shouldn't contain older versions anyhow
2017-03-06 10:44:35 +00:00
if ( bGameSpecific ) {
2019-07-18 04:28:21 +00:00
loadGameConfig ( gameId_ , gameIdTitle_ ) ;
2014-12-14 19:33:20 +00:00
}
2013-08-16 17:34:44 +00:00
2013-04-13 19:24:07 +00:00
CleanRecent ( ) ;
2014-09-14 10:59:27 +00:00
2022-12-17 16:54:31 +00:00
PostLoadCleanup ( false ) ;
2020-07-20 09:38:39 +00:00
INFO_LOG ( LOADER , " Config loaded: '%s' " , iniFilename_ . c_str ( ) ) ;
2012-11-01 15:19:01 +00:00
}
2021-07-25 13:33:11 +00:00
bool Config : : Save ( const char * saveReason ) {
2020-07-20 09:38:39 +00:00
if ( ! IsFirstInstance ( ) ) {
// TODO: Should we allow saving config if started from a different directory?
// How do we tell?
WARN_LOG ( LOADER , " Not saving config - secondary instances don't. " ) ;
2021-07-25 13:33:11 +00:00
// Don't want to retry or something.
return true ;
2020-07-20 09:38:39 +00:00
}
2021-05-05 23:31:38 +00:00
if ( ! iniFilename_ . empty ( ) & & g_Config . bSaveSettings ) {
2019-07-14 22:04:09 +00:00
saveGameConfig ( gameId_ , gameIdTitle_ ) ;
2014-12-14 19:33:20 +00:00
2022-12-17 16:54:31 +00:00
PreSaveCleanup ( false ) ;
2013-04-13 19:24:07 +00:00
CleanRecent ( ) ;
2012-11-01 15:19:01 +00:00
IniFile iniFile ;
2021-05-05 23:31:38 +00:00
if ( ! iniFile . Load ( iniFilename_ ) ) {
2023-08-18 13:04:20 +00:00
WARN_LOG ( LOADER , " Likely saving config for first time - couldn't read ini '%s' " , iniFilename_ . c_str ( ) ) ;
2013-01-04 09:26:14 +00:00
}
2012-11-01 15:19:01 +00:00
2013-06-01 17:01:43 +00:00
// Need to do this somewhere...
bFirstRun = false ;
2014-02-04 11:58:37 +00:00
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ & ] ( Section * section , const ConfigSetting & setting ) {
2023-04-05 14:23:31 +00:00
if ( ! bGameSpecific | | ! setting . PerGame ( ) ) {
2023-02-01 09:27:15 +00:00
setting . Set ( section ) ;
2014-02-09 23:46:49 +00:00
}
2016-01-06 07:01:49 +00:00
} ) ;
2013-11-29 13:20:37 +00:00
2020-08-10 13:53:52 +00:00
Section * recent = iniFile . GetOrCreateSection ( " Recent " ) ;
2013-08-30 17:48:56 +00:00
recent - > Set ( " MaxRecent " , iMaxRecent ) ;
2013-11-29 13:20:37 +00:00
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
2013-09-08 05:31:22 +00:00
for ( int i = 0 ; i < iMaxRecent ; i + + ) {
2013-08-30 17:48:56 +00:00
char keyName [ 64 ] ;
2014-09-13 22:14:11 +00:00
snprintf ( keyName , sizeof ( keyName ) , " FileName%d " , i ) ;
2022-07-12 06:46:09 +00:00
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2013-09-08 05:31:22 +00:00
if ( i < ( int ) recentIsos . size ( ) ) {
2013-09-05 16:45:41 +00:00
recent - > Set ( keyName , recentIsos [ i ] ) ;
2013-09-08 05:31:22 +00:00
} else {
2013-09-05 16:45:41 +00:00
recent - > Delete ( keyName ) ; // delete the nonexisting FileName
2013-11-29 13:20:37 +00:00
}
2013-08-30 17:48:56 +00:00
}
2013-03-01 16:51:01 +00:00
2020-08-10 13:53:52 +00:00
Section * pinnedPaths = iniFile . GetOrCreateSection ( " PinnedPaths " ) ;
2013-12-08 06:39:35 +00:00
pinnedPaths - > Clear ( ) ;
for ( size_t i = 0 ; i < vPinnedPaths . size ( ) ; + + i ) {
char keyName [ 64 ] ;
2013-12-30 00:08:06 +00:00
snprintf ( keyName , sizeof ( keyName ) , " Path%d " , ( int ) i ) ;
2013-12-08 06:39:35 +00:00
pinnedPaths - > Set ( keyName , vPinnedPaths [ i ] ) ;
}
2020-05-15 22:52:38 +00:00
if ( ! bGameSpecific ) {
2020-08-10 13:53:52 +00:00
Section * postShaderSetting = iniFile . GetOrCreateSection ( " PostShaderSetting " ) ;
2020-05-15 22:52:38 +00:00
postShaderSetting - > Clear ( ) ;
for ( auto it = mPostShaderSetting . begin ( ) , end = mPostShaderSetting . end ( ) ; it ! = end ; + + it ) {
postShaderSetting - > Set ( it - > first . c_str ( ) , it - > second ) ;
}
2020-05-18 09:17:45 +00:00
Section * postShaderChain = iniFile . GetOrCreateSection ( " PostShaderList " ) ;
postShaderChain - > Clear ( ) ;
for ( size_t i = 0 ; i < vPostShaderNames . size ( ) ; + + i ) {
char keyName [ 64 ] ;
snprintf ( keyName , sizeof ( keyName ) , " PostShader%d " , ( int ) i + 1 ) ;
postShaderChain - > Set ( keyName , vPostShaderNames [ i ] ) ;
}
2020-05-15 22:52:38 +00:00
}
2020-08-10 13:53:52 +00:00
Section * control = iniFile . GetOrCreateSection ( " Control " ) ;
2013-12-12 13:52:46 +00:00
control - > Delete ( " DPadRadius " ) ;
2013-11-26 13:04:29 +00:00
2020-08-10 13:53:52 +00:00
Section * log = iniFile . GetOrCreateSection ( logSectionName ) ;
2017-04-15 23:30:37 +00:00
if ( LogManager : : GetInstance ( ) )
LogManager : : GetInstance ( ) - > SaveConfig ( log ) ;
2017-03-06 10:44:35 +00:00
2021-05-05 23:31:38 +00:00
if ( ! iniFile . Save ( iniFilename_ ) ) {
2019-02-23 09:49:49 +00:00
ERROR_LOG ( LOADER , " Error saving config (%s)- can't write ini '%s' " , saveReason , iniFilename_ . c_str ( ) ) ;
2021-07-25 13:33:11 +00:00
return false ;
2013-01-04 09:26:14 +00:00
}
2019-02-23 09:49:49 +00:00
INFO_LOG ( LOADER , " Config saved (%s): '%s' " , saveReason , iniFilename_ . c_str ( ) ) ;
2013-08-16 17:34:44 +00:00
2014-12-14 19:33:20 +00:00
if ( ! bGameSpecific ) //otherwise we already did this in saveGameConfig()
{
IniFile controllerIniFile ;
2021-05-05 23:31:38 +00:00
if ( ! controllerIniFile . Load ( controllerIniFilename_ ) ) {
2021-05-13 08:24:49 +00:00
ERROR_LOG ( LOADER , " Error saving controller config - can't read ini first '%s' " , controllerIniFilename_ . c_str ( ) ) ;
2014-12-14 19:33:20 +00:00
}
KeyMap : : SaveToIni ( controllerIniFile ) ;
2021-05-05 23:31:38 +00:00
if ( ! controllerIniFile . Save ( controllerIniFilename_ ) ) {
2018-03-24 11:51:54 +00:00
ERROR_LOG ( LOADER , " Error saving config - can't write ini '%s' " , controllerIniFilename_ . c_str ( ) ) ;
2021-07-25 13:33:11 +00:00
return false ;
2014-12-14 19:33:20 +00:00
}
INFO_LOG ( LOADER , " Controller config saved: %s " , controllerIniFilename_ . c_str ( ) ) ;
2013-08-16 17:34:44 +00:00
}
2022-12-17 16:54:31 +00:00
PostSaveCleanup ( false ) ;
2012-11-04 10:54:45 +00:00
} else {
2013-01-04 09:26:14 +00:00
INFO_LOG ( LOADER , " Not saving config " ) ;
2012-11-01 15:19:01 +00:00
}
2022-12-17 16:54:31 +00:00
return true ;
}
void Config : : PostLoadCleanup ( bool gameSpecific ) {
// Override ppsspp.ini JIT value to prevent crashing
2023-08-21 01:36:06 +00:00
jitForcedOff = DefaultCpuCore ( ) ! = ( int ) CPUCore : : JIT & & ( g_Config . iCpuCore = = ( int ) CPUCore : : JIT | | g_Config . iCpuCore = = ( int ) CPUCore : : JIT_IR ) ;
2023-03-05 05:57:04 +00:00
if ( jitForcedOff ) {
2023-08-21 01:36:06 +00:00
g_Config . iCpuCore = ( int ) CPUCore : : IR_INTERPRETER ;
2022-12-17 16:54:31 +00:00
}
2022-12-17 16:58:27 +00:00
// This caps the exponent 4 (so 16x.)
if ( iAnisotropyLevel > 4 ) {
iAnisotropyLevel = 4 ;
}
// Set a default MAC, and correct if it's an old format.
if ( sMACAddress . length ( ) ! = 17 )
sMACAddress = CreateRandMAC ( ) ;
if ( g_Config . bAutoFrameSkip & & g_Config . bSkipBufferEffects ) {
g_Config . bSkipBufferEffects = false ;
}
// Automatically silence secondary instances. Could be an option I guess, but meh.
if ( PPSSPP_ID > 1 ) {
g_Config . iGlobalVolume = 0 ;
}
// Automatically switch away from deprecated setting value.
if ( iTexScalingLevel < = 0 ) {
iTexScalingLevel = 1 ;
}
2022-12-17 16:54:31 +00:00
}
void Config : : PreSaveCleanup ( bool gameSpecific ) {
if ( jitForcedOff ) {
2023-02-28 14:57:47 +00:00
// If we forced jit off and it's still set to IR, change it back to jit.
2023-08-21 01:36:06 +00:00
if ( g_Config . iCpuCore = = ( int ) CPUCore : : IR_INTERPRETER )
2023-02-28 14:57:47 +00:00
g_Config . iCpuCore = ( int ) CPUCore : : JIT ;
2022-12-17 16:54:31 +00:00
}
}
void Config : : PostSaveCleanup ( bool gameSpecific ) {
2015-11-03 17:34:33 +00:00
if ( jitForcedOff ) {
2023-02-28 14:57:47 +00:00
// Force JIT off again just in case Config::Save() is called without exiting PPSSPP.
if ( g_Config . iCpuCore = = ( int ) CPUCore : : JIT )
2023-08-21 01:36:06 +00:00
g_Config . iCpuCore = ( int ) CPUCore : : IR_INTERPRETER ;
2015-11-03 17:34:33 +00:00
}
2012-11-01 15:19:01 +00:00
}
2013-03-24 19:03:42 +00:00
2023-02-28 14:58:30 +00:00
void Config : : NotifyUpdatedCpuCore ( ) {
2023-08-21 01:36:06 +00:00
if ( jitForcedOff & & g_Config . iCpuCore = = ( int ) CPUCore : : IR_INTERPRETER ) {
2023-02-28 14:58:30 +00:00
// No longer forced off, the user set it to IR jit.
jitForcedOff = false ;
}
}
2013-11-26 13:04:29 +00:00
// Use for debugging the version check without messing with the server
#if 0
# define PPSSPP_GIT_VERSION "v0.0.1-gaaaaaaaaa"
# endif
2023-07-21 20:04:05 +00:00
void Config : : DownloadCompletedCallback ( http : : Request & download ) {
2013-11-26 13:04:29 +00:00
if ( download . ResultCode ( ) ! = 200 ) {
2017-03-12 16:24:46 +00:00
ERROR_LOG ( LOADER , " Failed to download %s: %d " , download . url ( ) . c_str ( ) , download . ResultCode ( ) ) ;
2013-11-26 19:10:35 +00:00
return ;
2013-11-26 13:04:29 +00:00
}
std : : string data ;
download . buffer ( ) . TakeAll ( & data ) ;
2013-11-26 19:10:35 +00:00
if ( data . empty ( ) ) {
ERROR_LOG ( LOADER , " Version check: Empty data from server! " ) ;
return ;
}
2018-08-12 22:05:00 +00:00
json : : JsonReader reader ( data . c_str ( ) , data . size ( ) ) ;
const json : : JsonGet root = reader . root ( ) ;
2016-04-09 16:20:31 +00:00
if ( ! root ) {
ERROR_LOG ( LOADER , " Failed to parse json " ) ;
return ;
}
2018-04-15 18:24:10 +00:00
std : : string version = root . getString ( " version " , " " ) ;
2013-11-26 13:04:29 +00:00
const char * gitVer = PPSSPP_GIT_VERSION ;
Version installed ( gitVer ) ;
Version upgrade ( version ) ;
Version dismissed ( g_Config . dismissedVersion ) ;
if ( ! installed . IsValid ( ) ) {
ERROR_LOG ( LOADER , " Version check: Local version string invalid. Build problems? %s " , PPSSPP_GIT_VERSION ) ;
return ;
}
if ( ! upgrade . IsValid ( ) ) {
ERROR_LOG ( LOADER , " Version check: Invalid server version: %s " , version . c_str ( ) ) ;
return ;
}
if ( installed > = upgrade ) {
INFO_LOG ( LOADER , " Version check: Already up to date, erasing any upgrade message " ) ;
2022-09-30 09:26:30 +00:00
g_Config . upgradeMessage . clear ( ) ;
2013-11-26 13:04:29 +00:00
g_Config . upgradeVersion = upgrade . ToString ( ) ;
2022-09-30 09:26:30 +00:00
g_Config . dismissedVersion . clear ( ) ;
2013-11-26 13:04:29 +00:00
return ;
}
if ( installed < upgrade & & dismissed ! = upgrade ) {
g_Config . upgradeMessage = " New version of PPSSPP available! " ;
g_Config . upgradeVersion = upgrade . ToString ( ) ;
2022-09-30 09:26:30 +00:00
g_Config . dismissedVersion . clear ( ) ;
2013-11-26 13:04:29 +00:00
}
}
void Config : : DismissUpgrade ( ) {
g_Config . dismissedVersion = g_Config . upgradeVersion ;
}
2013-03-24 19:03:42 +00:00
void Config : : AddRecent ( const std : : string & file ) {
2014-06-29 03:21:36 +00:00
// Don't bother with this if the user disabled recents (it's -1).
if ( iMaxRecent < = 0 )
return ;
2018-08-18 17:22:55 +00:00
// We'll add it back below. This makes sure it's at the front, and only once.
RemoveRecent ( file ) ;
2018-08-12 15:24:33 +00:00
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2018-08-18 17:22:55 +00:00
const std : : string filename = File : : ResolvePath ( file ) ;
2017-02-21 10:22:28 +00:00
recentIsos . insert ( recentIsos . begin ( ) , filename ) ;
2013-07-06 09:09:08 +00:00
if ( ( int ) recentIsos . size ( ) > iMaxRecent )
2013-05-16 00:51:15 +00:00
recentIsos . resize ( iMaxRecent ) ;
2013-03-24 19:03:42 +00:00
}
2013-04-13 19:24:07 +00:00
2018-08-12 15:24:33 +00:00
void Config : : RemoveRecent ( const std : : string & file ) {
// Don't bother with this if the user disabled recents (it's -1).
if ( iMaxRecent < = 0 )
return ;
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2018-08-12 15:24:33 +00:00
const std : : string filename = File : : ResolvePath ( file ) ;
2018-08-14 19:26:42 +00:00
for ( auto iter = recentIsos . begin ( ) ; iter ! = recentIsos . end ( ) ; ) {
const std : : string recent = File : : ResolvePath ( * iter ) ;
2018-08-12 15:24:33 +00:00
if ( filename = = recent ) {
2018-08-14 19:26:42 +00:00
// Note that the increment-erase idiom doesn't work with vectors.
iter = recentIsos . erase ( iter ) ;
} else {
iter + + ;
2018-08-12 15:24:33 +00:00
}
}
}
2013-04-13 19:24:07 +00:00
void Config : : CleanRecent ( ) {
2022-07-12 06:46:09 +00:00
private_ - > SetRecentIsosThread ( [ this ] {
2023-01-03 18:01:51 +00:00
SetCurrentThreadName ( " RecentISOs " ) ;
2023-01-03 22:29:22 +00:00
AndroidJNIThreadContext jniContext ; // destructor detaches
2022-07-12 05:01:06 +00:00
double startTime = time_now_d ( ) ;
2022-07-12 06:46:09 +00:00
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2022-07-12 05:01:06 +00:00
std : : vector < std : : string > cleanedRecent ;
for ( size_t i = 0 ; i < recentIsos . size ( ) ; i + + ) {
bool exists = false ;
Path path = Path ( recentIsos [ i ] ) ;
switch ( path . Type ( ) ) {
case PathType : : CONTENT_URI :
case PathType : : NATIVE :
exists = File : : Exists ( path ) ;
break ;
default :
FileLoader * loader = ConstructFileLoader ( path ) ;
exists = loader - > ExistsFast ( ) ;
delete loader ;
break ;
}
2021-11-13 21:47:29 +00:00
2022-07-12 05:01:06 +00:00
if ( exists ) {
// Make sure we don't have any redundant items.
auto duplicate = std : : find ( cleanedRecent . begin ( ) , cleanedRecent . end ( ) , recentIsos [ i ] ) ;
if ( duplicate = = cleanedRecent . end ( ) ) {
cleanedRecent . push_back ( recentIsos [ i ] ) ;
}
2013-09-04 22:04:24 +00:00
}
}
2021-11-13 21:47:29 +00:00
2023-01-30 13:30:24 +00:00
double recentTime = time_now_d ( ) - startTime ;
if ( recentTime > 0.1 ) {
INFO_LOG ( SYSTEM , " CleanRecent took %0.2f " , recentTime ) ;
}
2022-07-12 05:01:06 +00:00
recentIsos = cleanedRecent ;
} ) ;
}
std : : vector < std : : string > Config : : RecentIsos ( ) const {
2022-07-12 06:46:09 +00:00
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2022-07-12 05:01:06 +00:00
return recentIsos ;
}
2023-02-01 09:19:33 +00:00
2022-07-12 05:01:06 +00:00
bool Config : : HasRecentIsos ( ) const {
2022-07-12 06:46:09 +00:00
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2022-07-12 05:01:06 +00:00
return ! recentIsos . empty ( ) ;
}
2023-02-01 09:19:33 +00:00
2022-07-12 05:01:06 +00:00
void Config : : ClearRecentIsos ( ) {
2022-07-12 06:46:09 +00:00
private_ - > ResetRecentIsosThread ( ) ;
std : : lock_guard < std : : mutex > guard ( private_ - > recentIsosLock ) ;
2022-07-12 05:01:06 +00:00
recentIsos . clear ( ) ;
2013-04-15 00:23:57 +00:00
}
2013-08-28 20:23:16 +00:00
2021-05-30 10:45:12 +00:00
void Config : : SetSearchPath ( const Path & searchPath ) {
searchPath_ = searchPath ;
2013-10-12 23:02:03 +00:00
}
2021-05-05 23:31:38 +00:00
const Path Config : : FindConfigFile ( const std : : string & baseFilename ) {
2013-10-12 23:02:03 +00:00
// Don't search for an absolute path.
if ( baseFilename . size ( ) > 1 & & baseFilename [ 0 ] = = ' / ' ) {
2021-05-05 23:31:38 +00:00
return Path ( baseFilename ) ;
2013-10-12 23:02:03 +00:00
}
2013-10-12 23:41:53 +00:00
# ifdef _WIN32
if ( baseFilename . size ( ) > 3 & & baseFilename [ 1 ] = = ' : ' & & ( baseFilename [ 2 ] = = ' / ' | | baseFilename [ 2 ] = = ' \\ ' ) ) {
2021-05-05 23:31:38 +00:00
return Path ( baseFilename ) ;
2013-10-12 23:41:53 +00:00
}
# endif
2013-10-12 23:02:03 +00:00
2021-05-30 10:45:12 +00:00
Path filename = searchPath_ / baseFilename ;
if ( File : : Exists ( filename ) ) {
return filename ;
2013-10-12 23:02:03 +00:00
}
2021-05-30 10:45:12 +00:00
// Make sure at least the directory it's supposed to be in exists.
Path path = filename . NavigateUp ( ) ;
// This check is just to avoid logging.
if ( ! File : : Exists ( path ) ) {
File : : CreateFullPath ( path ) ;
2013-10-12 23:02:03 +00:00
}
return filename ;
}
2023-01-31 17:56:18 +00:00
void Config : : RestoreDefaults ( RestoreSettingsBits whatToRestore ) {
2016-01-06 07:01:49 +00:00
if ( bGameSpecific ) {
2023-02-01 10:01:48 +00:00
// TODO: This should be possible to do in a cleaner way.
2014-12-30 18:05:36 +00:00
deleteGameConfig ( gameId_ ) ;
createGameConfig ( gameId_ ) ;
2023-01-31 17:56:18 +00:00
Load ( ) ;
2016-01-06 07:01:49 +00:00
} else {
2023-01-31 17:56:18 +00:00
if ( whatToRestore & RestoreSettingsBits : : SETTINGS ) {
2023-02-01 10:01:48 +00:00
IterateSettings ( [ ] ( const ConfigSetting & setting ) {
setting . RestoreToDefault ( ) ;
} ) ;
2023-01-31 17:56:18 +00:00
}
if ( whatToRestore & RestoreSettingsBits : : CONTROLS ) {
2023-02-01 14:53:20 +00:00
KeyMap : : RestoreDefault ( ) ;
2023-01-31 17:56:18 +00:00
}
if ( whatToRestore & RestoreSettingsBits : : RECENT ) {
ClearRecentIsos ( ) ;
currentDirectory = defaultCurrentDirectory ;
}
2014-12-19 13:52:44 +00:00
}
2013-08-28 20:23:16 +00:00
}
2013-12-12 13:52:46 +00:00
2016-01-06 07:01:49 +00:00
bool Config : : hasGameConfig ( const std : : string & pGameId ) {
2021-05-05 23:31:38 +00:00
Path fullIniFilePath = getGameConfigFile ( pGameId ) ;
2015-09-07 21:20:31 +00:00
return File : : Exists ( fullIniFilePath ) ;
2014-12-14 19:33:20 +00:00
}
2019-07-14 22:04:09 +00:00
void Config : : changeGameSpecific ( const std : : string & pGameId , const std : : string & title ) {
2020-03-08 22:25:20 +00:00
if ( ! reload_ )
Save ( " changeGameSpecific " ) ;
2014-12-30 18:05:36 +00:00
gameId_ = pGameId ;
2019-07-14 22:04:09 +00:00
gameIdTitle_ = title ;
2014-12-14 19:33:20 +00:00
bGameSpecific = ! pGameId . empty ( ) ;
}
2016-01-06 07:01:49 +00:00
bool Config : : createGameConfig ( const std : : string & pGameId ) {
2021-05-11 07:50:28 +00:00
Path fullIniFilePath = getGameConfigFile ( pGameId ) ;
2014-12-14 19:33:20 +00:00
2016-01-06 07:01:49 +00:00
if ( hasGameConfig ( pGameId ) ) {
2014-12-14 19:33:20 +00:00
return false ;
}
File : : CreateEmptyFile ( fullIniFilePath ) ;
return true ;
}
2016-01-06 07:01:49 +00:00
bool Config : : deleteGameConfig ( const std : : string & pGameId ) {
2021-05-05 23:31:38 +00:00
Path fullIniFilePath = Path ( getGameConfigFile ( pGameId ) ) ;
2014-12-14 19:33:20 +00:00
File : : Delete ( fullIniFilePath ) ;
return true ;
}
2021-05-05 23:31:38 +00:00
Path Config : : getGameConfigFile ( const std : : string & pGameId ) {
2022-12-07 20:40:13 +00:00
const char * ppssppIniFilename = IsVREnabled ( ) ? " _ppssppvr.ini " : " _ppsspp.ini " ;
std : : string iniFileName = pGameId + ppssppIniFilename ;
2021-05-05 23:31:38 +00:00
Path iniFileNameFull = FindConfigFile ( iniFileName ) ;
2014-12-14 19:33:20 +00:00
return iniFileNameFull ;
}
2019-07-14 22:04:09 +00:00
bool Config : : saveGameConfig ( const std : : string & pGameId , const std : : string & title ) {
2016-01-06 07:01:49 +00:00
if ( pGameId . empty ( ) ) {
2014-12-14 19:33:20 +00:00
return false ;
}
2021-05-05 23:31:38 +00:00
Path fullIniFilePath = getGameConfigFile ( pGameId ) ;
2014-12-14 19:33:20 +00:00
IniFile iniFile ;
2020-08-10 13:53:52 +00:00
Section * top = iniFile . GetOrCreateSection ( " " ) ;
2019-07-14 22:04:09 +00:00
top - > AddComment ( StringFromFormat ( " Game config for %s - %s " , pGameId . c_str ( ) , title . c_str ( ) ) ) ;
2022-12-17 16:54:31 +00:00
PreSaveCleanup ( true ) ;
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ ] ( Section * section , const ConfigSetting & setting ) {
2023-04-05 14:23:31 +00:00
if ( setting . PerGame ( ) ) {
2023-02-01 09:27:15 +00:00
setting . Set ( section ) ;
2014-12-14 19:33:20 +00:00
}
2016-01-06 07:01:49 +00:00
} ) ;
2014-12-14 19:33:20 +00:00
2020-08-10 13:53:52 +00:00
Section * postShaderSetting = iniFile . GetOrCreateSection ( " PostShaderSetting " ) ;
2020-05-15 22:52:38 +00:00
postShaderSetting - > Clear ( ) ;
for ( auto it = mPostShaderSetting . begin ( ) , end = mPostShaderSetting . end ( ) ; it ! = end ; + + it ) {
postShaderSetting - > Set ( it - > first . c_str ( ) , it - > second ) ;
}
2020-05-18 09:17:45 +00:00
Section * postShaderChain = iniFile . GetOrCreateSection ( " PostShaderList " ) ;
postShaderChain - > Clear ( ) ;
for ( size_t i = 0 ; i < vPostShaderNames . size ( ) ; + + i ) {
char keyName [ 64 ] ;
snprintf ( keyName , sizeof ( keyName ) , " PostShader%d " , ( int ) i + 1 ) ;
postShaderChain - > Set ( keyName , vPostShaderNames [ i ] ) ;
}
2014-12-14 19:33:20 +00:00
KeyMap : : SaveToIni ( iniFile ) ;
2022-12-17 16:44:40 +00:00
iniFile . Save ( fullIniFilePath ) ;
2014-12-14 19:33:20 +00:00
2022-12-17 16:54:31 +00:00
PostSaveCleanup ( true ) ;
2014-12-20 17:10:18 +00:00
return true ;
2014-12-14 19:33:20 +00:00
}
2019-07-18 04:28:21 +00:00
bool Config : : loadGameConfig ( const std : : string & pGameId , const std : : string & title ) {
2021-05-05 23:31:38 +00:00
Path iniFileNameFull = getGameConfigFile ( pGameId ) ;
2014-12-14 19:33:20 +00:00
2016-01-06 07:01:49 +00:00
if ( ! hasGameConfig ( pGameId ) ) {
2021-08-28 16:14:53 +00:00
DEBUG_LOG ( LOADER , " No game-specific settings found in %s. Using global defaults. " , iniFileNameFull . c_str ( ) ) ;
2014-12-14 19:33:20 +00:00
return false ;
}
2019-07-18 04:28:21 +00:00
changeGameSpecific ( pGameId , title ) ;
2014-12-14 19:33:20 +00:00
IniFile iniFile ;
2022-12-17 16:44:40 +00:00
iniFile . Load ( iniFileNameFull ) ;
2014-12-14 19:33:20 +00:00
2020-05-15 22:52:38 +00:00
auto postShaderSetting = iniFile . GetOrCreateSection ( " PostShaderSetting " ) - > ToMap ( ) ;
mPostShaderSetting . clear ( ) ;
2021-10-07 21:51:26 +00:00
for ( const auto & it : postShaderSetting ) {
float value = 0.0f ;
if ( sscanf ( it . second . c_str ( ) , " %f " , & value ) ) {
mPostShaderSetting [ it . first ] = value ;
} else {
WARN_LOG ( LOADER , " Invalid float value string for param %s: '%s' " , it . first . c_str ( ) , it . second . c_str ( ) ) ;
}
2020-05-15 22:52:38 +00:00
}
2020-05-18 09:17:45 +00:00
auto postShaderChain = iniFile . GetOrCreateSection ( " PostShaderList " ) - > ToMap ( ) ;
vPostShaderNames . clear ( ) ;
for ( auto it : postShaderChain ) {
2021-04-11 01:35:23 +00:00
if ( it . second ! = " Off " )
vPostShaderNames . push_back ( it . second ) ;
2020-05-18 09:17:45 +00:00
}
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ ] ( Section * section , const ConfigSetting & setting ) {
2023-04-05 14:23:31 +00:00
if ( setting . PerGame ( ) ) {
2023-02-01 09:27:15 +00:00
setting . Get ( section ) ;
2014-12-14 19:33:20 +00:00
}
2016-01-06 07:01:49 +00:00
} ) ;
2014-12-14 19:33:20 +00:00
KeyMap : : LoadFromIni ( iniFile ) ;
2023-03-07 09:02:59 +00:00
if ( ! appendedConfigFileName_ . ToString ( ) . empty ( ) & &
2022-10-09 13:04:19 +00:00
std : : find ( appendedConfigUpdatedGames_ . begin ( ) , appendedConfigUpdatedGames_ . end ( ) , pGameId ) = = appendedConfigUpdatedGames_ . end ( ) ) {
LoadAppendedConfig ( ) ;
appendedConfigUpdatedGames_ . push_back ( pGameId ) ;
}
2022-12-17 16:54:31 +00:00
PostLoadCleanup ( true ) ;
2014-12-14 19:33:20 +00:00
return true ;
}
2016-01-06 07:01:49 +00:00
void Config : : unloadGameConfig ( ) {
2020-03-08 22:25:20 +00:00
if ( bGameSpecific ) {
2014-12-14 19:33:20 +00:00
changeGameSpecific ( ) ;
2016-01-06 07:02:19 +00:00
IniFile iniFile ;
2022-12-17 16:44:40 +00:00
iniFile . Load ( iniFilename_ ) ;
2016-01-06 07:02:19 +00:00
// Reload game specific settings back to standard.
2023-02-01 09:27:15 +00:00
IterateSettings ( iniFile , [ ] ( Section * section , const ConfigSetting & setting ) {
2023-04-05 14:23:31 +00:00
if ( setting . PerGame ( ) ) {
2023-02-01 09:27:15 +00:00
setting . Get ( section ) ;
2016-01-06 07:02:19 +00:00
}
} ) ;
2020-05-16 07:27:53 +00:00
auto postShaderSetting = iniFile . GetOrCreateSection ( " PostShaderSetting " ) - > ToMap ( ) ;
mPostShaderSetting . clear ( ) ;
for ( auto it : postShaderSetting ) {
mPostShaderSetting [ it . first ] = std : : stof ( it . second ) ;
}
2020-05-18 09:17:45 +00:00
auto postShaderChain = iniFile . GetOrCreateSection ( " PostShaderList " ) - > ToMap ( ) ;
vPostShaderNames . clear ( ) ;
for ( auto it : postShaderChain ) {
2021-04-11 01:35:23 +00:00
if ( it . second ! = " Off " )
vPostShaderNames . push_back ( it . second ) ;
2020-05-18 09:17:45 +00:00
}
2016-01-06 07:02:19 +00:00
LoadStandardControllerIni ( ) ;
2022-12-17 16:54:31 +00:00
PostLoadCleanup ( true ) ;
2014-12-14 19:33:20 +00:00
}
}
2016-01-06 07:01:49 +00:00
void Config : : LoadStandardControllerIni ( ) {
IniFile controllerIniFile ;
2022-12-17 16:44:40 +00:00
if ( ! controllerIniFile . Load ( controllerIniFilename_ ) ) {
2016-01-06 07:01:49 +00:00
ERROR_LOG ( LOADER , " Failed to read %s. Setting controller config to default. " , controllerIniFilename_ . c_str ( ) ) ;
KeyMap : : RestoreDefault ( ) ;
} else {
// Continue anyway to initialize the config. It will just restore the defaults.
KeyMap : : LoadFromIni ( controllerIniFile ) ;
}
}
2013-12-12 13:52:46 +00:00
void Config : : ResetControlLayout ( ) {
2018-06-17 05:14:41 +00:00
auto reset = [ ] ( ConfigTouchPos & pos ) {
pos . x = defaultTouchPosShow . x ;
pos . y = defaultTouchPosShow . y ;
pos . scale = defaultTouchPosShow . scale ;
} ;
reset ( g_Config . touchActionButtonCenter ) ;
2013-12-12 13:52:46 +00:00
g_Config . fActionButtonSpacing = 1.0f ;
2018-06-17 05:14:41 +00:00
reset ( g_Config . touchDpad ) ;
2013-12-12 13:52:46 +00:00
g_Config . fDpadSpacing = 1.0f ;
2018-06-17 05:14:41 +00:00
reset ( g_Config . touchStartKey ) ;
reset ( g_Config . touchSelectKey ) ;
2021-08-17 14:48:47 +00:00
reset ( g_Config . touchFastForwardKey ) ;
2018-06-17 05:14:41 +00:00
reset ( g_Config . touchLKey ) ;
reset ( g_Config . touchRKey ) ;
reset ( g_Config . touchAnalogStick ) ;
2019-07-18 01:16:46 +00:00
reset ( g_Config . touchRightAnalogStick ) ;
2023-06-20 07:30:38 +00:00
for ( int i = 0 ; i < CUSTOM_BUTTON_COUNT ; i + + ) {
reset ( g_Config . touchCustom [ i ] ) ;
}
2021-07-11 15:51:10 +00:00
g_Config . fLeftStickHeadScale = 1.0f ;
g_Config . fRightStickHeadScale = 1.0f ;
2013-12-08 06:39:35 +00:00
}
2014-02-10 01:15:00 +00:00
void Config : : GetReportingInfo ( UrlEncoder & data ) {
2023-04-05 09:46:44 +00:00
for ( size_t i = 0 ; i < numSections ; + + i ) {
2014-02-10 01:15:00 +00:00
const std : : string prefix = std : : string ( " config. " ) + sections [ i ] . section ;
2023-02-01 09:45:03 +00:00
for ( size_t j = 0 ; j < sections [ i ] . settingsCount ; j + + ) {
2023-04-05 14:27:44 +00:00
sections [ i ] . settings [ j ] . ReportSetting ( data , prefix ) ;
2014-02-10 01:15:00 +00:00
}
}
}
2018-06-17 01:42:31 +00:00
bool Config : : IsPortrait ( ) const {
2022-11-06 18:20:10 +00:00
return ( iInternalScreenRotation = = ROTATION_LOCKED_VERTICAL | | iInternalScreenRotation = = ROTATION_LOCKED_VERTICAL180 ) & & ! bSkipBufferEffects ;
2018-06-17 01:42:31 +00:00
}
2023-07-23 09:05:08 +00:00
int Config : : GetPSPLanguage ( ) {
if ( g_Config . iLanguage = = - 1 ) {
const auto & langValuesMapping = GetLangValuesMapping ( ) ;
auto iter = langValuesMapping . find ( g_Config . sLanguageIni ) ;
if ( iter ! = langValuesMapping . end ( ) ) {
return iter - > second . second ;
} else {
// Fallback to English
return PSP_SYSTEMPARAM_LANGUAGE_ENGLISH ;
}
} else {
return g_Config . iLanguage ;
}
}