pub fn new(joycon: &Arc<Mutex<JoyConDevice>>) -> JoyConResult<Self> {
        // joycon.set_blocking_mode(true);
        // joycon.set_blocking_mode(false);

        let mut enabled_features = HashSet::new();
        enabled_features.insert(JoyConFeature::IMUFeature(IMUConfig::default()));
        enabled_features.insert(JoyConFeature::Vibration);

        let mut driver = Self {
            joycon: Arc::clone(joycon),
            rotation: Rotation::Portrait,
            rumble: (None, None),
            enabled_features,
            valid_reply: {
                let device = match joycon.lock() {
                    Ok(j) => j,
                    Err(e) => e.into_inner(),
                }
                .device_type();
                !matches!(device, JoyConDeviceType::ProCon)
            },
            global_packet_number: GlobalPacketNumber::default(),
        };

        let check_reply = {
            let device = match joycon.lock() {
                Ok(d) => d,
                Err(e) => e.into_inner(),
            };
            !matches!(device.device_type(), JoyConDeviceType::ProCon)
        };

        if check_reply {
            driver.reset()?;
        } else {
            let _ = driver.reset();
        }

        Ok(driver)
    }
/// Constructs a new `SimpleJoyConDriver`.
Constructs a new `SimpleJoyConDriver`.
Constructs a new ` SimpleJoyConDriver ` .
pub fn new(joycon: &Arc<Mutex<JoyConDevice>>) -> JoyConResult<Self> {
        // joycon.set_blocking_mode(true);
        // joycon.set_blocking_mode(false);
        let mut enabled_features = HashSet::new();
        enabled_features.insert(JoyConFeature::IMUFeature(IMUConfig::default()));
        enabled_features.insert(JoyConFeature::Vibration);
        let mut driver = Self {
            joycon: Arc::clone(joycon),
            rotation: Rotation::Portrait,
            rumble: (None, None),
            enabled_features,
            valid_reply: {
                let device = match joycon.lock() {
                    Ok(j) => j,
                    Err(e) => e.into_inner(),
                }
                .device_type();
                !matches!(device, JoyConDeviceType::ProCon)
            },
            global_packet_number: GlobalPacketNumber::default(),
        };
        let check_reply = {
            let device = match joycon.lock() {
                Ok(d) => d,
                Err(e) => e.into_inner(),
            };
            !matches!(device.device_type(), JoyConDeviceType::ProCon)
        };
        if check_reply {
            driver.reset()?;
        } else {
            let _ = driver.reset();
        }
        Ok(driver)
    }
pub fn new ( joycon : & Arc < Mutex < JoyConDevice > > ) -> JoyConResult < Self > { // joycon.set_blocking_mode(true); // joycon.set_blocking_mode(false); let mut enabled_features = HashSet :: new ( ) ; enabled_features . insert ( JoyConFeature :: IMUFeature ( IMUConfig :: default ( ) ) ) ; enabled_features . insert ( JoyConFeature :: Vibration ) ; let mut driver = Self { joycon : Arc :: clone ( joycon ) , rotation : Rotation :: Portrait , rumble : ( None , None ) , enabled_features , valid_reply : { let device = match joycon . lock ( ) { Ok ( j ) => j , Err ( e ) => e . into_inner ( ) , } . device_type ( ) ; ! matches ! ( device JoyConDeviceType ProCon ) } , global_packet_number : GlobalPacketNumber :: default ( ) , } ; let check_reply = { let device = match joycon . lock ( ) { Ok ( d ) => d , Err ( e ) => e . into_inner ( ) , } ; ! matches ! ( device device_type ( ) JoyConDeviceType ProCon ) } ; if check_reply { driver . reset ( ) ? ; } else { let _ = driver . reset ( ) ; } Ok ( driver ) }
Constructs a new `SimpleJoyConDriver`.
Constructs a new ` SimpleJoyConDriver ` .
joycon
&Arc<Mutex<JoyConDevice>>
joycon
&Arc<Mutex<JoyConDevice>>