Add support to click touchpad using back button on non PS4/5 controllers (#1258)

* Working touchpad support

Tested on PS5 controller plugged in via USB.

* fix lint

* Add support to click touchpad using back button on other controllers

Takes the back button and allows the user to change the behavior of how it clicks the touchpad. The current options are left, right, center, and none.

* add description text

* make more generic so translations can be supported in combobox

* fix lint

* linter again

* support back button to touchpad for spacebar as well

* linter at it again
This commit is contained in:
fireph 2024-10-07 23:15:30 -07:00 committed by GitHub
parent 7389cf3e89
commit ce53c41205
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 136 additions and 17 deletions

View file

@ -98,6 +98,15 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Restore Defaults"));
ui->buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close"));
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Left"), "left");
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Center"), "center");
ui->backButtonBehaviorComboBox->addItem(tr("Touchpad Right"), "right");
ui->backButtonBehaviorComboBox->addItem(tr("None"), "none");
QString currentBackButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior());
int index = ui->backButtonBehaviorComboBox->findData(currentBackButtonBehavior);
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
connect(ui->tabWidgetSettings, &QTabWidget::currentChanged, this,
[this]() { ui->buttonBox->button(QDialogButtonBox::Close)->setFocus(); });
@ -151,6 +160,14 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
Config::setBGMvolume(val);
BackgroundMusicPlayer::getInstance().setVolume(val);
});
connect(ui->backButtonBehaviorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this](int index) {
if (index >= 0 && index < ui->backButtonBehaviorComboBox->count()) {
QString data = ui->backButtonBehaviorComboBox->itemData(index).toString();
Config::setBackButtonBehavior(data.toStdString());
}
});
}
// GPU TAB
@ -204,6 +221,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
ui->logFilter->installEventFilter(this);
ui->updaterGroupBox->installEventFilter(this);
ui->GUIgroupBox->installEventFilter(this);
ui->backButtonBehaviorGroupBox->installEventFilter(this);
// Graphics
ui->graphicsAdapterGroupBox->installEventFilter(this);
@ -258,6 +276,10 @@ void SettingsDialog::LoadValuesFromConfig() {
}
}
ui->updateComboBox->setCurrentText(QString::fromStdString(updateChannel));
QString backButtonBehavior = QString::fromStdString(Config::getBackButtonBehavior());
int index = ui->backButtonBehaviorComboBox->findData(backButtonBehavior);
ui->backButtonBehaviorComboBox->setCurrentIndex(index != -1 ? index : 0);
}
void SettingsDialog::InitializeEmulatorLanguages() {
@ -319,6 +341,8 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
text = tr("updaterGroupBox");
} else if (elementName == "GUIgroupBox") {
text = tr("GUIgroupBox");
} else if (elementName == "backButtonBehaviorGroupBox") {
text = tr("backButtonBehaviorGroupBox");
}
// Graphics