summaryrefslogtreecommitdiff
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/gcadapter/gc_adapter.cpp8
-rw-r--r--src/input_common/gcadapter/gc_adapter.h1
-rw-r--r--src/input_common/motion_input.cpp10
3 files changed, 15 insertions, 4 deletions
diff --git a/src/input_common/gcadapter/gc_adapter.cpp b/src/input_common/gcadapter/gc_adapter.cpp
index ec3167bea..320f51ee6 100644
--- a/src/input_common/gcadapter/gc_adapter.cpp
+++ b/src/input_common/gcadapter/gc_adapter.cpp
@@ -155,8 +155,12 @@ void Adapter::UpdateStateAxes(std::size_t port, const AdapterPayload& adapter_pa
155 for (const PadAxes axis : axes) { 155 for (const PadAxes axis : axes) {
156 const auto index = static_cast<std::size_t>(axis); 156 const auto index = static_cast<std::size_t>(axis);
157 const u8 axis_value = adapter_payload[offset + 3 + index]; 157 const u8 axis_value = adapter_payload[offset + 3 + index];
158 if (pads[port].axis_origin[index] == 255) { 158 if (pads[port].reset_origin_counter <= 18) {
159 if (pads[port].axis_origin[index] != axis_value) {
160 pads[port].reset_origin_counter = 0;
161 }
159 pads[port].axis_origin[index] = axis_value; 162 pads[port].axis_origin[index] = axis_value;
163 pads[port].reset_origin_counter++;
160 } 164 }
161 pads[port].axis_values[index] = 165 pads[port].axis_values[index] =
162 static_cast<s16>(axis_value - pads[port].axis_origin[index]); 166 static_cast<s16>(axis_value - pads[port].axis_origin[index]);
@@ -375,7 +379,7 @@ void Adapter::ResetDevice(std::size_t port) {
375 pads[port].buttons = 0; 379 pads[port].buttons = 0;
376 pads[port].last_button = PadButton::Undefined; 380 pads[port].last_button = PadButton::Undefined;
377 pads[port].axis_values.fill(0); 381 pads[port].axis_values.fill(0);
378 pads[port].axis_origin.fill(255); 382 pads[port].reset_origin_counter = 0;
379} 383}
380 384
381void Adapter::Reset() { 385void Adapter::Reset() {
diff --git a/src/input_common/gcadapter/gc_adapter.h b/src/input_common/gcadapter/gc_adapter.h
index 7a6c545bd..e5de5e94f 100644
--- a/src/input_common/gcadapter/gc_adapter.h
+++ b/src/input_common/gcadapter/gc_adapter.h
@@ -70,6 +70,7 @@ struct GCController {
70 PadButton last_button{}; 70 PadButton last_button{};
71 std::array<s16, 6> axis_values{}; 71 std::array<s16, 6> axis_values{};
72 std::array<u8, 6> axis_origin{}; 72 std::array<u8, 6> axis_origin{};
73 u8 reset_origin_counter{};
73}; 74};
74 75
75class Adapter { 76class Adapter {
diff --git a/src/input_common/motion_input.cpp b/src/input_common/motion_input.cpp
index 6a65f175e..1c9d561c0 100644
--- a/src/input_common/motion_input.cpp
+++ b/src/input_common/motion_input.cpp
@@ -195,7 +195,8 @@ Input::MotionStatus MotionInput::GetMotion() const {
195 const Common::Vec3f accelerometer = GetAcceleration(); 195 const Common::Vec3f accelerometer = GetAcceleration();
196 const Common::Vec3f rotation = GetRotations(); 196 const Common::Vec3f rotation = GetRotations();
197 const std::array<Common::Vec3f, 3> orientation = GetOrientation(); 197 const std::array<Common::Vec3f, 3> orientation = GetOrientation();
198 return {accelerometer, gyroscope, rotation, orientation}; 198 const Common::Quaternion<f32> quaternion = GetQuaternion();
199 return {accelerometer, gyroscope, rotation, orientation, quaternion};
199} 200}
200 201
201Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const { 202Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_magnitude) const {
@@ -218,7 +219,12 @@ Input::MotionStatus MotionInput::GetRandomMotion(int accel_magnitude, int gyro_m
218 Common::Vec3f{0.0f, 1.0f, 0.0f}, 219 Common::Vec3f{0.0f, 1.0f, 0.0f},
219 Common::Vec3f{0.0f, 0.0f, 1.0f}, 220 Common::Vec3f{0.0f, 0.0f, 1.0f},
220 }; 221 };
221 return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation}; 222 constexpr Common::Quaternion<f32> quaternion{
223 {0.0f, 0.0f, 0.0f},
224 1.0f,
225 };
226 return {accelerometer * accel_magnitude, gyroscope * gyro_magnitude, rotation, orientation,
227 quaternion};
222} 228}
223 229
224void MotionInput::ResetOrientation() { 230void MotionInput::ResetOrientation() {