From 9b771bcb8f2da7af507aa7be1b44599901028284 Mon Sep 17 00:00:00 2001 From: german77 Date: Fri, 5 May 2023 22:48:52 -0600 Subject: [PATCH] input_common: Add experimental motion to button --- src/core/hid/input_converter.cpp | 7 +++++++ src/input_common/input_mapping.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 7cee39a538..2772bc0129 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp @@ -61,6 +61,9 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu case Common::Input::InputType::Button: status = callback.button_status; break; + case Common::Input::InputType::Motion: + status.value = std::abs(callback.motion_status.gyro.x.raw_value) > 1.0f; + break; default: LOG_ERROR(Input, "Conversion from type {} to button not implemented", callback.type); break; @@ -226,6 +229,10 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta status = callback.trigger_status; calculate_button_value = false; break; + case Common::Input::InputType::Motion: + status.analog.properties.range = 1.0f; + raw_value = callback.motion_status.accel.x.raw_value; + break; default: LOG_ERROR(Input, "Conversion from type {} to trigger not implemented", callback.type); break; diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 9361b00c59..8c2ee4eb30 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp @@ -82,6 +82,9 @@ void MappingFactory::RegisterButton(const MappingData& data) { new_input.Set("axis", data.index); new_input.Set("threshold", 0.5f); break; + case EngineInputType::Motion: + new_input.Set("motion", data.index); + break; default: return; }