Skip to content

Commit bcdbcca

Browse files
committed
Dependency update
- FIXED: tests did not check for devices that were already connected. - Moved away from deprecated usb-detection and using the usb module instead. - Added note in README.md about future feature to allow multiple devices.
1 parent ce3dfd4 commit bcdbcca

File tree

5 files changed

+66
-531
lines changed

5 files changed

+66
-531
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ By default, the udev system adds ShuttleXpress, ShuttlePro V1, and ShuttlePro V2
9595
Then reboot your computer.
9696

9797

98+
# Future Features
99+
I'm looking at allowing multiple devices to be connected at once. Stay tuned for this feature. It will likely result in a change to the API and will be a breaking change.
100+
101+
98102
## Licence
99103
MIT
100104

lib/Shuttle.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const hid = require('node-hid')
4-
const usbDetect = require('usb-detection')
4+
const { usb } = require('usb')
55
const shuttleDevices = require('./ShuttleDefs')
66
const EventEmitter = require('events').EventEmitter
77

@@ -21,8 +21,7 @@ class Shuttle extends EventEmitter {
2121

2222
start () {
2323
if (!this._connected) {
24-
usbDetect.startMonitoring()
25-
usbDetect.on('add', (d) => {
24+
usb.on('attach', (d) => {
2625
// Delay connection by 1 second because
2726
// it takes a second to load on macOS
2827
setTimeout(() => {
@@ -35,7 +34,7 @@ class Shuttle extends EventEmitter {
3534
}
3635

3736
stop () {
38-
usbDetect.stopMonitoring()
37+
usb.unrefHotplugEvents()
3938
if (this._connected) {
4039
if (this._hid !== null) {
4140
this._hid.close()

0 commit comments

Comments
 (0)