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 InputMapInputMap.FORMAT_VERSION
ts
static readonly FORMAT_VERSION: intThe version written by save and the only one load accepts.
InputMap.MAX_SERIALIZED_BYTES
ts
static readonly MAX_SERIALIZED_BYTES: intload refuses documents larger than this many bytes.
InputMap.MAX_ENTRIES
ts
static readonly MAX_ENTRIES: intload refuses documents with more bindings and axes than this.
InputMap.MAX_JSON_DEPTH
ts
static readonly MAX_JSON_DEPTH: intload refuses documents nested deeper than this.
InputMap.CAPTURE_AXIS_THRESHOLD
ts
static readonly CAPTURE_AXIS_THRESHOLD: floatA stick must pass this magnitude, from below, for captureNext to take it.
InputMap.CAPTURE_POLL_MS
ts
static readonly CAPTURE_POLL_MS: intHow often a pending captureNext looks at the devices.
InputMap.PAD_SLOTS
ts
static readonly PAD_SLOTS: intGamepads are indexed 0 to 3; a pad binding is satisfied by any of them.
InputMap.bind
ts
static bind(action: actionid, inputs: Array<int>): voidReplaces the bindings of action with inputs. Values that are not input constants are dropped.
InputMap.rebind
ts
static rebind(action: actionid, input: int): voidReplaces the bindings of action with the one input (what captureNext resolves with).
InputMap.unbind
ts
static unbind(action: actionid): voidRemoves the bindings and axis of action.
InputMap.clear
ts
static clear(): voidRemoves every binding and axis.
InputMap.axis
ts
static axis(axisAction: actionid, negativeAction: actionid, positiveAction: actionid, padAxis?: int): voidMakes 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): booleanWhether any input of action is held. False while text input is active.
InputMap.isPressed
ts
static isPressed(action: actionid): booleanWhether action went down: once per edge on a tick, once per frame outside one.
InputMap.isReleased
ts
static isReleased(action: actionid): booleanWhether 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(): voidRejects a pending captureNext (at its next poll).
InputMap.save
ts
static save(): stringVersion 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: intGenerated from lang/inputmap/index.tks in the ThicketScript repository.