diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2023-10-14 09:58:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-14 09:58:27 -0400 |
commit | 9524d7034ccc7a048b7dfc1c72b4ba368ad7759b (patch) | |
tree | 6b649f5b6a8fedb9a400ad59c5bb5a539d2b0565 /src/yuzu/configuration/configure_input.cpp | |
parent | 36d18e457bfa7c178547b77c8e961b20baf1590f (diff) | |
parent | 27ab2a6e13885fc93aeaa402b1efa9e920429f28 (diff) |
Merge pull request #11779 from flodavid/improve-player-config-click
yuzu: Improve behavior when clicking on controller box in Control configuration
Diffstat (limited to 'src/yuzu/configuration/configure_input.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index e8f9ebfd8..5a48e388b 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -115,17 +115,9 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, for (std::size_t i = 0; i < player_tabs.size(); ++i) { player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i])); player_tabs[i]->layout()->addWidget(player_controllers[i]); - connect(player_controllers[i], &ConfigureInputPlayer::Connected, [&, i](bool is_connected) { + connect(player_connected[i], &QCheckBox::clicked, [this, i](int checked) { // Ensures that the controllers are always connected in sequential order - if (is_connected) { - for (std::size_t index = 0; index <= i; ++index) { - player_connected[index]->setChecked(is_connected); - } - } else { - for (std::size_t index = i; index < player_tabs.size(); ++index) { - player_connected[index]->setChecked(is_connected); - } - } + this->propagateMouseClickOnPlayers(i, checked, true); }); connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices, this, &ConfigureInput::UpdateAllInputDevices); @@ -183,6 +175,30 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, LoadConfiguration(); } +void ConfigureInput::propagateMouseClickOnPlayers(size_t player_index, bool checked, bool origin) { + // Origin has already been toggled + if (!origin) { + player_connected[player_index]->setChecked(checked); + } + + if (checked) { + // Check all previous buttons when checked + if (player_index > 0) { + propagateMouseClickOnPlayers(player_index - 1, checked, false); + } + } else { + // Unchecked all following buttons when unchecked + if (player_index < player_tabs.size() - 1) { + // Reconnect current player if it was the last one checked + // (player number was reduced by more than one) + if (origin && player_connected[player_index + 1]->checkState() == Qt::Checked) { + player_connected[player_index]->setCheckState(Qt::Checked); + } + propagateMouseClickOnPlayers(player_index + 1, checked, false); + } + } +} + QList<QWidget*> ConfigureInput::GetSubTabs() const { return { ui->tabPlayer1, ui->tabPlayer2, ui->tabPlayer3, ui->tabPlayer4, ui->tabPlayer5, |