Skip to content

InputMap

Defined in: inputMap.ts:131

new InputMap(actions): InputMap

Defined in: inputMap.ts:136

Record<string, ActionDef>

InputMap

actions(): string[]

Defined in: inputMap.ts:185

string[]


axis2d(name): Vec2

Defined in: inputMap.ts:181

2D value (axis2d); scalar actions return {value, 0}. A fresh object each call.

string

Vec2


cancelListen(): void

Defined in: inputMap.ts:244

Cancel a pending listenForBinding (resolves it with null).

void


down(name): boolean

Defined in: inputMap.ts:175

string

boolean


evaluate(input): void

Defined in: inputMap.ts:145

Recompute every action from the current raw input. Called once per frame by the registered evaluation system; edges (pressed/released) diff vs last frame.

InputState

void


getBindings(name): Binding[]

Defined in: inputMap.ts:188

string

Binding[]


isListening(): boolean

Defined in: inputMap.ts:248

boolean


listenForBinding(opts?): Promise<Binding | null>

Defined in: inputMap.ts:233

Resolve with the next physical input the user presses (or null if cancelled / superseded by another listen). Drives a rebind UI — the evaluation system feeds it each frame, so the map must be installed and the app running.

ListenOptions

Promise<Binding | null>


load(key): boolean

Defined in: inputMap.ts:222

Apply bindings previously saved under key; returns true if found.

string

boolean


loadJSON(data): void

Defined in: inputMap.ts:212

Override bindings for actions that EXIST in this map (unknown names ignored, so stale saved data for a removed action never resurrects it).

Record<string, Binding[]>

void


pressed(name): boolean

Defined in: inputMap.ts:176

string

boolean


rebind(name, opts?): Promise<Binding | null>

Defined in: inputMap.ts:238

Capture the next input and (re)bind it to name (replaces, or appends when append).

string

ListenOptions & object

Promise<Binding | null>


released(name): boolean

Defined in: inputMap.ts:177

string

boolean


save(key): void

Defined in: inputMap.ts:220

Save current bindings under key.

string

void


setBindings(name, bindings): void

Defined in: inputMap.ts:190

Replace an action’s bindings (no-op for an unknown action).

string

Binding[]

void


toAsset(): InputMapAsset

Defined in: inputMap.ts:203

Serialize the FULL map (action types + bindings) — an .inputmap asset’s content. (vs toJSON, which is bindings-only for rebind persistence.)

InputMapAsset


toJSON(): Record<string, Binding[]>

Defined in: inputMap.ts:195

Serialize current bindings (persist via Storage).

Record<string, Binding[]>


value(name): number

Defined in: inputMap.ts:179

Scalar value: button [0,1], axis [-1,1], axis2d the magnitude [0,1].

string

number