1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
use crate::packet::header::Header;
use crate::types::CornerProperty;
use bitflags::bitflags;
use derive_new::new;
use getset::{CopyGetters, Getters};
bitflags! {
pub struct Button: u32 {
const NONE = 0x0;
const CROSS_OR_A = 0x0001;
const TRIANGLE_OR_Y = 0x0002;
const CIRCLE_OR_B = 0x0004;
const SQUARE_OR_X = 0x0008;
const DPAD_LEFT = 0x0010;
const DPAD_RIGHT = 0x0020;
const DPAD_UP = 0x0040;
const DPAD_DOWN = 0x0080;
const OPTIONS_OR_MENU = 0x0100;
const L1_OR_LB = 0x0200;
const R1_OR_RB = 0x0400;
const L2_OR_LT = 0x0800;
const R2_OR_RT = 0x1000;
const LEFT_STICK_CLICK = 0x2000;
const RIGHT_STICK_CLICK =0x4000;
}
}
impl Default for Button {
fn default() -> Self {
Button::NONE
}
}
#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
pub enum Gear {
Reverse = -1,
Neutral = 0,
First = 1,
Second = 2,
Third = 3,
Fourth = 4,
Fifth = 5,
Sixth = 6,
Seventh = 7,
Eighth = 8,
}
impl Default for Gear {
fn default() -> Self {
Gear::Neutral
}
}
#[derive(Debug, PartialEq, Copy, Clone, Eq, Ord, PartialOrd, Hash)]
pub enum Surface {
Tarmac = 0,
RumbleStrip = 1,
Concrete = 2,
Rock = 3,
Gravel = 4,
Mud = 5,
Sand = 6,
Grass = 7,
Water = 8,
Cobblestone = 9,
Metal = 10,
Ridged = 11,
}
impl Default for Surface {
fn default() -> Self {
Surface::Tarmac
}
}
#[derive(new, Debug, CopyGetters, Getters, PartialEq, Copy, Clone, PartialOrd, Default)]
#[allow(clippy::too_many_arguments)]
pub struct Telemetry {
#[getset(get_copy = "pub")]
speed: u16,
#[getset(get_copy = "pub")]
throttle: f32,
#[getset(get_copy = "pub")]
steering: f32,
#[getset(get_copy = "pub")]
brake: f32,
#[getset(get_copy = "pub")]
clutch: u8,
#[getset(get_copy = "pub")]
gear: Gear,
#[getset(get_copy = "pub")]
engine_rpm: u16,
#[getset(get_copy = "pub")]
drs: bool,
#[getset(get_copy = "pub")]
rev_lights: u8,
#[getset(get = "pub")]
brake_temperature: CornerProperty<u16>,
#[getset(get = "pub")]
tyre_surface_temperature: CornerProperty<u16>,
#[getset(get = "pub")]
tyre_inner_temperature: CornerProperty<u16>,
#[getset(get_copy = "pub")]
engine_temperature: u16,
#[getset(get = "pub")]
tyre_pressure: CornerProperty<f32>,
#[getset(get = "pub")]
surface_type: CornerProperty<Surface>,
}
#[derive(new, Debug, CopyGetters, Getters, PartialEq, Clone, PartialOrd)]
pub struct TelemetryPacket {
#[getset(get = "pub")]
header: Header,
#[getset(get = "pub")]
telemetry: Vec<Telemetry>,
#[getset(get_copy = "pub")]
button_status: Button,
}