From a60338bf1e18b9066f006d88257d4ef08b44291b Mon Sep 17 00:00:00 2001 From: Nicola Papale Date: Sun, 2 Jul 2023 16:24:44 +0200 Subject: [PATCH 1/2] 0.11 Section: Gamepad Rumble Support Part of #657 --- content/news/2023-07-07-bevy-0.11/index.md | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/content/news/2023-07-07-bevy-0.11/index.md b/content/news/2023-07-07-bevy-0.11/index.md index 3d0bc99389..90456d8a26 100644 --- a/content/news/2023-07-07-bevy-0.11/index.md +++ b/content/news/2023-07-07-bevy-0.11/index.md @@ -15,13 +15,42 @@ Since our last release a few months ago we've added a _ton_ of new features, bug -* **Feature**: description - -## Feature - -
authors: @todo
- -Description +* **Gamepad Rumble API**: an ECS-friendly way of making controllers rumble + +## Gamepad Rumble API + +
authors: @johanhelsing, @nicopap
+ +You can now use the `EventWriter` system parameter to +trigger controllers force-feedback motors. + +[`gilrs`], the crate bevy uses for gamepad support, allows controlling +force-feedback motors. Sadly, there were no easy way of accessing the +force-feedback API in bevy without tedious bookkeeping. + +Now bevy has the `GamepadRumbleRequest` event to do just that. + +```rust +fn rumble_system( + gamepads: Res, + mut rumble_requests: EventWriter, +) { + for gamepad in gamepads.iter() { + rumble_requests.send(GamepadRumbleRequest::Add { + gamepad, + duration: Duration::from_secs(5), + intensity: GamepadRumbleIntensity::MAX, + }); + } +} +``` + +The `GamepadRumbleRequest::Add` event triggers a force-feedback motor, +controlling how long the vibration should last, the motor to activate, +and the vibration strength. `GamepadRumbleRequest::Stop` immediately stops all +motors. + +[`gilrs`]: https://crates.io/crates/gilrs ## What's Next? From 5353b7efffdfadcd9f3a8c51d44f80e02d283a07 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Thu, 6 Jul 2023 19:39:15 -0700 Subject: [PATCH 2/2] Formatting tweaks --- content/news/2023-07-07-bevy-0.11/index.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/content/news/2023-07-07-bevy-0.11/index.md b/content/news/2023-07-07-bevy-0.11/index.md index 90456d8a26..bc19e75d82 100644 --- a/content/news/2023-07-07-bevy-0.11/index.md +++ b/content/news/2023-07-07-bevy-0.11/index.md @@ -24,11 +24,11 @@ Since our last release a few months ago we've added a _ton_ of new features, bug You can now use the `EventWriter` system parameter to trigger controllers force-feedback motors. -[`gilrs`], the crate bevy uses for gamepad support, allows controlling +[`gilrs`], the crate Bevy uses for gamepad support, allows controlling force-feedback motors. Sadly, there were no easy way of accessing the -force-feedback API in bevy without tedious bookkeeping. +force-feedback API in Bevy without tedious bookkeeping. -Now bevy has the `GamepadRumbleRequest` event to do just that. +Now Bevy has the `GamepadRumbleRequest` event to do just that. ```rust fn rumble_system( @@ -47,8 +47,7 @@ fn rumble_system( The `GamepadRumbleRequest::Add` event triggers a force-feedback motor, controlling how long the vibration should last, the motor to activate, -and the vibration strength. `GamepadRumbleRequest::Stop` immediately stops all -motors. +and the vibration strength. `GamepadRumbleRequest::Stop` immediately stops all motors. [`gilrs`]: https://crates.io/crates/gilrs