summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/yuzu/configuration/configure_input.cpp6
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp46
2 files changed, 37 insertions, 15 deletions
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 567a36d9b..422022d02 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -190,12 +190,16 @@ void ConfigureInput::ApplyConfiguration() {
190 // This emulates a delay between disconnecting and reconnecting controllers as some games 190 // This emulates a delay between disconnecting and reconnecting controllers as some games
191 // do not respond to a change in controller type if it was instantaneous. 191 // do not respond to a change in controller type if it was instantaneous.
192 using namespace std::chrono_literals; 192 using namespace std::chrono_literals;
193 std::this_thread::sleep_for(60ms); 193 std::this_thread::sleep_for(150ms);
194 194
195 for (auto* controller : player_controllers) { 195 for (auto* controller : player_controllers) {
196 controller->TryConnectSelectedController(); 196 controller->TryConnectSelectedController();
197 } 197 }
198 198
199 // This emulates a delay between disconnecting and reconnecting controllers as some games
200 // do not respond to a change in controller type if it was instantaneous.
201 std::this_thread::sleep_for(150ms);
202
199 advanced->ApplyConfiguration(); 203 advanced->ApplyConfiguration();
200 204
201 const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue(); 205 const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 13f0351d4..fbe36046b 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -579,11 +579,11 @@ void ConfigureInputPlayer::ApplyConfiguration() {
579 // Apply configuration for handheld 579 // Apply configuration for handheld
580 if (player_index == 0) { 580 if (player_index == 0) {
581 auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX]; 581 auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
582 const auto handheld_connected = handheld.connected;
582 if (player.controller_type == Settings::ControllerType::Handheld) { 583 if (player.controller_type == Settings::ControllerType::Handheld) {
583 handheld = player; 584 handheld = player;
584 } 585 }
585 handheld.connected = ui->groupConnectedController->isChecked() && 586 handheld.connected = handheld_connected;
586 player.controller_type == Settings::ControllerType::Handheld;
587 } 587 }
588} 588}
589 589
@@ -595,6 +595,18 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
595 const auto player_connected = ui->groupConnectedController->isChecked() && 595 const auto player_connected = ui->groupConnectedController->isChecked() &&
596 controller_type != Settings::ControllerType::Handheld; 596 controller_type != Settings::ControllerType::Handheld;
597 597
598 // Connect Handheld depending on Player 1's controller configuration.
599 if (player_index == 0 && controller_type == Settings::ControllerType::Handheld) {
600 auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
601 const auto handheld_connected = ui->groupConnectedController->isChecked() &&
602 controller_type == Settings::ControllerType::Handheld;
603 // Connect only if handheld is going from disconnected to connected
604 if (!handheld.connected && handheld_connected) {
605 UpdateController(controller_type, HANDHELD_INDEX, true);
606 }
607 handheld.connected = handheld_connected;
608 }
609
598 if (player.controller_type == controller_type && player.connected == player_connected) { 610 if (player.controller_type == controller_type && player.connected == player_connected) {
599 // Set vibration devices in the event that the input device has changed. 611 // Set vibration devices in the event that the input device has changed.
600 ConfigureVibration::SetVibrationDevices(player_index); 612 ConfigureVibration::SetVibrationDevices(player_index);
@@ -606,22 +618,11 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
606 618
607 ConfigureVibration::SetVibrationDevices(player_index); 619 ConfigureVibration::SetVibrationDevices(player_index);
608 620
609 // Connect/Disconnect Handheld depending on Player 1's controller configuration.
610 if (player_index == 0) {
611 auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
612 if (controller_type == Settings::ControllerType::Handheld) {
613 handheld = player;
614 }
615 handheld.connected = ui->groupConnectedController->isChecked() &&
616 controller_type == Settings::ControllerType::Handheld;
617 UpdateController(Settings::ControllerType::Handheld, HANDHELD_INDEX, handheld.connected);
618 }
619
620 if (!player.connected) { 621 if (!player.connected) {
621 return; 622 return;
622 } 623 }
623 624
624 UpdateController(controller_type, player_index, player_connected); 625 UpdateController(controller_type, player_index, true);
625} 626}
626 627
627void ConfigureInputPlayer::TryDisconnectSelectedController() { 628void ConfigureInputPlayer::TryDisconnectSelectedController() {
@@ -632,11 +633,28 @@ void ConfigureInputPlayer::TryDisconnectSelectedController() {
632 const auto player_connected = ui->groupConnectedController->isChecked() && 633 const auto player_connected = ui->groupConnectedController->isChecked() &&
633 controller_type != Settings::ControllerType::Handheld; 634 controller_type != Settings::ControllerType::Handheld;
634 635
636 // Disconnect Handheld depending on Player 1's controller configuration.
637 if (player_index == 0 && player.controller_type == Settings::ControllerType::Handheld) {
638 const auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
639 const auto handheld_connected = ui->groupConnectedController->isChecked() &&
640 controller_type == Settings::ControllerType::Handheld;
641 // Disconnect only if handheld is going from connected to disconnected
642 if (handheld.connected && !handheld_connected) {
643 UpdateController(controller_type, HANDHELD_INDEX, false);
644 }
645 return;
646 }
647
635 // Do not do anything if the controller configuration has not changed. 648 // Do not do anything if the controller configuration has not changed.
636 if (player.controller_type == controller_type && player.connected == player_connected) { 649 if (player.controller_type == controller_type && player.connected == player_connected) {
637 return; 650 return;
638 } 651 }
639 652
653 // Do not disconnect if the controller is already disconnected
654 if (!player.connected) {
655 return;
656 }
657
640 // Disconnect the controller first. 658 // Disconnect the controller first.
641 UpdateController(controller_type, player_index, false); 659 UpdateController(controller_type, player_index, false);
642} 660}