update: function (dt) {
var pads = this.poll();
var i, len = pads.length;
for (i = 0;i < len; i++) {
this.previous[i] = this.current[i];
this.current[i] = pads[i];
}
},
poll: function () {
var pads = [];
if (this.gamepadsSupported) {
var padDevices = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads();
var i, len = padDevices.length;
for (i = 0; i < len; i++) {
if (padDevices[i]) {
pads.push({
map: this.getMap(padDevices[i]),
pad: padDevices[i]
});
}
}
}
return pads;
},
When poll() gets called, it allocates a new array to store the current gamepad state.
When poll() gets called, it allocates a new array to store the current gamepad state.