Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Gamepad

You can get a handle to the gamepad input state with gamepad::input(). With this, you can get an iterator of the connected gamepads and their IDs with gamepad::input().gamepads().

Using a Gamepad, which can also be obtained from gamepad::input().gamepad(id), you can query the state of the buttons and sticks using the methods on the Gamepad struct.

Importantly:

  • .right_stick, .left_stick, and .d_pad for getting the input of sticks/dpad as a vector.
  • .is_pressed for checking if a gamepad::Button is pressed

See: gamepad module

See also: /examples/gamepad.rs for an example on how to use the API, and to test if your controller is being recognised properly.