mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-08-27 01:17:40 +00:00
[hid_core, input_common] use std::numbers::pi{_v} instead of re-defining (#4160)
don't reinvent the wheel, simple as that. Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4160 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
|
||||
#include "common/math_util.h"
|
||||
#include "hid_core/frontend/motion_input.h"
|
||||
@@ -145,7 +149,7 @@ void MotionInput::UpdateOrientation(u64 elapsed_time) {
|
||||
}
|
||||
|
||||
const auto normal_accel = accel.Normalized();
|
||||
auto rad_gyro = gyro * Common::PI * 2;
|
||||
auto rad_gyro = gyro * std::numbers::pi_v<float> * 2.f;
|
||||
const f32 swap = rad_gyro.x;
|
||||
rad_gyro.x = rad_gyro.y;
|
||||
rad_gyro.y = -swap;
|
||||
@@ -272,7 +276,7 @@ Common::Vec3f MotionInput::GetEulerAngles() const {
|
||||
|
||||
return {
|
||||
std::atan2(sinr_cosp, cosr_cosp),
|
||||
2 * std::atan2(sinp, cosp) - Common::PI / 2,
|
||||
2 * std::atan2(sinp, cosp) - float(std::numbers::pi_v<float>) / 2,
|
||||
std::atan2(siny_cosp, cosy_cosp),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <numbers>
|
||||
#include "common/math_util.h"
|
||||
#include "hid_core/resources/touch_screen/gesture_handler.h"
|
||||
|
||||
@@ -214,7 +215,7 @@ void GestureHandler::UpdatePanEvent(GestureState& next_state, GestureType& type)
|
||||
if (std::abs(angle_between_two_lines) > AngleThreshold) {
|
||||
type = GestureType::Rotate;
|
||||
next_state.scale = 0;
|
||||
next_state.rotation_angle = angle_between_two_lines * 180.0f / Common::PI;
|
||||
next_state.rotation_angle = angle_between_two_lines * 180.0f / float(std::numbers::pi_v<float>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user