summaryrefslogtreecommitdiff
path: root/src/input_common/motion_input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/motion_input.h')
-rw-r--r--src/input_common/motion_input.h74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/input_common/motion_input.h b/src/input_common/motion_input.h
deleted file mode 100644
index efe74cf19..000000000
--- a/src/input_common/motion_input.h
+++ /dev/null
@@ -1,74 +0,0 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included
4
5#pragma once
6
7#include "common/common_types.h"
8#include "common/quaternion.h"
9#include "common/vector_math.h"
10#include "core/frontend/input.h"
11
12namespace InputCommon {
13
14class MotionInput {
15public:
16 explicit MotionInput(f32 new_kp, f32 new_ki, f32 new_kd);
17
18 MotionInput(const MotionInput&) = default;
19 MotionInput& operator=(const MotionInput&) = default;
20
21 MotionInput(MotionInput&&) = default;
22 MotionInput& operator=(MotionInput&&) = default;
23
24 void SetAcceleration(const Common::Vec3f& acceleration);
25 void SetGyroscope(const Common::Vec3f& gyroscope);
26 void SetQuaternion(const Common::Quaternion<f32>& quaternion);
27 void SetGyroDrift(const Common::Vec3f& drift);
28 void SetGyroThreshold(f32 threshold);
29
30 void EnableReset(bool reset);
31 void ResetRotations();
32
33 void UpdateRotation(u64 elapsed_time);
34 void UpdateOrientation(u64 elapsed_time);
35
36 [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const;
37 [[nodiscard]] Common::Vec3f GetAcceleration() const;
38 [[nodiscard]] Common::Vec3f GetGyroscope() const;
39 [[nodiscard]] Common::Vec3f GetRotations() const;
40 [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const;
41 [[nodiscard]] Input::MotionStatus GetMotion() const;
42 [[nodiscard]] Input::MotionStatus GetRandomMotion(int accel_magnitude,
43 int gyro_magnitude) const;
44
45 [[nodiscard]] bool IsMoving(f32 sensitivity) const;
46 [[nodiscard]] bool IsCalibrated(f32 sensitivity) const;
47
48private:
49 void ResetOrientation();
50 void SetOrientationFromAccelerometer();
51
52 // PID constants
53 f32 kp;
54 f32 ki;
55 f32 kd;
56
57 // PID errors
58 Common::Vec3f real_error;
59 Common::Vec3f integral_error;
60 Common::Vec3f derivative_error;
61
62 Common::Quaternion<f32> quat{{0.0f, 0.0f, -1.0f}, 0.0f};
63 Common::Vec3f rotations;
64 Common::Vec3f accel;
65 Common::Vec3f gyro;
66 Common::Vec3f gyro_drift;
67
68 f32 gyro_threshold = 0.0f;
69 u32 reset_counter = 0;
70 bool reset_enabled = true;
71 bool only_accelerometer = true;
72};
73
74} // namespace InputCommon