diff options
Diffstat (limited to 'src/input_common/motion_input.h')
-rw-r--r-- | src/input_common/motion_input.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/input_common/motion_input.h b/src/input_common/motion_input.h index 54b4439d9..efe74cf19 100644 --- a/src/input_common/motion_input.h +++ b/src/input_common/motion_input.h @@ -7,12 +7,13 @@ #include "common/common_types.h" #include "common/quaternion.h" #include "common/vector_math.h" +#include "core/frontend/input.h" namespace InputCommon { class MotionInput { public: - MotionInput(f32 new_kp, f32 new_ki, f32 new_kd); + explicit MotionInput(f32 new_kp, f32 new_ki, f32 new_kd); MotionInput(const MotionInput&) = default; MotionInput& operator=(const MotionInput&) = default; @@ -21,7 +22,7 @@ public: MotionInput& operator=(MotionInput&&) = default; void SetAcceleration(const Common::Vec3f& acceleration); - void SetGyroscope(const Common::Vec3f& acceleration); + void SetGyroscope(const Common::Vec3f& gyroscope); void SetQuaternion(const Common::Quaternion<f32>& quaternion); void SetGyroDrift(const Common::Vec3f& drift); void SetGyroThreshold(f32 threshold); @@ -32,29 +33,33 @@ public: void UpdateRotation(u64 elapsed_time); void UpdateOrientation(u64 elapsed_time); - std::array<Common::Vec3f, 3> GetOrientation() const; - Common::Vec3f GetAcceleration() const; - Common::Vec3f GetGyroscope() const; - Common::Vec3f GetRotations() const; - Common::Quaternion<f32> GetQuaternion() const; + [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const; + [[nodiscard]] Common::Vec3f GetAcceleration() const; + [[nodiscard]] Common::Vec3f GetGyroscope() const; + [[nodiscard]] Common::Vec3f GetRotations() const; + [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const; + [[nodiscard]] Input::MotionStatus GetMotion() const; + [[nodiscard]] Input::MotionStatus GetRandomMotion(int accel_magnitude, + int gyro_magnitude) const; - bool IsMoving(f32 sensitivity) const; - bool IsCalibrated(f32 sensitivity) const; + [[nodiscard]] bool IsMoving(f32 sensitivity) const; + [[nodiscard]] bool IsCalibrated(f32 sensitivity) const; private: void ResetOrientation(); + void SetOrientationFromAccelerometer(); // PID constants - const f32 kp; - const f32 ki; - const f32 kd; + f32 kp; + f32 ki; + f32 kd; // PID errors Common::Vec3f real_error; Common::Vec3f integral_error; Common::Vec3f derivative_error; - Common::Quaternion<f32> quat; + Common::Quaternion<f32> quat{{0.0f, 0.0f, -1.0f}, 0.0f}; Common::Vec3f rotations; Common::Vec3f accel; Common::Vec3f gyro; @@ -63,6 +68,7 @@ private: f32 gyro_threshold = 0.0f; u32 reset_counter = 0; bool reset_enabled = true; + bool only_accelerometer = true; }; } // namespace InputCommon |