use crate::wire::DeviceInput;
#[derive(Debug, Clone, Default)]
pub struct Dualshock4Input {
pub stick_lx: i8,
pub stick_ly: i8,
pub stick_rx: i8,
pub stick_ry: i8,
pub buttons: u16,
pub dpad: u8,
pub trigger_l2: u8,
pub trigger_r2: u8,
pub touch1x: u16,
pub touch1y: u16,
pub touch1_active: u8,
pub touch2x: u16,
pub touch2y: u16,
pub touch2_active: u8,
pub gyro_x: i16,
pub gyro_y: i16,
pub gyro_z: i16,
pub accel_x: i16,
pub accel_y: i16,
pub accel_z: i16,
}
impl DeviceInput for Dualshock4Input {
fn to_bytes(&self) -> Vec<u8> {
let mut buf = Vec::new();
buf.extend_from_slice(&self.stick_lx.to_le_bytes());
buf.extend_from_slice(&self.stick_ly.to_le_bytes());
buf.extend_from_slice(&self.stick_rx.to_le_bytes());
buf.extend_from_slice(&self.stick_ry.to_le_bytes());
buf.extend_from_slice(&self.buttons.to_le_bytes());
buf.extend_from_slice(&self.dpad.to_le_bytes());
buf.extend_from_slice(&self.trigger_l2.to_le_bytes());
buf.extend_from_slice(&self.trigger_r2.to_le_bytes());
buf.extend_from_slice(&self.touch1x.to_le_bytes());
buf.extend_from_slice(&self.touch1y.to_le_bytes());
buf.extend_from_slice(&self.touch1_active.to_le_bytes());
buf.extend_from_slice(&self.touch2x.to_le_bytes());
buf.extend_from_slice(&self.touch2y.to_le_bytes());
buf.extend_from_slice(&self.touch2_active.to_le_bytes());
buf.extend_from_slice(&self.gyro_x.to_le_bytes());
buf.extend_from_slice(&self.gyro_y.to_le_bytes());
buf.extend_from_slice(&self.gyro_z.to_le_bytes());
buf.extend_from_slice(&self.accel_x.to_le_bytes());
buf.extend_from_slice(&self.accel_y.to_le_bytes());
buf.extend_from_slice(&self.accel_z.to_le_bytes());
buf
}
}