Talos docs

InputMap

Since 0.6

A logical action map over ctx.input; rebinding is a data edit, not a code edit.

Plain text

Signature

export class InputMap {
  deadzone: number
  lookSensitivity: Vec2
  invertLook: [boolean, boolean]
  constructor(init: InputMapInit = {})
  bind(action: ActionName, sources: string | string[]): this
  bindAxis(axis: string, source: string): this
  unbind(action: ActionName): this
  sources(action: ActionName): string[]
  axisSource(axis: string): string
  toJSON(): InputConfig
  static fromJSON(data: unknown): InputMap
  static fromContract(doc: SceneInputDoc, context: string): InputMap
  bound(): string[]
  axis(input: InputState | null, name: string): Vec2
  move(input: InputState | null): Vec2
  lookParts(input: InputState | null): AxisParts
  look(input: InputState | null): Vec2
  action(input: InputState | null, action: ActionName): ActionState
  pressed(input: InputState | null, action: ActionName): boolean
  held(input: InputState | null, action: ActionName): boolean
  released(input: InputState | null, action: ActionName): boolean
}

Import: import { InputMap } from "@argus/gameplay"

Members

MemberSignatureDescription
deadzonedeadzone: number
lookSensitivitylookSensitivity: Vec2
invertLookinvertLook: [boolean, boolean]
constructorconstructor(init: InputMapInit = {})
bindbind(action: ActionName, sources: string | string[]): thisRebind a button action to one or more source names. Returns this so calls chain.
bindAxisbindAxis(axis: string, source: string): thisRebind an axis to a source axis name.
unbindunbind(action: ActionName): thisDrop every source for an action; it then reads as never pressed. An empty list, not a missing entry: a missing entry is the identity now, so deleting the key would rebind the action to itself rather than silence it.
sourcessources(action: ActionName): string[]The actions currently bound to a button, in priority order. Its own name when unbound.
axisSourceaxisSource(axis: string): stringThe source a logical axis reads from (its own name when unbound).
toJSONtoJSON(): InputConfigThe binding table as plain data, ready to store in props or a settings file.
fromJSONstatic fromJSON(data: unknown): InputMapRebuild a map from data (a script component's props, a saved settings blob). Unknown fields are ignored.
fromContractstatic fromContract(doc: SceneInputDoc, context: string): InputMapBuild a map from a meta.input document and one of its contexts. The identity for every action that context binds, plus the per-action deadzone the document asked for where all of them agree. Its use is a rebinding screen: read the scene's map, list actions(), let the player pick, write the edit back to the scene document. It is NOT needed to read input — the engine has already applied the map by the time ctx.input answers, so a behavior that just wants move uses new InputMap(). An unknown context, or a malformed document, yields an empty map rather than throwing.
boundbound(): string[]Every action this map names, in name order. What a rebinding screen lists.
axisaxis(input: InputState | null, name: string): Vec2A logical axis with the deadzone applied. Neutral when the entity has no input component.
movemove(input: InputState | null): Vec2The move axis: [strafe, forward], deadzoned.
lookPartslookParts(input: InputState | null): AxisPartsThe look axis split into its stick rate and its mouse angle, each with sensitivity and inversion applied: rate is [yaw, pitch] in -1..1 (deadzoned), delta is [yaw, pitch] in degrees this tick. What the camera rigs turn by (RigInput.look and lookDelta).
looklook(input: InputState | null): Vec2The legacy look axis with sensitivity and inversion applied: [yaw, pitch] in -1..1, with the mouse folded in as a rate (so a flick is capped). Turn a view with {@link lookParts}.
actionaction(input: InputState | null, action: ActionName): ActionStateThe merged state of every source bound to action.
pressedpressed(input: InputState | null, action: ActionName): boolean
heldheld(input: InputState | null, action: ActionName): boolean
releasedreleased(input: InputState | null, action: ActionName): boolean