2024-01-26 06:03:57 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
2024-07-30 11:42:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0+
|
2021-12-13 12:12:54 +00:00
|
|
|
|
|
|
|
#include "Settings/ControllerGlobalSettingsWidget.h"
|
2023-10-14 08:45:09 +00:00
|
|
|
#include "Settings/ControllerSettingsWindow.h"
|
2022-06-08 12:15:10 +00:00
|
|
|
#include "Settings/ControllerSettingWidgetBinder.h"
|
2021-12-13 12:12:54 +00:00
|
|
|
#include "QtUtils.h"
|
|
|
|
#include "SettingWidgetBinder.h"
|
|
|
|
|
2023-05-13 04:30:41 +00:00
|
|
|
#include "pcsx2/Input/InputManager.h"
|
|
|
|
#include "pcsx2/Input/SDLInputSource.h"
|
2023-01-15 07:00:52 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent, ControllerSettingsWindow* dialog)
|
2021-12-13 12:12:54 +00:00
|
|
|
: QWidget(parent)
|
2022-06-08 12:15:10 +00:00
|
|
|
, m_dialog(dialog)
|
2021-12-13 12:12:54 +00:00
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
SettingsInterface* sif = dialog->getProfileSettingsInterface();
|
|
|
|
|
2024-05-04 13:33:35 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLSource, "InputSources", "SDL", true);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLEnhancedMode, "InputSources", "SDLControllerEnhancedMode", false);
|
2024-04-12 12:22:58 +00:00
|
|
|
connect(m_ui.enableSDLSource, &QCheckBox::checkStateChanged, this, &ControllerGlobalSettingsWidget::updateSDLOptionsEnabled);
|
2023-01-15 07:00:52 +00:00
|
|
|
connect(m_ui.ledSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::ledSettingsClicked);
|
2023-04-13 18:25:55 +00:00
|
|
|
|
2023-08-26 04:37:56 +00:00
|
|
|
#ifdef _WIN32
|
2024-05-04 13:33:35 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLRawInput, "InputSources", "SDLRawInput", false);
|
2023-04-13 18:25:55 +00:00
|
|
|
#else
|
2024-02-04 14:57:44 +00:00
|
|
|
m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLRawInput);
|
2023-04-13 18:25:55 +00:00
|
|
|
m_ui.enableSDLRawInput->deleteLater();
|
|
|
|
m_ui.enableSDLRawInput = nullptr;
|
2023-01-15 07:00:52 +00:00
|
|
|
#endif
|
|
|
|
|
2024-02-04 14:57:44 +00:00
|
|
|
#ifdef __APPLE__
|
2024-05-04 13:33:35 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLIOKitDriver, "InputSources", "SDLIOKitDriver", true);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLMFIDriver, "InputSources", "SDLMFIDriver", true);
|
2024-02-04 14:57:44 +00:00
|
|
|
#else
|
|
|
|
m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLIOKitDriver);
|
|
|
|
m_ui.enableSDLIOKitDriver->deleteLater();
|
|
|
|
m_ui.enableSDLIOKitDriver = nullptr;
|
|
|
|
m_ui.sdlGridLayout->removeWidget(m_ui.enableSDLMFIDriver);
|
|
|
|
m_ui.enableSDLMFIDriver->deleteLater();
|
|
|
|
m_ui.enableSDLMFIDriver = nullptr;
|
|
|
|
#endif
|
|
|
|
|
2023-09-09 04:13:27 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableMouseMapping, "UI", "EnableMouseMapping", false);
|
2023-02-11 23:58:58 +00:00
|
|
|
connect(m_ui.mouseSettings, &QToolButton::clicked, this, &ControllerGlobalSettingsWidget::mouseSettingsClicked);
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort1, "Pad", "MultitapPort1", false);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.multitapPort2, "Pad", "MultitapPort2", false);
|
|
|
|
|
2022-10-15 09:04:30 +00:00
|
|
|
#ifdef _WIN32
|
2024-05-04 13:33:35 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableXInputSource, "InputSources", "XInput", false);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableDInputSource, "InputSources", "DInput", false);
|
2022-10-15 09:04:30 +00:00
|
|
|
#else
|
|
|
|
m_ui.mainLayout->removeWidget(m_ui.xinputGroup);
|
|
|
|
m_ui.xinputGroup->deleteLater();
|
|
|
|
m_ui.xinputGroup = nullptr;
|
|
|
|
m_ui.mainLayout->removeWidget(m_ui.dinputGroup);
|
|
|
|
m_ui.dinputGroup->deleteLater();
|
|
|
|
m_ui.dinputGroup = nullptr;
|
|
|
|
#endif
|
|
|
|
|
2022-06-08 12:15:10 +00:00
|
|
|
if (dialog->isEditingProfile())
|
|
|
|
{
|
|
|
|
m_ui.useProfileHotkeyBindings->setChecked(m_dialog->getBoolValue("Pad", "UseProfileHotkeyBindings", false));
|
2024-04-12 12:22:58 +00:00
|
|
|
connect(m_ui.useProfileHotkeyBindings, &QCheckBox::checkStateChanged, this, [this](int new_state) {
|
2022-06-08 12:15:10 +00:00
|
|
|
m_dialog->setBoolValue("Pad", "UseProfileHotkeyBindings", (new_state == Qt::Checked));
|
|
|
|
emit bindingSetupChanged();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// remove profile options from the UI.
|
|
|
|
m_ui.mainLayout->removeWidget(m_ui.profileSettings);
|
|
|
|
m_ui.profileSettings->deleteLater();
|
|
|
|
m_ui.profileSettings = nullptr;
|
|
|
|
}
|
2021-12-13 12:12:54 +00:00
|
|
|
|
2022-06-07 14:16:37 +00:00
|
|
|
for (QCheckBox* cb : {m_ui.multitapPort1, m_ui.multitapPort2})
|
2024-04-12 12:22:58 +00:00
|
|
|
connect(cb, &QCheckBox::checkStateChanged, this, [this]() { emit bindingSetupChanged(); });
|
2022-06-07 14:16:37 +00:00
|
|
|
|
2021-12-13 12:12:54 +00:00
|
|
|
updateSDLOptionsEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerGlobalSettingsWidget::~ControllerGlobalSettingsWidget() = default;
|
|
|
|
|
|
|
|
void ControllerGlobalSettingsWidget::addDeviceToList(const QString& identifier, const QString& name)
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = new QListWidgetItem();
|
|
|
|
item->setText(QStringLiteral("%1: %2").arg(identifier).arg(name));
|
|
|
|
item->setData(Qt::UserRole, identifier);
|
|
|
|
m_ui.deviceList->addItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerGlobalSettingsWidget::removeDeviceFromList(const QString& identifier)
|
|
|
|
{
|
|
|
|
const int count = m_ui.deviceList->count();
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
QListWidgetItem* item = m_ui.deviceList->item(i);
|
|
|
|
if (item->data(Qt::UserRole) != identifier)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
delete m_ui.deviceList->takeItem(i);
|
2022-01-31 12:31:25 +00:00
|
|
|
break;
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerGlobalSettingsWidget::updateSDLOptionsEnabled()
|
|
|
|
{
|
|
|
|
const bool enabled = m_ui.enableSDLSource->isChecked();
|
|
|
|
m_ui.enableSDLEnhancedMode->setEnabled(enabled);
|
2023-01-15 07:00:52 +00:00
|
|
|
m_ui.ledSettings->setEnabled(enabled);
|
2023-04-13 18:25:55 +00:00
|
|
|
#ifdef _WIN32
|
2023-03-31 13:49:41 +00:00
|
|
|
m_ui.enableSDLRawInput->setEnabled(enabled);
|
2023-04-13 18:25:55 +00:00
|
|
|
#endif
|
2024-02-04 14:57:44 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
m_ui.enableSDLIOKitDriver->setEnabled(enabled);
|
|
|
|
m_ui.enableSDLMFIDriver->setEnabled(enabled);
|
|
|
|
#endif
|
2023-01-15 07:00:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerGlobalSettingsWidget::ledSettingsClicked()
|
|
|
|
{
|
|
|
|
ControllerLEDSettingsDialog dialog(this, m_dialog);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2023-02-11 23:58:58 +00:00
|
|
|
void ControllerGlobalSettingsWidget::mouseSettingsClicked()
|
|
|
|
{
|
|
|
|
ControllerMouseSettingsDialog dialog(this, m_dialog);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerLEDSettingsDialog::ControllerLEDSettingsDialog(QWidget* parent, ControllerSettingsWindow* dialog)
|
2023-01-15 07:00:52 +00:00
|
|
|
: QDialog(parent)
|
|
|
|
, m_dialog(dialog)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
linkButton(m_ui.SDL0LED, 0);
|
|
|
|
linkButton(m_ui.SDL1LED, 1);
|
|
|
|
linkButton(m_ui.SDL2LED, 2);
|
|
|
|
linkButton(m_ui.SDL3LED, 3);
|
|
|
|
|
2024-02-27 03:57:17 +00:00
|
|
|
SettingsInterface* sif = dialog->getProfileSettingsInterface();
|
|
|
|
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.enableSDLPS5PlayerLED, "InputSources", "SDLPS5PlayerLED", false);
|
2023-01-15 07:00:52 +00:00
|
|
|
connect(m_ui.buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &QDialog::accept);
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerLEDSettingsDialog::~ControllerLEDSettingsDialog() = default;
|
|
|
|
|
|
|
|
void ControllerLEDSettingsDialog::linkButton(ColorPickerButton* button, u32 player_id)
|
|
|
|
{
|
|
|
|
std::string key(fmt::format("Player{}LED", player_id));
|
|
|
|
const u32 current_value = SDLInputSource::ParseRGBForPlayerId(m_dialog->getStringValue("SDLExtra", key.c_str(), ""), player_id);
|
|
|
|
button->setColor(current_value);
|
|
|
|
|
2023-01-26 03:07:10 +00:00
|
|
|
connect(button, &ColorPickerButton::colorChanged, this, [this, key = std::move(key)](u32 new_rgb) {
|
2023-01-15 07:00:52 +00:00
|
|
|
m_dialog->setStringValue("SDLExtra", key.c_str(), fmt::format("{:06X}", new_rgb).c_str());
|
|
|
|
});
|
2021-12-13 12:12:54 +00:00
|
|
|
}
|
2023-02-11 23:58:58 +00:00
|
|
|
|
2023-10-14 08:45:09 +00:00
|
|
|
ControllerMouseSettingsDialog::ControllerMouseSettingsDialog(QWidget* parent, ControllerSettingsWindow* dialog)
|
2023-02-11 23:58:58 +00:00
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
SettingsInterface* sif = dialog->getProfileSettingsInterface();
|
|
|
|
|
|
|
|
m_ui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("mouse-line")).pixmap(32, 32));
|
|
|
|
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerXSpeedSlider, "Pad", "PointerXSpeed", 40.0f);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerYSpeedSlider, "Pad", "PointerYSpeed", 40.0f);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerXDeadZoneSlider, "Pad", "PointerXDeadZone", 20.0f);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerYDeadZoneSlider, "Pad", "PointerYDeadZone", 20.0f);
|
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileFloat(sif, m_ui.pointerInertiaSlider, "Pad", "PointerInertia", 10.0f);
|
|
|
|
|
|
|
|
connect(m_ui.pointerXSpeedSlider, &QSlider::valueChanged, this, [this](int value) { m_ui.pointerXSpeedVal->setText(QStringLiteral("%1").arg(value)); });
|
|
|
|
connect(m_ui.pointerYSpeedSlider, &QSlider::valueChanged, this, [this](int value) { m_ui.pointerYSpeedVal->setText(QStringLiteral("%1").arg(value)); });
|
|
|
|
connect(m_ui.pointerXDeadZoneSlider, &QSlider::valueChanged, this, [this](int value) { m_ui.pointerXDeadZoneVal->setText(QStringLiteral("%1").arg(value)); });
|
|
|
|
connect(m_ui.pointerYDeadZoneSlider, &QSlider::valueChanged, this, [this](int value) { m_ui.pointerYDeadZoneVal->setText(QStringLiteral("%1").arg(value)); });
|
|
|
|
connect(m_ui.pointerInertiaSlider, &QSlider::valueChanged, this, [this](int value) { m_ui.pointerInertiaVal->setText(QStringLiteral("%1").arg(value)); });
|
|
|
|
|
|
|
|
m_ui.pointerXSpeedVal->setText(QStringLiteral("%1").arg(m_ui.pointerXSpeedSlider->value()));
|
|
|
|
m_ui.pointerYSpeedVal->setText(QStringLiteral("%1").arg(m_ui.pointerYSpeedSlider->value()));
|
|
|
|
m_ui.pointerXDeadZoneVal->setText(QStringLiteral("%1").arg(m_ui.pointerXDeadZoneSlider->value()));
|
|
|
|
m_ui.pointerYDeadZoneVal->setText(QStringLiteral("%1").arg(m_ui.pointerYDeadZoneSlider->value()));
|
|
|
|
m_ui.pointerInertiaVal->setText(QStringLiteral("%1").arg(m_ui.pointerInertiaSlider->value()));
|
|
|
|
|
|
|
|
connect(m_ui.buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &QDialog::accept);
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerMouseSettingsDialog::~ControllerMouseSettingsDialog() = default;
|
2024-01-26 06:03:57 +00:00
|
|
|
|
|
|
|
ControllerMappingSettingsDialog::ControllerMappingSettingsDialog(ControllerSettingsWindow* parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
|
|
|
SettingsInterface* sif = parent->getProfileSettingsInterface();
|
|
|
|
|
|
|
|
m_ui.icon->setPixmap(QIcon::fromTheme(QStringLiteral("settings-3-line")).pixmap(32, 32));
|
|
|
|
|
2024-05-04 13:33:35 +00:00
|
|
|
ControllerSettingWidgetBinder::BindWidgetToInputProfileBool(sif, m_ui.ignoreInversion, "InputSources", "IgnoreInversion", false);
|
2024-01-26 06:03:57 +00:00
|
|
|
|
|
|
|
connect(m_ui.buttonBox->button(QDialogButtonBox::Close), &QPushButton::clicked, this, &QDialog::accept);
|
|
|
|
}
|
|
|
|
|
|
|
|
ControllerMappingSettingsDialog::~ControllerMappingSettingsDialog() = default;
|