diff options
| -rw-r--r-- | src/yuzu/applets/controller.cpp | 46 | ||||
| -rw-r--r-- | src/yuzu/applets/controller.h | 6 |
2 files changed, 29 insertions, 23 deletions
diff --git a/src/yuzu/applets/controller.cpp b/src/yuzu/applets/controller.cpp index 4783446a8..4920d2df6 100644 --- a/src/yuzu/applets/controller.cpp +++ b/src/yuzu/applets/controller.cpp | |||
| @@ -171,7 +171,18 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 171 | ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected, | 171 | ui->checkboxPlayer7Connected, ui->checkboxPlayer8Connected, |
| 172 | }; | 172 | }; |
| 173 | 173 | ||
| 174 | // Setup/load everything prior to setting up connections. | ||
| 175 | // This avoids unintentionally changing the states of elements while loading them in. | ||
| 176 | SetSupportedControllers(); | ||
| 177 | DisableUnsupportedPlayers(); | ||
| 178 | LoadConfiguration(); | ||
| 179 | |||
| 174 | for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { | 180 | for (std::size_t i = 0; i < NUM_PLAYERS; ++i) { |
| 181 | SetExplainText(i); | ||
| 182 | UpdateControllerIcon(i); | ||
| 183 | UpdateLEDPattern(i); | ||
| 184 | UpdateBorderColor(i); | ||
| 185 | |||
| 175 | connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) { | 186 | connect(player_groupboxes[i], &QGroupBox::toggled, [this, i](bool checked) { |
| 176 | if (checked) { | 187 | if (checked) { |
| 177 | for (std::size_t index = 0; index <= i; ++index) { | 188 | for (std::size_t index = 0; index <= i; ++index) { |
| @@ -208,8 +219,6 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 208 | Settings::ControllerType::Handheld); | 219 | Settings::ControllerType::Handheld); |
| 209 | }); | 220 | }); |
| 210 | } | 221 | } |
| 211 | |||
| 212 | SetExplainText(i); | ||
| 213 | } | 222 | } |
| 214 | 223 | ||
| 215 | connect(ui->inputConfigButton, &QPushButton::clicked, this, | 224 | connect(ui->inputConfigButton, &QPushButton::clicked, this, |
| @@ -218,10 +227,6 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 218 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, | 227 | connect(ui->buttonBox, &QDialogButtonBox::accepted, this, |
| 219 | &QtControllerSelectorDialog::ApplyConfiguration); | 228 | &QtControllerSelectorDialog::ApplyConfiguration); |
| 220 | 229 | ||
| 221 | SetSupportedControllers(); | ||
| 222 | DisableUnsupportedPlayers(); | ||
| 223 | LoadConfiguration(); | ||
| 224 | |||
| 225 | // If keep_controllers_connected is false, forcefully disconnect all controllers | 230 | // If keep_controllers_connected is false, forcefully disconnect all controllers |
| 226 | if (!parameters.keep_controllers_connected) { | 231 | if (!parameters.keep_controllers_connected) { |
| 227 | for (auto player : player_groupboxes) { | 232 | for (auto player : player_groupboxes) { |
| @@ -249,6 +254,21 @@ void QtControllerSelectorDialog::ApplyConfiguration() { | |||
| 249 | Settings::values.vibration_enabled = ui->vibrationGroup->isChecked(); | 254 | Settings::values.vibration_enabled = ui->vibrationGroup->isChecked(); |
| 250 | } | 255 | } |
| 251 | 256 | ||
| 257 | void QtControllerSelectorDialog::LoadConfiguration() { | ||
| 258 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { | ||
| 259 | const auto connected = Settings::values.players[index].connected || | ||
| 260 | (index == 0 && Settings::values.players[8].connected); | ||
| 261 | player_groupboxes[index]->setChecked(connected); | ||
| 262 | connected_controller_checkboxes[index]->setChecked(connected); | ||
| 263 | emulated_controllers[index]->setCurrentIndex( | ||
| 264 | GetIndexFromControllerType(Settings::values.players[index].controller_type)); | ||
| 265 | } | ||
| 266 | |||
| 267 | UpdateDockedState(Settings::values.players[8].connected); | ||
| 268 | |||
| 269 | ui->vibrationGroup->setChecked(Settings::values.vibration_enabled); | ||
| 270 | } | ||
| 271 | |||
| 252 | void QtControllerSelectorDialog::CallConfigureInputDialog() { | 272 | void QtControllerSelectorDialog::CallConfigureInputDialog() { |
| 253 | const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players; | 273 | const auto max_supported_players = parameters.enable_single_mode ? 1 : parameters.max_players; |
| 254 | 274 | ||
| @@ -557,20 +577,6 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() { | |||
| 557 | } | 577 | } |
| 558 | } | 578 | } |
| 559 | 579 | ||
| 560 | void QtControllerSelectorDialog::LoadConfiguration() { | ||
| 561 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { | ||
| 562 | const auto connected = Settings::values.players[index].connected || | ||
| 563 | (index == 0 && Settings::values.players[8].connected); | ||
| 564 | player_groupboxes[index]->setChecked(connected); | ||
| 565 | emulated_controllers[index]->setCurrentIndex( | ||
| 566 | GetIndexFromControllerType(Settings::values.players[index].controller_type)); | ||
| 567 | } | ||
| 568 | |||
| 569 | UpdateDockedState(Settings::values.players[8].connected); | ||
| 570 | |||
| 571 | ui->vibrationGroup->setChecked(Settings::values.vibration_enabled); | ||
| 572 | } | ||
| 573 | |||
| 574 | QtControllerSelector::QtControllerSelector(GMainWindow& parent) { | 580 | QtControllerSelector::QtControllerSelector(GMainWindow& parent) { |
| 575 | connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent, | 581 | connect(this, &QtControllerSelector::MainWindowReconfigureControllers, &parent, |
| 576 | &GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection); | 582 | &GMainWindow::ControllerSelectorReconfigureControllers, Qt::QueuedConnection); |
diff --git a/src/yuzu/applets/controller.h b/src/yuzu/applets/controller.h index 6ab4bea09..2d6d588c6 100644 --- a/src/yuzu/applets/controller.h +++ b/src/yuzu/applets/controller.h | |||
| @@ -37,6 +37,9 @@ private: | |||
| 37 | // Applies the current configuration. | 37 | // Applies the current configuration. |
| 38 | void ApplyConfiguration(); | 38 | void ApplyConfiguration(); |
| 39 | 39 | ||
| 40 | // Loads the current input configuration into the frontend applet. | ||
| 41 | void LoadConfiguration(); | ||
| 42 | |||
| 40 | // Initializes the "Configure Input" Dialog. | 43 | // Initializes the "Configure Input" Dialog. |
| 41 | void CallConfigureInputDialog(); | 44 | void CallConfigureInputDialog(); |
| 42 | 45 | ||
| @@ -68,9 +71,6 @@ private: | |||
| 68 | // Disables and disconnects unsupported players based on the given parameters. | 71 | // Disables and disconnects unsupported players based on the given parameters. |
| 69 | void DisableUnsupportedPlayers(); | 72 | void DisableUnsupportedPlayers(); |
| 70 | 73 | ||
| 71 | // Loads the current input configuration into the frontend applet. | ||
| 72 | void LoadConfiguration(); | ||
| 73 | |||
| 74 | std::unique_ptr<Ui::QtControllerSelectorDialog> ui; | 74 | std::unique_ptr<Ui::QtControllerSelectorDialog> ui; |
| 75 | 75 | ||
| 76 | // Parameters sent in from the backend HLE applet. | 76 | // Parameters sent in from the backend HLE applet. |