vex_sdk/
controller.rs

1//! V5 Controller
2
3use crate::map_jump_table;
4
5#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
6#[repr(transparent)]
7pub struct V5_ControllerId(pub core::ffi::c_uchar);
8
9impl V5_ControllerId {
10    pub const kControllerMaster: Self = Self(0);
11    pub const kControllerPartner: Self = Self(1);
12}
13
14#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
15#[repr(transparent)]
16pub struct V5_ControllerStatus(pub core::ffi::c_uchar);
17
18impl V5_ControllerStatus {
19    pub const kV5ControllerOffline: Self = Self(0);
20    pub const kV5ControllerTethered: Self = Self(1);
21    pub const kV5ControllerVexnet: Self = Self(2);
22}
23
24#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
25#[repr(transparent)]
26pub struct V5_ControllerIndex(pub core::ffi::c_uchar);
27
28impl V5_ControllerIndex {
29    pub const AnaLeftX: Self = Self(0);
30    pub const AnaLeftY: Self = Self(1);
31    pub const AnaRightX: Self = Self(2);
32    pub const AnaRightY: Self = Self(3);
33    pub const AnaSpare1: Self = Self(4);
34    pub const AnaSpare2: Self = Self(5);
35    pub const Button5U: Self = Self(6);
36    pub const Button5D: Self = Self(7);
37    pub const Button6U: Self = Self(8);
38    pub const Button6D: Self = Self(9);
39    pub const Button7U: Self = Self(10);
40    pub const Button7D: Self = Self(11);
41    pub const Button7L: Self = Self(12);
42    pub const Button7R: Self = Self(13);
43    pub const Button8U: Self = Self(14);
44    pub const Button8D: Self = Self(15);
45    pub const Button8L: Self = Self(16);
46    pub const Button8R: Self = Self(17);
47    pub const ButtonSEL: Self = Self(18);
48    pub const BatteryLevel: Self = Self(19);
49    pub const ButtonAll: Self = Self(20);
50    pub const Flags: Self = Self(21);
51    pub const BatteryCapacity: Self = Self(22);
52    pub const Axis1: Self = Self::AnaRightX;
53    pub const Axis2: Self = Self::AnaRightY;
54    pub const Axis3: Self = Self::AnaLeftY;
55    pub const Axis4: Self = Self::AnaLeftX;
56    pub const ButtonL1: Self = Self::Button5U;
57    pub const ButtonL2: Self = Self::Button5D;
58    pub const ButtonR1: Self = Self::Button6U;
59    pub const ButtonR2: Self = Self::Button6D;
60    pub const ButtonUp: Self = Self::Button7U;
61    pub const ButtonDown: Self = Self::Button7D;
62    pub const ButtonLeft: Self = Self::Button7L;
63    pub const ButtonRight: Self = Self::Button7R;
64    pub const ButtonX: Self = Self::Button8U;
65    pub const ButtonB: Self = Self::Button8D;
66    pub const ButtonY: Self = Self::Button8L;
67    pub const ButtonA: Self = Self::Button8R;
68}
69
70map_jump_table! {
71    0x1a4 =>
72        /// Get the value of a controller's data channel.
73        pub fn vexControllerGet(id: V5_ControllerId, index: V5_ControllerIndex) -> i32,
74    0x1a8 =>
75        /// Returns `1` if the controller on the given ID is connected, or `0` if not.
76        pub fn vexControllerConnectionStatusGet(id: V5_ControllerId) -> V5_ControllerStatus,
77    0x1ac => pub fn vexControllerTextSet(id: u32, line: u32, col: u32, buf: *const u8) -> u32,
78}