pub struct IOHIDManager { /* private fields */ }hid only.Expand description
This is the type of a reference to the IOHIDManager.
See also Apple’s documentation
Implementations§
Source§impl IOHIDManager
impl IOHIDManager
Sourcepub fn new(
allocator: Option<&CFAllocator>,
options: IOOptionBits,
) -> CFRetained<IOHIDManager>
pub fn new( allocator: Option<&CFAllocator>, options: IOOptionBits, ) -> CFRetained<IOHIDManager>
Creates an IOHIDManager object.
The IOHIDManager object is meant as a global management system for communicating with HID devices.
Parameter allocator: Allocator to be used during creation.
Parameter options: Supply
kIOHIDManagerOptionUsePersistentPropertiesto load properties from the default persistent property store. Otherwise supply
kIOHIDManagerOptionNone(or 0).
Returns: Returns a new IOHIDManagerRef.
Sourcepub fn open(&self, options: IOOptionBits) -> IOReturn
pub fn open(&self, options: IOOptionBits) -> IOReturn
Opens the IOHIDManager.
This will open both current and future devices that are enumerated. To establish an exclusive link use the kIOHIDOptionsTypeSeizeDevice option.
Parameter manager: Reference to an IOHIDManager.
Parameter options: Option bits to be sent down to the manager and device.
Returns: Returns kIOReturnSuccess if successful.
Sourcepub fn close(&self, options: IOOptionBits) -> IOReturn
pub fn close(&self, options: IOOptionBits) -> IOReturn
Closes the IOHIDManager.
This will also close all devices that are currently enumerated.
Parameter manager: Reference to an IOHIDManager.
Parameter options: Option bits to be sent down to the manager and device.
Returns: Returns kIOReturnSuccess if successful.
Sourcepub fn property(&self, key: &CFString) -> Option<CFRetained<CFType>>
pub fn property(&self, key: &CFString) -> Option<CFRetained<CFType>>
Obtains a property of an IOHIDManager.
Property keys are prefixed by kIOHIDDevice and declared in <IOKit /hid/IOHIDKeys.h>.
Parameter manager: Reference to an IOHIDManager.
Parameter key: CFStringRef containing key to be used when querying the
manager.
Returns: Returns CFTypeRef containing the property.
Sourcepub unsafe fn set_property(&self, key: &CFString, value: &CFType) -> bool
pub unsafe fn set_property(&self, key: &CFString, value: &CFType) -> bool
Sets a property for an IOHIDManager.
Property keys are prefixed by kIOHIDDevice and kIOHIDManager and declared in <IOKit /hid/IOHIDKeys.h>. This method will propagate any relevent properties to current and future devices that are enumerated.
Parameter manager: Reference to an IOHIDManager.
Parameter key: CFStringRef containing key to be used when modifiying the
device property.
Parameter value: CFTypeRef containing the property value to be set.
Returns: Returns TRUE if successful.
§Safety
value should 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 manager with run loop.
Formally associates manager with client’s run loop. Scheduling this device with the run loop is necessary before making use of any asynchronous APIs. This will propagate to current and future devices that are enumerated.
Parameter manager: Reference to an IOHIDManager.
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 manager with run loop.
Formally disassociates device with client’s run loop. This will propagate to current devices that are enumerated.
Parameter manager: Reference to an IOHIDManager.
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 IOHIDManager. This is necessary in order to receive asynchronous events from the kernel.
An IOHIDManager should not be associated with both a runloop and dispatch queue. A call to IOHIDManagerSetDispatchQueue should only be made once.
After a dispatch queue is set, the IOHIDManager must make a call to activate via IOHIDManagerActivate and cancel via IOHIDManagerCancel. All calls to “Register” functions should be done before activation and not after cancellation.
Parameter manager: Reference to an IOHIDManager
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 IOHIDManagerSetDispatchQueue.
The cancellation handler (if specified) will be will be submitted to the manager’s dispatch queue in response to a call to IOHIDManagerCancel after all the events have been handled.
IOHIDManagerSetCancelHandler should not be used when scheduling with a run loop.
The IOHIDManagerRef should only be released after the manager 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(manager); }); IOHIDManagerSetCancelHandler(manager, cancelHandler); IOHIDManagerActivate(manager); IOHIDManageCancel(manager);
Parameter manager: Reference to an IOHIDManager.
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 IOHIDManager object.
An IOHIDManager 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 IOHIDManagerSetDispatchQueue before activation.
An activated manager must be cancelled via IOHIDManagerCancel. All calls to “Register” functions should be done before activation and not after cancellation.
Calling IOHIDManagerActivate on an active IOHIDManager has no effect.
Parameter manager: Reference to an IOHIDManager
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancels the IOHIDManager 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 IOHIDManager is required, no implicit cancellation takes place.
Calling IOHIDManagerCancel on an already cancelled queue has no effect.
The IOHIDManagerRef should only be released after the manager 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(manager); }); IOHIDManagerSetCancelHandler(manager, cancelHandler); IOHIDManagerActivate(manager); IOHIDManageCancel(manager);
Parameter manager: Reference to an IOHIDManager
Sourcepub unsafe fn set_device_matching(&self, matching: Option<&CFDictionary>)
pub unsafe fn set_device_matching(&self, matching: Option<&CFDictionary>)
Sets matching criteria for device enumeration.
Matching keys are prefixed by kIOHIDDevice 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 enumerated devices and restart the enuerate process using the revised criteria. If interested in multiple, specific device classes, please defer to using IOHIDManagerSetDeviceMatchingMultiple. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManager.
Parameter matching: CFDictionaryRef containg device matching criteria.
§Safety
matching generics must be of the correct type.
Sourcepub unsafe fn set_device_matching_multiple(&self, multiple: Option<&CFArray>)
pub unsafe fn set_device_matching_multiple(&self, multiple: Option<&CFArray>)
Sets multiple matching criteria for device enumeration.
Matching keys are prefixed by kIOHIDDevice and declared in <IOKit /hid/IOHIDKeys.h>. This method is useful if interested in multiple, specific device classes. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManager.
Parameter multiple: CFArrayRef containing multiple CFDictionaryRef objects
containg device matching criteria.
§Safety
multiple generic must be of the correct type.
Sourcepub fn devices(&self) -> Option<CFRetained<CFSet>>
pub fn devices(&self) -> Option<CFRetained<CFSet>>
Obtains currently enumerated devices.
Parameter manager: Reference to an IOHIDManager.
Returns: CFSetRef containing IOHIDDeviceRefs.
Sourcepub unsafe fn register_device_matching_callback(
&self,
callback: IOHIDDeviceCallback,
context: *mut c_void,
)
pub unsafe fn register_device_matching_callback( &self, callback: IOHIDDeviceCallback, context: *mut c_void, )
Registers a callback to be used a device is enumerated.
Only device matching the set criteria will be enumerated. If a dispatch queue is set, this call must occur before activation. Devices provided in the callback will be scheduled with the same runloop/dispatch queue as the IOHIDManagerRef, and should not be rescheduled.
Parameter manager: Reference to an IOHIDManagerRef.
Parameter callback: Pointer to a callback method of type
IOHIDDeviceCallback.
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_device_removal_callback(
&self,
callback: IOHIDDeviceCallback,
context: *mut c_void,
)
pub unsafe fn register_device_removal_callback( &self, callback: IOHIDDeviceCallback, context: *mut c_void, )
Registers a callback to be used when any enumerated device 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 manager: Reference to an IOHIDManagerRef.
Parameter callback: Pointer to a callback method of type
IOHIDDeviceCallback.
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,
callback: IOHIDReportCallback,
context: *mut c_void,
)
pub unsafe fn register_input_report_callback( &self, callback: IOHIDReportCallback, context: *mut c_void, )
Registers a callback to be used when an input report is issued by any enumerated device.
An input report is an interrupt driver report issued by a device. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManagerRef.
Parameter callback: Pointer to a callback method of type IOHIDReportCallback.
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_with_time_stamp_callback(
&self,
callback: IOHIDReportWithTimeStampCallback,
context: *mut c_void,
)
pub unsafe fn register_input_report_with_time_stamp_callback( &self, callback: IOHIDReportWithTimeStampCallback, context: *mut c_void, )
Registers a callback to be used when an input report is issued by any enumerated device.
An input report is an interrupt driver report issued by a device. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManagerRef.
Parameter callback: Pointer to a callback method of type
IOHIDReportWithTimeStampCallback.
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 any enumerated device.
An input element refers to any element of type kIOHIDElementTypeInput and is usually issued by interrupt driven reports. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManagerRef.
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 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 IOHIDManagerRegisterInputValueCallback.
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 IOHIDManagerSetInputValueMatchingMultiple. If a dispatch queue is set, this call must occur before activation.
Parameter manager: Reference to an IOHIDManager.
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 IOHIDManagerRegisterInputValueCallback.
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 manager: Reference to an IOHIDManager.
Parameter multiple: CFArrayRef containing multiple CFDictionaryRef objects
containing input element matching criteria.
§Safety
multiple generic must be of the correct type.
Sourcepub fn save_to_property_domain(
&self,
application_id: &CFString,
user_name: &CFString,
host_name: &CFString,
options: IOOptionBits,
)
pub fn save_to_property_domain( &self, application_id: &CFString, user_name: &CFString, host_name: &CFString, options: IOOptionBits, )
Used to write out the current properties to a specific domain.
Using this function will cause the persistent properties to be saved out replacing any properties that already existed in the specified domain. All arguments must be non-NULL except options.
Parameter manager: Reference to an IOHIDManager.
Parameter applicationID: Reference to a CFPreferences applicationID.
Parameter userName: Reference to a CFPreferences userName.
Parameter hostName: Reference to a CFPreferences hostName.
Parameter options: Reserved for future use.
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 IOHIDManager
impl AsRef<AnyObject> for IOHIDManager
Source§impl AsRef<CFType> for IOHIDManager
impl AsRef<CFType> for IOHIDManager
Source§impl AsRef<IOHIDManager> for IOHIDManager
impl AsRef<IOHIDManager> for IOHIDManager
Source§impl Borrow<AnyObject> for IOHIDManager
impl Borrow<AnyObject> for IOHIDManager
Source§impl Borrow<CFType> for IOHIDManager
impl Borrow<CFType> for IOHIDManager
Source§impl ConcreteType for IOHIDManager
impl ConcreteType for IOHIDManager
Source§impl Debug for IOHIDManager
impl Debug for IOHIDManager
Source§impl Deref for IOHIDManager
impl Deref for IOHIDManager
Source§impl Hash for IOHIDManager
impl Hash for IOHIDManager
Source§impl Message for IOHIDManager
impl Message for IOHIDManager
Source§impl PartialEq for IOHIDManager
impl PartialEq for IOHIDManager
Source§impl RefEncode for IOHIDManager
impl RefEncode for IOHIDManager
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for IOHIDManager
impl Type for IOHIDManager
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