Scale input to account for deadzones#17015
Conversation
|
I can't work on fixing the unit tests until this is fixed: |
alice-i-cecile
left a comment
There was a problem hiding this comment.
I agree that this is the right default behavior. Otherwise setting a deadzone makes it very hard / impossible to get small directional inputs.
This PR needs a bit of cleanup still. It would be particularly helpful to cleanup the tests: right now, the values just look like magic numbers. Maybe we should add some algebra + consts inside of the Some arms?
|
For the alloc error, I think you need to fix the feature flags in a new PR. @bushrat011899, FYI. |
He's already got that fixed in the no_std bevy_input PR. |
|
Can confirm I have this issue resolved in the |
3eac744 to
91be8f2
Compare
|
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
|
Let's do a quick migration guide noting this change (since it's otherwise surprising), but this LGTM now. Good work on the tests; I like the balance you struck. |
2a41eee to
207b9ae
Compare
|
Sorry for the noise. I realized that I could make the implementation and test data cleaner by storing the raw values in the gamepad, which means the old values will be raw values. Everything is very optimal now, imo. |
…to scaled-deadzones
|
Migration guide made me realize the doc comment should be improved. Both are done now. |
alice-i-cecile
left a comment
There was a problem hiding this comment.
I like the latest changes, and particularly appreciate the comments on the tests.
Shatur
left a comment
There was a problem hiding this comment.
Looks good to me! Left a few small suggestions.
Personally, I think deadzone is a more high-level functionality and should be handled by input managers🤔 But since we already have this feature, it's definitely an improvement!
I handle deadzones in the same way in the bevy_enhanced_input library.
Agreed. In the medium term, I think this functionality should be removed from bevy_input and moved up a level. But until we have a first party input manager / action crate we're blocked there. |
|
I think deadzones and scaling are good here because they address hardware limitations. Before then, the events are "raw". The part I would move into another crate is actually the clamping/rounding. Those are more about what "feels right". But then again, the same applies for the press/release/change thresholds, and I don't think those can be moved out. |
|
I would consider We on the same page with @alice-i-cecile, this PR is good. |
|
I'm choosing to not split up the unit test. It can be done as an improvement in a separate PR if someone would like. :) |
# Objective Fixes bevyengine#3450 ## Solution Scale the input to account for the range ## Testing Updated unit tests ## Migration Guide `GamepadButtonChangedEvent.value` is now linearly rescaled to be from `0.0..=1.0` (instead of `low..=high`) and `GamepadAxisChangedEvent.value` is now linearly rescaled to be from `-1.0..=0.0`/`0.0..=1.0` (accounting for the deadzone).
Objective
Fixes #3450
Solution
Scale the input to account for the range
Testing
Updated unit tests
Migration Guide
GamepadButtonChangedEvent.valueis now linearly rescaled to be from0.0..=1.0(instead oflow..=high) andGamepadAxisChangedEvent.valueis now linearly rescaled to be from-1.0..=0.0/0.0..=1.0(accounting for the deadzone).