Skip to content

Commit cfffdde

Browse files
committed
Keywords, extra checks
- Added keywords - Added checks for connections in start() and stop()
1 parent 2e44a98 commit cfffdde

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

lib/Shuttle.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,27 @@ class Shuttle extends EventEmitter {
2020
}
2121

2222
start () {
23-
usbDetect.startMonitoring()
24-
usbDetect.on('add', (d) => {
25-
// Delay connection by 1 second because
26-
// it takes a second to load on macOS
27-
setTimeout(() => {
28-
this._connect()
29-
}, process.platform === 'darwin' ? 1000 : 0)
30-
})
31-
// Find already
32-
this._connect()
23+
if (!this._connected) {
24+
usbDetect.startMonitoring()
25+
usbDetect.on('add', (d) => {
26+
// Delay connection by 1 second because
27+
// it takes a second to load on macOS
28+
setTimeout(() => {
29+
this._connect()
30+
}, process.platform === 'darwin' ? 1000 : 0)
31+
})
32+
// Find already
33+
this._connect()
34+
}
3335
}
3436

3537
stop () {
36-
usbDetect.stopMonitoring()
37-
this._hid.close()
38-
this._hid = null
38+
if (this._connected) {
39+
usbDetect.stopMonitoring()
40+
this._hid.close()
41+
this._hid = null
42+
this._connected = false
43+
}
3944
}
4045

4146
_connect () {

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
"url": "https://github.com/hopejr/ShuttleControlUSB/issues"
1717
},
1818
"homepage": "https://github.com/hopejr/ShuttleControlUSB",
19+
"keywords": [
20+
"shuttlexpress",
21+
"shuttlepro",
22+
"usb",
23+
"shuttle",
24+
"jog"
25+
],
1926
"dependencies": {
2027
"node-hid": "^1.3.0",
2128
"usb-detection": "^4.10.0"

0 commit comments

Comments
 (0)