summaryrefslogtreecommitdiff
path: root/src/input_common/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers')
-rw-r--r--src/input_common/drivers/virtual_gamepad.cpp16
-rw-r--r--src/input_common/drivers/virtual_gamepad.h12
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
39 SetStickPosition(player_index, static_cast<int>(axis_id), x_value, y_value); 39 SetStickPosition(player_index, static_cast<int>(axis_id), x_value, y_value);
40} 40}
41 41
42void VirtualGamepad::SetMotionState(std::size_t player_index, u64 delta_timestamp, float gyro_x,
43 float gyro_y, float gyro_z, float accel_x, float accel_y,
44 float accel_z) {
45 const auto identifier = GetIdentifier(player_index);
46 const BasicMotion motion_data{
47 .gyro_x = gyro_x,
48 .gyro_y = gyro_y,
49 .gyro_z = gyro_z,
50 .accel_x = accel_x,
51 .accel_y = accel_y,
52 .accel_z = accel_z,
53 .delta_timestamp = delta_timestamp,
54 };
55 SetMotion(identifier, 0, motion_data);
56}
57
42void VirtualGamepad::ResetControllers() { 58void VirtualGamepad::ResetControllers() {
43 for (std::size_t i = 0; i < PlayerIndexCount; i++) { 59 for (std::size_t i = 0; i < PlayerIndexCount; i++) {
44 SetStickPosition(i, VirtualStick::Left, 0.0f, 0.0f); 60 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:
52 void SetButtonState(std::size_t player_index, VirtualButton button_id, bool value); 52 void SetButtonState(std::size_t player_index, VirtualButton button_id, bool value);
53 53
54 /** 54 /**
55 * Sets the status of all buttons bound with the key to released 55 * Sets the status of a stick to a specific player index
56 * @param player_index the player number that will take this action 56 * @param player_index the player number that will take this action
57 * @param axis_id the id of the axis to move 57 * @param axis_id the id of the axis to move
58 * @param x_value the position of the stick in the x axis 58 * @param x_value the position of the stick in the x axis
@@ -62,6 +62,16 @@ public:
62 void SetStickPosition(std::size_t player_index, VirtualStick axis_id, float x_value, 62 void SetStickPosition(std::size_t player_index, VirtualStick axis_id, float x_value,
63 float y_value); 63 float y_value);
64 64
65 /**
66 * Sets the status of the motion sensor to a specific player index
67 * @param player_index the player number that will take this action
68 * @param delta_timestamp time passed since last reading
69 * @param gyro_x,gyro_y,gyro_z the gyro sensor readings
70 * @param accel_x,accel_y,accel_z the acelerometer reading
71 */
72 void SetMotionState(std::size_t player_index, u64 delta_timestamp, float gyro_x, float gyro_y,
73 float gyro_z, float accel_x, float accel_y, float accel_z);
74
65 /// Restores all inputs into the neutral position 75 /// Restores all inputs into the neutral position
66 void ResetControllers(); 76 void ResetControllers();
67 77