An HIDElement describes an element, or a control, of an HID device. These are created for the device automatically when you open a device. The only interaction a user will have with elements are to query the properties of the element (with .postElement
), query the value
or rawValue
, or set the value, set the repeat
property or set an action
to be performed when new data comes in.
Set or get the action to be performed upon receiving element data. The function will be passed the following arguments: the value (mapped between 0 and 1) and the raw value.
set or get the value of the element. Setting only makes sense for an output element.
val |
The raw value to send to the device |
By default element's data from the device is not updated unless the data is changing. For certain elements however, you may want to receive updates even if the data is not changing, e.g. for scrollwheel of mice.
rp |
a Boolean to turn repeat on or off |
The raw value of the element.
The logical value of the element. In principal the same as value.
The physical value of the element. This can be calculated from the raw value and the device's specification for conversion: the physical minimum, the physical maximum, the unit and unit exponent. How the conversion works is described in the USB HID standard documentation.
The array value of the element. This value is only of importance for those elements which can represent multiple usages, such as from keyboards. In that case it indicates the key that is pressed, and by adding this number to the usage of the element you know which function the key has.
Post a human readable description of the element to the post window.
The index of this element. This index may vary between operating systems.
Get the device to which this element belongs.
an instance of HID
Get the collection index to which this element belongs.
Retrieve the usage index of this collection.
a Number - the usage index of this element
Retrieve the usage page index of this element.
a Number- the usage page index
Retrieve the usage name of this element. The name is looked up from the standardized HID usage tables using the usage page index.
a String - the usage name
Retrieve the page name of this element. The name is looked up from the standardized HID usage tables using the usage page index.
a String - the usage page name
A byte describing the type of element.
a number describing the type of element.
The type of element, decoded from the type byte.
an Array with Strings describing the type of element.
Type of the element, input (1), output (2) or feature (3)
a Number indicating the ioType
Type of the element, one of \input
, \output
, or \feature
a Symbol indicating the type
Minimum value of the range that is to be expected. This is reported by the device. The element's raw value is mapped between the logical minimum and maximum to obtain the element's value.
Maximum value of the range that is to be expected. This is reported by the device. The element's raw value is mapped between the logical minimum and maximum to obtain the element's value.
Minimum value of the range that is to be expected in a physical sense. This is reported by the device. For example, for a hat switch the physical range may be the direction in degrees in which the hat switch is pointing.
Maximum value of the range that is to be expected in a physical sense. This is reported by the device. For example, for a hat switch the physical range may be the direction in degrees in which the hat switch is pointing.
Index for the unit of the physical range.
The exponent for the physical range.
Minimum value of the usage range that is to be expected. This is reported by the device. This is only relevant for elements that report array values.
Maximum value of the usage range that is to be expected. This is reported by the device. This is only relevant for elements that report array values.
This method is used to get a dictionary of all the usages that this element produces. In most cases an element has only one usage, but in the case of an array-element it will have several uses (for a keyboard, an element represents one keypress, but they can be various different keys).
The report ID with which this element receives the data. This is a low level device specific identifier
The report size in bits with which this element receives the data. This is a low level device specific identifier
The report index with which this element receives the data. This is a low level device specific identifier