changed getGamepads for refreshGamepads method

This commit is contained in:
e7d
2017-05-14 11:05:19 +02:00
parent 5f7038fe93
commit 7b60f20398

View File

@ -92,8 +92,8 @@ class Gamepad {
} }
} }
getGamepads() { refreshGamepads() {
return navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []); this.gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
} }
getActiveGamepad() { getActiveGamepad() {
@ -124,7 +124,7 @@ class Gamepad {
return; return;
} }
this.gamepads = this.getGamepads(); this.refreshGamepads();
for (let gamepadIndex = 0; gamepadIndex < this.gamepads.length; gamepadIndex++) { for (let gamepadIndex = 0; gamepadIndex < this.gamepads.length; gamepadIndex++) {
const gamepad = this.gamepads[gamepadIndex]; const gamepad = this.gamepads[gamepadIndex];
if (gamepad) { if (gamepad) {
@ -209,7 +209,8 @@ class Gamepad {
} }
updateVisualStatus() { updateVisualStatus() {
this.gamepads = this.getGamepads(); this.refreshGamepads();
// ensure that a gamepad is currently active // ensure that a gamepad is currently active
if (!this.activeGamepad) { if (!this.activeGamepad) {
return; return;