input.js icon indicating copy to clipboard operation
input.js copied to clipboard

Abstract Mapping Interface

Open secretrobotron opened this issue 14 years ago • 0 comments

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).

secretrobotron avatar Nov 13 '11 09:11 secretrobotron