9 releases (breaking)

✓ Uses Rust 2018 edition

0.7.1 Jul 18, 2019
0.6.0 May 13, 2019
0.4.1 Aug 5, 2018
0.4.0 May 24, 2018
0.3.0 Feb 4, 2018

#20 in Hardware support

Download history 16/week @ 2019-04-03 5/week @ 2019-04-10 8/week @ 2019-04-24 11/week @ 2019-05-01 26/week @ 2019-05-08 13/week @ 2019-05-15 45/week @ 2019-05-22 6/week @ 2019-05-29 15/week @ 2019-06-05 17/week @ 2019-06-12 27/week @ 2019-06-19 70/week @ 2019-06-26 45/week @ 2019-07-03 27/week @ 2019-07-10

105 downloads per month
Used in 8 crates (2 directly)

MIT / BSL-1.0

41KB
890 lines

Stick

About

Stick is a cross-platform Rust library for getting joystick, gamepad, or other controller input.

Features

  • Asynchronously get events from multiple joysticks on one thread, joystick state shared via atomics to the other threads.
  • Get controller input (Linux)
  • Remap controller input (Linux)
  • Connect to multiple controllers (Linux)
  • CONTROLLER: GameCube controllers (with MAYFLASH adapter)
  • CONTROLLER: Flight simulator joystick
  • CONTROLLER: XBox controller
  • CONTROLLER: PlayStation controller

Getting Started

// jstest.rs
use stick::Port;

fn main() {
    // Connect to all devices.
    let mut port = Port::new();

    // Loop showing state of all devices.
    loop {
        // Cycle through all currently plugged in devices.
        let id = if let Some(a) = port.poll() {
            a
        } else {
            continue;
        };

        if let Some(state) = port.get(id) {
            println!("{}: {}", id, state);
        }
    }
}

TODO

  • Better haptic (vibration) support
  • CONTROLLER: Emulated joystick
  • CONTROLLER: Probably some other controllers
  • PLATFORM: Windows
  • PLATFORM: MacOS
  • PLATFORM: Android
  • PLATFORM: Nintendo switch

Links

No runtime deps