diff options
| author | 2019-02-26 22:38:34 -0500 | |
|---|---|---|
| committer | 2019-02-26 22:38:36 -0500 | |
| commit | 1b855efd5eb21ef802d15f6a531878754904ad4d (patch) | |
| tree | ae6fe25b9e889790b1770bbc77d67e4819d5f572 /src/input_common/motion_emu.cpp | |
| parent | common/quaternion: Move Quaternion into the Common namespace (diff) | |
| download | yuzu-1b855efd5eb21ef802d15f6a531878754904ad4d.tar.gz yuzu-1b855efd5eb21ef802d15f6a531878754904ad4d.tar.xz yuzu-1b855efd5eb21ef802d15f6a531878754904ad4d.zip | |
common/vector_math: Move Vec[x] types into the Common namespace
These types are within the common library, so they should be using the
Common namespace.
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/motion_emu.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/input_common/motion_emu.cpp b/src/input_common/motion_emu.cpp index defb1a567..d5af05ee3 100644 --- a/src/input_common/motion_emu.cpp +++ b/src/input_common/motion_emu.cpp | |||
| @@ -32,12 +32,12 @@ public: | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | void BeginTilt(int x, int y) { | 34 | void BeginTilt(int x, int y) { |
| 35 | mouse_origin = Math::MakeVec(x, y); | 35 | mouse_origin = Common::MakeVec(x, y); |
| 36 | is_tilting = true; | 36 | is_tilting = true; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | void Tilt(int x, int y) { | 39 | void Tilt(int x, int y) { |
| 40 | auto mouse_move = Math::MakeVec(x, y) - mouse_origin; | 40 | auto mouse_move = Common::MakeVec(x, y) - mouse_origin; |
| 41 | if (is_tilting) { | 41 | if (is_tilting) { |
| 42 | std::lock_guard<std::mutex> guard(tilt_mutex); | 42 | std::lock_guard<std::mutex> guard(tilt_mutex); |
| 43 | if (mouse_move.x == 0 && mouse_move.y == 0) { | 43 | if (mouse_move.x == 0 && mouse_move.y == 0) { |
| @@ -56,7 +56,7 @@ public: | |||
| 56 | is_tilting = false; | 56 | is_tilting = false; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() { | 59 | std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() { |
| 60 | std::lock_guard<std::mutex> guard(status_mutex); | 60 | std::lock_guard<std::mutex> guard(status_mutex); |
| 61 | return status; | 61 | return status; |
| 62 | } | 62 | } |
| @@ -66,17 +66,17 @@ private: | |||
| 66 | const std::chrono::steady_clock::duration update_duration; | 66 | const std::chrono::steady_clock::duration update_duration; |
| 67 | const float sensitivity; | 67 | const float sensitivity; |
| 68 | 68 | ||
| 69 | Math::Vec2<int> mouse_origin; | 69 | Common::Vec2<int> mouse_origin; |
| 70 | 70 | ||
| 71 | std::mutex tilt_mutex; | 71 | std::mutex tilt_mutex; |
| 72 | Math::Vec2<float> tilt_direction; | 72 | Common::Vec2<float> tilt_direction; |
| 73 | float tilt_angle = 0; | 73 | float tilt_angle = 0; |
| 74 | 74 | ||
| 75 | bool is_tilting = false; | 75 | bool is_tilting = false; |
| 76 | 76 | ||
| 77 | Common::Event shutdown_event; | 77 | Common::Event shutdown_event; |
| 78 | 78 | ||
| 79 | std::tuple<Math::Vec3<float>, Math::Vec3<float>> status; | 79 | std::tuple<Common::Vec3<float>, Common::Vec3<float>> status; |
| 80 | std::mutex status_mutex; | 80 | std::mutex status_mutex; |
| 81 | 81 | ||
| 82 | // Note: always keep the thread declaration at the end so that other objects are initialized | 82 | // Note: always keep the thread declaration at the end so that other objects are initialized |
| @@ -85,7 +85,7 @@ private: | |||
| 85 | 85 | ||
| 86 | void MotionEmuThread() { | 86 | void MotionEmuThread() { |
| 87 | auto update_time = std::chrono::steady_clock::now(); | 87 | auto update_time = std::chrono::steady_clock::now(); |
| 88 | Common::Quaternion<float> q = Common::MakeQuaternion(Math::Vec3<float>(), 0); | 88 | Common::Quaternion<float> q = Common::MakeQuaternion(Common::Vec3<float>(), 0); |
| 89 | Common::Quaternion<float> old_q; | 89 | Common::Quaternion<float> old_q; |
| 90 | 90 | ||
| 91 | while (!shutdown_event.WaitUntil(update_time)) { | 91 | while (!shutdown_event.WaitUntil(update_time)) { |
| @@ -96,14 +96,14 @@ private: | |||
| 96 | std::lock_guard<std::mutex> guard(tilt_mutex); | 96 | std::lock_guard<std::mutex> guard(tilt_mutex); |
| 97 | 97 | ||
| 98 | // Find the quaternion describing current 3DS tilting | 98 | // Find the quaternion describing current 3DS tilting |
| 99 | q = Common::MakeQuaternion(Math::MakeVec(-tilt_direction.y, 0.0f, tilt_direction.x), | 99 | q = Common::MakeQuaternion( |
| 100 | tilt_angle); | 100 | Common::MakeVec(-tilt_direction.y, 0.0f, tilt_direction.x), tilt_angle); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | auto inv_q = q.Inverse(); | 103 | auto inv_q = q.Inverse(); |
| 104 | 104 | ||
| 105 | // Set the gravity vector in world space | 105 | // Set the gravity vector in world space |
| 106 | auto gravity = Math::MakeVec(0.0f, -1.0f, 0.0f); | 106 | auto gravity = Common::MakeVec(0.0f, -1.0f, 0.0f); |
| 107 | 107 | ||
| 108 | // Find the angular rate vector in world space | 108 | // Find the angular rate vector in world space |
| 109 | auto angular_rate = ((q - old_q) * inv_q).xyz * 2; | 109 | auto angular_rate = ((q - old_q) * inv_q).xyz * 2; |
| @@ -131,7 +131,7 @@ public: | |||
| 131 | device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity); | 131 | device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const override { | 134 | std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const override { |
| 135 | return device->GetStatus(); | 135 | return device->GetStatus(); |
| 136 | } | 136 | } |
| 137 | 137 | ||