robotics_signals/sensors/
joystick.rs

1use cdds_derive::*;
2use cyclonedds_rs::*;
3use serde_derive::{Deserialize, Serialize};
4
5use crate::standard::Header;
6
7#[repr(C)]
8#[derive(Serialize, Deserialize, Topic)]
9pub struct Joystick {
10    pub header: Header,
11    /// The axes measurements from a joystick.
12    pub axes: Vec<f32>,
13    /// The buttons measurements from a joystick.
14    pub buttons: Vec<i32>,
15}
16
17#[repr(C)]
18#[derive(Serialize, Deserialize)]
19pub enum FeedbackType {
20    Led = 0,
21    Rumble = 1,
22    Buzzer = 2,
23}
24
25#[repr(C)]
26#[derive(Serialize, Deserialize)]
27pub struct JoystickFeedback {
28    pub ty: FeedbackType,
29    /// This will hold an id number for each type of each feedback.
30    /// Example, the first led would be id=0, the second would be id=1
31    pub id: u8,
32    /// Intensity of the feedback, from 0.0 to 1.0, inclusive.  If device is
33    /// actually binary, driver should treat 0<=x<0.5 as off, 0.5<=x<=1 as on.
34    pub intensity: f32,
35}