diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-12-21 10:46:19 -0500 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-01-01 06:39:24 -0500 |
commit | 904ac1daec186a98c33f2e8ac140d919ca8fe0a7 (patch) | |
tree | 0c525192706039bd757264fdf0cf8b87d322ee7a /src/yuzu/configuration/configure_input_player.cpp | |
parent | da07977db0b71e52f5870e3adf8c2fa0ada3c706 (diff) |
configure_input: Modify controller connection delay
Increases the controller connection delay to 60ms and refactors it to attempt to disconnect all controllers prior to connecting all controllers in HID.
Diffstat (limited to 'src/yuzu/configuration/configure_input_player.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 3c7500ee33..46ea026e40 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -4,7 +4,6 @@ #include <algorithm> #include <memory> -#include <thread> #include <utility> #include <QGridLayout> #include <QInputDialog> @@ -576,6 +575,10 @@ void ConfigureInputPlayer::ApplyConfiguration() { std::transform(motions_param.begin(), motions_param.end(), motions.begin(), [](const Common::ParamPackage& param) { return param.Serialize(); }); +} + +void ConfigureInputPlayer::TryConnectSelectedController() { + auto& player = Settings::values.players.GetValue()[player_index]; const auto controller_type = GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); @@ -588,15 +591,12 @@ void ConfigureInputPlayer::ApplyConfiguration() { return; } - // Disconnect the controller first. - UpdateController(controller_type, player_index, false); - player.controller_type = controller_type; player.connected = player_connected; ConfigureVibration::SetVibrationDevices(player_index); - // Handheld + // Connect/Disconnect Handheld depending on Player 1's controller configuration. if (player_index == 0) { auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX]; if (controller_type == Settings::ControllerType::Handheld) { @@ -611,14 +611,26 @@ void ConfigureInputPlayer::ApplyConfiguration() { return; } - // This emulates a delay between disconnecting and reconnecting controllers as some games - // do not respond to a change in controller type if it was instantaneous. - using namespace std::chrono_literals; - std::this_thread::sleep_for(20ms); - UpdateController(controller_type, player_index, player_connected); } +void ConfigureInputPlayer::TryDisconnectSelectedController() { + const auto& player = Settings::values.players.GetValue()[player_index]; + + const auto controller_type = + GetControllerTypeFromIndex(ui->comboControllerType->currentIndex()); + const auto player_connected = ui->groupConnectedController->isChecked() && + controller_type != Settings::ControllerType::Handheld; + + // Do not do anything if the controller configuration has not changed. + if (player.controller_type == controller_type && player.connected == player_connected) { + return; + } + + // Disconnect the controller first. + UpdateController(controller_type, player_index, false); +} + void ConfigureInputPlayer::showEvent(QShowEvent* event) { if (bottom_row == nullptr) { return; |