Rust gamepad input library with a focus on ease of use.
```rust use gamepads::Gamepads;
fn main() { let mut gamepads = Gamepads::new();
loop {
gamepads.poll();
for gamepad in gamepads.all() {
println!("Gamepad id: {:?}", gamepad.id());
for button in gamepad.all_currently_pressed() {
println!("Pressed button: {:?}", button);
}
println!("Left thumbstick: {:?}", gamepad.left_stick());
println!("Right thumbstick: {:?}", gamepad.right_stick());
}
std::thread::sleep(std::time::Duration::from_millis(500));
} } ```
See the crate documentation and the examples for documentation and sample code.
wasm-bindgen
, allowing it to be used as a macroquad
pluginwasm-bindgen
by activating the features = ["wasm-bindgen"]
For non-web targets, nothing special needs to be done to use this library with macroquad
. But for a web build to work properly, two things needs to be done.
First, since macroquad
does not use wasm-bindgen
, that feature in gamepads needs to be turned off by setting default-features = false
:
toml
gamepads = { version = "*", default-features = false }
Instead a javascript plug-in needs to be registered in the page embedding the built wasm file:
```html
```
See the gamepads-macroquad example.
Please report any issues found or discuss questions and ideas!