mirror of
				https://github.com/RetroDECK/Duckstation.git
				synced 2025-04-10 19:15:14 +00:00 
			
		
		
		
	CommonHostInterface: Fully clear controller section before loading profile
This commit is contained in:
		
							parent
							
								
									a5f04f2a8e
								
							
						
					
					
						commit
						189656cbc4
					
				|  | @ -204,6 +204,11 @@ void AndroidSettingsInterface::DeleteValue(const char* section, const char* key) | |||
|   Log_ErrorPrintf("DeleteValue(\"%s\", \"%s\") not implemented", section, key); | ||||
| } | ||||
| 
 | ||||
| void AndroidSettingsInterface::ClearSection(const char* section) | ||||
| { | ||||
|   Log_ErrorPrintf("ClearSection(\"%s\") not implemented", section); | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> AndroidSettingsInterface::GetStringList(const char* section, const char* key) | ||||
| { | ||||
|   JNIEnv* env = AndroidHelpers::GetJNIEnv(); | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ public: | |||
|   void SetBoolValue(const char* section, const char* key, bool value) override; | ||||
|   void SetStringValue(const char* section, const char* key, const char* value) override; | ||||
|   void DeleteValue(const char* section, const char* key) override; | ||||
|   void ClearSection(const char* section) override; | ||||
| 
 | ||||
|   std::vector<std::string> GetStringList(const char* section, const char* key) override; | ||||
|   void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override; | ||||
|  |  | |||
|  | @ -29,6 +29,7 @@ public: | |||
|   virtual bool AddToStringList(const char* section, const char* key, const char* item) = 0; | ||||
| 
 | ||||
|   virtual void DeleteValue(const char* section, const char* key) = 0; | ||||
|   virtual void ClearSection(const char* section) = 0; | ||||
| }; | ||||
| 
 | ||||
| struct SettingInfo | ||||
|  |  | |||
|  | @ -115,3 +115,8 @@ void LibretroSettingsInterface::DeleteValue(const char* section, const char* key | |||
| { | ||||
|   Log_ErrorPrintf("DeleteValue(\"%s\", \"%s\") not implemented", section, key); | ||||
| } | ||||
| 
 | ||||
| void LibretroSettingsInterface::ClearSection(const char* section) | ||||
| { | ||||
|   Log_ErrorPrintf("ClearSection(\"%s\") not implemented", section); | ||||
| } | ||||
|  |  | |||
|  | @ -22,4 +22,5 @@ public: | |||
|   bool AddToStringList(const char* section, const char* key, const char* item) override; | ||||
| 
 | ||||
|   void DeleteValue(const char* section, const char* key) override; | ||||
| }; | ||||
|   void ClearSection(const char* section) override; | ||||
| }; | ||||
|  |  | |||
|  | @ -1781,24 +1781,7 @@ std::string CommonHostInterface::GetInputProfilePath(const char* name) const | |||
| void CommonHostInterface::ClearAllControllerBindings(SettingsInterface& si) | ||||
| { | ||||
|   for (u32 controller_index = 1; controller_index <= NUM_CONTROLLER_AND_CARD_PORTS; controller_index++) | ||||
|   { | ||||
|     const ControllerType ctype = g_settings.controller_types[controller_index - 1]; | ||||
|     if (ctype == ControllerType::None) | ||||
|       continue; | ||||
| 
 | ||||
|     const auto section_name = TinyString::FromFormat("Controller%u", controller_index); | ||||
| 
 | ||||
|     si.DeleteValue(section_name, "Type"); | ||||
| 
 | ||||
|     for (const auto& button : Controller::GetButtonNames(ctype)) | ||||
|       si.DeleteValue(section_name, button.first.c_str()); | ||||
| 
 | ||||
|     for (const auto& axis : Controller::GetAxisNames(ctype)) | ||||
|       si.DeleteValue(section_name, std::get<std::string>(axis).c_str()); | ||||
| 
 | ||||
|     if (Controller::GetVibrationMotorCount(ctype) > 0) | ||||
|       si.DeleteValue(section_name, "Rumble"); | ||||
|   } | ||||
|     si.ClearSection(TinyString::FromFormat("Controller%u", controller_index)); | ||||
| } | ||||
| 
 | ||||
| void CommonHostInterface::ApplyInputProfile(const char* profile_path, SettingsInterface& si) | ||||
|  | @ -1813,7 +1796,11 @@ void CommonHostInterface::ApplyInputProfile(const char* profile_path, SettingsIn | |||
|     const auto section_name = TinyString::FromFormat("Controller%u", controller_index); | ||||
|     const std::string ctype_str = profile.GetStringValue(section_name, "Type"); | ||||
|     if (ctype_str.empty()) | ||||
|     { | ||||
|       si.SetStringValue(section_name, "Type", Settings::GetControllerTypeName(ControllerType::None)); | ||||
|       g_settings.controller_types[controller_index - 1] = ControllerType::None; | ||||
|       continue; | ||||
|     } | ||||
| 
 | ||||
|     std::optional<ControllerType> ctype = Settings::ParseControllerTypeName(ctype_str.c_str()); | ||||
|     if (!ctype) | ||||
|  |  | |||
|  | @ -102,6 +102,13 @@ void INISettingsInterface::DeleteValue(const char* section, const char* key) | |||
|   m_ini.Delete(section, key); | ||||
| } | ||||
| 
 | ||||
| void INISettingsInterface::ClearSection(const char* section) | ||||
| { | ||||
|   m_dirty = true; | ||||
|   m_ini.Delete(section, nullptr); | ||||
|   m_ini.SetValue(section, nullptr, nullptr); | ||||
| } | ||||
| 
 | ||||
| std::vector<std::string> INISettingsInterface::GetStringList(const char* section, const char* key) | ||||
| { | ||||
|   std::list<CSimpleIniA::Entry> entries; | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ public: | |||
|   void SetBoolValue(const char* section, const char* key, bool value) override; | ||||
|   void SetStringValue(const char* section, const char* key, const char* value) override; | ||||
|   void DeleteValue(const char* section, const char* key) override; | ||||
|   void ClearSection(const char* section) override; | ||||
| 
 | ||||
|   std::vector<std::string> GetStringList(const char* section, const char* key) override; | ||||
|   void SetStringList(const char* section, const char* key, const std::vector<std::string>& items) override; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Albert Liu
						Albert Liu