IOHIDElement

Struct IOHIDElement 

Source
pub struct IOHIDElement { /* private fields */ }
Available on crate feature hid only.
Expand description

This is the type of a reference to the IOHIDElement.

See also Apple’s documentation

Implementations§

Source§

impl IOHIDElement

Source

pub unsafe fn with_dictionary( allocator: Option<&CFAllocator>, dictionary: &CFDictionary, ) -> CFRetained<IOHIDElement>

Creates an element from a dictionary.

The dictionary should contain keys defined in IOHIDKeys.h and start with kIOHIDElement. This call is meant be used by a IOHIDDeviceDeviceInterface object.

Parameter allocator: Allocator to be used during creation.

Parameter dictionary: dictionary containing values in which to create element.

Returns: Returns a new IOHIDElementRef.

§Safety

dictionary generics must be of the correct type.

Source

pub fn device(&self) -> CFRetained<IOHIDDevice>

Obtain the device associated with the element.

Parameter element: IOHIDElement to be queried.

Returns: Returns the a reference to the device.

Source

pub fn parent(&self) -> Option<CFRetained<IOHIDElement>>

Returns the parent for the element.

The parent element can be an element of type kIOHIDElementTypeCollection.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns an IOHIDElementRef referencing the parent element.

Source

pub fn children(&self) -> Option<CFRetained<CFArray>>

Returns the children for the element.

An element of type kIOHIDElementTypeCollection usually contains children.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns an CFArrayRef containing element objects of type IOHIDElementRef.

Source

pub fn attach(&self, to_attach: &IOHIDElement)

Establish a relationship between one or more elements.

This is useful for grouping HID elements with related functionality.

Parameter element: The element to be modified. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Parameter toAttach: The element to be attached. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Source

pub fn detach(&self, to_detach: &IOHIDElement)

Remove a relationship between one or more elements.

This is useful for grouping HID elements with related functionality.

Parameter element: The element to be modified. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Parameter toDetach: The element to be detached. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Source

pub fn attached(&self) -> Option<CFRetained<CFArray>>

Obtain attached elements.

Attached elements are those that have been grouped via IOHIDElementAttach.

Parameter element: The element to be modified. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns a copy of the current attached elements.

Source

pub fn cookie(&self) -> IOHIDElementCookie

Retrieves the cookie for the element.

The IOHIDElementCookie represent a unique identifier for an element within a device.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the IOHIDElementCookie for the element.

Source

pub fn type(&self) -> IOHIDElementType

Retrieves the type for the element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the IOHIDElementType for the element.

Source

pub fn collection_type(&self) -> IOHIDElementCollectionType

Retrieves the collection type for the element.

The value returned by this method only makes sense if the element type is kIOHIDElementTypeCollection.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the IOHIDElementCollectionType for the element.

Source

pub fn usage_page(&self) -> u32

Retrieves the usage page for an element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the usage page for the element.

Source

pub fn usage(&self) -> u32

Retrieves the usage for an element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the usage for the element.

Source

pub fn is_virtual(&self) -> bool

Returns the virtual property for the element.

Indicates whether the element is a virtual element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the TRUE if virtual or FALSE if not.

Source

pub fn is_relative(&self) -> bool

Returns the relative property for the element.

Indicates whether the data is relative (indicating the change in value from the last report) or absolute (based on a fixed origin).

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if relative or FALSE if absolute.

Source

pub fn is_wrapping(&self) -> bool

Returns the wrap property for the element.

Wrap indicates whether the data “rolls over” when reaching either the extreme high or low value.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if wrapping or FALSE if non-wrapping.

Source

pub fn is_array(&self) -> bool

Returns the array property for the element.

Indicates whether the element represents variable or array data values. Variable values represent data from a physical control. An array returns an index in each field that corresponds to the pressed button (like keyboard scan codes).
Note: The HID Manager will represent most elements as “variable” including the possible usages of an array. Array indices will remain as “array” elements with a usage of 0xffffffff.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if array or FALSE if variable.

Source

pub fn is_non_linear(&self) -> bool

