input.js
input.js copied to clipboard
Abstract Mapping Interface
I know we talked about implementing some abstraction over the input names, so that users can attach events to things like "jump" which is tied to every button or something.
Maybe (with some leniency on event-driven paradigm, please):
var gamepad,
mapping = { "BUTTON_A": "jump" };
window.addEventListener("MozGamepadConnected", function(e) {
gamepad = new Input.Device(e.gamepad, mapping);
});
gamepad.listen( "jump", function() {
player.jump();
});
Code for using a hilariously 8-bit joystick can look effectively the same as code for using a PS3 controller, given that the control scheme for the game is relatively simple (e.g. NES Mario-like controls).