use crate::wire::DeviceInput;
#[derive(Debug, Clone, Default)]
pub struct Ns2proInput {
pub buttons: u32,
pub lx: u16,
pub ly: u16,
pub rx: u16,
pub ry: u16,
pub accel_x: i16,
pub accel_y: i16,
pub accel_z: i16,
pub gyro_x: i16,
pub gyro_y: i16,
pub gyro_z: i16,
}
impl DeviceInput for Ns2proInput {
fn to_bytes(&self) -> Vec<u8> {
let mut buf = Vec::new();
buf.extend_from_slice(&self.buttons.to_le_bytes());
buf.extend_from_slice(&self.lx.to_le_bytes());
buf.extend_from_slice(&self.ly.to_le_bytes());
buf.extend_from_slice(&self.rx.to_le_bytes());
buf.extend_from_slice(&self.ry.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.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
}
}