mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 19:00:14 -05:00
yuzu: Improve behavior when clicking on controller box in Control Configuration
When reducing the number of Connecter Controllers, keep the one clicked if it was not the last one of the list
This commit is contained in:
parent
3e4edbe007
commit
27ab2a6e13
2 changed files with 27 additions and 10 deletions
|
@ -115,17 +115,9 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
||||||
for (std::size_t i = 0; i < player_tabs.size(); ++i) {
|
for (std::size_t i = 0; i < player_tabs.size(); ++i) {
|
||||||
player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i]));
|
player_tabs[i]->setLayout(new QHBoxLayout(player_tabs[i]));
|
||||||
player_tabs[i]->layout()->addWidget(player_controllers[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
|
// Ensures that the controllers are always connected in sequential order
|
||||||
if (is_connected) {
|
this->propagateMouseClickOnPlayers(i, checked, true);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices, this,
|
connect(player_controllers[i], &ConfigureInputPlayer::RefreshInputDevices, this,
|
||||||
&ConfigureInput::UpdateAllInputDevices);
|
&ConfigureInput::UpdateAllInputDevices);
|
||||||
|
@ -183,6 +175,30 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem,
|
||||||
LoadConfiguration();
|
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 {
|
QList<QWidget*> ConfigureInput::GetSubTabs() const {
|
||||||
return {
|
return {
|
||||||
ui->tabPlayer1, ui->tabPlayer2, ui->tabPlayer3, ui->tabPlayer4, ui->tabPlayer5,
|
ui->tabPlayer1, ui->tabPlayer2, ui->tabPlayer3, ui->tabPlayer4, ui->tabPlayer5,
|
||||||
|
|
|
@ -56,6 +56,7 @@ private:
|
||||||
void UpdateDockedState(bool is_handheld);
|
void UpdateDockedState(bool is_handheld);
|
||||||
void UpdateAllInputDevices();
|
void UpdateAllInputDevices();
|
||||||
void UpdateAllInputProfiles(std::size_t player_index);
|
void UpdateAllInputProfiles(std::size_t player_index);
|
||||||
|
void propagateMouseClickOnPlayers(size_t player_index, bool origin, bool checked);
|
||||||
|
|
||||||
/// Load configuration settings.
|
/// Load configuration settings.
|
||||||
void LoadConfiguration();
|
void LoadConfiguration();
|
||||||
|
|
Loading…
Reference in a new issue