Returns the linear property for the element.

Indicates whether the value for the element has been processed in some way, and no longer represents a linear relationship between what is measured and the value that is reported.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if non linear or FALSE if linear.

Source

pub fn has_preferred_state(&self) -> bool

Returns the preferred state property for the element.

Indicates whether the element has a preferred state to which it will return when the user is not physically interacting with the control.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if preferred state or FALSE if no preferred state.

Source

pub fn has_null_state(&self) -> bool

Returns the null state property for the element.

Indicates whether the element has a state in which it is not sending meaningful data.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns TRUE if null state or FALSE if no null state.

Source

pub fn name(&self) -> CFRetained<CFString>

Returns the name for the element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns CFStringRef containing the element name.

Source

pub fn report_id(&self) -> u32

Returns the report ID for the element.

The report ID represents what report this particular element belongs to.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the report ID.

Source

pub fn report_size(&self) -> u32

Returns the report size in bits for the element.

If the element is an array type the total number of bit in the element is equal to IOHIDElementGetReportSize(element) * IOHIDElementGetReportCount(element). Otherwise this size is the total number of bits in the element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the report size.

Source

pub fn report_count(&self) -> u32

Returns the report count for the element.

If the IOHIDElementGetReportCount(element) is greater than one and the element does not represent an array then the element represents a repeated set of usages, the size of each usage in the element is IOHIDElementGetReportSize(element) / IOHIDElementGetReportCount(element).

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the report count.

Source

pub fn unit(&self) -> u32

Returns the unit property for the element.

The unit property is described in more detail in Section 6.2.2.7 of the “Device Class Definition for Human Interface Devices(HID)” Specification, Version 1.11.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the unit.

Source

pub fn unit_exponent(&self) -> u32

Returns the code associated with the unit exponent as outlined in the HID spec

The unit exponent property is described in more detail in Section 6.2.2.7 of the “Device Class Definition for Human Interface Devices(HID)” Specification, Version 1.11.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the unit exponent.

Source

pub fn logical_min(&self) -> CFIndex

Returns the minimum value possible for the element.

This corresponds to the logical minimun, which indicates the lower bounds of a variable element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the logical minimum.

Source

pub fn logical_max(&self) -> CFIndex

Returns the maximum value possible for the element.

This corresponds to the logical maximum, which indicates the upper bounds of a variable element.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the logical maximum.

Source

pub fn physical_min(&self) -> CFIndex

Returns the scaled minimum value possible for the element.

Minimum value for the physical extent of a variable element. This represents the value for the logical minimum with units applied to it.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the physical minimum.

Source

pub fn physical_max(&self) -> CFIndex

Returns the scaled maximum value possible for the element.

Maximum value for the physical extent of a variable element. This represents the value for the logical maximum with units applied to it.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Returns: Returns the physical maximum.

Source

pub fn property(&self, key: &CFString) -> Option<CFRetained<CFType>>

Returns the an element property.

Property keys are prefixed by kIOHIDElement and declared in IOHIDKeys.h.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Parameter key: The key to be used when querying the element.

Returns: Returns the property.

Source

pub unsafe fn set_property(&self, key: &CFString, property: &CFType) -> bool

Sets an element property.

This method can be used to set arbitrary element properties, such as application specific references.

Parameter element: The element to be queried. If this parameter is not a valid IOHIDElementRef, the behavior is undefined.

Parameter key: The key to be used when querying the element.

Returns: Returns TRUE if successful.

§Safety

property should be of the correct type.

Methods from Deref<Target = CFType>§

Source

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.

Source

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 IOHIDElement

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for IOHIDElement

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<IOHIDElement> for IOHIDElement

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for IOHIDElement

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for IOHIDElement

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for IOHIDElement

Source§

fn type_id() -> CFTypeID

Returns the type identifier of all IOHIDElement instances.

Source§

impl Debug for IOHIDElement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for IOHIDElement

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for IOHIDElement

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for IOHIDElement

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for IOHIDElement

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for IOHIDElement

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for IOHIDElement

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for IOHIDElement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,