Skip to content

Commit a60338b

Browse files
committed
0.11 Section: Gamepad Rumble Support
Part of bevyengine#657
1 parent 84cab00 commit a60338b

File tree

1 file changed

+36
-7
lines changed
  • content/news/2023-07-07-bevy-0.11

1 file changed

+36
-7
lines changed

content/news/2023-07-07-bevy-0.11/index.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,42 @@ Since our last release a few months ago we've added a _ton_ of new features, bug
1515

1616
<!-- more -->
1717

18-
* **Feature**: description
19-
20-
## Feature
21-
22-
<div class="release-feature-authors">authors: @todo</div>
23-
24-
Description
18+
* **Gamepad Rumble API**: an ECS-friendly way of making controllers rumble
19+
20+
## Gamepad Rumble API
21+
22+
<div class="release-feature-authors">authors: @johanhelsing, @nicopap</div>
23+
24+
You can now use the `EventWriter<GamepadRumbleRequest>` system parameter to
25+
trigger controllers force-feedback motors.
26+
27+
[`gilrs`], the crate bevy uses for gamepad support, allows controlling
28+
force-feedback motors. Sadly, there were no easy way of accessing the
29+
force-feedback API in bevy without tedious bookkeeping.
30+
31+
Now bevy has the `GamepadRumbleRequest` event to do just that.
32+
33+
```rust
34+
fn rumble_system(
35+
gamepads: Res<Gamepads>,
36+
mut rumble_requests: EventWriter<GamepadRumbleRequest>,
37+
) {
38+
for gamepad in gamepads.iter() {
39+
rumble_requests.send(GamepadRumbleRequest::Add {
40+
gamepad,
41+
duration: Duration::from_secs(5),
42+
intensity: GamepadRumbleIntensity::MAX,
43+
});
44+
}
45+
}
46+
```
47+
48+
The `GamepadRumbleRequest::Add` event triggers a force-feedback motor,
49+
controlling how long the vibration should last, the motor to activate,
50+
and the vibration strength. `GamepadRumbleRequest::Stop` immediately stops all
51+
motors.
52+
53+
[`gilrs`]: https://crates.io/crates/gilrs
2554

2655
## <a name="what-s-next"></a>What's Next?
2756

0 commit comments

Comments
 (0)