diff options
| author | 2021-11-26 18:55:28 -0600 | |
|---|---|---|
| committer | 2021-11-26 18:55:28 -0600 | |
| commit | a4a0638bc8043ddaea13025dd7e07b198cdb3cee (patch) | |
| tree | 206e482be788e1000ebe81dbe191b2129c4cd5c1 /src | |
| parent | input_common: Fully implement UDP controllers (diff) | |
| download | yuzu-a4a0638bc8043ddaea13025dd7e07b198cdb3cee.tar.gz yuzu-a4a0638bc8043ddaea13025dd7e07b198cdb3cee.tar.xz yuzu-a4a0638bc8043ddaea13025dd7e07b198cdb3cee.zip | |
applet/controller: Enable configuring mode while the applet is open
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 6a2cdda63..eaa0f39f2 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -29,7 +29,7 @@ namespace { | |||
| 29 | 29 | ||
| 30 | void UpdateController(Core::HID::EmulatedController* controller, | 30 | void UpdateController(Core::HID::EmulatedController* controller, |
| 31 | Core::HID::NpadStyleIndex controller_type, bool connected) { | 31 | Core::HID::NpadStyleIndex controller_type, bool connected) { |
| 32 | if (controller->IsConnected()) { | 32 | if (controller->IsConnected(true)) { |
| 33 | controller->Disconnect(); | 33 | controller->Disconnect(); |
| 34 | } | 34 | } |
| 35 | controller->SetNpadStyleIndex(controller_type); | 35 | controller->SetNpadStyleIndex(controller_type); |
| @@ -139,6 +139,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog( | |||
| 139 | DisableUnsupportedPlayers(); | 139 | DisableUnsupportedPlayers(); |
| 140 | 140 | ||
| 141 | for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { | 141 | for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { |
| 142 | system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration(); | ||
| 142 | SetEmulatedControllers(player_index); | 143 | SetEmulatedControllers(player_index); |
| 143 | } | 144 | } |
| 144 | 145 | ||
| @@ -233,20 +234,24 @@ void QtControllerSelectorDialog::ApplyConfiguration() { | |||
| 233 | 234 | ||
| 234 | Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); | 235 | Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked()); |
| 235 | Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked()); | 236 | Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked()); |
| 237 | for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) { | ||
| 238 | system.HIDCore().GetEmulatedControllerByIndex(player_index)->DisableConfiguration(); | ||
| 239 | } | ||
| 236 | } | 240 | } |
| 237 | 241 | ||
| 238 | void QtControllerSelectorDialog::LoadConfiguration() { | 242 | void QtControllerSelectorDialog::LoadConfiguration() { |
| 239 | const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); | 243 | const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld); |
| 240 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { | 244 | for (std::size_t index = 0; index < NUM_PLAYERS; ++index) { |
| 241 | const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); | 245 | const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); |
| 242 | const auto connected = controller->IsConnected() || (index == 0 && handheld->IsConnected()); | 246 | const auto connected = |
| 247 | controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true)); | ||
| 243 | player_groupboxes[index]->setChecked(connected); | 248 | player_groupboxes[index]->setChecked(connected); |
| 244 | connected_controller_checkboxes[index]->setChecked(connected); | 249 | connected_controller_checkboxes[index]->setChecked(connected); |
| 245 | emulated_controllers[index]->setCurrentIndex( | 250 | emulated_controllers[index]->setCurrentIndex( |
| 246 | GetIndexFromControllerType(controller->GetNpadStyleIndex(), index)); | 251 | GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index)); |
| 247 | } | 252 | } |
| 248 | 253 | ||
| 249 | UpdateDockedState(handheld->IsConnected()); | 254 | UpdateDockedState(handheld->IsConnected(true)); |
| 250 | 255 | ||
| 251 | ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue()); | 256 | ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue()); |
| 252 | ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue()); | 257 | ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue()); |
| @@ -510,8 +515,8 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index) | |||
| 510 | const auto player_connected = player_groupboxes[player_index]->isChecked() && | 515 | const auto player_connected = player_groupboxes[player_index]->isChecked() && |
| 511 | controller_type != Core::HID::NpadStyleIndex::Handheld; | 516 | controller_type != Core::HID::NpadStyleIndex::Handheld; |
| 512 | 517 | ||
| 513 | if (controller->GetNpadStyleIndex() == controller_type && | 518 | if (controller->GetNpadStyleIndex(true) == controller_type && |
| 514 | controller->IsConnected() == player_connected) { | 519 | controller->IsConnected(true) == player_connected) { |
| 515 | // Set vibration devices in the event that the input device has changed. | 520 | // Set vibration devices in the event that the input device has changed. |
| 516 | ConfigureVibration::SetVibrationDevices(player_index); | 521 | ConfigureVibration::SetVibrationDevices(player_index); |
| 517 | return; | 522 | return; |
| @@ -633,7 +638,7 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() { | |||
| 633 | for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) { | 638 | for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) { |
| 634 | auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); | 639 | auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index); |
| 635 | // Disconnect any unsupported players here and disable or hide them if applicable. | 640 | // Disconnect any unsupported players here and disable or hide them if applicable. |
| 636 | UpdateController(controller, controller->GetNpadStyleIndex(), false); | 641 | UpdateController(controller, controller->GetNpadStyleIndex(true), false); |
| 637 | // Hide the player widgets when max_supported_controllers is less than or equal to 4. | 642 | // Hide the player widgets when max_supported_controllers is less than or equal to 4. |
| 638 | if (max_supported_players <= 4) { | 643 | if (max_supported_players <= 4) { |
| 639 | player_widgets[index]->hide(); | 644 | player_widgets[index]->hide(); |