input_common: Add experimental motion to button

This commit is contained in:
german77 2023-05-05 22:48:52 -06:00
parent 2506594c50
commit 9b771bcb8f
2 changed files with 10 additions and 0 deletions

View file

@ -61,6 +61,9 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu
case Common::Input::InputType::Button: case Common::Input::InputType::Button:
status = callback.button_status; status = callback.button_status;
break; break;
case Common::Input::InputType::Motion:
status.value = std::abs(callback.motion_status.gyro.x.raw_value) > 1.0f;
break;
default: default:
LOG_ERROR(Input, "Conversion from type {} to button not implemented", callback.type); LOG_ERROR(Input, "Conversion from type {} to button not implemented", callback.type);
break; break;
@ -226,6 +229,10 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta
status = callback.trigger_status; status = callback.trigger_status;
calculate_button_value = false; calculate_button_value = false;
break; break;
case Common::Input::InputType::Motion:
status.analog.properties.range = 1.0f;
raw_value = callback.motion_status.accel.x.raw_value;
break;
default: default:
LOG_ERROR(Input, "Conversion from type {} to trigger not implemented", callback.type); LOG_ERROR(Input, "Conversion from type {} to trigger not implemented", callback.type);
break; break;

View file

@ -82,6 +82,9 @@ void MappingFactory::RegisterButton(const MappingData& data) {
new_input.Set("axis", data.index); new_input.Set("axis", data.index);
new_input.Set("threshold", 0.5f); new_input.Set("threshold", 0.5f);
break; break;
case EngineInputType::Motion:
new_input.Set("motion", data.index);
break;
default: default:
return; return;
} }