Add gamepad rumble support to bevy_input#8398
Add gamepad rumble support to bevy_input#8398alice-i-cecile merged 57 commits intobevyengine:mainfrom
Conversation
This adds the `RumbleRequest` event and a system to read them and rumble controllers accordingly. It gives users two ways of controlling controller rumble: 1. A very primitive API with `RumbleIntensity` that is easy to understand and use. 2. A direct access to the girls `ff::Effect` system for complete fine-grained control over how the gamepad rumbles.
Conflicts: crates/bevy_gilrs/Cargo.toml crates/bevy_gilrs/src/lib.rs crates/bevy_gilrs/src/rumble.rs examples/README.md examples/input/gamepad_rumble.rs
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
|
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
non-wasm, for now
nicopap
left a comment
There was a problem hiding this comment.
Looks good, just need to adjust the clamping and IMO it's good to go.
Co-authored-by: Nicola Papale <nicopap@users.noreply.github.com>
nicopap
left a comment
There was a problem hiding this comment.
I actually didn't know that f32 as u16 did round (therefore clamp) the value.
LGTM
alice-i-cecile
left a comment
There was a problem hiding this comment.
We need to clamp in to_gilrs_magnitude still. Once that's resolved, this LGTM and I'll merge!
How so? As far as i understand it shouldn't be needed: rust-lang/rust#71269 Or do you mean for clarity of intent? |
Co-authored-by: Bruce Reif (Buswolley) <bruce.reif@dynata.com>
|
Ah, TIL. Can we add tests for it instead then? |
There already are some ;) |
|
I think a single line comment on the |
Objective
Provide the ability to trigger controller rumbling (force-feedback) with a cross-platform API.
Solution
This adds the
GamepadRumbleRequestevent tobevy_inputand adds a system inbevy_gilrsto read them and rumble controllers accordingly.It's a relatively primitive API with a
durationin seconds andGamepadRumbleIntensitywith values for the weak and strong gamepad motors. It's is an almost 1-to-1 mapping to platform APIs. Some platforms refer to these motors as left and right, and low frequency and high frequency, but by convention, they're usually the same.I used #3868 as a starting point, updated to main, removed the low-level gilrs effect API, and moved the requests to
bevy_inputand exposed the strong and weak intensities.I intend this to hopefully be a non-controversial cross-platform starting point we can build upon to eventually support more fine-grained control (closer to the gilrs effect API)
Changelog
Added
GamepadRumbleRequestevent.