From f1bb2f3685a73c68765ada5298bfdc91fdb75e37 Mon Sep 17 00:00:00 2001 From: Narr the Reg Date: Mon, 13 Feb 2023 14:08:06 -0600 Subject: android: Add motion sensor --- src/input_common/drivers/virtual_gamepad.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/input_common/drivers/virtual_gamepad.cpp') diff --git a/src/input_common/drivers/virtual_gamepad.cpp b/src/input_common/drivers/virtual_gamepad.cpp index 7db945aa6..c15cbbe58 100644 --- a/src/input_common/drivers/virtual_gamepad.cpp +++ b/src/input_common/drivers/virtual_gamepad.cpp @@ -39,6 +39,22 @@ void VirtualGamepad::SetStickPosition(std::size_t player_index, VirtualStick axi SetStickPosition(player_index, static_cast(axis_id), x_value, y_value); } +void VirtualGamepad::SetMotionState(std::size_t player_index, u64 delta_timestamp, float gyro_x, + float gyro_y, float gyro_z, float accel_x, float accel_y, + float accel_z) { + const auto identifier = GetIdentifier(player_index); + const BasicMotion motion_data{ + .gyro_x = gyro_x, + .gyro_y = gyro_y, + .gyro_z = gyro_z, + .accel_x = accel_x, + .accel_y = accel_y, + .accel_z = accel_z, + .delta_timestamp = delta_timestamp, + }; + SetMotion(identifier, 0, motion_data); +} + void VirtualGamepad::ResetControllers() { for (std::size_t i = 0; i < PlayerIndexCount; i++) { SetStickPosition(i, VirtualStick::Left, 0.0f, 0.0f); -- cgit v1.2.3