diff options
Diffstat (limited to 'src/frontend_common/config.cpp')
-rw-r--r-- | src/frontend_common/config.cpp | 78 |
1 files changed, 58 insertions, 20 deletions
diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index 51576b4ee..905f35118 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -5,13 +5,14 @@ #include <array> #include "common/fs/fs.h" #include "common/fs/path_util.h" +#include "common/logging/log.h" #include "common/settings.h" #include "common/settings_common.h" #include "common/settings_enums.h" #include "config.h" #include "core/core.h" #include "core/hle/service/acc/profile_manager.h" -#include "core/hle/service/hid/controllers/npad.h" +#include "hid_core/resources/npad/npad.h" #include "network/network.h" #include <boost/algorithm/string/replace.hpp> @@ -58,6 +59,19 @@ void Config::Initialize(const std::optional<std::string> config_path) { } void Config::WriteToIni() const { + std::string config_type; + switch (type) { + case ConfigType::GlobalConfig: + config_type = "Global"; + break; + case ConfigType::PerGameConfig: + config_type = "Game Specific"; + break; + case ConfigType::InputProfile: + config_type = "Input Profile"; + break; + } + LOG_INFO(Config, "Writing {} configuration to: {}", config_type, config_loc); FILE* fp = nullptr; #ifdef _WIN32 fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb"); @@ -117,10 +131,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { player_prefix.append("player_").append(ToString(player_index)).append("_"); } + const auto profile_name = ReadStringSetting(std::string(player_prefix).append("profile_name")); + auto& player = Settings::values.players.GetValue()[player_index]; if (IsCustomConfig()) { - const auto profile_name = - ReadStringSetting(std::string(player_prefix).append("profile_name")); if (profile_name.empty()) { // Use the global input config player = Settings::values.players.GetValue(true)[player_index]; @@ -139,6 +153,10 @@ void Config::ReadPlayerValues(const std::size_t player_index) { player.controller_type = controller; } } else { + if (global) { + auto& player_global = Settings::values.players.GetValue(true)[player_index]; + player_global.profile_name = profile_name; + } std::string connected_key = player_prefix; player.connected = ReadBooleanSetting(connected_key.append("connected"), std::make_optional(player_index == 0)); @@ -280,6 +298,16 @@ void Config::ReadDebuggingValues() { EndGroup(); } +#ifdef __unix__ +void Config::ReadLinuxValues() { + BeginGroup(Settings::TranslateCategory(Settings::Category::Linux)); + + ReadCategory(Settings::Category::Linux); + + EndGroup(); +} +#endif + void Config::ReadServiceValues() { BeginGroup(Settings::TranslateCategory(Settings::Category::Services)); @@ -386,6 +414,9 @@ void Config::ReadValues() { ReadControlValues(); ReadCoreValues(); ReadCpuValues(); +#ifdef __unix__ + ReadLinuxValues(); +#endif ReadRendererValues(); ReadAudioValues(); ReadSystemValues(); @@ -412,6 +443,11 @@ void Config::SavePlayerValues(const std::size_t player_index) { std::make_optional(static_cast<u8>(Settings::ControllerType::ProController))); if (!player_prefix.empty() || !Settings::IsConfiguringGlobal()) { + if (global) { + const auto& player_global = Settings::values.players.GetValue(true)[player_index]; + WriteStringSetting(std::string(player_prefix).append("profile_name"), + player_global.profile_name, std::make_optional(std::string(""))); + } WriteBooleanSetting(std::string(player_prefix).append("connected"), player.connected, std::make_optional(player_index == 0)); WriteIntegerSetting(std::string(player_prefix).append("vibration_enabled"), @@ -468,16 +504,22 @@ void Config::SaveMotionTouchValues() { void Config::SaveValues() { if (global) { + LOG_DEBUG(Config, "Saving global generic configuration values"); SaveDataStorageValues(); SaveDebuggingValues(); SaveDisabledAddOnValues(); SaveNetworkValues(); SaveWebServiceValues(); SaveMiscellaneousValues(); + } else { + LOG_DEBUG(Config, "Saving only generic configuration values"); } SaveControlValues(); SaveCoreValues(); SaveCpuValues(); +#ifdef __unix__ + SaveLinuxValues(); +#endif SaveRendererValues(); SaveAudioValues(); SaveSystemValues(); @@ -552,6 +594,16 @@ void Config::SaveDebuggingValues() { EndGroup(); } +#ifdef __unix__ +void Config::SaveLinuxValues() { + BeginGroup(Settings::TranslateCategory(Settings::Category::Linux)); + + WriteCategory(Settings::Category::Linux); + + EndGroup(); +} +#endif + void Config::SaveNetworkValues() { BeginGroup(Settings::TranslateCategory(Settings::Category::Services)); @@ -762,17 +814,6 @@ void Config::WriteBooleanSetting(const std::string& key, const bool& value, WritePreparedSetting(key, AdjustOutputString(ToString(value)), string_default, use_global); } -template <typename T> -std::enable_if_t<std::is_integral_v<T>> Config::WriteIntegerSetting( - const std::string& key, const T& value, const std::optional<T>& default_value, - const std::optional<bool>& use_global) { - std::optional<std::string> string_default = std::nullopt; - if (default_value.has_value()) { - string_default = std::make_optional(ToString(default_value.value())); - } - WritePreparedSetting(key, AdjustOutputString(ToString(value)), string_default, use_global); -} - void Config::WriteDoubleSetting(const std::string& key, const double& value, const std::optional<double>& default_value, const std::optional<bool>& use_global) { @@ -825,10 +866,6 @@ void Config::Reload() { SaveValues(); } -void Config::Save() { - SaveValues(); -} - void Config::ClearControlPlayerValues() const { // If key is an empty string, all keys in the current group() are removed. const char* section = Settings::TranslateCategory(Settings::Category::Controls); @@ -894,9 +931,10 @@ void Config::WriteSettingGeneric(const Settings::BasicSetting* const setting) { WriteBooleanSetting(std::string(key).append("\\use_global"), setting->UsingGlobal()); } if (global || !setting->UsingGlobal()) { + auto value = global ? setting->ToStringGlobal() : setting->ToString(); WriteBooleanSetting(std::string(key).append("\\default"), - setting->ToString() == setting->DefaultToString()); - WriteStringSetting(key, setting->ToString()); + value == setting->DefaultToString()); + WriteStringSetting(key, value); } } else if (global) { WriteBooleanSetting(std::string(key).append("\\default"), |