use byteorder::{
ByteOrder,
LittleEndian
};
#[repr(C)]
#[derive(Clone)]
pub struct GunconButtons {
data: u16
}
impl GunconButtons {
const GC_A: u16 = 0x0008;
const GC_B: u16 = 0x4000;
const GC_TRIGGER: u16 = 0x2000;
pub fn a(&self) -> bool {
self.data & Self::GC_A == 0
}
pub fn b(&self) -> bool {
self.data & Self::GC_B == 0
}
pub fn trigger(&self) -> bool {
self.data & Self::GC_TRIGGER == 0
}
}
#[repr(C)]
pub struct GunCon {
pub buttons: GunconButtons,
x: [u8; 2],
y: [u8; 2],
}
impl GunCon {
pub fn x(&self) -> u16 {
LittleEndian::read_u16(&self.x)
}
pub fn y(&self) -> u16 {
LittleEndian::read_u16(&self.y)
}
}