From 4b4af29f860fb2fdecb76d705265b0bc2bcc7254 Mon Sep 17 00:00:00 2001 From: german77 Date: Thu, 6 Jan 2022 18:06:05 -0600 Subject: input_common: Use accelerometer data for mapping --- src/input_common/input_engine.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 9c17ca4f7..b57330e51 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -298,8 +298,16 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot if (!configuring || !mapping_callback.on_data) { return; } - if (std::abs(value.gyro_x) < 0.6f && std::abs(value.gyro_y) < 0.6f && - std::abs(value.gyro_z) < 0.6f) { + bool is_active = false; + if (std::abs(value.accel_x) > 1.5f || std::abs(value.accel_y) > 1.5f || + std::abs(value.accel_z) > 1.5f) { + is_active = true; + } + if (std::abs(value.gyro_x) > 0.6f || std::abs(value.gyro_y) > 0.6f || + std::abs(value.gyro_z) > 0.6f) { + is_active = true; + } + if (!is_active) { return; } mapping_callback.on_data(MappingData{ -- cgit v1.2.3 From 50a71529416ccf52fed6fc96af28641eb043c414 Mon Sep 17 00:00:00 2001 From: german77 Date: Thu, 6 Jan 2022 18:43:41 -0600 Subject: core/hid: Set minimum gyro threshold --- src/core/hid/motion_input.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp index a23f192d7..43152492e 100644 --- a/src/core/hid/motion_input.cpp +++ b/src/core/hid/motion_input.cpp @@ -10,6 +10,7 @@ namespace Core::HID { MotionInput::MotionInput() { // Initialize PID constants with default values SetPID(0.3f, 0.005f, 0.0f); + SetGyroThreshold(0.001f); } void MotionInput::SetPID(f32 new_kp, f32 new_ki, f32 new_kd) { -- cgit v1.2.3