-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gamepad rumble support to bevy_input #8398
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually didn't know that f32 as u16
did round (therefore clamp) the value.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
GamepadRumbleRequest
event tobevy_input
and adds a system inbevy_gilrs
to read them and rumble controllers accordingly.It's a relatively primitive API with a
duration
in seconds andGamepadRumbleIntensity
with 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_input
and 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
GamepadRumbleRequest
event.