use bitflags::bitflags;
use derive_new::new;
use getset::{CopyGetters, Getters};
use crate::packet::header::Header;
use crate::types::CornerProperty;
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,
}