summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/StickGate.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
index 797d19aadf..d57a2402cf 100644
--- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
@@ -128,6 +128,7 @@ std::optional<u32> SquareStickGate::GetIdealCalibrationSampleCount() const
ReshapableInput::ReshapableInput(std::string name_, std::string ui_name_, GroupType type_)
: ControlGroup(std::move(name_), std::move(ui_name_), type_)
{
+ // 50 is not always enough but users can set it to more with an expression
AddDeadzoneSetting(&m_deadzone_setting, 50);
}
@@ -280,11 +281,16 @@ void ReshapableInput::SaveConfig(IniFile::Section* section, const std::string& d
}
ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlState y,
- ControlState modifier)
+ ControlState modifier,
+ ControlState clamp) const
{
x -= m_center.x;
y -= m_center.y;
+ // We run this even if both x and y will be zero.
+ // In that case, std::atan2(0, 0) returns a valid non-NaN value, but the exact value
+ // (which depends on the signs of x and y) does not matter here as dist is zero
+
// TODO: make the AtAngle functions work with negative angles:
ControlState angle = std::atan2(y, x) + MathUtil::TAU;
@@ -321,8 +327,8 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
// Scale to the gate shape/radius:
dist *= gate_max_dist;
- return {std::clamp(std::cos(angle) * dist, -1.0, 1.0),
- std::clamp(std::sin(angle) * dist, -1.0, 1.0)};
+ return {std::clamp(std::cos(angle) * dist, -clamp, clamp),
+ std::clamp(std::sin(angle) * dist, -clamp, clamp)};
}
} // namespace ControllerEmu