From 2db12b9d84a2c5995d848a73580c003d0381020f Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 3 May 2022 23:23:39 +1000 Subject: [PATCH] Qt: Hook up axis/vibration scale in controller settings --- .../ControllerBindingWidget_DualShock2.ui | 424 +++++++++--------- .../Settings/ControllerBindingWidgets.cpp | 22 + 2 files changed, 237 insertions(+), 209 deletions(-) diff --git a/pcsx2-qt/Settings/ControllerBindingWidget_DualShock2.ui b/pcsx2-qt/Settings/ControllerBindingWidget_DualShock2.ui index d4334fc311..6b6ffe7012 100644 --- a/pcsx2-qt/Settings/ControllerBindingWidget_DualShock2.ui +++ b/pcsx2-qt/Settings/ControllerBindingWidget_DualShock2.ui @@ -7,7 +7,7 @@ 0 0 1100 - 550 + 500 @@ -19,7 +19,7 @@ 1100 - 550 + 500 @@ -378,29 +378,6 @@ - - - - Axis Scale - - - - - - Qt::Horizontal - - - - - - - 1.0x - - - - - - @@ -460,126 +437,6 @@ - - - - R2 - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - PushButton - - - - - - - - - - Select - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - PushButton - - - - - - - - - - L1 - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - PushButton - - - - - - @@ -620,7 +477,127 @@ - + + + + L1 + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + PushButton + + + + + + + + + + Select + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + PushButton + + + + + + + + + + R2 + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + PushButton + + + + + + + Start @@ -660,6 +637,32 @@ + + + + Axis Scale + + + + + + 200 + + + Qt::Horizontal + + + + + + + 1.0x + + + + + + @@ -719,46 +722,6 @@ - - - - L3 - - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - PushButton - - - - - - @@ -777,6 +740,19 @@ 6 + + + + x + + + 3.000000000000000 + + + 0.100000000000000 + + + @@ -836,6 +812,19 @@ + + + + x + + + 3.000000000000000 + + + 0.100000000000000 + + + @@ -879,6 +868,46 @@ + + + + L3 + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + PushButton + + + + + + @@ -1236,29 +1265,6 @@ - - - - Vibration Scale - - - - - - Qt::Horizontal - - - - - - - 1.0x - - - - - - diff --git a/pcsx2-qt/Settings/ControllerBindingWidgets.cpp b/pcsx2-qt/Settings/ControllerBindingWidgets.cpp index 2bbec8ccad..34234d5eb0 100644 --- a/pcsx2-qt/Settings/ControllerBindingWidgets.cpp +++ b/pcsx2-qt/Settings/ControllerBindingWidgets.cpp @@ -29,6 +29,8 @@ #include "common/StringUtil.h" #include "pcsx2/PAD/Host/PAD.h" +#include "SettingWidgetBinder.h" + ControllerBindingWidget::ControllerBindingWidget(QWidget* parent, ControllerSettingsDialog* dialog, u32 port) : QWidget(parent) , m_dialog(dialog) @@ -186,6 +188,26 @@ void ControllerBindingWidget_Base::initBindingWidgets() default: break; } + + if (QSlider* widget = findChild(QStringLiteral("AxisScale")); widget) + { + // position 1.0f at the halfway point + const float range = static_cast(widget->maximum()) * 0.5f; + QLabel* label = findChild(QStringLiteral("AxisScaleLabel")); + if (label) + { + connect(widget, &QSlider::valueChanged, this, [range, label](int value) { + label->setText(tr("%1x").arg(static_cast(value) / range, 0, 'f', 2)); + }); + } + + SettingWidgetBinder::BindWidgetToNormalizedSetting(nullptr, widget, config_section, "AxisScale", range, 1.0f); + } + + if (QDoubleSpinBox* widget = findChild(QStringLiteral("SmallMotorScale")); widget) + SettingWidgetBinder::BindWidgetToFloatSetting(nullptr, widget, config_section, "SmallMotorScale", 1.0f); + if (QDoubleSpinBox* widget = findChild(QStringLiteral("LargeMotorScale")); widget) + SettingWidgetBinder::BindWidgetToFloatSetting(nullptr, widget, config_section, "LargeMotorScale", 1.0f); } ControllerBindingWidget_DualShock2::ControllerBindingWidget_DualShock2(ControllerBindingWidget* parent)