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 +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ Mac OSX driver: http://tattiebogle.net/index.php/ProjectRoot/Xbox360Controller/O
3939
4040## TODO
4141
42- * stick deadzones
4342* rumble control
4443* led control
4544
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var HID = require('node-hid'),
33 colors = require ( 'colors' ) ,
44 events = require ( 'events' ) ;
55
6+ var dead = 6000 ;
67
78var buttons = {
89 'dup' : {
@@ -144,6 +145,13 @@ XboxController.prototype.interpretData = function(error, data) {
144145 var lefty = uint8Toint16 ( data [ 8 ] , data [ 9 ] )
145146
146147 if ( leftx ^ this . leftx | lefty ^ this . lefty ) {
148+ if ( leftx > - 1 * dead && leftx < dead ) {
149+ leftx = 0
150+ }
151+ if ( lefty > - 1 * dead && lefty < dead ) {
152+ lefty = 0
153+ }
154+
147155 this . emit ( 'left:move' , { x : leftx , y : lefty } )
148156 this . leftx = leftx
149157 this . lefty = lefty
@@ -153,6 +161,12 @@ XboxController.prototype.interpretData = function(error, data) {
153161 var righty = uint8Toint16 ( data [ 12 ] , data [ 13 ] )
154162
155163 if ( rightx ^ this . rightx | righty ^ this . righty ) {
164+ if ( rightx > - 1 * dead && rightx < dead ) {
165+ rightx = 0
166+ }
167+ if ( righty > - 1 * dead && righty < dead ) {
168+ righty = 0
169+ }
156170 this . emit ( 'right:move' , { x : rightx , y : righty } )
157171 this . rightx = rightx
158172 this . righty = righty
You can’t perform that action at this time.
0 commit comments