From 31dc3477ad9cdcc4ba3259f8c7373e2981c13ff3 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 15 Apr 2024 14:51:06 -0500 Subject: [PATCH] DolphinQt/Mapping: Disable relative input when "Mouse Controlled Pointing" button is pressed. --- Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp | 7 ++++++- .../Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp | 5 +++++ .../Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h | 2 ++ .../InputCommon/ControllerEmu/Setting/NumericSetting.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp index d1e09ac973..96a5040704 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp @@ -172,7 +172,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con { QPushButton* mouse_button = new QPushButton(tr("Use Mouse Controlled Pointing")); form_layout->insertRow(2, mouse_button); - connect(mouse_button, &QCheckBox::clicked, [this, group] { + + using ControllerEmu::Cursor; + connect(mouse_button, &QCheckBox::clicked, [this, group = static_cast(group)] { std::string default_device = g_controller_interface.GetDefaultDeviceString() + ":"; const std::string controller_device = GetController()->GetDefaultDevice().ToString() + ":"; if (default_device == controller_device) @@ -183,6 +185,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con group->SetControlExpression(1, fmt::format("`{}Cursor Y+`", default_device)); group->SetControlExpression(2, fmt::format("`{}Cursor X-`", default_device)); group->SetControlExpression(3, fmt::format("`{}Cursor X+`", default_device)); + + group->SetRelativeInput(false); + emit ConfigChanged(); GetController()->UpdateReferences(g_controller_interface); }); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 98784c00ae..0ba4bfa3ea 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -181,6 +181,11 @@ ControlState Cursor::GetVerticalOffset() const return m_vertical_offset_setting.GetValue() / 100; } +void Cursor::SetRelativeInput(bool value) +{ + m_relative_setting.SetValue(value); +} + bool Cursor::StateData::IsVisible() const { return !std::isnan(x); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h index 3710a40d92..7b2e5f581c 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h @@ -40,6 +40,8 @@ public: // Vertical offset in meters. ControlState GetVerticalOffset() const; + void SetRelativeInput(bool enabled); + private: Cursor::StateData UpdateState(Cursor::ReshapeData input); diff --git a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h index b102b062e7..863e211cae 100644 --- a/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h +++ b/Source/Core/InputCommon/ControllerEmu/Setting/NumericSetting.h @@ -186,7 +186,6 @@ public: bool IsSimpleValue() const { return m_input.GetExpression().empty(); } -private: void SetValue(ValueType value) { m_value = value; @@ -195,6 +194,7 @@ private: m_input.SetExpression(""); } +private: // Values are R/W by both UI and CPU threads. mutable std::atomic m_value = {};