summaryrefslogtreecommitdiff
path: root/src/core/hid/motion_input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hid/motion_input.h')
-rw-r--r--src/core/hid/motion_input.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/hid/motion_input.h b/src/core/hid/motion_input.h
index 482719359..11678983d 100644
--- a/src/core/hid/motion_input.h
+++ b/src/core/hid/motion_input.h
@@ -23,6 +23,8 @@ public:
23 static constexpr float GyroMaxValue = 5.0f; 23 static constexpr float GyroMaxValue = 5.0f;
24 static constexpr float AccelMaxValue = 7.0f; 24 static constexpr float AccelMaxValue = 7.0f;
25 25
26 static constexpr std::size_t CalibrationSamples = 300;
27
26 explicit MotionInput(); 28 explicit MotionInput();
27 29
28 MotionInput(const MotionInput&) = default; 30 MotionInput(const MotionInput&) = default;
@@ -49,6 +51,8 @@ public:
49 void UpdateRotation(u64 elapsed_time); 51 void UpdateRotation(u64 elapsed_time);
50 void UpdateOrientation(u64 elapsed_time); 52 void UpdateOrientation(u64 elapsed_time);
51 53
54 void Calibrate();
55
52 [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const; 56 [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const;
53 [[nodiscard]] Common::Vec3f GetAcceleration() const; 57 [[nodiscard]] Common::Vec3f GetAcceleration() const;
54 [[nodiscard]] Common::Vec3f GetGyroscope() const; 58 [[nodiscard]] Common::Vec3f GetGyroscope() const;
@@ -61,6 +65,7 @@ public:
61 [[nodiscard]] bool IsCalibrated(f32 sensitivity) const; 65 [[nodiscard]] bool IsCalibrated(f32 sensitivity) const;
62 66
63private: 67private:
68 void StopCalibration();
64 void ResetOrientation(); 69 void ResetOrientation();
65 void SetOrientationFromAccelerometer(); 70 void SetOrientationFromAccelerometer();
66 71
@@ -103,6 +108,12 @@ private:
103 108
104 // Use accelerometer values to calculate position 109 // Use accelerometer values to calculate position
105 bool only_accelerometer = true; 110 bool only_accelerometer = true;
111
112 // When enabled it will aggressively adjust for gyro drift
113 bool calibration_mode = false;
114
115 // Used to auto disable calibration mode
116 std::size_t calibration_counter = 0;
106}; 117};
107 118
108} // namespace Core::HID 119} // namespace Core::HID