Skip to content

Commit

Permalink
Keywords, extra checks
Browse files Browse the repository at this point in the history
- Added keywords
- Added checks for connections in start() and stop()
  • Loading branch information
hopejr committed Aug 11, 2020
1 parent 2e44a98 commit cfffdde
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
31 changes: 18 additions & 13 deletions lib/Shuttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@ class Shuttle extends EventEmitter {
}

start () {
usbDetect.startMonitoring()
usbDetect.on('add', (d) => {
// Delay connection by 1 second because
// it takes a second to load on macOS
setTimeout(() => {
this._connect()
}, process.platform === 'darwin' ? 1000 : 0)
})
// Find already
this._connect()
if (!this._connected) {
usbDetect.startMonitoring()
usbDetect.on('add', (d) => {
// Delay connection by 1 second because
// it takes a second to load on macOS
setTimeout(() => {
this._connect()
}, process.platform === 'darwin' ? 1000 : 0)
})
// Find already
this._connect()
}
}

stop () {
usbDetect.stopMonitoring()
this._hid.close()
this._hid = null
if (this._connected) {
usbDetect.stopMonitoring()
this._hid.close()
this._hid = null
this._connected = false
}
}

_connect () {
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"url": "https://github.com/hopejr/ShuttleControlUSB/issues"
},
"homepage": "https://github.com/hopejr/ShuttleControlUSB",
"keywords": [
"shuttlexpress",
"shuttlepro",
"usb",
"shuttle",
"jog"
],
"dependencies": {
"node-hid": "^1.3.0",
"usb-detection": "^4.10.0"
Expand Down

0 comments on commit cfffdde

Please sign in to comment.