Skip to content

Commit

Permalink
DolphinQt/Mapping: Disable relative input when "Mouse Controlled Poin…
Browse files Browse the repository at this point in the history
…ting" button is pressed.
  • Loading branch information
jordan-woyak committed Apr 15, 2024
1 parent dbc7e03 commit 31dc347
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
Expand Up @@ -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<Cursor*>(group)] {
std::string default_device = g_controller_interface.GetDefaultDeviceString() + ":";
const std::string controller_device = GetController()->GetDefaultDevice().ToString() + ":";
if (default_device == controller_device)
Expand All @@ -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);
});
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.h
Expand Up @@ -40,6 +40,8 @@ class Cursor : public ReshapableInput
// Vertical offset in meters.
ControlState GetVerticalOffset() const;

void SetRelativeInput(bool enabled);

private:
Cursor::StateData UpdateState(Cursor::ReshapeData input);

Expand Down
Expand Up @@ -186,7 +186,6 @@ class SettingValue

bool IsSimpleValue() const { return m_input.GetExpression().empty(); }

private:
void SetValue(ValueType value)
{
m_value = value;
Expand All @@ -195,6 +194,7 @@ class SettingValue
m_input.SetExpression("");
}

private:
// Values are R/W by both UI and CPU threads.
mutable std::atomic<ValueType> m_value = {};

Expand Down

0 comments on commit 31dc347

Please sign in to comment.