Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

Commit 8c0b150

Browse files
committed
Fixed up some jshint warnings
1 parent 9c56a90 commit 8c0b150

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

lib/xbox.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,15 @@ function uint8Toint16(low, high) {
8787
return int16View[0];
8888
}
8989

90-
function XboxController(name)
91-
{
90+
function XboxController(name) {
9291
this.name = name || 'controller';
9392
this.position = 0;
9493

95-
for (var key in buttons) {
96-
this[key] = 0;
94+
for (var button in buttons) {
95+
this[button] = 0;
9796
}
98-
for (var key in triggers) {
99-
this[key] = 0;
97+
for (var trigger in triggers) {
98+
this[trigger] = 0;
10099
}
101100
this.leftx = 0;
102101
this.lefty = 0;
@@ -105,7 +104,7 @@ function XboxController(name)
105104
this.hid = false;
106105
this._controllerLoadingInterval = false;
107106
this.loadController();
108-
}
107+
}
109108

110109
util.inherits(XboxController, events.EventEmitter);
111110

@@ -154,12 +153,12 @@ XboxController.prototype.interpretData = function(error, data) {
154153
}
155154
}
156155

157-
for (var key in triggers) {
158-
var address = triggers[key];
156+
for (var trigger in triggers) {
157+
var address = triggers[trigger];
159158
var state = data[address.block];
160-
if(state ^ this[key]){
161-
this.emit(key+'trigger', state);
162-
this[key] = state;
159+
if(state ^ this[trigger]){
160+
this.emit(trigger+'trigger', state);
161+
this[trigger] = state;
163162
}
164163
}
165164

@@ -195,13 +194,13 @@ XboxController.prototype.interpretData = function(error, data) {
195194
}
196195

197196
this.hid.read(this.interpretData.bind(this));
198-
};
197+
};
199198

200199

201200
XboxController.prototype.sendCommand = function(command, errorMsg) {
202201
try{
203202
this.hid.write(command);
204-
}
203+
}
205204
catch ( ex ){
206205
console.log( chalk.red('error: '), errorMsg );
207206
}
@@ -236,8 +235,8 @@ XboxController.prototype.powerOff = function() {
236235
};
237236

238237
XboxController.prototype.rumble = function(left, right) {
239-
if (typeof left === "undefined" || left===null) left = 0xff;
240-
if (typeof right === "undefined" || right===null) right = 0xff;
238+
if (typeof left === "undefined" || left===null) {left = 0xff;}
239+
if (typeof right === "undefined" || right===null) {right = 0xff;}
241240
this.sendCommand([0x00, 0x00, 0x04, left, right], 'Xbox controller wont rumble');
242241
};
243242

0 commit comments

Comments
 (0)