From 407ae3972ac7c6e8d2e14bb876b2998691684c43 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Thu, 3 Nov 2022 14:01:24 +0200 Subject: [PATCH] Revert "code: Use std::numbers::pi" * Not available on Android This reverts commit d6e545932a56a40461123de673356857e7fbf9ed. --- src/common/math_util.h | 2 ++ src/input_common/motion_emu.cpp | 4 ++-- src/input_common/sdl/sdl_impl.cpp | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index c42f45fe5..dbae4f05d 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -10,6 +10,8 @@ namespace Common { +constexpr float PI = 3.14159265f; + template struct Rectangle { T left{}; diff --git a/src/input_common/motion_emu.cpp b/src/input_common/motion_emu.cpp index 431c8712b..50964f86a 100644 --- a/src/input_common/motion_emu.cpp +++ b/src/input_common/motion_emu.cpp @@ -47,7 +47,7 @@ public: } else { tilt_direction = mouse_move.Cast(); tilt_angle = std::clamp(tilt_direction.Normalize() * sensitivity, 0.0f, - std::numbers::pi_v * this->tilt_clamp / 180.0f); + Common::PI * this->tilt_clamp / 180.0f); } } } @@ -110,7 +110,7 @@ private: // Find the angular rate vector in world space auto angular_rate = ((q - old_q) * inv_q).xyz * 2; - angular_rate *= 1000 / update_millisecond / std::numbers::pi_v * 180; + angular_rate *= 1000 / update_millisecond / Common::PI * 180; // Transform the two vectors from world space to 3DS space gravity = QuaternionRotate(inv_q, gravity); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 626e56bc6..ec73bd871 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -16,6 +16,8 @@ #include #include #include +#include "common/assert.h" +#include "common/math_util.h" #include "common/logging/log.h" #include "common/param_package.h" #include "common/threadsafe_queue.h" @@ -596,9 +598,9 @@ void SDLState::HandleGameControllerEvent(const SDL_Event& event) { event.csensor.data[2] / SDL_STANDARD_GRAVITY); break; case SDL_SENSOR_GYRO: - joystick->SetGyro(-event.csensor.data[0] * (180.0f / std::numbers::pi), - event.csensor.data[1] * (180.0f / std::numbers::pi), - -event.csensor.data[2] * (180.0f / std::numbers::pi)); + joystick->SetGyro(-event.csensor.data[0] * (180.0f / Common::PI), + event.csensor.data[1] * (180.0f / Common::PI), + -event.csensor.data[2] * (180.0f / Common::PI)); break; } }