pub mod classic;
pub mod nunchuk;
pub type ExtReport = [u8; 6];
pub type ExtHdReport = [u8; 8];
pub type ControllerIdReport = [u8; 6];
#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug)]
pub enum ControllerType {
Nunchuk,
Classic,
ClassicPro,
}
pub const EXT_I2C_ADDR: u16 = 0x52;
pub const INTERMESSAGE_DELAY_MICROSEC_U32: u32 = 200;
pub fn identify_controller(id: ControllerIdReport) -> Option<ControllerType> {
if id[2] != 0xA4 || id[3] != 0x20 {
None
} else if id[0] == 0 && id[1] == 0 && id[4] == 0 && id[5] == 0 {
Some(ControllerType::Nunchuk)
} else if id[0] == 0 && id[1] == 0 && id[4] == 3 && id[5] == 1 {
Some(ControllerType::Classic)
} else if id[0] == 1 && id[1] == 0 && id[4] == 1 && id[5] == 1 {
Some(ControllerType::ClassicPro)
} else {
None
}
}