diff options
| author | 2021-11-29 12:40:29 -0600 | |
|---|---|---|
| committer | 2021-12-12 23:26:04 -0600 | |
| commit | 316f80af87c3290ad3ceda99fe9cf02f1d935b0c (patch) | |
| tree | 6b933d2399f02ff42c077d0f2f342b9ffbb21cf5 /src/core/hid/motion_input.cpp | |
| parent | Merge pull request #7488 from vonchenplus/support_multiple_videos_playing (diff) | |
| download | yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.tar.gz yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.tar.xz yuzu-316f80af87c3290ad3ceda99fe9cf02f1d935b0c.zip | |
service/hid: Improve console motion accuracy
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 c25fea966..a23f192d7 100644 --- a/src/core/hid/motion_input.cpp +++ b/src/core/hid/motion_input.cpp | |||
| @@ -23,11 +23,11 @@ void MotionInput::SetAcceleration(const Common::Vec3f& acceleration) { | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { | 25 | void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { |
| 26 | gyro = gyroscope - gyro_drift; | 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(0.1f)) { |
| 30 | gyro_drift = (gyro_drift * 0.9999f) + (gyroscope * 0.0001f); | 30 | gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | if (gyro.Length2() < gyro_threshold) { | 33 | if (gyro.Length2() < gyro_threshold) { |
| @@ -41,8 +41,8 @@ void MotionInput::SetQuaternion(const Common::Quaternion<f32>& quaternion) { | |||
| 41 | quat = quaternion; | 41 | quat = quaternion; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | void MotionInput::SetGyroDrift(const Common::Vec3f& drift) { | 44 | void MotionInput::SetGyroBias(const Common::Vec3f& bias) { |
| 45 | gyro_drift = drift; | 45 | gyro_bias = bias; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void MotionInput::SetGyroThreshold(f32 threshold) { | 48 | void MotionInput::SetGyroThreshold(f32 threshold) { |
| @@ -192,6 +192,10 @@ Common::Vec3f MotionInput::GetGyroscope() const { | |||
| 192 | return gyro; | 192 | return gyro; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | Common::Vec3f MotionInput::GetGyroBias() const { | ||
| 196 | return gyro_bias; | ||
| 197 | } | ||
| 198 | |||
| 195 | Common::Quaternion<f32> MotionInput::GetQuaternion() const { | 199 | Common::Quaternion<f32> MotionInput::GetQuaternion() const { |
| 196 | return quat; | 200 | return quat; |
| 197 | } | 201 | } |