joycon_rs::joycon

Trait JoyConDriver

Source
pub trait JoyConDriver {
    const ACK_TRY: usize = 5usize;
Show 18 methods // Required methods fn valid_reply(&self) -> bool; fn set_valid_reply(&mut self, valid: bool); fn write(&self, data: &[u8]) -> JoyConResult<usize>; fn read(&self, buf: &mut [u8]) -> JoyConResult<usize>; fn read_timeout(&self, buf: &mut [u8], timeout: i32) -> JoyConResult<usize>; fn global_packet_number(&self) -> u8; fn increase_global_packet_number(&mut self); fn set_rumble_status( &mut self, rumble_l_r: (Option<Rumble>, Option<Rumble>), ); fn get_rumble_status(&self) -> (Option<Rumble>, Option<Rumble>); fn enable_feature(&mut self, feature: JoyConFeature) -> JoyConResult<()>; fn enabled_features(&self) -> &HashSet<JoyConFeature>; fn devices(&self) -> Vec<Arc<Mutex<JoyConDevice>>>; // Provided methods fn rumble( &mut self, rumble_l_r: (Option<Rumble>, Option<Rumble>), ) -> JoyConResult<usize> { ... } fn send_command_raw( &mut self, command: u8, sub_command: u8, data: &[u8], ) -> JoyConResult<usize> { ... } fn send_sub_command_raw( &mut self, sub_command: u8, data: &[u8], ) -> JoyConResult<SubCommandReply<[u8; 362]>> { ... } fn send_command( &mut self, command: Command, sub_command: SubCommand, data: &[u8], ) -> JoyConResult<usize> { ... } fn send_sub_command( &mut self, sub_command: SubCommand, data: &[u8], ) -> JoyConResult<SubCommandReply<[u8; 362]>> { ... } fn reset(&mut self) -> JoyConResult<()> { ... }
}

Provided Associated Constants§

Source

const ACK_TRY: usize = 5usize

If a sub-command is sent and no ACK packet is returned, tread again for the number of times of this value.

Required Methods§

Source

fn valid_reply(&self) -> bool

If true, driver does not read and check reply of sub-command.

Source

fn set_valid_reply(&mut self, valid: bool)

Source

fn write(&self, data: &[u8]) -> JoyConResult<usize>

Send command to Joy-Con

Source

fn read(&self, buf: &mut [u8]) -> JoyConResult<usize>

Read reply from Joy-Con

Source

fn read_timeout(&self, buf: &mut [u8], timeout: i32) -> JoyConResult<usize>

  • timeout - milli seconds
Source

fn global_packet_number(&self) -> u8

Get global packet number

Source

fn increase_global_packet_number(&mut self)

Increase global packet number. Increment by 1 for each packet sent. It loops in 0x0 - 0xF range.

Source

fn set_rumble_status(&mut self, rumble_l_r: (Option<Rumble>, Option<Rumble>))

Set rumble status.

Source

fn get_rumble_status(&self) -> (Option<Rumble>, Option<Rumble>)

Get rumble status.

Source

fn enable_feature(&mut self, feature: JoyConFeature) -> JoyConResult<()>

Enable Joy-Con’s feature. ex. IMU(6-Axis sensor), Vibration(Rumble)

Source

fn enabled_features(&self) -> &HashSet<JoyConFeature>

Get Enabled features.

Source

fn devices(&self) -> Vec<Arc<Mutex<JoyConDevice>>>

Get Joy-Con devices deal with.

Provided Methods§

Source

fn rumble( &mut self, rumble_l_r: (Option<Rumble>, Option<Rumble>), ) -> JoyConResult<usize>

Set rumble status and send rumble command to JoyCon. If Joy-Con’s rumble feature isn’t activated, activate it.

Source

fn send_command_raw( &mut self, command: u8, sub_command: u8, data: &[u8], ) -> JoyConResult<usize>

Send command, sub-command, and data (sub-command’s arguments) with u8 integers This returns ACK packet for the command or Error.

Source

fn send_sub_command_raw( &mut self, sub_command: u8, data: &[u8], ) -> JoyConResult<SubCommandReply<[u8; 362]>>

Send sub-command, and data (sub-command’s arguments) with u8 integers This returns ACK packet for the command or Error.

§Notice

If you are using non-blocking mode, it is more likely to fail to validate the sub command reply.

Source

fn send_command( &mut self, command: Command, sub_command: SubCommand, data: &[u8], ) -> JoyConResult<usize>

Send command, sub-command, and data (sub-command’s arguments) with Command and SubCommand This returns ACK packet for the command or Error.

§Notice

If you are using non-blocking mode, it is more likely to fail to validate the sub command reply.

Source

fn send_sub_command( &mut self, sub_command: SubCommand, data: &[u8], ) -> JoyConResult<SubCommandReply<[u8; 362]>>

Send sub-command, and data (sub-command’s arguments) with Command and SubCommand This returns ACK packet for the command or Error.

Source

fn reset(&mut self) -> JoyConResult<()>

Initialize Joy-Con’s status

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§