@@ -547,21 +547,6 @@ static const ConfigSetting generalSettings[] = {
547547 ConfigSetting (" GridView1" , &g_Config.bGridView1 , true ),
548548 ConfigSetting (" GridView2" , &g_Config.bGridView2 , true ),
549549 ConfigSetting (" GridView3" , &g_Config.bGridView3 , false ),
550- ConfigSetting (" RightAnalogUp" , &g_Config.iRightAnalogUp , 0 , true , true ),
551- ConfigSetting (" RightAnalogDown" , &g_Config.iRightAnalogDown , 0 , true , true ),
552- ConfigSetting (" RightAnalogLeft" , &g_Config.iRightAnalogLeft , 0 , true , true ),
553- ConfigSetting (" RightAnalogRight" , &g_Config.iRightAnalogRight , 0 , true , true ),
554- ConfigSetting (" RightAnalogPress" , &g_Config.iRightAnalogPress , 0 , true , true ),
555- ConfigSetting (" RightAnalogCustom" , &g_Config.bRightAnalogCustom , false , true , true ),
556- ConfigSetting (" RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal , false , true , true ),
557- ConfigSetting (" SwipeUp" , &g_Config.iSwipeUp , 0 , true , true ),
558- ConfigSetting (" SwipeDown" , &g_Config.iSwipeDown , 0 , true , true ),
559- ConfigSetting (" SwipeLeft" , &g_Config.iSwipeLeft , 0 , true , true ),
560- ConfigSetting (" SwipeRight" , &g_Config.iSwipeRight , 0 , true , true ),
561- ConfigSetting (" SwipeSensitivity" , &g_Config.fSwipeSensitivity , 1 .0f , true , true ),
562- ConfigSetting (" SwipeSmoothing" , &g_Config.fSwipeSmoothing , 0 .3f , true , true ),
563- ConfigSetting (" DoubleTapGesture" , &g_Config.iDoubleTapGesture , 0 , true , true ),
564- ConfigSetting (" GestureControlEnabled" , &g_Config.bGestureControlEnabled , false , true , true ),
565550
566551 // "default" means let emulator decide, "" means disable.
567552 ConfigSetting (" ReportingHost" , &g_Config.sReportHost , " default" ),
@@ -606,6 +591,7 @@ static const ConfigSetting generalSettings[] = {
606591 ConfigSetting (" EnablePlugins" , &g_Config.bLoadPlugins , true , true , true ),
607592
608593 ReportedConfigSetting (" IgnoreCompatSettings" , &g_Config.sIgnoreCompatSettings , " " , true , true ),
594+ ConfigSetting (" SettingsVersion" , &g_Config.uSettingsVersion , 0u , true , true ), // Per game for game configs
609595};
610596
611597static bool DefaultSasThread () {
@@ -1039,6 +1025,23 @@ static const ConfigSetting controlSettings[] = {
10391025 ConfigSetting (" MouseSensitivity" , &g_Config.fMouseSensitivity , 0 .1f , true , true ),
10401026 ConfigSetting (" MouseSmoothing" , &g_Config.fMouseSmoothing , 0 .9f , true , true ),
10411027
1028+ ConfigSetting (" RightAnalogUp" , &g_Config.iRightAnalogUp , 0 , true , true ),
1029+ ConfigSetting (" RightAnalogDown" , &g_Config.iRightAnalogDown , 0 , true , true ),
1030+ ConfigSetting (" RightAnalogLeft" , &g_Config.iRightAnalogLeft , 0 , true , true ),
1031+ ConfigSetting (" RightAnalogRight" , &g_Config.iRightAnalogRight , 0 , true , true ),
1032+ ConfigSetting (" RightAnalogPress" , &g_Config.iRightAnalogPress , 0 , true , true ),
1033+ ConfigSetting (" RightAnalogCustom" , &g_Config.bRightAnalogCustom , false , true , true ),
1034+ ConfigSetting (" RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal , false , true , true ),
1035+
1036+ ConfigSetting (" SwipeUp" , &g_Config.iSwipeUp , 0 , true , true ),
1037+ ConfigSetting (" SwipeDown" , &g_Config.iSwipeDown , 0 , true , true ),
1038+ ConfigSetting (" SwipeLeft" , &g_Config.iSwipeLeft , 0 , true , true ),
1039+ ConfigSetting (" SwipeRight" , &g_Config.iSwipeRight , 0 , true , true ),
1040+ ConfigSetting (" SwipeSensitivity" , &g_Config.fSwipeSensitivity , 1 .0f , true , true ),
1041+ ConfigSetting (" SwipeSmoothing" , &g_Config.fSwipeSmoothing , 0 .3f , true , true ),
1042+ ConfigSetting (" DoubleTapGesture" , &g_Config.iDoubleTapGesture , 0 , true , true ),
1043+ ConfigSetting (" GestureControlEnabled" , &g_Config.bGestureControlEnabled , false , true , true ),
1044+
10421045 ConfigSetting (" SystemControls" , &g_Config.bSystemControls , true , true , false ),
10431046};
10441047
@@ -1315,6 +1318,24 @@ void Config::UpdateAfterSettingAutoFrameSkip() {
13151318 }
13161319}
13171320
1321+ static void loadOldControlSettings (IniFile &iniFile) {
1322+ iniFile.GetIfExists (" General" , " RightAnalogUp" , &g_Config.iRightAnalogUp );
1323+ iniFile.GetIfExists (" General" , " RightAnalogDown" , &g_Config.iRightAnalogDown );
1324+ iniFile.GetIfExists (" General" , " RightAnalogLeft" , &g_Config.iRightAnalogLeft );
1325+ iniFile.GetIfExists (" General" , " RightAnalogRight" , &g_Config.iRightAnalogRight );
1326+ iniFile.GetIfExists (" General" , " RightAnalogPress" , &g_Config.iRightAnalogPress );
1327+ iniFile.GetIfExists (" General" , " SwipeUp" , &g_Config.iSwipeUp );
1328+ iniFile.GetIfExists (" General" , " SwipeDown" , &g_Config.iSwipeDown );
1329+ iniFile.GetIfExists (" General" , " SwipeLeft" , &g_Config.iSwipeLeft );
1330+ iniFile.GetIfExists (" General" , " SwipeRight" , &g_Config.iSwipeRight );
1331+ iniFile.GetIfExists (" General" , " DoubleTapGesture" , &g_Config.iDoubleTapGesture );
1332+ iniFile.GetIfExists (" General" , " SwipeSensitivity" , &g_Config.fSwipeSensitivity );
1333+ iniFile.GetIfExists (" General" , " SwipeSmoothing" , &g_Config.fSwipeSmoothing );
1334+ iniFile.GetIfExists (" General" , " RightAnalogCustom" , &g_Config.bRightAnalogCustom );
1335+ iniFile.GetIfExists (" General" , " RightAnalogDisableDiagonal" , &g_Config.bRightAnalogDisableDiagonal );
1336+ iniFile.GetIfExists (" General" , " GestureControlEnabled" , &g_Config.bGestureControlEnabled );
1337+ }
1338+
13181339void Config::Load (const char *iniFileName, const char *controllerIniFilename) {
13191340 if (!bUpdatedInstanceCounter) {
13201341 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);
@@ -1466,6 +1493,58 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
14661493 INFO_LOG (LOADER, " Config loaded: '%s'" , iniFilename_.c_str ());
14671494}
14681495
1496+ bool Config::SaveControllerProfile (uint32_t id) {
1497+ IniFile iniFile;
1498+ if (!iniFile.Load (controllerIniFilename_)) {
1499+ ERROR_LOG (LOADER, " Error saving controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1500+ return false ;
1501+ }
1502+
1503+ Section *section = iniFile.GetOrCreateSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1504+ for (auto &setting : controlSettings) {
1505+ setting.Set (section);
1506+ }
1507+
1508+ KeyMap::SaveToIni (iniFile, StringFromFormat (" ControlProfile%uMapping" , id).c_str ());
1509+
1510+ if (!iniFile.Save (controllerIniFilename_)) {
1511+ ERROR_LOG (LOADER, " Error saving controller profile - can't write ini '%s'" , controllerIniFilename_.c_str ());
1512+ return false ;
1513+ }
1514+
1515+ return true ;
1516+ }
1517+
1518+ bool Config::ControllerProfileExist (uint32_t id) {
1519+ IniFile iniFile;
1520+ if (!iniFile.Load (controllerIniFilename_)) {
1521+ ERROR_LOG (LOADER, " Error checking controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1522+ return false ;
1523+ }
1524+
1525+ return iniFile.HasSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1526+ }
1527+
1528+ bool Config::LoadControllerProfile (uint32_t id) {
1529+ IniFile iniFile;
1530+ if (!iniFile.Load (controllerIniFilename_)) {
1531+ ERROR_LOG (LOADER, " Error loading controller profile - can't read ini '%s'" , controllerIniFilename_.c_str ());
1532+ return false ;
1533+ }
1534+
1535+ if (!iniFile.HasSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ()))
1536+ return false ;
1537+
1538+ Section *section = iniFile.GetOrCreateSection (StringFromFormat (" ControlProfile%uSettings" , id).c_str ());
1539+ for (auto &setting : controlSettings) {
1540+ setting.Get (section);
1541+ }
1542+
1543+ KeyMap::LoadFromIni (iniFile, StringFromFormat (" ControlProfile%uMapping" , id).c_str ());
1544+
1545+ return true ;
1546+ }
1547+
14691548bool Config::Save (const char *saveReason) {
14701549 if (!IsFirstInstance ()) {
14711550 // TODO: Should we allow saving config if started from a different directory?
@@ -1944,6 +2023,12 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
19442023 }
19452024 });
19462025
2026+ if (g_Config.uSettingsVersion == 0 ) {
2027+ g_Config.uSettingsVersion = 1 ;
2028+
2029+ loadOldControlSettings (iniFile);
2030+ }
2031+
19472032 KeyMap::LoadFromIni (iniFile);
19482033
19492034 if (!appendedConfigFileName_.ToString ().empty () &&
0 commit comments