pub struct IOHIDDevice { /* private fields */ }hid only.Expand description
This is the type of a reference to the IOHIDDevice.
See also Apple’s documentation
Implementations§
Source§impl IOHIDDevice
impl IOHIDDevice
Sourcepub fn new(
allocator: Option<&CFAllocator>,
service: io_service_t,
) -> Option<CFRetained<IOHIDDevice>>
Available on crate feature libc only.
pub fn new( allocator: Option<&CFAllocator>, service: io_service_t, ) -> Option<CFRetained<IOHIDDevice>>
libc only.Creates an element from an io_service_t.
The io_service_t passed in this method must reference an object in the kernel of type IOHIDDevice.
Parameter allocator: Allocator to be used during creation.
Parameter service: Reference to service object in the kernel.
Returns: Returns a new IOHIDDeviceRef.
Sourcepub fn service(&self) -> io_service_t
Available on crate feature libc only.
pub fn service(&self) -> io_service_t
libc only.Returns the io_service_t for an IOHIDDevice, if it has one.
If the IOHIDDevice references an object in the kernel, this is used to get the io_service_t for that object.
Parameter device: Reference to an IOHIDDevice.
Returns: Returns the io_service_t if the IOHIDDevice has one, or MACH_PORT_NULL if it does not.
Sourcepub fn open(&self, options: IOOptionBits) -> IOReturn
pub fn open(&self, options: IOOptionBits) -> IOReturn
Opens a HID device for communication.
Before the client can issue commands that change the state of the device, it must have succeeded in opening the device. This establishes a link between the client’s task and the actual device. To establish an exclusive link use the kIOHIDOptionsTypeSeizeDevice option.
Parameter device: Reference to an IOHIDDevice.
Parameter options: Option bits to be sent down to the device.
Returns: Returns kIOReturnSuccess if successful.
Sourcepub fn close(&self, options: IOOptionBits) -> IOReturn
pub fn close(&self, options: IOOptionBits) -> IOReturn
Closes communication with a HID device.
This closes a link between the client’s task and the actual device.
Parameter device: Reference to an IOHIDDevice.
Parameter options: Option bits to be sent down to the device.
Returns: Returns kIOReturnSuccess if successful.
Sourcepub fn conforms_to(&self, usage_page: u32, usage: u32) -> bool
pub fn conforms_to(&self, usage_page: u32, usage: u32) -> bool
Convenience function that scans the Application Collection elements to see if it conforms to the provided usagePage and usage.
Examples of Application Collection usages pairs are:
usagePage = kHIDPage_GenericDesktop
usage = kHIDUsage_GD_Mouse
or
usagePage = kHIDPage_GenericDesktop
usage = kHIDUsage_GD_Keyboard
Parameter device: Reference to an IOHIDDevice.
Parameter usagePage: Device usage page
Parameter usage: Device usage
Returns: Returns TRUE if device conforms to provided usage.
Sourcepub fn property(&self, key: &CFString) -> Option<CFRetained<CFType>>
pub fn property(&self, key: &CFString) -> Option<CFRetained<CFType>>
Obtains a property from an IOHIDDevice.
Property keys are prefixed by kIOHIDDevice and declared in <IOKit /hid/IOHIDKeys.h>.
Parameter device: Reference to an IOHIDDevice.
Parameter key: CFStringRef containing key to be used when querying the
device.
Returns: Returns CFTypeRef containing the property.
Sourcepub unsafe fn set_property(&self, key: &CFString, property: &CFType) -> bool
pub unsafe fn set_property(&self, key: &CFString, property: &CFType) -> bool
Sets a property for an IOHIDDevice.
Property keys are prefixed by kIOHIDDevice and declared in <IOKit /hid/IOHIDKeys.h>.
Parameter device: Reference to an IOHIDDevice.
Parameter key: CFStringRef containing key to be used when modifiying the
device property.
Parameter property: CFTypeRef containg the property to be set.
Returns: Returns TRUE if successful.
§Safety
property should be of the correct type.
Sourcepub unsafe fn matching_elements(
&self,
matching: Option<&CFDictionary>,
options: IOOptionBits,
) -> Option<CFRetained<CFArray>>
pub unsafe fn matching_elements( &self, matching: Option<&CFDictionary>, options: IOOptionBits, ) -> Option<CFRetained<CFArray>>
Obtains HID elements that match the criteria contained in the matching dictionary.
Matching keys are prefixed by kIOHIDElement and declared in <IOKit /hid/IOHIDKeys.h>. Passing a NULL dictionary will result in all device elements being returned.
Parameter device: Reference to an IOHIDDevice.
Parameter matching: CFDictionaryRef containg element matching criteria.
Parameter options: Reserved for future use.
Returns: Returns CFArrayRef containing multiple IOHIDElement object.
§Safety
matching generics must be of the correct type.
Sourcepub unsafe fn schedule_with_run_loop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: &CFString,
)
pub unsafe fn schedule_with_run_loop( &self, run_loop: &CFRunLoop, run_loop_mode: &CFString, )
Schedules HID device with run loop.
Formally associates device with client’s run loop. Scheduling this device with the run loop is necessary before making use of any asynchronous APIs.
Parameter device: Reference to an IOHIDDevice.
Parameter runLoop: RunLoop to be used when scheduling any asynchronous
activity.
Parameter runLoopMode: Run loop mode to be used when scheduling any
asynchronous activity.
§Safety
run_loop possibly has additional threading requirements.
Sourcepub unsafe fn unschedule_from_run_loop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: &CFString,
)
pub unsafe fn unschedule_from_run_loop( &self, run_loop: &CFRunLoop, run_loop_mode: &CFString, )
Unschedules HID device with run loop.
Formally disassociates device with client’s run loop.
Parameter device: Reference to an IOHIDDevice.
Parameter runLoop: RunLoop to be used when unscheduling any asynchronous
activity.
Parameter runLoopMode: Run loop mode to be used when unscheduling any
asynchronous activity.
§Safety
run_loop possibly has additional threading requirements.
Sourcepub unsafe fn set_dispatch_queue(&self, queue: &DispatchQueue)
Available on crate feature dispatch2 only.
pub unsafe fn set_dispatch_queue(&self, queue: &DispatchQueue)
dispatch2 only.Sets the dispatch queue to be associated with the IOHIDDevice. This is necessary in order to receive asynchronous events from the kernel.
An IOHIDDevice should not be associated with both a runloop and dispatch queue. A call to IOHIDDeviceSetDispatchQueue should only be made once. After a dispatch queue is set, the IOHIDDevice must make a call to activate via IOHIDDeviceActivate and cancel via IOHIDDeviceCancel. All calls to “Register” functions should be done before activation and not after cancellation.
Parameter device: Reference to an IOHIDDevice
Parameter queue: The dispatch queue to which the event handler block will be submitted.
§Safety
queue possibly has additional threading requirements.
Sourcepub unsafe fn set_cancel_handler(&self, handler: dispatch_block_t)
Available on crate feature dispatch2 only.
pub unsafe fn set_cancel_handler(&self, handler: dispatch_block_t)
dispatch2 only.Sets a cancellation handler for the dispatch queue associated with IOHIDDeviceSetDispatchQueue.
The cancellation handler (if specified) will be will be submitted to the device’s dispatch queue in response to a call to IOHIDDeviceCancel after all the events have been handled. IOHIDDeviceSetCancelHandler should not be used when scheduling with a run loop. The IOHIDDeviceRef should only be released after the device has been cancelled, and the cancel handler has been called. This is to ensure all asynchronous objects are released. For example: dispatch_block_t cancelHandler = dispatch_block_create(0, ^{ CFRelease(device); }); IOHIDDeviceSetCancelHandler(device, cancelHandler); IOHIDDeviceActivate(device); IOHIDDeviceCancel(device);
Parameter device: Reference to an IOHIDDevice.
Parameter handler: The cancellation handler block to be associated with the dispatch queue.
§Safety
handler must be a valid pointer.
Sourcepub fn activate(&self)
pub fn activate(&self)
Activates the IOHIDDevice object.
An IOHIDDevice object associated with a dispatch queue is created in an inactive state. The object must be activated in order to receive asynchronous events from the kernel. A dispatch queue must be set via IOHIDDeviceSetDispatchQueue before activation. An activated device must be cancelled via IOHIDDeviceCancel. All calls to “Register” functions should be done before activation and not after cancellation. Calling IOHIDDeviceActivate on an active IOHIDDevice has no effect.
Parameter device: Reference to an IOHIDDevice
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancels the IOHIDDevice preventing any further invocation of its event handler block.
Cancelling prevents any further invocation of the event handler block for the specified dispatch queue, but does not interrupt an event handler block that is already in progress. Explicit cancellation of the IOHIDDevice is required, no implicit cancellation takes place. Calling IOHIDDeviceCancel on an already cancelled queue has no effect. The IOHIDDeviceRef should only be released after the device has been cancelled, and the cancel handler has been called. This is to ensure all asynchronous objects are released. For example: dispatch_block_t cancelHandler = dispatch_block_create(0, ^{ CFRelease(device); }); IOHIDDeviceSetCancelHandler(device, cancelHandler); IOHIDDeviceActivate(device); IOHIDDeviceCancel(device);
Parameter device: Reference to an IOHIDDevice
Sourcepub unsafe fn register_removal_callback(
&self,
callback: IOHIDCallback,
context: *mut c_void,
)
pub unsafe fn register_removal_callback( &self, callback: IOHIDCallback, context: *mut c_void, )
Registers a callback to be used when a IOHIDDevice is removed.
In most cases this occurs when a device is unplugged. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter callback: Pointer to a callback method of type IOHIDCallback.
Parameter context: Pointer to data to be passed to the callback.
§Safety
callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn register_input_value_callback(
&self,
callback: IOHIDValueCallback,
context: *mut c_void,
)
pub unsafe fn register_input_value_callback( &self, callback: IOHIDValueCallback, context: *mut c_void, )
Registers a callback to be used when an input value is issued by the device.
An input element refers to any element of type kIOHIDElementTypeInput and is usually issued by interrupt driven reports. If more specific element values are desired, you can specify matching criteria via IOHIDDeviceSetInputValueMatching and IOHIDDeviceSetInputValueMatchingMultiple. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter callback: Pointer to a callback method of type IOHIDValueCallback.
Parameter context: Pointer to data to be passed to the callback.
§Safety
callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn register_input_report_callback(
&self,
report: NonNull<u8>,
report_length: CFIndex,
callback: IOHIDReportCallback,
context: *mut c_void,
)
pub unsafe fn register_input_report_callback( &self, report: NonNull<u8>, report_length: CFIndex, callback: IOHIDReportCallback, context: *mut c_void, )
Registers a callback to be used when an input report is issued by the device.
An input report is an interrupt driver report issued by the device. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter report: Pointer to preallocated buffer in which to copy inbound
report data.
Parameter reportLength: Length of preallocated buffer.
Parameter callback: Pointer to a callback method of type
IOHIDReportCallback.
Parameter context: Pointer to data to be passed to the callback.
§Safety
reportmust be a valid pointer.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn register_input_report_with_time_stamp_callback(
&self,
report: NonNull<u8>,
report_length: CFIndex,
callback: IOHIDReportWithTimeStampCallback,
context: *mut c_void,
)
pub unsafe fn register_input_report_with_time_stamp_callback( &self, report: NonNull<u8>, report_length: CFIndex, callback: IOHIDReportWithTimeStampCallback, context: *mut c_void, )
Registers a timestamped callback to be used when an input report is issued by the device.
An input report is an interrupt driver report issued by the device. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter report: Pointer to preallocated buffer in which to copy inbound
report data.
Parameter reportLength: Length of preallocated buffer.
Parameter callback: Pointer to a callback method of type
IOHIDReportWithTimeStampCallback.
Parameter context: Pointer to data to be passed to the callback.
§Safety
reportmust be a valid pointer.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn set_input_value_matching(&self, matching: Option<&CFDictionary>)
pub unsafe fn set_input_value_matching(&self, matching: Option<&CFDictionary>)
Sets matching criteria for input values received via IOHIDDeviceRegisterInputValueCallback.
Matching keys are prefixed by kIOHIDElement and declared in <IOKit /hid/IOHIDKeys.h>. Passing a NULL dictionary will result in all devices being enumerated. Any subsequent calls will cause the hid manager to release previously matched input elements and restart the matching process using the revised criteria. If interested in multiple, specific device elements, please defer to using IOHIDDeviceSetInputValueMatchingMultiple. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter matching: CFDictionaryRef containg device matching criteria.
§Safety
matching generics must be of the correct type.
Sourcepub unsafe fn set_input_value_matching_multiple(
&self,
multiple: Option<&CFArray>,
)
pub unsafe fn set_input_value_matching_multiple( &self, multiple: Option<&CFArray>, )
Sets multiple matching criteria for input values received via IOHIDDeviceRegisterInputValueCallback.
Matching keys are prefixed by kIOHIDElement and declared in <IOKit /hid/IOHIDKeys.h>. This method is useful if interested in multiple, specific elements. If a dispatch queue is set, this call must occur before activation.
Parameter device: Reference to an IOHIDDevice.
Parameter multiple: CFArrayRef containing multiple CFDictionaryRef objects
containg input element matching criteria.
§Safety
multiple generic must be of the correct type.
Sourcepub fn set_value(&self, element: &IOHIDElement, value: &IOHIDValue) -> IOReturn
pub fn set_value(&self, element: &IOHIDElement, value: &IOHIDValue) -> IOReturn
Sets a value for an element.
This method behaves synchronously and will block until the report has been issued to the device. It is only relevent for either output or feature type elements. If setting values for multiple elements you may want to consider using IOHIDDeviceSetValueMultiple or IOHIDTransaction.
Parameter device: Reference to an IOHIDDevice.
Parameter element: IOHIDElementRef whose value is to be modified.
Parameter value: IOHIDValueRef containing value to be set.
Returns: Returns kIOReturnSuccess if successful.
Sourcepub unsafe fn set_value_multiple(&self, multiple: &CFDictionary) -> IOReturn
pub unsafe fn set_value_multiple(&self, multiple: &CFDictionary) -> IOReturn
Sets multiple values for multiple elements.
This method behaves synchronously and will block until the report has been issued to the device. It is only relevent for either output or feature type elements.
Parameter device: Reference to an IOHIDDevice.
Parameter multiple: CFDictionaryRef where key is IOHIDElementRef and
value is IOHIDValueRef.
Returns: Returns kIOReturnSuccess if successful.
§Safety
multiple generics must be of the correct type.
Sourcepub unsafe fn set_value_with_callback(
&self,
element: &IOHIDElement,
value: &IOHIDValue,
timeout: CFTimeInterval,
callback: IOHIDValueCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn set_value_with_callback( &self, element: &IOHIDElement, value: &IOHIDValue, timeout: CFTimeInterval, callback: IOHIDValueCallback, context: *mut c_void, ) -> IOReturn
Sets a value for an element.
This method currently only behaves synchronously and will not invoke the callback. It is only relevent for either output or feature type elements. If setting values for multiple elements you may want to consider using IOHIDDeviceSetValueMultipleWithCallback or IOHIDTransaction.
Parameter device: Reference to an IOHIDDevice.
Parameter element: IOHIDElementRef whose value is to be modified.
Parameter value: IOHIDValueRef containing value to be set.
Parameter timeout: Currently unused.
Parameter callback: Currently unused.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn set_value_multiple_with_callback(
&self,
multiple: &CFDictionary,
timeout: CFTimeInterval,
callback: IOHIDValueMultipleCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn set_value_multiple_with_callback( &self, multiple: &CFDictionary, timeout: CFTimeInterval, callback: IOHIDValueMultipleCallback, context: *mut c_void, ) -> IOReturn
Sets multiple values for multiple elements and returns status via a completion callback.
This method behaves asynchronously and will invoke the callback once the report has been issued to the device. It is only relevent for either output or feature type elements.
Parameter device: Reference to an IOHIDDevice.
Parameter multiple: CFDictionaryRef where key is IOHIDElementRef and
value is IOHIDValueRef.
Parameter timeout: CFTimeInterval containing the timeout in milliseconds.
Parameter callback: Pointer to a callback method of type
IOHIDValueMultipleCallback.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
multiplegenerics must be of the correct type.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn value(
&self,
element: &IOHIDElement,
p_value: NonNull<NonNull<IOHIDValue>>,
) -> IOReturn
pub unsafe fn value( &self, element: &IOHIDElement, p_value: NonNull<NonNull<IOHIDValue>>, ) -> IOReturn
Gets a value for an element.
This method behaves synchronously and returns immediately for input type elements. If requesting a value for a feature element, this will block until the report has been issued to the device. If obtaining values for multiple elements you may want to consider using IOHIDDeviceCopyValueMultiple or IOHIDTransaction.
Parameter device: Reference to an IOHIDDevice.
Parameter element: IOHIDElementRef whose value is to be obtained.
Parameter pValue: Pointer to IOHIDValueRef to be obtained.
Returns: Returns kIOReturnSuccess if successful.
§Safety
p_value must be a valid pointer.
Source§impl IOHIDDevice
impl IOHIDDevice
Sourcepub unsafe fn value_with_options(
&self,
element: &IOHIDElement,
p_value: NonNull<NonNull<IOHIDValue>>,
options: u32,
) -> IOReturn
pub unsafe fn value_with_options( &self, element: &IOHIDElement, p_value: NonNull<NonNull<IOHIDValue>>, options: u32, ) -> IOReturn
Gets a value for an element.
This method behaves synchronously and returns immediately for input type elements. If requesting a value for a feature element, this will block until the report has been issued to the device. If obtaining values for multiple elements you may want to consider using IOHIDDeviceCopyValueMultiple or IOHIDTransaction.
Parameter device: Reference to an IOHIDDevice.
Parameter element: IOHIDElementRef whose value is to be obtained.
Parameter pValue: Pointer to IOHIDValueRef to be obtained.
Parameter options: (see IOHIDDeviceGetValueOptions).
Returns: Returns kIOReturnSuccess if successful.
§Safety
p_value must be a valid pointer.
Sourcepub unsafe fn copy_value_multiple(
&self,
elements: &CFArray,
p_multiple: *mut *const CFDictionary,
) -> IOReturn
pub unsafe fn copy_value_multiple( &self, elements: &CFArray, p_multiple: *mut *const CFDictionary, ) -> IOReturn
Copies a values for multiple elements.
This method behaves synchronously and returns immediately for input type elements. If requesting a value for a feature element, this will block until the report has been issued to the device.
Parameter device: Reference to an IOHIDDevice.
Parameter elements: CFArrayRef containing multiple IOHIDElementRefs whose
values are to be obtained.
Parameter pMultiple: Pointer to CFDictionaryRef where the keys are the
provided elements and the values are the requested values.
Returns: Returns kIOReturnSuccess if successful.
§Safety
elementsgeneric must be of the correct type.p_multiplemust be a valid pointer or null.
Sourcepub unsafe fn value_with_callback(
&self,
element: &IOHIDElement,
p_value: NonNull<NonNull<IOHIDValue>>,
timeout: CFTimeInterval,
callback: IOHIDValueCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn value_with_callback( &self, element: &IOHIDElement, p_value: NonNull<NonNull<IOHIDValue>>, timeout: CFTimeInterval, callback: IOHIDValueCallback, context: *mut c_void, ) -> IOReturn
Gets a value for an element.
This method currently only behaves synchronously and will not invoke the callback. It is only relevent for either output or feature type elements. If setting values for multiple elements you may want to consider using IOHIDDeviceCopyValueMultipleWithCallback or IOHIDTransaction.
Parameter device: Reference to an IOHIDDevice.
Parameter element: IOHIDElementRef whose value is to be obtained.
Parameter pValue: Pointer to IOHIDValueRef to be passedback.
Parameter timeout: Currently unused.
Parameter callback: Currently unused.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
p_valuemust be a valid pointer.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn copy_value_multiple_with_callback(
&self,
elements: &CFArray,
p_multiple: *mut *const CFDictionary,
timeout: CFTimeInterval,
callback: IOHIDValueMultipleCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn copy_value_multiple_with_callback( &self, elements: &CFArray, p_multiple: *mut *const CFDictionary, timeout: CFTimeInterval, callback: IOHIDValueMultipleCallback, context: *mut c_void, ) -> IOReturn
Copies a values for multiple elements and returns status via a completion callback.
This method behaves asynchronusly and is only relevent for either output or feature type elements.
Parameter device: Reference to an IOHIDDevice.
Parameter elements: CFArrayRef containing multiple IOHIDElementRefs whose
values are to be obtained.
Parameter pMultiple: Pointer to CFDictionaryRef where the keys are the
provided elements and the values are the requested values.
Parameter timeout: CFTimeInterval containing the timeout in milliseconds.
Parameter callback: Pointer to a callback method of type
IOHIDValueMultipleCallback.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
elementsgeneric must be of the correct type.p_multiplemust be a valid pointer or null.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn set_report(
&self,
report_type: IOHIDReportType,
report_id: CFIndex,
report: NonNull<u8>,
report_length: CFIndex,
) -> IOReturn
pub unsafe fn set_report( &self, report_type: IOHIDReportType, report_id: CFIndex, report: NonNull<u8>, report_length: CFIndex, ) -> IOReturn
Sends a report to the device.
This method behaves synchronously and will block until the report has been issued to the device. It is only relevent for either output or feature type reports.
Parameter device: Reference to an IOHIDDevice.
Parameter reportType: Type of report being sent.
Parameter reportID: ID of the report being sent. If the device supports
multiple reports, this should also be set in the first byte of
the report.
Parameter report: The report bytes to be sent to the device.
Parameter reportLength: The length of the report to be sent to the device.
Returns: Returns kIOReturnSuccess if successful.
§Safety
report must be a valid pointer.
Sourcepub unsafe fn set_report_with_callback(
&self,
report_type: IOHIDReportType,
report_id: CFIndex,
report: NonNull<u8>,
report_length: CFIndex,
timeout: CFTimeInterval,
callback: IOHIDReportCallback,
context: *mut c_void,
) -> IOReturn
pub unsafe fn set_report_with_callback( &self, report_type: IOHIDReportType, report_id: CFIndex, report: NonNull<u8>, report_length: CFIndex, timeout: CFTimeInterval, callback: IOHIDReportCallback, context: *mut c_void, ) -> IOReturn
Sends a report to the device.
This method behaves asynchronously. It is only relevent for either output or feature type reports.
Parameter device: Reference to an IOHIDDevice.
Parameter reportType: Type of report being sent.
Parameter reportID: ID of the report being sent. If the device supports
multiple reports, this should also be set in the first byte of
the report.
Parameter report: The report bytes to be sent to the device.
Parameter reportLength: The length of the report to be sent to the device.
Parameter timeout: CFTimeInterval containing the timeout in milliseconds.
Parameter callback: Pointer to a callback method of type
IOHIDReportCallback.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
reportmust be a valid pointer.callbackmust be implemented correctly.contextmust be a valid pointer or null.
Sourcepub unsafe fn report(
&self,
report_type: IOHIDReportType,
report_id: CFIndex,
report: NonNull<u8>,
p_report_length: NonNull<CFIndex>,
) -> IOReturn
pub unsafe fn report( &self, report_type: IOHIDReportType, report_id: CFIndex, report: NonNull<u8>, p_report_length: NonNull<CFIndex>, ) -> IOReturn
Obtains a report from the device.
This method behaves synchronously and will block until the report has been received from the device. It is only relevent for either output or feature type reports. Please defer to using IOHIDDeviceRegisterInputReportCallback for obtaining input reports.
Parameter device: Reference to an IOHIDDevice.
Parameter reportType: Type of report being requested.
Parameter reportID: ID of the report being requested.
Parameter report: Pointer to preallocated buffer in which to copy inbound
report data.
Parameter pReportLength: Pointer to length of preallocated buffer. This
value will be modified to refect the length of the returned
report.
Returns: Returns kIOReturnSuccess if successful.
§Safety
reportmust be a valid pointer.p_report_lengthmust be a valid pointer.
Sourcepub unsafe fn report_with_callback(
&self,
report_type: IOHIDReportType,
report_id: CFIndex,
report: NonNull<u8>,
p_report_length: NonNull<CFIndex>,
timeout: CFTimeInterval,
callback: IOHIDReportCallback,
context: NonNull<c_void>,
) -> IOReturn
pub unsafe fn report_with_callback( &self, report_type: IOHIDReportType, report_id: CFIndex, report: NonNull<u8>, p_report_length: NonNull<CFIndex>, timeout: CFTimeInterval, callback: IOHIDReportCallback, context: NonNull<c_void>, ) -> IOReturn
Obtains a report from the device.
This method behaves asynchronously. It is only relevent for either output or feature type reports. Please defer to using IOHIDDeviceRegisterInputReportCallback for obtaining input reports.
Parameter device: Reference to an IOHIDDevice.
Parameter reportType: Type of report being requested.
Parameter reportID: ID of the report being requested.
Parameter report: Pointer to preallocated buffer in which to copy inbound
report data.
Parameter pReportLength: Pointer to length of preallocated buffer. This
value will be modified to refect the length of the returned
report.
Parameter timeout: CFTimeInterval containing the timeout in milliseconds.
Parameter callback: Pointer to a callback method of type
IOHIDReportCallback.
Parameter context: Pointer to data to be passed to the callback.
Returns: Returns kIOReturnSuccess if successful.
§Safety
reportmust be a valid pointer.p_report_lengthmust be a valid pointer.callbackmust be implemented correctly.contextmust be a valid pointer.
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl AsRef<AnyObject> for IOHIDDevice
impl AsRef<AnyObject> for IOHIDDevice
Source§impl AsRef<CFType> for IOHIDDevice
impl AsRef<CFType> for IOHIDDevice
Source§impl AsRef<IOHIDDevice> for IOHIDDevice
impl AsRef<IOHIDDevice> for IOHIDDevice
Source§impl Borrow<AnyObject> for IOHIDDevice
impl Borrow<AnyObject> for IOHIDDevice
Source§impl Borrow<CFType> for IOHIDDevice
impl Borrow<CFType> for IOHIDDevice
Source§impl ConcreteType for IOHIDDevice
impl ConcreteType for IOHIDDevice
Source§impl Debug for IOHIDDevice
impl Debug for IOHIDDevice
Source§impl Deref for IOHIDDevice
impl Deref for IOHIDDevice
Source§impl Hash for IOHIDDevice
impl Hash for IOHIDDevice
Source§impl Message for IOHIDDevice
impl Message for IOHIDDevice
Source§impl PartialEq for IOHIDDevice
impl PartialEq for IOHIDDevice
Source§impl RefEncode for IOHIDDevice
impl RefEncode for IOHIDDevice
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for IOHIDDevice
impl Type for IOHIDDevice
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more