[][src]Trait joycon_rs::joycon::JoyConDriver

pub trait JoyConDriver {
    const ACK_TRY: usize;

    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>>>; 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<()> { ... } }

Associated Constants

const ACK_TRY: usize

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

Loading content...

Required methods

fn valid_reply(&self) -> bool

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

fn set_valid_reply(&mut self, valid: bool)

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

Send command to Joy-Con

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

Read reply from Joy-Con

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

  • timeout - milli seconds

fn global_packet_number(&self) -> u8

Get global packet number

fn increase_global_packet_number(&mut self)

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

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

Set rumble status.

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

Get rumble status.

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

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

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

Get Enabled features.

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

Get Joy-Con devices deal with.

Loading content...

Provided methods

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.

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.

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.

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.

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.

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

Initialize Joy-Con's status

Loading content...

Implementors

Loading content...