[−][src]Trait joycon_rs::joycon::input_report_mode::sub_command_mode::SubCommandReplyData
An interface for dealing with sub-command's reply.
Example - implement SubCommandReplyData
ⓘThis example is not tested
#[derive(Debug, Clone, Hash, Eq, PartialEq)] pub struct LightsStatus { light_up: Vec<LightUp>, flash: Vec<Flash>, } const LIGHT_UP: [LightUp; 4] = [LightUp::LED0, LightUp::LED1, LightUp::LED2, LightUp::LED3]; const FLASH: [Flash; 4] = [Flash::LED0, Flash::LED1, Flash::LED2, Flash::LED3]; impl TryFrom<[u8; 35]> for LightsStatus { type Error = JoyConError; fn try_from(value: [u8; 35]) -> Result<Self, Self::Error> { let value = value[0]; // parse reply let light_up = LIGHT_UP.iter() .filter(|&&l| { let light = l as u8; value & light == light }) .cloned() .collect(); let flash = FLASH.iter() .filter(|&&f| { let flash = f as u8; value & flash == flash }) .cloned() .collect(); Ok(LightsStatus { light_up, flash }) } } impl SubCommandReplyData for LightsStatus { type ArgsType = [u8; 0]; const SUB_COMMAND: SubCommand = SubCommand::GetPlayerLights; const ARGS: Self::ArgsType = []; }
Associated Types
Loading content...Associated Constants
const SUB_COMMAND: SubCommand
const ARGS: Self::ArgsType
Provided methods
fn once<D>(
driver: &mut D
) -> JoyConResult<StandardInputReport<SubCommandReport<Self>>> where
Self: Sized,
D: JoyConDriver,
driver: &mut D
) -> JoyConResult<StandardInputReport<SubCommandReport<Self>>> where
Self: Sized,
D: JoyConDriver,
The mode remains the same, sending commands and receiving replies.