diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2023-02-13 21:08:06 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-03 09:05:30 +0200 |
commit | f1bb2f3685a73c68765ada5298bfdc91fdb75e37 (patch) | |
tree | f85eee36f69b1467c15304cb08d05a6708148e53 /src/input_common/drivers | |
parent | android: Hook jni input properly (diff) | |
download | yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar.gz yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar.bz2 yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar.lz yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar.xz yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.tar.zst yuzu-f1bb2f3685a73c68765ada5298bfdc91fdb75e37.zip |
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r-- | src/input_common/drivers/virtual_gamepad.cpp | 16 | ||||
-rw-r--r-- | src/input_common/drivers/virtual_gamepad.h | 12 |
2 files changed, 27 insertions, 1 deletions
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<int>(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); diff --git a/src/input_common/drivers/virtual_gamepad.h b/src/input_common/drivers/virtual_gamepad.h index 3df91cc6f..dfbc45a28 100644 --- a/src/input_common/drivers/virtual_gamepad.h +++ b/src/input_common/drivers/virtual_gamepad.h @@ -52,7 +52,7 @@ public: void SetButtonState(std::size_t player_index, VirtualButton button_id, bool value); /** - * Sets the status of all buttons bound with the key to released + * Sets the status of a stick to a specific player index * @param player_index the player number that will take this action * @param axis_id the id of the axis to move * @param x_value the position of the stick in the x axis @@ -62,6 +62,16 @@ public: void SetStickPosition(std::size_t player_index, VirtualStick axis_id, float x_value, float y_value); + /** + * Sets the status of the motion sensor to a specific player index + * @param player_index the player number that will take this action + * @param delta_timestamp time passed since last reading + * @param gyro_x,gyro_y,gyro_z the gyro sensor readings + * @param accel_x,accel_y,accel_z the acelerometer reading + */ + void 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); + /// Restores all inputs into the neutral position void ResetControllers(); |