Skip to content

Commit

Permalink
feat(node): accept array of hid devices in manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 25, 2022
1 parent c97db65 commit cbaa1f8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/node/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,23 @@ async function tryOpenDevice(path: string): Promise<NodeHIDDevice> {
}
}
export class XencelabsQuickKeysManager extends XencelabsQuickKeysManagerBase<string> {
/** Newly discovered devices will be announced via the connect event, as they are not always immediately accessible */
/**
* Perform a scan and open any new devices
* Once opened they will be announced via the connect event, as they are not always immediately accessible
*/
public async scanDevices(): Promise<void> {
const devices = HID.devices()

// TODO - this needs to wait for other scans to have finished

return this.openDevicesFromArray(devices)
}

/**
* Open any new devices from the list.
* Once opened they will be announced via the connect event, as they are not always immediately accessible
*/
public async openDevicesFromArray(devices: Array<HID.Device>): Promise<void> {
for (const dev of devices) {
if (dev.vendorId === VENDOR_ID && dev.path && dev.interface === DEVICE_INTERFACE) {
const path = dev.path
Expand Down

0 comments on commit cbaa1f8

Please sign in to comment.