[](https://github.com/fornwall/gamepads/actions/workflows/ci.yml)
[](https://docs.rs/gamepads/)
[](https://crates.io/crates/gamepads)
# gamepads
Gamepad input library in Rust, optionally as a [macroquad](https://github.com/not-fl3/macroquad) plugin.
- On desktop this is an abstraction on top of [gilrs](https://crates.io/crates/gilrs).
- On web this is a direct (not using `wasm-bindgen`) implementation on top of the [Gamepad API](https://www.w3.org/TR/gamepad/) exposed by browsers.
Add the dependency as:
```toml
[dependencies]
gamepads = "0.1.1"
```
See the [crate documentation](https://docs.rs/gamepads/latest/gamepads/) and the [hello-gamepads example](https://github.com/fornwall/gamepads/tree/main/examples/hello-gamepads) for documentation and sample code.
## On web, as a macroquad plugin
For non-web targets, nothing special needs to be done to use this library with [macroquad](https://github.com/not-fl3/macroquad).
For a web build to work properly, a small javascript plug-in needs to be registered in the page embedding the built wasm file:
```html
<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
<script src="https://fornwall.github.io/gamepads/macroquad-gamepads-0.1.js"></script>
<script>
load("your-wasm-file.wasm");
</script>
```
See the [hello-gamepads example](https://github.com/fornwall/gamepads/tree/main/examples/hello-gamepads).
# Feedback
Please [report any issues found](https://github.com/fornwall/gamepads/issues) or [discuss questions and ideas](https://github.com/fornwall/gamepads/discussions)!