Input actions and gamepads
· 2 min read
A game asks for "jump", not for Space. Actions are declared in
project.toml, bound to keys, buttons and sticks, and read as one snapshot
per frame.
What landed
- Actions.
action_valueis −1 to 1 — a key answers 0 or 1, a stick or a key pair the whole range — andaction_pressed,action_just_pressedandaction_just_releasedare the edges.input::bindrebinds an action and saves it to the user data directory;reset_bindingsgoes back to what the project declared. - Gamepads.
input::gamepads()lists the pads; every query takes a pad id and a named constant,PAD_SOUTH,AXIS_LEFT_STICK_X. - Rumble, gyro, touchpad.
gamepad_rumble(pad, #{ strong, weak, duration })runs the two motors. A PlayStation pad also reportsgamepad_gyro,gamepad_accelerationandgamepad_touches, decoded from its own HID reports over USB or Bluetooth. - The overlay. A chip per key and button held, the actions they drive, and a ring from every press. It reads the same snapshot the game reads, so during 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, so a motion-controlled session replays exactly. Input has the full surface.
