Struct joycon_rs::joycon::input_report_mode::simple_hid_mode::SimpleHIDMode[][src]

pub struct SimpleHIDMode<D: JoyConDriver> { /* fields omitted */ }
Expand description

Simple HID mode pushes updates with every button press.

Example

use joycon_rs::prelude::*;

let (sender, receiver) = std::sync::mpsc::channel();

// Receive all Joy-Con's simple HID reports
while let Ok(simple_hid_report) = receiver.recv() {
    // Output reports
    dbg!(simple_hid_report);
}

let manager = JoyConManager::get_instance();

let devices = {
    let lock = manager.lock();
    match lock {
        Ok(manager) => manager.new_devices(),
        Err(_) => return,
    }
};

devices.iter()
    .flat_map(|d| SimpleJoyConDriver::new(&d))
    .try_for_each::<_, JoyConResult<()>>(|driver| {
        let sender = sender.clone();

        // Set Joy-Con's mode
        let simple_hid_mode_joycon = SimpleHIDMode::new(driver)?;

        std::thread::spawn( move || {
            loop {
                sender.send(simple_hid_mode_joycon.read_input_report())
                      .unwrap();
            }
        });

        Ok(())
    })
    .unwrap();

Trait Implementations

Set Joy-Con’s input report mode and return instance

Refference of driver.

Mutable refference of driver.

Unwrap.

read Joy-Con’s input report

  • timeout - milli seconds
  • Auto Trait Implementations

    Blanket Implementations

    Gets the TypeId of self. Read more

    Immutably borrows from an owned value. Read more

    Mutably borrows from an owned value. Read more

    Performs the conversion.

    Performs the conversion.

    The type returned in the event of a conversion error.

    Performs the conversion.

    The type returned in the event of a conversion error.

    Performs the conversion.