diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/frontend/input.h | 29 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 10 |
3 files changed, 16 insertions, 28 deletions
diff --git a/src/core/frontend/input.h b/src/core/frontend/input.h index 6770475cf..9da0d2829 100644 --- a/src/core/frontend/input.h +++ b/src/core/frontend/input.h | |||
| @@ -119,25 +119,7 @@ using ButtonDevice = InputDevice<bool>; | |||
| 119 | using AnalogDevice = InputDevice<std::tuple<float, float>>; | 119 | using AnalogDevice = InputDevice<std::tuple<float, float>>; |
| 120 | 120 | ||
| 121 | /** | 121 | /** |
| 122 | * A motion device is an input device that returns a tuple of accelerometer state vector and | 122 | * A motion status is an object that returns a tuple of accelerometer state vector, |
| 123 | * gyroscope state vector. | ||
| 124 | * | ||
| 125 | * For both vectors: | ||
| 126 | * x+ is the same direction as LEFT on D-pad. | ||
| 127 | * y+ is normal to the touch screen, pointing outward. | ||
| 128 | * z+ is the same direction as UP on D-pad. | ||
| 129 | * | ||
| 130 | * For accelerometer state vector | ||
| 131 | * Units: g (gravitational acceleration) | ||
| 132 | * | ||
| 133 | * For gyroscope state vector: | ||
| 134 | * Orientation is determined by right-hand rule. | ||
| 135 | * Units: deg/sec | ||
| 136 | */ | ||
| 137 | using MotionDevice = InputDevice<std::tuple<Common::Vec3<float>, Common::Vec3<float>>>; | ||
| 138 | |||
| 139 | /** | ||
| 140 | * A real motion device is an input device that returns a tuple of accelerometer state vector, | ||
| 141 | * gyroscope state vector, rotation state vector and orientation state matrix. | 123 | * gyroscope state vector, rotation state vector and orientation state matrix. |
| 142 | * | 124 | * |
| 143 | * For both vectors: | 125 | * For both vectors: |
| @@ -160,8 +142,13 @@ using MotionDevice = InputDevice<std::tuple<Common::Vec3<float>, Common::Vec3<fl | |||
| 160 | * y vector | 142 | * y vector |
| 161 | * z vector | 143 | * z vector |
| 162 | */ | 144 | */ |
| 163 | using RealMotionDevice = InputDevice<std::tuple<Common::Vec3<float>, Common::Vec3<float>, | 145 | using MotionStatus = std::tuple<Common::Vec3<float>, Common::Vec3<float>, Common::Vec3<float>, |
| 164 | Common::Vec3<float>, std::array<Common::Vec3f, 3>>>; | 146 | std::array<Common::Vec3f, 3>>; |
| 147 | |||
| 148 | /** | ||
| 149 | * A motion device is an input device that returns a motion status object | ||
| 150 | */ | ||
| 151 | using MotionDevice = InputDevice<MotionStatus>; | ||
| 165 | 152 | ||
| 166 | /** | 153 | /** |
| 167 | * A touch device is an input device that returns a tuple of two floats and a bool. The floats are | 154 | * A touch device is an input device that returns a tuple of two floats and a bool. The floats are |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 9701318b5..2e06372a4 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -251,7 +251,7 @@ void Controller_NPad::OnLoadInputDevices() { | |||
| 251 | sticks[i].begin(), Input::CreateDevice<Input::AnalogDevice>); | 251 | sticks[i].begin(), Input::CreateDevice<Input::AnalogDevice>); |
| 252 | std::transform(players[i].motions.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, | 252 | std::transform(players[i].motions.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, |
| 253 | players[i].motions.begin() + Settings::NativeMotion::MOTION_HID_END, | 253 | players[i].motions.begin() + Settings::NativeMotion::MOTION_HID_END, |
| 254 | motions[i].begin(), Input::CreateDevice<Input::RealMotionDevice>); | 254 | motions[i].begin(), Input::CreateDevice<Input::MotionDevice>); |
| 255 | } | 255 | } |
| 256 | } | 256 | } |
| 257 | 257 | ||
| @@ -397,7 +397,8 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* | |||
| 397 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, | 397 | std::tie(motion_devices[e].accel, motion_devices[e].gyro, |
| 398 | motion_devices[e].rotation, motion_devices[e].orientation) = | 398 | motion_devices[e].rotation, motion_devices[e].orientation) = |
| 399 | device->GetStatus(); | 399 | device->GetStatus(); |
| 400 | sixaxis_at_rest = sixaxis_at_rest && motion_devices[e].gyro.Length2() < 1.0f; | 400 | sixaxis_at_rest = |
| 401 | sixaxis_at_rest && motion_devices[e].gyro.Length2() < 0.00005f; | ||
| 401 | } | 402 | } |
| 402 | } | 403 | } |
| 403 | } | 404 | } |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 99d7e459a..7b07d2e8b 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -299,9 +299,9 @@ private: | |||
| 299 | 299 | ||
| 300 | struct MotionDevice { | 300 | struct MotionDevice { |
| 301 | Common::Vec3f accel; | 301 | Common::Vec3f accel; |
| 302 | Common::Vec3f gyro{}; | 302 | Common::Vec3f gyro; |
| 303 | Common::Vec3f rotation; | 303 | Common::Vec3f rotation; |
| 304 | std::array<Common::Vec3f, 3> orientation{}; | 304 | std::array<Common::Vec3f, 3> orientation; |
| 305 | }; | 305 | }; |
| 306 | 306 | ||
| 307 | struct NPadEntry { | 307 | struct NPadEntry { |
| @@ -358,9 +358,9 @@ private: | |||
| 358 | using StickArray = std::array< | 358 | using StickArray = std::array< |
| 359 | std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>, | 359 | std::array<std::unique_ptr<Input::AnalogDevice>, Settings::NativeAnalog::NUM_STICKS_HID>, |
| 360 | 10>; | 360 | 10>; |
| 361 | using MotionArray = std::array<std::array<std::unique_ptr<Input::RealMotionDevice>, | 361 | using MotionArray = std::array< |
| 362 | Settings::NativeMotion::NUM_MOTION_HID>, | 362 | std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTION_HID>, |
| 363 | 10>; | 363 | 10>; |
| 364 | ButtonArray buttons; | 364 | ButtonArray buttons; |
| 365 | StickArray sticks; | 365 | StickArray sticks; |
| 366 | MotionArray motions; | 366 | MotionArray motions; |