diff options
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/StickGate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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); |
