pub fn register_notification<F>(&mut self, func: F) -> Result<NotificationHandle<F>>
    where
        F: Fn(X360NotificationData) + RefUnwindSafe + Sync,
    {
        if self.has_notification {
            return Err(Error::AlreadyHasCallback);
        }

        let ptr = Box::leak(Box::new(func));
        check(unsafe {
            ffi::vigem_target_x360_register_notification(
                self.client.vigem.as_ptr(),
                self.target.as_ptr(),
                Some(x360_notification_handler::<F>),
                ptr as *mut _ as *mut _,
            )
        })?;
        self.has_notification = true;
        Ok(NotificationHandle(ptr))
    }
/// Register a notification callback for this target.
/// It will be called anytime there is a vibration request and/or the led number changes.
///
/// The callback must be [RefUnwindSafe] since we utilize [catch_unwind] to avoid
/// panicking over the FFI boundary. This means that any panics in your handler will simply be eaten up.
///
/// The callback must also be [Sync] as it will be called, by reference, in another
/// thread spawned by ViGEmClient.
///
/// Only one notification callback may be registered at a time.
/// You can unregister via [unregister_notification](Self::unregister_notification). Make sure to do so before dropping a target or memory may be leaked.
Register a notification callback for this target.
It will be called anytime there is a vibration request and/or the led number changes.

The callback must be [RefUnwindSafe] since we utilize [catch_unwind] to avoid
panicking over the FFI boundary. This means that any panics in your handler will simply be eaten up.

The callback must also be [Sync] as it will be called, by reference, in another
thread spawned by ViGEmClient.

Only one notification callback may be registered at a time.
Register a notification callback for this target . It will be called anytime there is a vibration request and / or the led number changes . The callback must be [ RefUnwindSafe ] since we utilize [ catch_unwind ] to avoid panicking over the FFI boundary . This means that any panics in your handler will simply be eaten up . The callback must also be [ Sync ] as it will be called by reference in another thread spawned by ViGEmClient . Only one notification callback may be registered at a time .
pub fn register_notification<F>(&mut self, func: F) -> Result<NotificationHandle<F>>
    where
        F: Fn(X360NotificationData) + RefUnwindSafe + Sync,
    {
        if self.has_notification {
            return Err(Error::AlreadyHasCallback);
        }
        let ptr = Box::leak(Box::new(func));
        check(unsafe {
            ffi::vigem_target_x360_register_notification(
                self.client.vigem.as_ptr(),
                self.target.as_ptr(),
                Some(x360_notification_handler::<F>),
                ptr as *mut _ as *mut _,
            )
        })?;
        self.has_notification = true;
        Ok(NotificationHandle(ptr))
    }
pub fn register_notification < F > ( & mut self , func : F ) -> Result < NotificationHandle < F > > where F : Fn ( X360NotificationData ) + RefUnwindSafe + Sync , { if self . has_notification { return Err ( Error :: AlreadyHasCallback ) ; } let ptr = Box :: leak ( Box :: new ( func ) ) ; check ( unsafe { ffi :: vigem_target_x360_register_notification ( self . client . vigem . as_ptr ( ) , self . target . as_ptr ( ) , Some ( x360_notification_handler :: < F > ) , ptr as * mut _ as * mut _ , ) } ) ? ; self . has_notification = true ; Ok ( NotificationHandle ( ptr ) ) }
Register a notification callback for this target.
Register a notification callback for this target .
&mut self
func
F
&mut self
func
F