diff options
Diffstat (limited to 'src/input_common/motion_input.h')
| -rw-r--r-- | src/input_common/motion_input.h | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/input_common/motion_input.h b/src/input_common/motion_input.h index 4b8093d8c..d1a7a9e13 100644 --- a/src/input_common/motion_input.h +++ b/src/input_common/motion_input.h | |||
| @@ -14,10 +14,16 @@ class MotionInput { | |||
| 14 | public: | 14 | public: |
| 15 | MotionInput(f32 new_kp, f32 new_ki, f32 new_kd); | 15 | MotionInput(f32 new_kp, f32 new_ki, f32 new_kd); |
| 16 | 16 | ||
| 17 | void SetAcceleration(Common::Vec3f acceleration); | 17 | MotionInput(const MotionInput&) = default; |
| 18 | void SetGyroscope(Common::Vec3f acceleration); | 18 | MotionInput& operator=(const MotionInput&) = default; |
| 19 | void SetQuaternion(Common::Quaternion<f32> quaternion); | 19 | |
| 20 | void SetGyroDrift(Common::Vec3f drift); | 20 | MotionInput(MotionInput&&) = default; |
| 21 | MotionInput& operator=(MotionInput&&) = default; | ||
| 22 | |||
| 23 | void SetAcceleration(const Common::Vec3f& acceleration); | ||
| 24 | void SetGyroscope(const Common::Vec3f& acceleration); | ||
| 25 | void SetQuaternion(const Common::Quaternion<f32>& quaternion); | ||
| 26 | void SetGyroDrift(const Common::Vec3f& drift); | ||
| 21 | void SetGyroThreshold(f32 threshold); | 27 | void SetGyroThreshold(f32 threshold); |
| 22 | 28 | ||
| 23 | void EnableReset(bool reset); | 29 | void EnableReset(bool reset); |
| @@ -26,23 +32,23 @@ public: | |||
| 26 | void UpdateRotation(u64 elapsed_time); | 32 | void UpdateRotation(u64 elapsed_time); |
| 27 | void UpdateOrientation(u64 elapsed_time); | 33 | void UpdateOrientation(u64 elapsed_time); |
| 28 | 34 | ||
| 29 | std::array<Common::Vec3f, 3> GetOrientation(); | 35 | std::array<Common::Vec3f, 3> GetOrientation() const; |
| 30 | Common::Vec3f GetAcceleration(); | 36 | Common::Vec3f GetAcceleration() const; |
| 31 | Common::Vec3f GetGyroscope(); | 37 | Common::Vec3f GetGyroscope() const; |
| 32 | Common::Vec3f GetRotations(); | 38 | Common::Vec3f GetRotations() const; |
| 33 | Common::Quaternion<f32> GetQuaternion(); | 39 | Common::Quaternion<f32> GetQuaternion() const; |
| 40 | |||
| 41 | bool IsMoving(f32 sensitivity) const; | ||
| 42 | bool IsCalibrated(f32 sensitivity) const; | ||
| 34 | 43 | ||
| 35 | bool IsMoving(f32 sensitivity); | 44 | private: |
| 36 | bool IsCalibrated(f32 sensitivity); | 45 | void ResetOrientation(); |
| 37 | 46 | ||
| 38 | // PID constants | 47 | // PID constants |
| 39 | const f32 kp; | 48 | const f32 kp; |
| 40 | const f32 ki; | 49 | const f32 ki; |
| 41 | const f32 kd; | 50 | const f32 kd; |
| 42 | 51 | ||
| 43 | private: | ||
| 44 | void resetOrientation(); | ||
| 45 | |||
| 46 | // PID errors | 52 | // PID errors |
| 47 | Common::Vec3f real_error; | 53 | Common::Vec3f real_error; |
| 48 | Common::Vec3f integral_error; | 54 | Common::Vec3f integral_error; |
| @@ -54,9 +60,9 @@ private: | |||
| 54 | Common::Vec3f gyro; | 60 | Common::Vec3f gyro; |
| 55 | Common::Vec3f gyro_drift; | 61 | Common::Vec3f gyro_drift; |
| 56 | 62 | ||
| 57 | f32 gyro_threshold; | 63 | f32 gyro_threshold = 0.0f; |
| 58 | f32 reset_counter; | 64 | f32 reset_counter = 0.0f; |
| 59 | bool reset_enabled; | 65 | bool reset_enabled = true; |
| 60 | }; | 66 | }; |
| 61 | 67 | ||
| 62 | } // namespace InputCommon | 68 | } // namespace InputCommon |