[READ-ONLY] Mirror of https://github.com/excaliburjs/Excalibur. 🎮 Your friendly TypeScript 2D game engine for the web 🗡️ excaliburjs.com
excalibur excaliburjs game-development game-engine game-framework gamedev games html5-canvas typescript

feat: Implement InputMapper (#2705) master

This PR implements a new input mapper for excalibur which is useful for mapping multiple input sources into specific commands. This can be used to enable accessibility for your users adding ways for them to provide different inputs! This examples shows how to map multiple types of input for the same action! ```typescript const moveRight = (amount: number) => { actor.vel.x = 100 * amount } const moveLeft = (amount: number) => { actor.vel.x = -100 * amount } const moveUp = (amount: number) => { actor.vel.y = -100 * amount } const moveDown = (amount: number) => { actor.vel.y = 100 * amount } engine.inputMapper.on(({keyboard}) => keyboard.isHeld(ex.Keys.ArrowRight) ? 1 : 0, moveRight); engine.inputMapper.on(({gamepads}) => gamepads.at(0).isButtonPressed(ex.Buttons.DpadRight) ? 1 : 0, moveRight); engine.inputMapper.on(({gamepads}) => gamepads.at(0).getAxes(ex.Axes.LeftStickX) > 0 ? gamepads.at(0).getAxes(ex.Axes.LeftStickX) : 0, moveRight); ```