From 2883c466f2ea26585a14b6e9765fa4146ba17554 Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Tue, 27 Oct 2020 10:13:30 +0100 Subject: [PATCH] fix: use device.interface instead of device.usage device.usage has been removed in node-hid, see https://github.com/SuperFlyTV/xkeys/issues/4 --- README.md | 2 +- logData/logHMI.js | 2 +- src/xkeys.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 215ec76..163cbe7 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ const XKeys = require('xkeys'); const devices = HID.devices(); const connectedXKeys = devices.filter(device => { - return (device.vendorId === XKeys.vendorId && device.usage === 1); // Make sure that the usage-property is set to 1 + return (device.vendorId === XKeys.vendorId && device.interface === 0); // Make sure that the interface-property is set to 0 }); if (connectedXKeys.length) { diff --git a/logData/logHMI.js b/logData/logHMI.js index 45b4215..980d611 100644 --- a/logData/logHMI.js +++ b/logData/logHMI.js @@ -41,7 +41,7 @@ if (devices.length) { log('product ',device.product); log('vendorId ',device.vendorId); log('productId ',device.productId); - log('usage ',device.usage); + log('interface ',device.interface); //log(device); diff --git a/src/xkeys.ts b/src/xkeys.ts index 0e67155..b37528b 100644 --- a/src/xkeys.ts +++ b/src/xkeys.ts @@ -63,9 +63,11 @@ export class XKeys extends EventEmitter { // Device not provided, will then select any connected device: const connectedXKeys = devices.filter(device => { - // Ensures device with usage 1 is selected (other usage id's do not seem to work) + // Ensures device with interface 0 is selected (other interface id's do not seem to work) - return (device.vendorId === XKeys.vendorId && device.usage === 1) + // Note: device.usage has been removed in node-hid: https://github.com/SuperFlyTV/xkeys/issues/4 + // Using interface instead: + return (device.vendorId === XKeys.vendorId && device.interface === 0) }) if (!connectedXKeys.length) { throw new Error('Could not find any connected X-keys panels.')