diff options
Diffstat (limited to 'Source/Core/InputCommon')
12 files changed, 19 insertions, 16 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); diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp index b22ace19f2..50c827d6d3 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp @@ -574,7 +574,7 @@ Device::Device(std::string name, int index, std::string server_address, u16 serv AddInput(new AccelerometerInput("Accel Backward", m_pad_data.accelerometer_z_g, -accel_scale)); // Convert degrees per second to radians per second - constexpr auto gyro_scale = 360.0 / MathUtil::TAU; + constexpr auto gyro_scale = MathUtil::RadiansToDegrees(1.0); AddInput(new GyroInput("Gyro Pitch Up", m_pad_data.gyro_pitch_deg_s, gyro_scale)); AddInput(new GyroInput("Gyro Pitch Down", m_pad_data.gyro_pitch_deg_s, -gyro_scale)); diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp index 8b8a22e400..6b29a95b2c 100644 --- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp +++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp @@ -189,7 +189,7 @@ bool ReshapableInputMapper::Update() float ReshapableInputMapper::GetCurrentAngle() const { - constexpr auto quarter_circle = float(MathUtil::TAU) * 0.25f; + constexpr auto quarter_circle = MathUtil::TAU_v<float> * 0.25f; return quarter_circle - (float(m_input_detector.GetResults().size()) * quarter_circle); } diff --git a/Source/Core/InputCommon/ControllerInterface/SteamDeck/SteamDeck.cpp b/Source/Core/InputCommon/ControllerInterface/SteamDeck/SteamDeck.cpp index b78c56afc6..689217822d 100644 --- a/Source/Core/InputCommon/ControllerInterface/SteamDeck/SteamDeck.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SteamDeck/SteamDeck.cpp @@ -257,7 +257,7 @@ Device::Device(hid_device* device) : m_device{device} // 16.384 (?) LSBs = 1 deg / s // final output in rads / s - constexpr auto gyro_scale = 16.384 * 360.0 / MathUtil::TAU; + constexpr auto gyro_scale = MathUtil::RadiansToDegrees(16.384); AddInput(new MotionInput("Gyro Pitch Up", m_latest_input.gyro_pitch, gyro_scale)); AddInput(new MotionInput("Gyro Pitch Down", m_latest_input.gyro_pitch, -gyro_scale)); AddInput(new MotionInput("Gyro Roll Left", m_latest_input.gyro_roll, -gyro_scale)); diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp index e7724c1840..42924a77ed 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp @@ -3,6 +3,8 @@ #include "InputCommon/ControllerInterface/Wiimote/WiimoteController.h" +#include <numbers> + #include "Common/BitUtils.h" #include "Common/Logging/Log.h" #include "Common/MathUtil.h" @@ -1258,7 +1260,7 @@ void Device::UpdateOrientation() m_rotation_inputs = Common::Vec3{WiimoteEmu::GetPitch(m_orientation), WiimoteEmu::GetRoll(m_orientation), WiimoteEmu::GetYaw(m_orientation)} / - float(MathUtil::PI); + std::numbers::pi_v<float>; } void Device::IRState::ProcessData(const DataReportManipulator& manipulator) diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index c8fa7b3647..fc10325fa0 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -541,7 +541,7 @@ bool evdevDevice::AddNode(std::string devnode, int fd, libevdev* dev) // evdev resolution is specified in "g"s and deg/s. // Convert these to m/s/s and rad/s. constexpr ControlState accel_scale = MathUtil::GRAVITY_ACCELERATION; - constexpr ControlState gyro_scale = MathUtil::TAU / 360; + constexpr ControlState gyro_scale = MathUtil::DegreesToRadians(ControlState{1}); add_motion_inputs(ABS_X, accel_scale); add_motion_inputs(ABS_RX, gyro_scale); |
