Input Forge - v0.3.1
    Preparing search index...

    Type Alias InputMap

    InputMap:
        | { axesInput?: AxesInputMap; id: string; singleInput: SingleInputMap }
        | { axesInput: AxesInputMap; id: string; singleInput?: SingleInputMap }
        | { axesInput: AxesInputMap; id: string; singleInput: SingleInputMap }

    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.

    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()
    }
    }
    };