Calls related to interaction with HID USB devices
Many of these calls can be accomplished from the qz.usb
namespace,
but HID allows for simpler interaction
- Since:
- Source:
Methods
(static) claimDevice(deviceInfo) → {Promise.<(null|Error)>}
Claim a HID device to enable sending/reading data across.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
|
- Since:
- Source:
Returns:
-
Type
-
Promise.<(null|Error)>
(static) closeStream(deviceInfo) → {Promise.<(null|Error)>}
Stops the stream of read data from a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
|
- Since:
- Source:
Returns:
-
Type
-
Promise.<(null|Error)>
(static) getFeatureReport(deviceInfo) → {Promise.<(Array.<string>|Error)>}
Get a feature report from a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
responseSize |
|
Size of the byte array to receive a response in. |
|
- Source:
Returns:
List of (hexadecimal) bytes received from the HID device.
-
Type
-
Promise.<(Array.<string>|Error)>
(static) isClaimed(deviceInfo) → {Promise.<(boolean|Error)>}
Check the current claim state of a HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
|
- Since:
- Source:
Returns:
-
Type
-
Promise.<(boolean|Error)>
(static) listDevices() → {Promise.<(Array.<Object>|Error)>}
List of available HID devices. Includes (hexadecimal) vendor ID and (hexadecimal) product ID.
If available, also returns manufacturer and product descriptions.
- Since:
- Source:
Returns:
Array of JSON objects containing information on connected HID devices.
-
Type
-
Promise.<(Array.<Object>|Error)>
(static) openStream(deviceInfo) → {Promise.<(null|Error)>}
Provides a continuous stream of read data from a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Default |
Description |
vendorId |
|
|
Hex string of HID device's vendor ID. |
productId |
|
|
Hex string of HID device's product ID. |
usagePage |
|
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
|
Serial ID of HID device. |
responseSize |
|
|
Size of the byte array to receive a response in. |
interval |
|
100
|
Frequency to send read data back, in milliseconds. |
|
- Since:
- Source:
- See:
-
Returns:
-
Type
-
Promise.<(null|Error)>
(static) readData(deviceInfo) → {Promise.<(Array.<string>|Error)>}
Read data from a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
responseSize |
|
Size of the byte array to receive a response in. |
|
- Since:
- Source:
Returns:
List of (hexadecimal) bytes received from the HID device.
-
Type
-
Promise.<(Array.<string>|Error)>
(static) releaseDevice(deviceInfo) → {Promise.<(null|Error)>}
Release a claimed HID device to free resources after sending/reading data.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Description |
vendorId |
|
Hex string of HID device's vendor ID. |
productId |
|
Hex string of HID device's product ID. |
usagePage |
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
Serial ID of HID device. |
|
- Since:
- Source:
Returns:
-
Type
-
Promise.<(null|Error)>
(static) sendData(deviceInfo) → {Promise.<(null|Error)>}
Send data to a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Attributes |
Default |
Description |
vendorId |
|
|
|
Hex string of HID device's vendor ID. |
productId |
|
|
|
Hex string of HID device's product ID. |
usagePage |
|
|
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
|
|
Serial ID of HID device. |
data |
|
|
|
Bytes to send over specified endpoint. |
endpoint |
|
|
0x00
|
First byte of the data packet signifying the HID report ID.
Must be 0x00 for devices only supporting a single report. |
reportId |
|
|
0x00
|
Alias for deviceInfo.endpoint . Not used if endpoint is provided. |
type |
string
|
<optional>
|
'PLAIN'
|
Valid values [FILE | PLAIN | HEX | BASE64] |
|
- Since:
- Source:
Returns:
-
Type
-
Promise.<(null|Error)>
(static) sendFeatureReport(deviceInfo) → {Promise.<(null|Error)>}
Send a feature report to a claimed HID device.
Parameters:
Name |
Type |
Description |
deviceInfo |
object
|
Config details of the HID device.
Properties
Name |
Type |
Attributes |
Default |
Description |
vendorId |
|
|
|
Hex string of HID device's vendor ID. |
productId |
|
|
|
Hex string of HID device's product ID. |
usagePage |
|
|
|
Hex string of HID device's usage page when multiple are present. |
serial |
|
|
|
Serial ID of HID device. |
data |
|
|
|
Bytes to send over specified endpoint. |
endpoint |
|
|
0x00
|
First byte of the data packet signifying the HID report ID.
Must be 0x00 for devices only supporting a single report. |
reportId |
|
|
0x00
|
Alias for deviceInfo.endpoint . Not used if endpoint is provided. |
type |
string
|
<optional>
|
'PLAIN'
|
Valid values [FILE | PLAIN | HEX | BASE64] |
|
- Source:
Returns:
-
Type
-
Promise.<(null|Error)>
(static) setHidCallbacks(calls)
List of functions called for any response from open usb devices.
Event data will contain {string} vendorId
and {string} productId
for all types.
For RECEIVE types, {Array} output
(in hexadecimal format).
For ERROR types, {string} exception
.
For ACTION types, {string} actionType
.
Parameters:
Name |
Type |
Description |
calls |
function
|
Array.<function()>
|
Single or array of Function({Object} eventData) calls. |
- Since:
- Source:
(static) startListening() → {Promise.<(null|Error)>}
Start listening for HID device actions, such as attach / detach events.
Reported under the ACTION type in the streamEvent on callbacks.
- Since:
- Source:
- See:
-
Returns:
-
Type
-
Promise.<(null|Error)>
(static) stopListening() → {Promise.<(null|Error)>}
Stop listening for HID device actions.
- Since:
- Source:
- See:
-
Returns:
-
Type
-
Promise.<(null|Error)>