summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2021-05-14 20:51:33 +1200
committerGitHub <noreply@github.com>2021-05-14 20:51:33 +1200
commit9f91fb64479d3df14489378a6b4fb3ffa7d12f2d (patch)
tree702ec73b3745420750d05644c639f357492e57a1 /Source/Core/InputCommon/ControllerEmu/StickGate.cpp
parent099bf16326c1549246fd1bd976fb1242e7ba0875 (diff)
parentf3ffac00583bd03d0620226392a2b15f3cfd273b (diff)
Merge pull request #9688 from Filoppi/input_cleanup
Input cleanup
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