#gamedev #joystick #input #gamepad #macroquad


Library to access information about connected gamepads

7 releases

new 0.1.6 Sep 19, 2023
0.1.5 Sep 19, 2023

#421 in Game dev

Download history 7/week @ 2023-09-09 159/week @ 2023-09-16

166 downloads per month


564 lines

CI Docs Crates.io version


Rust gamepad input library with a focus on ease of use.

use gamepads::Gamepads;

fn main() {
    let mut gamepads = Gamepads::new();

    loop {

        for gamepad in gamepads.all() {
            println!("Gamepad id: {:?}", gamepad.id());
            for button in gamepad.all_currently_pressed() {
                println!("Pressed button: {:?}", button);
            println!("Left thumbstick: {:?}", gamepad.left_stick());
            println!("Right thumbstick: {:?}", gamepad.right_stick());


See the crate documentation and the examples for documentation and sample code.

What it is

  • On desktop this library is implemented on top of gilrs.
  • On web this is implemented on top of the Gamepad API exposed by browsers, including support for haptic feedback (aka "dual rumble" or "force feedback").
    • It can be used in a wasm-bindgen-using project without any setup necessary.
    • It can be used without wasm-bindgen (by specifying default-features = false), allowing it to be used as a macroquad plugin (see more below) or in a direct wasm build (example).

How to use as a macroquad plugin

For non-web targets, nothing special needs to be done to use this library with macroquad. But for a web build to work properly, two things needs to be done.

First, since macroquad does not use wasm-bindgen, that feature in gamepads needs to be turned off by setting default-features = false:

gamepads = { version = "*", default-features = false }

Second, a javascript plug-in (source) needs to be registered in the page embedding the built wasm file:

<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
<script src="https://fornwall.github.io/gamepads/js/macroquad-gamepads-0.1.js"></script>

See the gamepads-macroquad example.


Please report any issues found or discuss questions and ideas!


~73K SLoC