Skip to content

InputMap ​

Named actions bound to keys, buttons and axes.

Always available

No import needed. These names are in scope in every file.

InputMap class ​

ts
class InputMap

InputMap.FORMAT_VERSION ​

ts
static readonly FORMAT_VERSION: int

The version written by save and the only one load accepts.

InputMap.MAX_SERIALIZED_BYTES ​

ts
static readonly MAX_SERIALIZED_BYTES: int

load refuses documents larger than this many bytes.

InputMap.MAX_ENTRIES ​

ts
static readonly MAX_ENTRIES: int

load refuses documents with more bindings and axes than this.

InputMap.MAX_JSON_DEPTH ​

ts
static readonly MAX_JSON_DEPTH: int

load refuses documents nested deeper than this.

InputMap.CAPTURE_AXIS_THRESHOLD ​

ts
static readonly CAPTURE_AXIS_THRESHOLD: float

A stick must pass this magnitude, from below, for captureNext to take it.

InputMap.CAPTURE_POLL_MS ​

ts
static readonly CAPTURE_POLL_MS: int

How often a pending captureNext looks at the devices.

InputMap.PAD_SLOTS ​

ts
static readonly PAD_SLOTS: int

Gamepads are indexed 0 to 3; a pad binding is satisfied by any of them.

InputMap.bind ​

ts
static bind(action: actionid, inputs: Array<int>): void

Replaces the bindings of action with inputs. Values that are not input constants are dropped.

InputMap.rebind ​

ts
static rebind(action: actionid, input: int): void

Replaces the bindings of action with the one input (what captureNext resolves with).

InputMap.unbind ​

ts
static unbind(action: actionid): void

Removes the bindings and axis of action.

InputMap.clear ​

ts
static clear(): void

Removes every binding and axis.

InputMap.axis ​

ts
static axis(axisAction: actionid, negativeAction: actionid, positiveAction: actionid, padAxis?: int): void

Makes axisAction read positiveAction - negativeAction (clamped to -1..1); when padAxis is given, the larger magnitude of that and the stick wins.

InputMap.isDown ​

ts
static isDown(action: actionid): boolean

Whether any input of action is held. False while text input is active.

InputMap.isPressed ​

ts
static isPressed(action: actionid): boolean

Whether action went down: once per edge on a tick, once per frame outside one.

InputMap.isReleased ​

ts
static isReleased(action: actionid): boolean

Whether action was let go: once per edge on a tick, once per frame outside one.

InputMap.value ​

ts
static value(action: actionid): float

-1..1 for an axis action, 0 or 1 for a digital one, the largest magnitude of a mixed list.

InputMap.captureNext ​

ts
static captureNext(): Promise<int>

Resolves with the next key, mouse button, pad button or stick (past the threshold) the player presses. Rejects if text input starts or cancelCapture is called. A second call while one is pending returns the same promise.

InputMap.cancelCapture ​

ts
static cancelCapture(): void

Rejects a pending captureNext (at its next poll).

InputMap.save ​

ts
static save(): string

Version 1 JSON with names (Key.SPACE), never numbers, so a saved file survives renumbering.

InputMap.load ​

ts
static load(json: string): Array<string>

Restores a saved document. Validates all of it before replacing anything, so a bad document leaves the current map unchanged. Returns the names it did not recognise (from a newer engine).

Other members of InputMap ​

ts
static readonly KIND_NONE: int
static readonly KIND_KEY: int
static readonly KIND_MOUSE: int
static readonly KIND_PAD_BUTTON: int
static readonly KIND_PAD_AXIS: int

Generated from lang/inputmap/index.tks in the ThicketScript repository.