diff options
| author | 2022-11-19 15:39:09 -0500 | |
|---|---|---|
| committer | 2022-11-28 19:22:18 -0500 | |
| commit | 3de05726eb9d6bd8637134eb37ce8072c4289cd6 (patch) | |
| tree | ca2d6dfe81cb75c45114a7037b05ed94cc9ecf12 /src | |
| parent | configure_input_per_game: Allow configuring all 8 players (diff) | |
| download | yuzu-3de05726eb9d6bd8637134eb37ce8072c4289cd6.tar.gz yuzu-3de05726eb9d6bd8637134eb37ce8072c4289cd6.tar.xz yuzu-3de05726eb9d6bd8637134eb37ce8072c4289cd6.zip | |
config: Custom profile detection fixes
Also only reads/writes applicable configs for the custom profiles.
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 89 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_per_game.cpp | 61 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_per_game.h | 17 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_per_game.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 1 |
6 files changed, 108 insertions, 64 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 4067ea607..cc1ba9f70 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -124,6 +124,10 @@ void Config::Initialize(const std::string& config_name) { | |||
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | bool Config::IsCustomConfig() { | ||
| 128 | return type == ConfigType::PerGameConfig; | ||
| 129 | } | ||
| 130 | |||
| 127 | /* {Read,Write}BasicSetting and WriteGlobalSetting templates must be defined here before their | 131 | /* {Read,Write}BasicSetting and WriteGlobalSetting templates must be defined here before their |
| 128 | * usages later in this file. This allows explicit definition of some types that don't work | 132 | * usages later in this file. This allows explicit definition of some types that don't work |
| 129 | * nicely with the general version. | 133 | * nicely with the general version. |
| @@ -186,7 +190,7 @@ void Config::WriteGlobalSetting(const Settings::SwitchableSetting<Type, ranged>& | |||
| 186 | 190 | ||
| 187 | void Config::ReadPlayerValue(std::size_t player_index) { | 191 | void Config::ReadPlayerValue(std::size_t player_index) { |
| 188 | const QString player_prefix = [this, player_index] { | 192 | const QString player_prefix = [this, player_index] { |
| 189 | if (type == ConfigType::InputProfile && global) { | 193 | if (type == ConfigType::InputProfile) { |
| 190 | return QString{}; | 194 | return QString{}; |
| 191 | } else { | 195 | } else { |
| 192 | return QStringLiteral("player_%1_").arg(player_index); | 196 | return QStringLiteral("player_%1_").arg(player_index); |
| @@ -194,8 +198,20 @@ void Config::ReadPlayerValue(std::size_t player_index) { | |||
| 194 | }(); | 198 | }(); |
| 195 | 199 | ||
| 196 | auto& player = Settings::values.players.GetValue()[player_index]; | 200 | auto& player = Settings::values.players.GetValue()[player_index]; |
| 201 | if (IsCustomConfig()) { | ||
| 202 | const auto profile_name = | ||
| 203 | qt_config->value(QStringLiteral("%1profile_name").arg(player_prefix), QString{}) | ||
| 204 | .toString() | ||
| 205 | .toStdString(); | ||
| 206 | if (profile_name.empty()) { | ||
| 207 | // Use the global input config | ||
| 208 | player = Settings::values.players.GetValue(true)[player_index]; | ||
| 209 | return; | ||
| 210 | } | ||
| 211 | player.profile_name = profile_name; | ||
| 212 | } | ||
| 197 | 213 | ||
| 198 | if (player_prefix.isEmpty()) { | 214 | if (player_prefix.isEmpty() && Settings::IsConfiguringGlobal()) { |
| 199 | const auto controller = static_cast<Settings::ControllerType>( | 215 | const auto controller = static_cast<Settings::ControllerType>( |
| 200 | qt_config | 216 | qt_config |
| 201 | ->value(QStringLiteral("%1type").arg(player_prefix), | 217 | ->value(QStringLiteral("%1type").arg(player_prefix), |
| @@ -244,14 +260,6 @@ void Config::ReadPlayerValue(std::size_t player_index) { | |||
| 244 | ->value(QStringLiteral("%1button_color_right").arg(player_prefix), | 260 | ->value(QStringLiteral("%1button_color_right").arg(player_prefix), |
| 245 | Settings::JOYCON_BUTTONS_NEON_RED) | 261 | Settings::JOYCON_BUTTONS_NEON_RED) |
| 246 | .toUInt(); | 262 | .toUInt(); |
| 247 | |||
| 248 | // This only applies to per-game configs | ||
| 249 | if (!global) { | ||
| 250 | player.profile_name = | ||
| 251 | qt_config->value(QStringLiteral("%1profile_name").arg(player_prefix), QString{}) | ||
| 252 | .toString() | ||
| 253 | .toStdString(); | ||
| 254 | } | ||
| 255 | } | 263 | } |
| 256 | 264 | ||
| 257 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 265 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| @@ -394,12 +402,28 @@ void Config::ReadAudioValues() { | |||
| 394 | } | 402 | } |
| 395 | 403 | ||
| 396 | void Config::ReadControlValues() { | 404 | void Config::ReadControlValues() { |
| 397 | Settings::values.players.SetGlobal(global); | ||
| 398 | qt_config->beginGroup(QStringLiteral("Controls")); | 405 | qt_config->beginGroup(QStringLiteral("Controls")); |
| 399 | 406 | ||
| 407 | Settings::values.players.SetGlobal(!IsCustomConfig()); | ||
| 400 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { | 408 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { |
| 401 | ReadPlayerValue(p); | 409 | ReadPlayerValue(p); |
| 402 | } | 410 | } |
| 411 | ReadGlobalSetting(Settings::values.use_docked_mode); | ||
| 412 | |||
| 413 | // Disable docked mode if handheld is selected | ||
| 414 | const auto controller_type = Settings::values.players.GetValue()[0].controller_type; | ||
| 415 | if (controller_type == Settings::ControllerType::Handheld) { | ||
| 416 | Settings::values.use_docked_mode.SetGlobal(!IsCustomConfig()); | ||
| 417 | Settings::values.use_docked_mode.SetValue(false); | ||
| 418 | } | ||
| 419 | |||
| 420 | ReadGlobalSetting(Settings::values.vibration_enabled); | ||
| 421 | ReadGlobalSetting(Settings::values.enable_accurate_vibrations); | ||
| 422 | ReadGlobalSetting(Settings::values.motion_enabled); | ||
| 423 | if (IsCustomConfig()) { | ||
| 424 | qt_config->endGroup(); | ||
| 425 | return; | ||
| 426 | } | ||
| 403 | ReadDebugValues(); | 427 | ReadDebugValues(); |
| 404 | ReadKeyboardValues(); | 428 | ReadKeyboardValues(); |
| 405 | ReadMouseValues(); | 429 | ReadMouseValues(); |
| @@ -421,18 +445,6 @@ void Config::ReadControlValues() { | |||
| 421 | ReadBasicSetting(Settings::values.tas_loop); | 445 | ReadBasicSetting(Settings::values.tas_loop); |
| 422 | ReadBasicSetting(Settings::values.pause_tas_on_load); | 446 | ReadBasicSetting(Settings::values.pause_tas_on_load); |
| 423 | 447 | ||
| 424 | ReadGlobalSetting(Settings::values.use_docked_mode); | ||
| 425 | |||
| 426 | // Disable docked mode if handheld is selected | ||
| 427 | const auto controller_type = Settings::values.players.GetValue()[0].controller_type; | ||
| 428 | if (controller_type == Settings::ControllerType::Handheld) { | ||
| 429 | Settings::values.use_docked_mode.SetValue(false); | ||
| 430 | } | ||
| 431 | |||
| 432 | ReadGlobalSetting(Settings::values.vibration_enabled); | ||
| 433 | ReadGlobalSetting(Settings::values.enable_accurate_vibrations); | ||
| 434 | ReadGlobalSetting(Settings::values.motion_enabled); | ||
| 435 | |||
| 436 | ReadBasicSetting(Settings::values.controller_navigation); | 448 | ReadBasicSetting(Settings::values.controller_navigation); |
| 437 | 449 | ||
| 438 | qt_config->endGroup(); | 450 | qt_config->endGroup(); |
| @@ -932,7 +944,7 @@ void Config::ReadValues() { | |||
| 932 | 944 | ||
| 933 | void Config::SavePlayerValue(std::size_t player_index) { | 945 | void Config::SavePlayerValue(std::size_t player_index) { |
| 934 | const QString player_prefix = [this, player_index] { | 946 | const QString player_prefix = [this, player_index] { |
| 935 | if (type == ConfigType::InputProfile && global) { | 947 | if (type == ConfigType::InputProfile) { |
| 936 | return QString{}; | 948 | return QString{}; |
| 937 | } else { | 949 | } else { |
| 938 | return QStringLiteral("player_%1_").arg(player_index); | 950 | return QStringLiteral("player_%1_").arg(player_index); |
| @@ -940,12 +952,20 @@ void Config::SavePlayerValue(std::size_t player_index) { | |||
| 940 | }(); | 952 | }(); |
| 941 | 953 | ||
| 942 | const auto& player = Settings::values.players.GetValue()[player_index]; | 954 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 955 | if (IsCustomConfig()) { | ||
| 956 | if (player.profile_name.empty()) { | ||
| 957 | // No custom profile selected | ||
| 958 | return; | ||
| 959 | } | ||
| 960 | WriteSetting(QStringLiteral("%1profile_name").arg(player_prefix), | ||
| 961 | QString::fromStdString(player.profile_name), QString{}); | ||
| 962 | } | ||
| 943 | 963 | ||
| 944 | WriteSetting(QStringLiteral("%1type").arg(player_prefix), | 964 | WriteSetting(QStringLiteral("%1type").arg(player_prefix), |
| 945 | static_cast<u8>(player.controller_type), | 965 | static_cast<u8>(player.controller_type), |
| 946 | static_cast<u8>(Settings::ControllerType::ProController)); | 966 | static_cast<u8>(Settings::ControllerType::ProController)); |
| 947 | 967 | ||
| 948 | if (!player_prefix.isEmpty()) { | 968 | if (!player_prefix.isEmpty() || !Settings::IsConfiguringGlobal()) { |
| 949 | WriteSetting(QStringLiteral("%1connected").arg(player_prefix), player.connected, | 969 | WriteSetting(QStringLiteral("%1connected").arg(player_prefix), player.connected, |
| 950 | player_index == 0); | 970 | player_index == 0); |
| 951 | WriteSetting(QStringLiteral("%1vibration_enabled").arg(player_prefix), | 971 | WriteSetting(QStringLiteral("%1vibration_enabled").arg(player_prefix), |
| @@ -960,12 +980,6 @@ void Config::SavePlayerValue(std::size_t player_index) { | |||
| 960 | player.button_color_left, Settings::JOYCON_BUTTONS_NEON_BLUE); | 980 | player.button_color_left, Settings::JOYCON_BUTTONS_NEON_BLUE); |
| 961 | WriteSetting(QStringLiteral("%1button_color_right").arg(player_prefix), | 981 | WriteSetting(QStringLiteral("%1button_color_right").arg(player_prefix), |
| 962 | player.button_color_right, Settings::JOYCON_BUTTONS_NEON_RED); | 982 | player.button_color_right, Settings::JOYCON_BUTTONS_NEON_RED); |
| 963 | |||
| 964 | // This only applies to per-game configs | ||
| 965 | if (!global) { | ||
| 966 | WriteSetting(QStringLiteral("%1profile_name").arg(player_prefix), | ||
| 967 | QString::fromStdString(player.profile_name), QString{}); | ||
| 968 | } | ||
| 969 | } | 983 | } |
| 970 | 984 | ||
| 971 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 985 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| @@ -1100,12 +1114,16 @@ void Config::SaveAudioValues() { | |||
| 1100 | } | 1114 | } |
| 1101 | 1115 | ||
| 1102 | void Config::SaveControlValues() { | 1116 | void Config::SaveControlValues() { |
| 1103 | Settings::values.players.SetGlobal(global); | ||
| 1104 | qt_config->beginGroup(QStringLiteral("Controls")); | 1117 | qt_config->beginGroup(QStringLiteral("Controls")); |
| 1105 | 1118 | ||
| 1119 | Settings::values.players.SetGlobal(!IsCustomConfig()); | ||
| 1106 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { | 1120 | for (std::size_t p = 0; p < Settings::values.players.GetValue().size(); ++p) { |
| 1107 | SavePlayerValue(p); | 1121 | SavePlayerValue(p); |
| 1108 | } | 1122 | } |
| 1123 | if (IsCustomConfig()) { | ||
| 1124 | qt_config->endGroup(); | ||
| 1125 | return; | ||
| 1126 | } | ||
| 1109 | SaveDebugValues(); | 1127 | SaveDebugValues(); |
| 1110 | SaveMouseValues(); | 1128 | SaveMouseValues(); |
| 1111 | SaveTouchscreenValues(); | 1129 | SaveTouchscreenValues(); |
| @@ -1590,6 +1608,13 @@ void Config::SaveControlPlayerValue(std::size_t player_index) { | |||
| 1590 | qt_config->endGroup(); | 1608 | qt_config->endGroup(); |
| 1591 | } | 1609 | } |
| 1592 | 1610 | ||
| 1611 | void Config::ClearControlPlayerValues() { | ||
| 1612 | qt_config->beginGroup(QStringLiteral("Controls")); | ||
| 1613 | // If key is an empty string, all keys in the current group() are removed. | ||
| 1614 | qt_config->remove(QString{}); | ||
| 1615 | qt_config->endGroup(); | ||
| 1616 | } | ||
| 1617 | |||
| 1593 | const std::string& Config::GetConfigFilePath() const { | 1618 | const std::string& Config::GetConfigFilePath() const { |
| 1594 | return qt_config_loc; | 1619 | return qt_config_loc; |
| 1595 | } | 1620 | } |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 06fa7d2d0..7d26e9ab6 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -34,6 +34,7 @@ public: | |||
| 34 | 34 | ||
| 35 | void ReadControlPlayerValue(std::size_t player_index); | 35 | void ReadControlPlayerValue(std::size_t player_index); |
| 36 | void SaveControlPlayerValue(std::size_t player_index); | 36 | void SaveControlPlayerValue(std::size_t player_index); |
| 37 | void ClearControlPlayerValues(); | ||
| 37 | 38 | ||
| 38 | const std::string& GetConfigFilePath() const; | 39 | const std::string& GetConfigFilePath() const; |
| 39 | 40 | ||
| @@ -58,6 +59,7 @@ public: | |||
| 58 | 59 | ||
| 59 | private: | 60 | private: |
| 60 | void Initialize(const std::string& config_name); | 61 | void Initialize(const std::string& config_name); |
| 62 | bool IsCustomConfig(); | ||
| 61 | 63 | ||
| 62 | void ReadValues(); | 64 | void ReadValues(); |
| 63 | void ReadPlayerValue(std::size_t player_index); | 65 | void ReadPlayerValue(std::size_t player_index); |
diff --git a/src/yuzu/configuration/configure_input_per_game.cpp b/src/yuzu/configuration/configure_input_per_game.cpp index af5cee542..78e65d468 100644 --- a/src/yuzu/configuration/configure_input_per_game.cpp +++ b/src/yuzu/configuration/configure_input_per_game.cpp | |||
| @@ -6,12 +6,14 @@ | |||
| 6 | #include "core/hid/emulated_controller.h" | 6 | #include "core/hid/emulated_controller.h" |
| 7 | #include "core/hid/hid_core.h" | 7 | #include "core/hid/hid_core.h" |
| 8 | #include "ui_configure_input_per_game.h" | 8 | #include "ui_configure_input_per_game.h" |
| 9 | #include "yuzu/configuration/config.h" | ||
| 9 | #include "yuzu/configuration/configure_input_per_game.h" | 10 | #include "yuzu/configuration/configure_input_per_game.h" |
| 10 | #include "yuzu/configuration/input_profiles.h" | 11 | #include "yuzu/configuration/input_profiles.h" |
| 11 | 12 | ||
| 12 | ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QWidget* parent) | 13 | ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, Config* config_, |
| 14 | QWidget* parent) | ||
| 13 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()), | 15 | : QWidget(parent), ui(std::make_unique<Ui::ConfigureInputPerGame>()), |
| 14 | profiles(std::make_unique<InputProfiles>()), system{system_} { | 16 | profiles(std::make_unique<InputProfiles>()), system{system_}, config{config_} { |
| 15 | ui->setupUi(this); | 17 | ui->setupUi(this); |
| 16 | const std::array labels = { | 18 | const std::array labels = { |
| 17 | ui->label_player_1, ui->label_player_2, ui->label_player_3, ui->label_player_4, | 19 | ui->label_player_1, ui->label_player_2, ui->label_player_3, ui->label_player_4, |
| @@ -22,6 +24,8 @@ ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QWidget* par | |||
| 22 | ui->profile_player_5, ui->profile_player_6, ui->profile_player_7, ui->profile_player_8, | 24 | ui->profile_player_5, ui->profile_player_6, ui->profile_player_7, ui->profile_player_8, |
| 23 | }; | 25 | }; |
| 24 | 26 | ||
| 27 | Settings::values.players.SetGlobal(false); | ||
| 28 | |||
| 25 | const auto& profile_names = profiles->GetInputProfileNames(); | 29 | const auto& profile_names = profiles->GetInputProfileNames(); |
| 26 | const auto populate_profiles = [this, &profile_names](size_t player_index) { | 30 | const auto populate_profiles = [this, &profile_names](size_t player_index) { |
| 27 | const auto previous_profile = | 31 | const auto previous_profile = |
| @@ -29,6 +33,7 @@ ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QWidget* par | |||
| 29 | 33 | ||
| 30 | auto* const player_combobox = profile_comboboxes[player_index]; | 34 | auto* const player_combobox = profile_comboboxes[player_index]; |
| 31 | player_combobox->addItem(tr("Use global input configuration")); | 35 | player_combobox->addItem(tr("Use global input configuration")); |
| 36 | |||
| 32 | for (size_t index = 0; index < profile_names.size(); ++index) { | 37 | for (size_t index = 0; index < profile_names.size(); ++index) { |
| 33 | const auto& profile_name = profile_names[index]; | 38 | const auto& profile_name = profile_names[index]; |
| 34 | player_combobox->addItem(QString::fromStdString(profile_name)); | 39 | player_combobox->addItem(QString::fromStdString(profile_name)); |
| @@ -38,7 +43,6 @@ ConfigureInputPerGame::ConfigureInputPerGame(Core::System& system_, QWidget* par | |||
| 38 | } | 43 | } |
| 39 | } | 44 | } |
| 40 | }; | 45 | }; |
| 41 | |||
| 42 | for (size_t index = 0; index < profile_comboboxes.size(); ++index) { | 46 | for (size_t index = 0; index < profile_comboboxes.size(); ++index) { |
| 43 | labels[index]->setText(tr("Player %1 profile").arg(index + 1)); | 47 | labels[index]->setText(tr("Player %1 profile").arg(index + 1)); |
| 44 | populate_profiles(index); | 48 | populate_profiles(index); |
| @@ -53,8 +57,10 @@ void ConfigureInputPerGame::ApplyConfiguration() { | |||
| 53 | } | 57 | } |
| 54 | 58 | ||
| 55 | void ConfigureInputPerGame::LoadConfiguration() { | 59 | void ConfigureInputPerGame::LoadConfiguration() { |
| 60 | static constexpr size_t HANDHELD_INDEX = 8; | ||
| 61 | |||
| 56 | auto& hid_core = system.HIDCore(); | 62 | auto& hid_core = system.HIDCore(); |
| 57 | const auto load_player_profile = [this, &hid_core](size_t player_index) { | 63 | for (size_t player_index = 0; player_index < profile_comboboxes.size(); ++player_index) { |
| 58 | Settings::values.players.SetGlobal(false); | 64 | Settings::values.players.SetGlobal(false); |
| 59 | 65 | ||
| 60 | auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); | 66 | auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); |
| @@ -63,40 +69,47 @@ void ConfigureInputPerGame::LoadConfiguration() { | |||
| 63 | const auto selection_index = player_combobox->currentIndex(); | 69 | const auto selection_index = player_combobox->currentIndex(); |
| 64 | if (selection_index == 0) { | 70 | if (selection_index == 0) { |
| 65 | Settings::values.players.GetValue()[player_index].profile_name = ""; | 71 | Settings::values.players.GetValue()[player_index].profile_name = ""; |
| 72 | if (player_index == 0) { | ||
| 73 | Settings::values.players.GetValue()[HANDHELD_INDEX] = {}; | ||
| 74 | } | ||
| 66 | Settings::values.players.SetGlobal(true); | 75 | Settings::values.players.SetGlobal(true); |
| 67 | emulated_controller->ReloadFromSettings(); | 76 | emulated_controller->ReloadFromSettings(); |
| 68 | return; | 77 | continue; |
| 69 | } | 78 | } |
| 70 | const auto profile_name = player_combobox->itemText(selection_index).toStdString(); | 79 | const auto profile_name = player_combobox->itemText(selection_index).toStdString(); |
| 71 | if (profile_name.empty()) { | 80 | if (profile_name.empty()) { |
| 72 | return; | 81 | continue; |
| 73 | } | 82 | } |
| 83 | auto& player = Settings::values.players.GetValue()[player_index]; | ||
| 84 | player.profile_name = profile_name; | ||
| 85 | // Read from the profile into the custom player settings | ||
| 74 | profiles->LoadProfile(profile_name, player_index); | 86 | profiles->LoadProfile(profile_name, player_index); |
| 75 | Settings::values.players.GetValue()[player_index].profile_name = profile_name; | 87 | // Make sure the controller is connected |
| 88 | player.connected = true; | ||
| 89 | |||
| 76 | emulated_controller->ReloadFromSettings(); | 90 | emulated_controller->ReloadFromSettings(); |
| 77 | }; | ||
| 78 | 91 | ||
| 79 | for (size_t index = 0; index < profile_comboboxes.size(); ++index) { | 92 | if (player_index > 0) { |
| 80 | load_player_profile(index); | 93 | continue; |
| 94 | } | ||
| 95 | // Handle Handheld cases | ||
| 96 | auto& handheld_player = Settings::values.players.GetValue()[HANDHELD_INDEX]; | ||
| 97 | auto* handheld_controller = hid_core.GetEmulatedController(Core::HID::NpadIdType::Handheld); | ||
| 98 | if (player.controller_type == Settings::ControllerType::Handheld) { | ||
| 99 | handheld_player = player; | ||
| 100 | } else { | ||
| 101 | handheld_player = {}; | ||
| 102 | } | ||
| 103 | handheld_controller->ReloadFromSettings(); | ||
| 81 | } | 104 | } |
| 82 | } | 105 | } |
| 83 | 106 | ||
| 84 | void ConfigureInputPerGame::SaveConfiguration() { | 107 | void ConfigureInputPerGame::SaveConfiguration() { |
| 85 | Settings::values.players.SetGlobal(false); | 108 | Settings::values.players.SetGlobal(false); |
| 86 | 109 | ||
| 87 | auto& hid_core = system.HIDCore(); | 110 | // Clear all controls from the config in case the user reverted back to globals |
| 88 | const auto save_player_profile = [this, &hid_core](size_t player_index) { | 111 | config->ClearControlPlayerValues(); |
| 89 | const auto selection_index = profile_comboboxes[player_index]->currentIndex(); | 112 | for (size_t index = 0; index < Settings::values.players.GetValue().size(); ++index) { |
| 90 | if (selection_index == 0) { | 113 | config->SaveControlPlayerValue(index); |
| 91 | return; | ||
| 92 | } | ||
| 93 | auto* emulated_controller = hid_core.GetEmulatedControllerByIndex(player_index); | ||
| 94 | profiles->SaveProfile(Settings::values.players.GetValue()[player_index].profile_name, | ||
| 95 | player_index); | ||
| 96 | emulated_controller->ReloadFromSettings(); | ||
| 97 | }; | ||
| 98 | |||
| 99 | for (size_t index = 0; index < profile_comboboxes.size(); ++index) { | ||
| 100 | save_player_profile(index); | ||
| 101 | } | 114 | } |
| 102 | } | 115 | } |
diff --git a/src/yuzu/configuration/configure_input_per_game.h b/src/yuzu/configuration/configure_input_per_game.h index a586ec07c..660faf574 100644 --- a/src/yuzu/configuration/configure_input_per_game.h +++ b/src/yuzu/configuration/configure_input_per_game.h | |||
| @@ -7,21 +7,23 @@ | |||
| 7 | 7 | ||
| 8 | #include <QWidget> | 8 | #include <QWidget> |
| 9 | 9 | ||
| 10 | #include "ui_configure_input_per_game.h" | ||
| 11 | #include "yuzu/configuration/input_profiles.h" | ||
| 12 | |||
| 13 | class QComboBox; | ||
| 14 | |||
| 10 | namespace Core { | 15 | namespace Core { |
| 11 | class System; | 16 | class System; |
| 12 | } | 17 | } // namespace Core |
| 13 | |||
| 14 | namespace Ui { | ||
| 15 | class ConfigureInputPerGame; | ||
| 16 | } | ||
| 17 | 18 | ||
| 18 | class InputProfiles; | 19 | class Config; |
| 19 | 20 | ||
| 20 | class ConfigureInputPerGame : public QWidget { | 21 | class ConfigureInputPerGame : public QWidget { |
| 21 | Q_OBJECT | 22 | Q_OBJECT |
| 22 | 23 | ||
| 23 | public: | 24 | public: |
| 24 | explicit ConfigureInputPerGame(Core::System& system_, QWidget* parent = nullptr); | 25 | explicit ConfigureInputPerGame(Core::System& system_, Config* config_, |
| 26 | QWidget* parent = nullptr); | ||
| 25 | 27 | ||
| 26 | /// Load and Save configurations to settings file. | 28 | /// Load and Save configurations to settings file. |
| 27 | void ApplyConfiguration(); | 29 | void ApplyConfiguration(); |
| @@ -39,4 +41,5 @@ private: | |||
| 39 | std::array<QComboBox*, 8> profile_comboboxes; | 41 | std::array<QComboBox*, 8> profile_comboboxes; |
| 40 | 42 | ||
| 41 | Core::System& system; | 43 | Core::System& system; |
| 44 | Config* config; | ||
| 42 | }; | 45 | }; |
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp index cf0a6dc0e..93db47cfd 100644 --- a/src/yuzu/configuration/configure_per_game.cpp +++ b/src/yuzu/configuration/configure_per_game.cpp | |||
| @@ -50,7 +50,7 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st | |||
| 50 | general_tab = std::make_unique<ConfigureGeneral>(system_, this); | 50 | general_tab = std::make_unique<ConfigureGeneral>(system_, this); |
| 51 | graphics_tab = std::make_unique<ConfigureGraphics>(system_, this); | 51 | graphics_tab = std::make_unique<ConfigureGraphics>(system_, this); |
| 52 | graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); | 52 | graphics_advanced_tab = std::make_unique<ConfigureGraphicsAdvanced>(system_, this); |
| 53 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, this); | 53 | input_tab = std::make_unique<ConfigureInputPerGame>(system_, game_config.get(), this); |
| 54 | system_tab = std::make_unique<ConfigureSystem>(system_, this); | 54 | system_tab = std::make_unique<ConfigureSystem>(system_, this); |
| 55 | 55 | ||
| 56 | ui->setupUi(this); | 56 | ui->setupUi(this); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e0c353788..21983a799 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1669,6 +1669,7 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t | |||
| 1669 | ? Common::FS::PathToUTF8String(file_path.filename()) | 1669 | ? Common::FS::PathToUTF8String(file_path.filename()) |
| 1670 | : fmt::format("{:016X}", title_id); | 1670 | : fmt::format("{:016X}", title_id); |
| 1671 | Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); | 1671 | Config per_game_config(config_file_name, Config::ConfigType::PerGameConfig); |
| 1672 | system->HIDCore().ReloadInputDevices(); | ||
| 1672 | system->ApplySettings(); | 1673 | system->ApplySettings(); |
| 1673 | } | 1674 | } |
| 1674 | 1675 | ||