From bf53e14abe32e60c18122b15529884b9fbb0c413 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Mon, 10 Oct 2022 21:18:55 -0500 Subject: [PATCH] WiimoteEmu: Fix gyroscope/quaternion conversion math. --- Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp index dd21cd721a..b3864e3c8b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Dynamics.cpp @@ -398,7 +398,9 @@ Common::Quaternion GetRotationFromAcceleration(const Common::Vec3& accel) Common::Quaternion GetRotationFromGyroscope(const Common::Vec3& gyro) { - return Common::Quaternion{1, gyro.x / 2, gyro.y / 2, gyro.z / 2}; + const auto length = gyro.Length(); + return (length != 0) ? Common::Quaternion::Rotate(length, gyro / length) : + Common::Quaternion::Identity(); } Common::Matrix33 GetRotationalMatrix(const Common::Vec3& angle)