File tree Expand file tree Collapse file tree 2 files changed +25
-13
lines changed Expand file tree Collapse file tree 2 files changed +25
-13
lines changed Original file line number Diff line number Diff 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 ( ) {
Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments