• Download
  • Demo
  • Buy
  • API
  • Docs
  • Support
  • About
  • Contact
  • Login
API Home
Namespaces
qzapiconfigsfilehidnetworkingprinterssecurityserialsocketusbwebsocket
API Home
Namespaces
qzapiconfigsfilehidnetworkingprinterssecurityserialsocketusbwebsocket

Namespace: hid

qz.hid

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:
  • 2.0.1
Source:
  • qz-tray.js, line 2018

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:
  • 2.0.1
Source:
  • qz-tray.js, line 2097
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2285
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:
  • qz-tray.js, line 2237
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:
  • 2.0.2
Source:
  • qz-tray.js, line 2116
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2035
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2258
See:
  • qz.hid.setHidCallbacks
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2190
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2304
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2140
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:
  • qz-tray.js, line 2220
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:
  • 2.0.1
Source:
  • qz-tray.js, line 2080

(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:
  • 2.0.1
Source:
  • qz-tray.js, line 2050
See:
  • qz.hid.setHidCallbacks
Returns:
Type
Promise.<(null|Error)>

(static) stopListening() → {Promise.<(null|Error)>}

Stop listening for HID device actions.
Since:
  • 2.0.1
Source:
  • qz-tray.js, line 2064
See:
  • qz.hid.setHidCallbacks
Returns:
Type
Promise.<(null|Error)>
Documentation generated by JSDoc 3.6.11

© 2023 qz | Privacy Policy