summaryrefslogtreecommitdiff
path: root/src/core/hid/motion_input.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2023-02-12 00:19:22 -0800
committerGravatar GitHub2023-02-12 00:19:22 -0800
commit8b74047b1b4eac10c6152a18920d0a8e1861fecd (patch)
tree74a64e8a680771cede461bb0945fa4242deae2ed /src/core/hid/motion_input.cpp
parentMerge pull request #9746 from ameerj/ogl-msaa-texcache (diff)
parentcore: hid: Use gyro thresholds modes set by the game (diff)
downloadyuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.gz
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.tar.xz
yuzu-8b74047b1b4eac10c6152a18920d0a8e1861fecd.zip
Merge pull request #9757 from german77/gyro
core: hid: Use gyro thresholds modes set by the game
Diffstat (limited to 'src/core/hid/motion_input.cpp')
-rw-r--r--src/core/hid/motion_input.cpp12
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 {
9MotionInput::MotionInput() { 9MotionInput::MotionInput() {
10 // Initialize PID constants with default values 10 // Initialize PID constants with default values
11 SetPID(0.3f, 0.005f, 0.0f); 11 SetPID(0.3f, 0.005f, 0.0f);
12 SetGyroThreshold(0.007f); 12 SetGyroThreshold(ThresholdStandard);
13} 13}
14 14
15void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) { 15void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) {
@@ -26,11 +26,11 @@ void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) {
26 gyro = gyroscope - gyro_bias; 26 gyro = gyroscope - gyro_bias;
27 27
28 // Auto adjust drift to minimize drift 28 // Auto adjust drift to minimize drift
29 if (!IsMoving(0.1f)) { 29 if (!IsMoving(IsAtRestRelaxed)) {
30 gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); 30 gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f);
31 } 31 }
32 32
33 if (gyro.Length() < gyro_threshold) { 33 if (gyro.Length() < gyro_threshold * user_gyro_threshold) {
34 gyro = {}; 34 gyro = {};
35 } else { 35 } else {
36 only_accelerometer = false; 36 only_accelerometer = false;
@@ -49,6 +49,10 @@ void MotionInput::SetGyroThreshold(f32 threshold) {
49 gyro_threshold = threshold; 49 gyro_threshold = threshold;
50} 50}
51 51
52void MotionInput::SetUserGyroThreshold(f32 threshold) {
53 user_gyro_threshold = threshold / ThresholdStandard;
54}
55
52void MotionInput::EnableReset(bool reset) { 56void MotionInput::EnableReset(bool reset) {
53 reset_enabled = reset; 57 reset_enabled = reset;
54} 58}
@@ -208,7 +212,7 @@ void MotionInput::ResetOrientation() {
208 if (!reset_enabled || only_accelerometer) { 212 if (!reset_enabled || only_accelerometer) {
209 return; 213 return;
210 } 214 }
211 if (!IsMoving(0.5f) && accel.z <= -0.9f) { 215 if (!IsMoving(IsAtRestRelaxed) && accel.z <= -0.9f) {
212 ++reset_counter; 216 ++reset_counter;
213 if (reset_counter > 900) { 217 if (reset_counter > 900) {
214 quat.w = 0; 218 quat.w = 0;