-
-
Save videlais/f63e86f91b5698a1de51 to your computer and use it in GitHub Desktop.
Gamepad3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In Firefox only, adds a gamepad when connected and starts the polling | |
* @param {EventObject} event A 'MozGamepadConnected' event object | |
*/ | |
function onGamepadConnect(event) { | |
var gamepad = event.gamepad; | |
self.gamepads[event.gamepad.id] = gamepad; | |
startPolling(); | |
} | |
/** | |
* In Firefox only, sets a disconnected gamepad to 'null' | |
* @param {EventObject} event A 'MozGamepadDisconnected' event object | |
*/ | |
function onGamepadDisconnect(event) { | |
self.gamepads[event.gamepad.id] = null; | |
if (self.gamepads.length === 0) { | |
stopPolling(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment