Skip to content

Search

Volver
· 2 min de lectura

Inputs

Input actions rebound at run time, gamepads, rumble, gyro and an input overlay.

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_down, 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, GAMEPAD_BUTTON_SOUTH, GAMEPAD_AXIS_LEFT_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.
  • Rumble also takes delay, pulse and gap, an attack and fade envelope, and a position that fades with distance from gamepad_set_listener. on_gamepad_rumble_finished fires when one ends.
  • Pad ids are player slots from 0, and a pad plugged back in gets its slot again. [input] gamepad_deadzone, gamepad_press and gamepad_release shape every pad alike; gamepad_pressure, gamepad_repeated, gamepad_info and gamepad_power read the rest.
  • input::feed_gamepad stands in for a pad, so a test drives one with no controller attached.
  • Pads are read on a thread of their own, so a driver that hangs, as Windows Gaming Input can after sleep, stops the pads and not the game.
  • 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:KeyA,KeyD", "axis:left_x"]
fire = ["mouse:left"]

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

¿Seguro?