All Projects → Arvamer → Gilrs

Arvamer / Gilrs

Licence: other
Game Input Library for Rust - Mirror of https://gitlab.com/gilrs-project/gilrs

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Gilrs

Unswitch
🕹 A tiny event handler for Switch controllers!
Stars: ✭ 574 (+608.64%)
Mutual labels:  gamepad, joystick, input
Key Mapper
🎮 An easy to use tool to change the mapping of your input device buttons.
Stars: ✭ 184 (+127.16%)
Mutual labels:  gamepad, input
Boipushy
Input module for LÖVE
Stars: ✭ 138 (+70.37%)
Mutual labels:  gamepad, input
stick
Platform-agnostic asynchronous gamepad, joystick and flightstick library for the Rust Programming Language
Stars: ✭ 41 (-49.38%)
Mutual labels:  joystick, gamepad
Hidguardian
Windows kernel-mode driver for controlling access to various input devices.
Stars: ✭ 138 (+70.37%)
Mutual labels:  gamepad, input
Vigem
Virtual Gamepad Emulation Framework
Stars: ✭ 225 (+177.78%)
Mutual labels:  gamepad, joystick
Segacontroller
Arduino library to read Sega Genesis (Mega Drive) and Master System (Mark III) controllers.
Stars: ✭ 55 (-32.1%)
Mutual labels:  gamepad, joystick
Vjoy
Virtual Joystick
Stars: ✭ 284 (+250.62%)
Mutual labels:  gamepad, joystick
input-event
🎹 Read and parse input device(like mouse, keyboard, joystick and IR-Remote)'s event data.
Stars: ✭ 45 (-44.44%)
Mutual labels:  input, joystick
joypad.js
JavaScript library that lets you connect and use various gaming controllers with browsers that support the Gamepad API. Less than 5KB in size with zero dependencies and support for button press, axis movement events and vibration play effect.
Stars: ✭ 97 (+19.75%)
Mutual labels:  joystick, gamepad
mi-360
Xbox360 controller emulation for Xiaomi Gamepad, with vibration support
Stars: ✭ 118 (+45.68%)
Mutual labels:  joystick, gamepad
Gainput
Cross-platform C++ input library supporting gamepads, keyboard, mouse, touch
Stars: ✭ 636 (+685.19%)
Mutual labels:  gamepad, input
Inputsystem
An efficient and versatile input system for Unity.
Stars: ✭ 1,013 (+1150.62%)
Mutual labels:  gamepad, input
Customui
Library to create custom UI's in MCPE 1.2+
Stars: ✭ 60 (-25.93%)
Mutual labels:  input
V Suggest
A Vue2 plugin for input content suggestions, support using keyboard to navigate and quick pick, it make use experience like search engine input element
Stars: ✭ 67 (-17.28%)
Mutual labels:  input
Awesomevalidation
Android validation library which helps developer boil down the tedious work to three easy steps.
Stars: ✭ 1,093 (+1249.38%)
Mutual labels:  input
Pc Optimization Hub
collection of various resources devoted to performance and input lag optimization
Stars: ✭ 55 (-32.1%)
Mutual labels:  input
Unijoystick
It is a powerful joystick component for UGUI.
Stars: ✭ 75 (-7.41%)
Mutual labels:  joystick
Autosize Input
🎈 Effortless, dynamic-width text boxes in vanilla JavaScript
Stars: ✭ 64 (-20.99%)
Mutual labels:  input
Svelte Input Mask
Input masking component for Svelte with simple API and rich customization
Stars: ✭ 56 (-30.86%)
Mutual labels:  input

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.

Example

[dependencies]
gilrs = "0.8.0"
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
Linux
Windows (XInput)
OS X
Wasm n/a
Android

Platform specific notes

Linux

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

Wasm implementation uses stdweb, or wasm-bindgen with the wasm-bindgen feature. For stdweb, you will need cargo-web to build gilrs for wasm32-unknown-unknown. For wasm-bindgen, you will need the wasm-bindgen cli or a tool like wasm-pack. Unlike other platforms, events are only generated when you call Gilrs::next_event().

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].