21 releases

0.7.4 Feb 6, 2020
0.7.3 Nov 30, 2019
0.7.2 Aug 6, 2019
0.7.1 Mar 4, 2019
0.3.1 Sep 23, 2016

#7 in Game development

Download history 1190/week @ 2019-12-10 673/week @ 2019-12-17 544/week @ 2019-12-24 810/week @ 2019-12-31 1668/week @ 2020-01-07 1180/week @ 2020-01-14 1448/week @ 2020-01-21 900/week @ 2020-01-28 784/week @ 2020-02-04 909/week @ 2020-02-11 864/week @ 2020-02-18 729/week @ 2020-02-25 865/week @ 2020-03-03 1366/week @ 2020-03-10 1519/week @ 2020-03-17 784/week @ 2020-03-24

3,740 downloads per month
Used in 17 crates (9 directly)


7.5K SLoC

GilRs - Game Input Library for Rust

pipeline status Crates.io Documentation Minimum rustc version

Documentation (master)

GilRs abstract platform specific APIs to provide unified interfaces for working with gamepads.

Main features:

  • Unified gamepad layout—buttons and axes are represented by familiar names
  • Support for SDL2 mappings including SDL_GAMECONTROLLERCONFIG environment variable which Steam uses
  • Hotplugging—GilRs will try to assign new ID for new gamepads and reuse same ID for gamepads which reconnected
  • Force feedback (rumble)
  • Power information (is gamepad wired, current battery status)

The project's main repository is on GitLab although there is also a GitHub mirror. Please use GitLab's issue tracker and merge requests.

This repository contains submodule; after you clone it, don't forget to run git submodule init; git submodule update (or clone with --recursive flag) or you will get compile errors.


gilrs = "0.7.2"
use gilrs::{Gilrs, Button, Event};

let mut gilrs = Gilrs::new().unwrap();

// Iterate over all connected gamepads
for (_id, gamepad) in gilrs.gamepads() {
    println!("{} is {:?}", gamepad.name(), gamepad.power_info());

let mut active_gamepad = None;

loop {
    // Examine new events
    while let Some(Event { id, event, time }) = gilrs.next_event() {
        println!("{:?} New event from {}: {:?}", time, id, event);
        active_gamepad = Some(id);

    // You can also use cached gamepad state
    if let Some(gamepad) = active_gamepad.map(|id| gilrs.gamepad(id)) {
        if gamepad.is_pressed(Button::South) {
            println!("Button South is pressed (XBox - A, PS - X)");

Supported features

Input Hotplugging Force feedback
Windows (XInput)
Wasm n/a

Platform specific notes


On Linux, GilRs read (and write, in case of force feedback) directly from appropriate /dev/input/event* file. This mean that user have to have read and write access to this file. On most distros it shouldn't be a problem, but if it is, you will have to create udev rule.

To build GilRs, you will need pkg-config and libudev .pc file. On some distributions this file is packaged in separate archive (for example libudev-dev in Debian).


Wasm implementation uses stdweb, so you will need cargo-web to build gilrs for wasm32-unknown-unknown. Unlike other platforms, events are only generated when you call Gilrs::next_event().


This project is licensed under the terms of both the Apache License (Version 2.0) and the MIT license. See LICENSE-APACHE and LICENSE-MIT for details.


~20K SLoC