#gamepad #joystick #input


Game Input Library for Rust

14 releases

0.6.1 Jul 18, 2018
0.6.0 Feb 11, 2018
0.5.2 Dec 30, 2017
0.5.1 Nov 12, 2017
0.3.1 Sep 23, 2016

#17 in Game engines

Download history 61/week @ 2018-09-20 190/week @ 2018-09-27 196/week @ 2018-10-04 166/week @ 2018-10-11 258/week @ 2018-10-18 108/week @ 2018-10-25 136/week @ 2018-11-01 145/week @ 2018-11-08 388/week @ 2018-11-15 323/week @ 2018-11-22 347/week @ 2018-11-29 71/week @ 2018-12-06 138/week @ 2018-12-13

1,336 downloads per month
Used in 1 crate


5.5K SLoC

GilRs - Game Input Library for Rust

pipeline status Crates.io Documentation

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.6.1"
use gilrs::{Gilrs, Button, Event};

let mut gilrs = Gilrs::new();

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

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

    // You can also use cached gamepad state
    if gilrs[0].is_pressed(Button::South) {
        println!("Button South is pressed (XBox - A, PS - X)");

Supported features

Input Hotplugging Force feedback
Windows (XInput)
Emscripten 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).


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.


~13K SLoC