11var HID = require ( 'node-hid' ) ,
22 util = require ( 'util' ) ,
3- colors = require ( 'colors ' ) ,
3+ chalk = require ( 'chalk ' ) ,
44 events = require ( 'events' ) ;
55
66var dead = 6000 ;
@@ -113,7 +113,7 @@ XboxController.prototype.loadController = function() {
113113 HID . devices ( ) . forEach ( ( function ( d ) {
114114 if ( typeof d === 'object' && d . product . toLowerCase ( ) . indexOf ( 'controller' ) !== - 1 ) {
115115 this . hid = new HID . HID ( d . path ) ;
116- console . log ( 'notice: ' . green , 'Xbox controller connected.' ) ;
116+ console . log ( chalk . green ( 'notice: ' ) , 'Xbox controller connected.' ) ;
117117 }
118118 } ) . bind ( this ) ) ;
119119
@@ -127,14 +127,14 @@ XboxController.prototype.loadController = function() {
127127 this . hid . read ( this . interpretData . bind ( this ) ) ;
128128 }
129129 catch ( ex ) {
130- console . log ( 'error: ' . red , 'Xbox controller could not be found.' ) ;
130+ console . log ( chalk . red ( 'error: ' ) , 'Xbox controller could not be found.' ) ;
131131 }
132132
133133} ;
134134
135135XboxController . prototype . interpretData = function ( error , data ) {
136136 if ( error && this . hid ) {
137- console . log ( 'error:' . red , error ) ;
137+ console . log ( chalk . red ( 'error:' ) , error ) ;
138138 this . hid = false ;
139139 this . loadController ( ) ;
140140 return false ;
@@ -202,7 +202,7 @@ XboxController.prototype.sendCommand = function(command, errorMsg) {
202202 this . hid . write ( command ) ;
203203 }
204204 catch ( ex ) {
205- console . log ( 'error: ' . red , errorMsg ) ;
205+ console . log ( chalk . red ( 'error: ' ) , errorMsg ) ;
206206 }
207207} ;
208208
0 commit comments