viiper_client/devices/ns2pro/
input.rs1use crate::wire::DeviceInput;
4
5#[derive(Debug, Clone, Default)]
6pub struct Ns2proInput {
7 pub buttons: u32,
8 pub lx: u16,
9 pub ly: u16,
10 pub rx: u16,
11 pub ry: u16,
12 pub accel_x: i16,
13 pub accel_y: i16,
14 pub accel_z: i16,
15 pub gyro_x: i16,
16 pub gyro_y: i16,
17 pub gyro_z: i16,
18}
19
20impl DeviceInput for Ns2proInput {
21 fn to_bytes(&self) -> Vec<u8> {
22 let mut buf = Vec::new();
23 buf.extend_from_slice(&self.buttons.to_le_bytes());
24 buf.extend_from_slice(&self.lx.to_le_bytes());
25 buf.extend_from_slice(&self.ly.to_le_bytes());
26 buf.extend_from_slice(&self.rx.to_le_bytes());
27 buf.extend_from_slice(&self.ry.to_le_bytes());
28 buf.extend_from_slice(&self.accel_x.to_le_bytes());
29 buf.extend_from_slice(&self.accel_y.to_le_bytes());
30 buf.extend_from_slice(&self.accel_z.to_le_bytes());
31 buf.extend_from_slice(&self.gyro_x.to_le_bytes());
32 buf.extend_from_slice(&self.gyro_y.to_le_bytes());
33 buf.extend_from_slice(&self.gyro_z.to_le_bytes());
34 buf
35 }
36}