Complete input map configuration.
An InputMap defines all the input bindings for a particular game context (e.g., gameplay, menu, cutscene). It must have a unique id and at least one of singleInput or axesInput defined.
id
singleInput
axesInput
import { InputMap, Inputs, Command, AxesCommand } from '@happy-pixels/input-forge';class JumpCommand extends Command { trigger() { player.jump(); }}class MoveCommand extends AxesCommand { update(axes: AxesInput) { player.move(axes.x, axes.y); }}const gameplayMap: InputMap = { id: 'gameplay', singleInput: { jump: { keyboardInput: Inputs.KEYBOARD_SPACE, controllerInput: Inputs.CONTROLLER_FACE_BOTTOM, command: new JumpCommand() }, attack: { keyboardInput: Inputs.KEYBOARD_J, controllerInput: Inputs.CONTROLLER_FACE_RIGHT, command: new AttackCommand() } }, axesInput: { move: { keyboardAxes: { vertical: { up: 'w', down: 's' }, horizontal: { left: 'a', right: 'd' } }, controllerStick: Inputs.CONTROLLER_LEFT_STICK, command: new MoveCommand() } }}; Copy
import { InputMap, Inputs, Command, AxesCommand } from '@happy-pixels/input-forge';class JumpCommand extends Command { trigger() { player.jump(); }}class MoveCommand extends AxesCommand { update(axes: AxesInput) { player.move(axes.x, axes.y); }}const gameplayMap: InputMap = { id: 'gameplay', singleInput: { jump: { keyboardInput: Inputs.KEYBOARD_SPACE, controllerInput: Inputs.CONTROLLER_FACE_BOTTOM, command: new JumpCommand() }, attack: { keyboardInput: Inputs.KEYBOARD_J, controllerInput: Inputs.CONTROLLER_FACE_RIGHT, command: new AttackCommand() } }, axesInput: { move: { keyboardAxes: { vertical: { up: 'w', down: 's' }, horizontal: { left: 'a', right: 'd' } }, controllerStick: Inputs.CONTROLLER_LEFT_STICK, command: new MoveCommand() } }};
Complete input map configuration.
An InputMap defines all the input bindings for a particular game context (e.g., gameplay, menu, cutscene). It must have a unique
idand at least one ofsingleInputoraxesInputdefined.Example