Skip to main content
Inputs

Inputs

· 2 min read
Balaur

Input actions are declared in project.toml and can be rebound at run time. Gamepads have named buttons and axes, rumble and gyro, and the editor draws an input overlay.

  • action_value runs −1 to 1: a key answers 0 or 1, a stick or a key pair the whole range. action_pressed, action_just_pressed and action_just_released are the edges. input::bind rebinds an action and saves it to the user data directory, and reset_bindings restores the project's bindings.
  • input::gamepads() lists the pads. Every query takes a pad id and a named constant, PAD_SOUTH, AXIS_LEFT_STICK_X.
  • gamepad_rumble(pad, #{ strong, weak, duration }) runs the two motors. A PlayStation pad also reports gamepad_gyro, gamepad_acceleration and gamepad_touches, decoded from its HID reports over USB or Bluetooth.
  • The overlay draws a chip per key and button held, the actions they drive, and a ring per press. It reads the game's input snapshot, so in a replay the cursor follows the recording.
[input.actions]
jump = ["Space", "gamepad:South"]
move_x = ["keys:A,D", "axis:LeftStickX"]
fire = ["mouse:left"]

All of it lands in the recorded snapshot; a motion-controlled session replays. Input has the full surface.