Răsfoiți Sursa

applet/controller: Enable configuring mode while the applet is open

german77 4 ani în urmă
părinte
comite
a4a0638bc8
1 a modificat fișierele cu 12 adăugiri și 7 ștergeri
  1. 12 7
      src/yuzu/applets/qt_controller.cpp

+ 12 - 7
src/yuzu/applets/qt_controller.cpp

@@ -29,7 +29,7 @@ namespace {
 
 void UpdateController(Core::HID::EmulatedController* controller,
                       Core::HID::NpadStyleIndex controller_type, bool connected) {
-    if (controller->IsConnected()) {
+    if (controller->IsConnected(true)) {
         controller->Disconnect();
     }
     controller->SetNpadStyleIndex(controller_type);
@@ -139,6 +139,7 @@ QtControllerSelectorDialog::QtControllerSelectorDialog(
     DisableUnsupportedPlayers();
 
     for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
+        system.HIDCore().GetEmulatedControllerByIndex(player_index)->EnableConfiguration();
         SetEmulatedControllers(player_index);
     }
 
@@ -233,20 +234,24 @@ void QtControllerSelectorDialog::ApplyConfiguration() {
 
     Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
     Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
+    for (std::size_t player_index = 0; player_index < NUM_PLAYERS; ++player_index) {
+        system.HIDCore().GetEmulatedControllerByIndex(player_index)->DisableConfiguration();
+    }
 }
 
 void QtControllerSelectorDialog::LoadConfiguration() {
     const auto* handheld = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
     for (std::size_t index = 0; index < NUM_PLAYERS; ++index) {
         const auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
-        const auto connected = controller->IsConnected() || (index == 0 && handheld->IsConnected());
+        const auto connected =
+            controller->IsConnected(true) || (index == 0 && handheld->IsConnected(true));
         player_groupboxes[index]->setChecked(connected);
         connected_controller_checkboxes[index]->setChecked(connected);
         emulated_controllers[index]->setCurrentIndex(
-            GetIndexFromControllerType(controller->GetNpadStyleIndex(), index));
+            GetIndexFromControllerType(controller->GetNpadStyleIndex(true), index));
     }
 
-    UpdateDockedState(handheld->IsConnected());
+    UpdateDockedState(handheld->IsConnected(true));
 
     ui->vibrationGroup->setChecked(Settings::values.vibration_enabled.GetValue());
     ui->motionGroup->setChecked(Settings::values.motion_enabled.GetValue());
@@ -510,8 +515,8 @@ void QtControllerSelectorDialog::UpdateControllerState(std::size_t player_index)
     const auto player_connected = player_groupboxes[player_index]->isChecked() &&
                                   controller_type != Core::HID::NpadStyleIndex::Handheld;
 
-    if (controller->GetNpadStyleIndex() == controller_type &&
-        controller->IsConnected() == player_connected) {
+    if (controller->GetNpadStyleIndex(true) == controller_type &&
+        controller->IsConnected(true) == player_connected) {
         // Set vibration devices in the event that the input device has changed.
         ConfigureVibration::SetVibrationDevices(player_index);
         return;
@@ -633,7 +638,7 @@ void QtControllerSelectorDialog::DisableUnsupportedPlayers() {
     for (std::size_t index = max_supported_players; index < NUM_PLAYERS; ++index) {
         auto* controller = system.HIDCore().GetEmulatedControllerByIndex(index);
         // Disconnect any unsupported players here and disable or hide them if applicable.
-        UpdateController(controller, controller->GetNpadStyleIndex(), false);
+        UpdateController(controller, controller->GetNpadStyleIndex(true), false);
         // Hide the player widgets when max_supported_controllers is less than or equal to 4.
         if (max_supported_players <= 4) {
             player_widgets[index]->hide();