This repository was archived by the owner on Dec 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,12 @@ Control left and right rumble motors:
7272
7373Where the strengths are between 0 and 255.
7474
75+ ## Third Party Controllers
76+
77+ If you have a third party controller with a different name you can specify the name when creating the controller:
78+
79+ var xbox = new XboxController('flight stick')
80+
7581## Copyright
7682
7783Copyright (c) 2013 Andrew Nesbitt. See [ LICENSE] ( https://github.com/andrew/node-xbox-controller/blob/master/LICENSE ) for details.
Original file line number Diff line number Diff line change @@ -87,8 +87,9 @@ function uint8Toint16(low, high) {
8787 return int16View [ 0 ] ;
8888}
8989
90- function XboxController ( )
90+ function XboxController ( name )
9191{
92+ this . name = name || 'controller' ;
9293 this . position = 0 ;
9394
9495 for ( var key in buttons ) {
@@ -111,7 +112,7 @@ util.inherits(XboxController, events.EventEmitter);
111112XboxController . prototype . loadController = function ( ) {
112113
113114 HID . devices ( ) . forEach ( ( function ( d ) {
114- if ( typeof d === 'object' && d . product . toLowerCase ( ) . indexOf ( 'controller' ) !== - 1 ) {
115+ if ( typeof d === 'object' && d . product . toLowerCase ( ) . indexOf ( this . name ) !== - 1 ) {
115116 this . hid = new HID . HID ( d . path ) ;
116117 console . log ( chalk . green ( 'notice: ' ) , 'Xbox controller connected.' ) ;
117118 }
You can’t perform that action at this time.
0 commit comments