diff options
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu')
7 files changed, 12 insertions, 11 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp index 9ff06d4056..68a24dff25 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp @@ -99,7 +99,7 @@ OctagonAnalogStick::OctagonAnalogStick(const char* name_, const char* ui_name_, ControlState OctagonAnalogStick::GetVirtualNotchSize() const { - return m_virtual_notch_setting.GetValue() * MathUtil::TAU / 360; + return MathUtil::DegreesToRadians(m_virtual_notch_setting.GetValue()); } ControlState OctagonAnalogStick::GetGateRadiusAtAngle(double ang) const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 169846c947..431b25012f 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -167,12 +167,12 @@ Cursor::StateData Cursor::UpdateState(Cursor::ReshapeData input) ControlState Cursor::GetTotalYaw() const { - return m_yaw_setting.GetValue() * MathUtil::TAU / 360; + return MathUtil::DegreesToRadians(m_yaw_setting.GetValue()); } ControlState Cursor::GetTotalPitch() const { - return m_pitch_setting.GetValue() * MathUtil::TAU / 360; + return MathUtil::DegreesToRadians(m_pitch_setting.GetValue()); } ControlState Cursor::GetVerticalOffset() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index d74c4df5eb..214d948f44 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -106,7 +106,7 @@ ControlState Force::GetReturnSpeed() const ControlState Force::GetTwistAngle() const { - return m_angle_setting.GetValue() * MathUtil::TAU / 360; + return MathUtil::DegreesToRadians(m_angle_setting.GetValue()); } ControlState Force::GetMaxDistance() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp index f9a2b0fba0..033477aeb7 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUCursor.cpp @@ -49,7 +49,7 @@ IMUCursor::IMUCursor(std::string name_, std::string ui_name_) ControlState IMUCursor::GetTotalYaw() const { - return m_yaw_setting.GetValue() * MathUtil::TAU / 360; + return MathUtil::DegreesToRadians(m_yaw_setting.GetValue()); } ControlState IMUCursor::GetAccelWeight() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp index 316ed45f84..11bcad964a 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp @@ -163,7 +163,7 @@ std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState(bool update) ControlState IMUGyroscope::GetDeadzone() const { - return m_deadzone_setting.GetValue() / 360 * MathUtil::TAU; + return MathUtil::DegreesToRadians(m_deadzone_setting.GetValue()); } bool IMUGyroscope::IsCalibrating() const diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index 5c604ef3d1..82b6eccb73 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -69,7 +69,7 @@ ControlState Tilt::GetDefaultInputRadiusAtAngle(double ang) const ControlState Tilt::GetMaxRotationalVelocity() const { - return m_max_rotational_velocity.GetValue() * MathUtil::TAU; + return m_max_rotational_velocity.GetValue() * MathUtil::TAU_v<ControlState>; } Control* Tilt::GetModifierInput() const diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp index 660ee939be..9898c452f4 100644 --- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp +++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <cmath> +#include <numbers> #include <ranges> #include <fmt/format.h> @@ -54,7 +55,7 @@ double GetNearestNotch(double angle, double virtual_notch_angle) constexpr auto rounding = MathUtil::TAU / sides; const auto closest_notch = std::round(angle / rounding) * rounding; const auto angle_diff = - std::fmod(angle - closest_notch + MathUtil::PI, MathUtil::TAU) - MathUtil::PI; + std::fmod(angle - closest_notch + std::numbers::pi, MathUtil::TAU) - std::numbers::pi; return std::abs(angle_diff) < virtual_notch_angle / 2 ? closest_notch : angle; } @@ -80,12 +81,12 @@ OctagonStickGate::OctagonStickGate(ControlState radius) : m_radius(radius) ControlState OctagonStickGate::GetRadiusAtAngle(double angle) const { constexpr int sides = 8; - constexpr double sum_int_angles = (sides - 2) * MathUtil::PI; + constexpr double sum_int_angles = (sides - 2) * std::numbers::pi; constexpr double half_int_angle = sum_int_angles / sides / 2; angle = std::fmod(angle, MathUtil::TAU / sides); // Solve ASA triangle using The Law of Sines: - return m_radius / std::sin(MathUtil::PI - angle - half_int_angle) * std::sin(half_int_angle); + return m_radius / std::sin(std::numbers::pi - angle - half_int_angle) * std::sin(half_int_angle); } std::optional<u32> OctagonStickGate::GetIdealCalibrationSampleCount() const @@ -306,7 +307,7 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta // (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; + ControlState angle = std::atan2(y, x) + MathUtil::TAU_v<ControlState>; const ControlState input_max_dist = GetInputRadiusAtAngle(angle); ControlState gate_max_dist = GetGateRadiusAtAngle(angle); |
