百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

gilrs

> 编程语言
开源

Rust 的游戏输入库 - https://GitLab.com/gilrs-project/gilrs 的镜像

184 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Rust 的游戏输入库 - https://GitLab.com/gilrs-project/gilrs 的镜像

GilRs - Game Input Library for Rust

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 IDs for new gamepads and reuse the 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

toml
[dependencies]
gilrs = "0.11.0"
…

Supported features

Input Hotplugging Force feedback
Linux/BSD (evdev) ✓ ✓ ✓
Windows ✓ ✓ ✓
OS X ✓ ✓ ✕
Wasm ✓ ✓ n/a
Android ✕ ✕ ✕

Platform specific notes

Linux/BSD (evdev)

With evdev, 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. On FreeBSD generic HID gamepads use hgame(4) and special use Linux driver via webcamd.

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

Windows

Windows defaults to using Windows Gaming Input instead of XInput. If you need to use XInput you can disable the wgi feature (it's enabled by default) and enable the xinput feature.

Windows Gaming Input requires an in focus window to be associated with the process to receive events. You can still switch back to using xInput by turning off default features and enabling the xinput feature.

Note: Some (Older?) devices may still report inputs without a window but this is not the case for all devices so if you are writing a terminal based game, use the xinput feature instead.

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().

See ./gilrs/examples/wasm/README.md for running the examples using Wasm.

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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustforce-feedbackgamepadinputjoystick

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言