diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-02-10 02:05:20 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-02-10 02:07:50 +0100 |
commit | 5e9fa5def5cf5ae3f00cc354a0b1363123dc6930 (patch) | |
tree | 90a707a21b66803010bbe707c36563e1ff583559 /src/core/hid/motion_input.cpp | |
parent | service: hid: Return error if arguments of SetSupportedNpadIdType is invalid (diff) | |
download | yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar.gz yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar.bz2 yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar.lz yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar.xz yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.tar.zst yuzu-5e9fa5def5cf5ae3f00cc354a0b1363123dc6930.zip |
Diffstat (limited to 'src/core/hid/motion_input.cpp')
-rw-r--r-- | src/core/hid/motion_input.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp index b1f658e62..eef6edf4b 100644 --- a/src/core/hid/motion_input.cpp +++ b/src/core/hid/motion_input.cpp @@ -9,7 +9,7 @@ namespace Core::HID { MotionInput::MotionInput() { // Initialize PID constants with default values SetPID(0.3f, 0.005f, 0.0f); - SetGyroThreshold(0.007f); + SetGyroThreshold(ThresholdStandard); } void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) { @@ -26,11 +26,11 @@ void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { gyro = gyroscope - gyro_bias; // Auto adjust drift to minimize drift - if (!IsMoving(0.1f)) { + if (!IsMoving(IsAtRestRelaxed)) { gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); } - if (gyro.Length() < gyro_threshold) { + if (gyro.Length() < gyro_threshold * user_gyro_threshold) { gyro = {}; } else { only_accelerometer = false; @@ -49,6 +49,10 @@ void MotionInput::SetGyroThreshold(f32 threshold) { gyro_threshold = threshold; } +void MotionInput::SetUserGyroThreshold(f32 threshold) { + user_gyro_threshold = threshold / ThresholdStandard; +} + void MotionInput::EnableReset(bool reset) { reset_enabled = reset; } @@ -208,7 +212,7 @@ void MotionInput::ResetOrientation() { if (!reset_enabled || only_accelerometer) { return; } - if (!IsMoving(0.5f) && accel.z <= -0.9f) { + if (!IsMoving(IsAtRestRelaxed) && accel.z <= -0.9f) { ++reset_counter; if (reset_counter > 900) { quat.w = 0; |