@@ -562,21 +562,6 @@ static ConfigSetting generalSettings[] = {
562562 ConfigSetting (" GridView1" , &g_Config.bGridView1 , true ),
563563 ConfigSetting (" GridView2" , &g_Config.bGridView2 , true ),
564564 ConfigSetting (" GridView3" , &g_Config.bGridView3 , false ),
565- ConfigSetting (" RightAnalogUp" , &g_Config.iRightAnalogUp , 0 , true , true ),
566- ConfigSetting (" RightAnalogDown" , &g_Config.iRightAnalogDown , 0 , true , true ),
567- ConfigSetting (" RightAnalogLeft" , &g_Config.iRightAnalogLeft , 0 , true , true ),
568- ConfigSetting (" RightAnalogRight" , &g_Config.iRightAnalogRight , 0 , true , true ),
569- ConfigSetting (" RightAnalogPress" , &g_Config.iRightAnalogPress , 0 , true , true ),
570- ConfigSetting (" RightAnalogCustom" , &g_Config.bRightAnalogCustom , false , true , true ),
571- ConfigSetting (" RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal , false , true , true ),
572- ConfigSetting (" SwipeUp" , &g_Config.iSwipeUp , 0 , true , true ),
573- ConfigSetting (" SwipeDown" , &g_Config.iSwipeDown , 0 , true , true ),
574- ConfigSetting (" SwipeLeft" , &g_Config.iSwipeLeft , 0 , true , true ),
575- ConfigSetting (" SwipeRight" , &g_Config.iSwipeRight , 0 , true , true ),
576- ConfigSetting (" SwipeSensitivity" , &g_Config.fSwipeSensitivity , 1 .0f , true , true ),
577- ConfigSetting (" SwipeSmoothing" , &g_Config.fSwipeSmoothing , 0 .3f , true , true ),
578- ConfigSetting (" DoubleTapGesture" , &g_Config.iDoubleTapGesture , 0 , true , true ),
579- ConfigSetting (" GestureControlEnabled" , &g_Config.bGestureControlEnabled , false , true , true ),
580565
581566 // "default" means let emulator decide, "" means disable.
582567 ConfigSetting (" ReportingHost" , &g_Config.sReportHost , " default" ),
@@ -616,6 +601,7 @@ static ConfigSetting generalSettings[] = {
616601 ConfigSetting (" EnablePlugins" , &g_Config.bLoadPlugins , true , true , true ),
617602
618603 ReportedConfigSetting (" IgnoreCompatSettings" , &g_Config.sIgnoreCompatSettings , " " , true , true ),
604+ ConfigSetting (" SettingsVersion" , &g_Config.uSettingsVersion , 0u , true , true ), // Per game for game configs
619605
620606 ConfigSetting (false ),
621607};
@@ -1089,6 +1075,23 @@ static ConfigSetting controlSettings[] = {
10891075 ConfigSetting (" MouseSensitivity" , &g_Config.fMouseSensitivity , 0 .1f , true , true ),
10901076 ConfigSetting (" MouseSmoothing" , &g_Config.fMouseSmoothing , 0 .9f , true , true ),
10911077
1078+ ConfigSetting (" RightAnalogUp" , &g_Config.iRightAnalogUp , 0 , true , true ),
1079+ ConfigSetting (" RightAnalogDown" , &g_Config.iRightAnalogDown , 0 , true , true ),
1080+ ConfigSetting (" RightAnalogLeft" , &g_Config.iRightAnalogLeft , 0 , true , true ),
1081+ ConfigSetting (" RightAnalogRight" , &g_Config.iRightAnalogRight , 0 , true , true ),
1082+ ConfigSetting (" RightAnalogPress" , &g_Config.iRightAnalogPress , 0 , true , true ),
1083+ ConfigSetting (" RightAnalogCustom" , &g_Config.bRightAnalogCustom , false , true , true ),
1084+ ConfigSetting (" RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal , false , true , true ),
1085+
1086+ ConfigSetting (" SwipeUp" , &g_Config.iSwipeUp , 0 , true , true ),
1087+ ConfigSetting (" SwipeDown" , &g_Config.iSwipeDown , 0 , true , true ),
1088+ ConfigSetting (" SwipeLeft" , &g_Config.iSwipeLeft , 0 , true , true ),
1089+ ConfigSetting (" SwipeRight" , &g_Config.iSwipeRight , 0 , true , true ),
1090+ ConfigSetting (" SwipeSensitivity" , &g_Config.fSwipeSensitivity , 1 .0f , true , true ),
1091+ ConfigSetting (" SwipeSmoothing" , &g_Config.fSwipeSmoothing , 0 .3f , true , true ),
1092+ ConfigSetting (" DoubleTapGesture" , &g_Config.iDoubleTapGesture , 0 , true , true ),
1093+ ConfigSetting (" GestureControlEnabled" , &g_Config.bGestureControlEnabled , false , true , true ),
1094+
10921095 ConfigSetting (" SystemControls" , &g_Config.bSystemControls , true , true , false ),
10931096
10941097 ConfigSetting (false ),
@@ -1322,6 +1325,24 @@ void Config::UpdateIniLocation(const char *iniFileName, const char *controllerIn
13221325 controllerIniFilename_ = FindConfigFile (useControllerIniFilename ? controllerIniFilename : " controls.ini" );
13231326}
13241327
1328+ static void loadOldControlSettings (IniFile &iniFile) {
1329+ iniFile.GetIfExists (" General" , " RightAnalogUp" , &g_Config.iRightAnalogUp );
1330+ iniFile.GetIfExists (" General" , " RightAnalogDown" , &g_Config.iRightAnalogDown );
1331+ iniFile.GetIfExists (" General" , " RightAnalogLeft" , &g_Config.iRightAnalogLeft );
1332+ iniFile.GetIfExists (" General" , " RightAnalogRight" , &g_Config.iRightAnalogRight );
1333+ iniFile.GetIfExists (" General" , " RightAnalogPress" , &g_Config.iRightAnalogPress );
1334+ iniFile.GetIfExists (" General" , " SwipeUp" , &g_Config.iSwipeUp );
1335+ iniFile.GetIfExists (" General" , " SwipeDown" , &g_Config.iSwipeDown );
1336+ iniFile.GetIfExists (" General" , " SwipeLeft" , &g_Config.iSwipeLeft );
1337+ iniFile.GetIfExists (" General" , " SwipeRight" , &g_Config.iSwipeRight );
1338+ iniFile.GetIfExists (" General" , " DoubleTapGesture" , &g_Config.iDoubleTapGesture );
1339+ iniFile.GetIfExists (" General" , " SwipeSensitivity" , &g_Config.fSwipeSensitivity );
1340+ iniFile.GetIfExists (" General" , " SwipeSmoothing" , &g_Config.fSwipeSmoothing );
1341+ iniFile.GetIfExists (" General" , " RightAnalogCustom" , &g_Config.bRightAnalogCustom );
1342+ iniFile.GetIfExists (" General" , " RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal );
1343+ iniFile.GetIfExists (" General" , " GestureControlEnabled" , &g_Config.bGestureControlEnabled );
1344+ }
1345+
13251346void Config::Load (const char *iniFileName, const char *controllerIniFilename) {
13261347 if (!bUpdatedInstanceCounter) {
13271348 InitInstanceCounter ();
@@ -1419,6 +1440,12 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
14191440 ResetControlLayout ();
14201441 }
14211442
1443+ if (g_Config.uSettingsVersion == 0 ) {
1444+ g_Config.uSettingsVersion = 1 ;
1445+
1446+ loadOldControlSettings (iniFile);
1447+ }
1448+
14221449 const char *gitVer = PPSSPP_GIT_VERSION;
14231450 Version installed (gitVer);
14241451 Version upgrade (upgradeVersion);
@@ -1488,6 +1515,58 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
14881515 INFO_LOG (LOADER, " Config loaded: '%s'" , iniFilename_.c_str ());
14891516}
14901517
1518+ bool Config::SaveControllerProfile (uint32_t id) {
1519+ IniFile iniFile;
1520+ if (!iniFile.Load (controllerIniFilename_)) {
1521+ ERROR_LOG (LOADER, " Error saving controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1522+ return false ;
1523+ }
1524+
1525+ Section *section = iniFile.GetOrCreateSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1526+ for (auto setting = controlSettings; setting->HasMore (); ++setting) {
1527+ setting->Set (section);
1528+ }
1529+
1530+ KeyMap::SaveToIni (iniFile, StringFromFormat (" ControlProfile%uMapping" , id).c_str ());
1531+
1532+ if (!iniFile.Save (controllerIniFilename_)) {
1533+ ERROR_LOG (LOADER, " Error saving controller profile - can't write ini '%s'" , controllerIniFilename_.c_str ());
1534+ return false ;
1535+ }
1536+
1537+ return true ;
1538+ }
1539+
1540+ bool Config::ControllerProfileExist (uint32_t id) {
1541+ IniFile iniFile;
1542+ if (!iniFile.Load (controllerIniFilename_)) {
1543+ ERROR_LOG (LOADER, " Error checking controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1544+ return false ;
1545+ }
1546+
1547+ return iniFile.HasSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1548+ }
1549+
1550+ bool Config::LoadControllerProfile (uint32_t id) {
1551+ IniFile iniFile;
1552+ if (!iniFile.Load (controllerIniFilename_)) {
1553+ ERROR_LOG (LOADER, " Error loading controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1554+ return false ;
1555+ }
1556+
1557+ if (!iniFile.HasSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ()))
1558+ return false ;
1559+
1560+ Section *section = iniFile.GetOrCreateSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1561+ for (auto setting = controlSettings; setting->HasMore (); ++setting) {
1562+ setting->Get (section);
1563+ }
1564+
1565+ KeyMap::LoadFromIni (iniFile, StringFromFormat (" ControlProfile%uMapping" , id).c_str ());
1566+
1567+ return true ;
1568+ }
1569+
14911570bool Config::Save (const char *saveReason) {
14921571 if (!IsFirstInstance ()) {
14931572 // TODO: Should we allow saving config if started from a different directory?
@@ -1895,6 +1974,12 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
18951974 }
18961975 });
18971976
1977+ if (g_Config.uSettingsVersion == 0 ) {
1978+ g_Config.uSettingsVersion = 1 ;
1979+
1980+ loadOldControlSettings (iniFile);
1981+ }
1982+
18981983 KeyMap::LoadFromIni (iniFile);
18991984 return true ;
19001985}
0 commit comments