-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Rescale Axis and Button value to avoid compression #3464
Rescale Axis and Button value to avoid compression #3464
Conversation
I'll update the test later today |
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 pretty nice! I have one nitpick, and a weird edge case to consider
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.
This looks really good! Just one question for you
crates/bevy_input/src/gamepad.rs
Outdated
}; | ||
|
||
if let Some(old_value) = old_value { | ||
if (new_value - old_value).abs() <= self.threshold { | ||
if (new_value >= 0.0 |
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.
This needs more comments, or a simpler approach.
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.
Tried to split this into several smaller functions. Is that better?
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.
Two changes:
- Add
inline
annotations to the added methods. - The changes on line 203 are far too complex; this needs more comments or preferably structure.
@thibaudio, you can mark comments as resolved by pressing the "Resolve comment" button once they're addressed, which makes it easier for reviewers.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Thanks for the review @alice-i-cecile |
This refactor is definitely an improvement! Spending some time thinking about this, I think the most natural way to model and communicate this in Rust would actually be with: enum AxisPosition {
BelowLowZone,
LowZone,
DeadZone,
HighZone,
AboveHighZone,
} I think that if we start there, we can make this code much easier to read and refactor in the future. Does that make sense to you? |
Thanks for your feedback @alice-i-cecile!
|
Yes, that's lovely! |
After toying with that, changing the return type of the |
Thanks for letting us know. I'll see about making a PR to your branch with the changes :) |
Objective
Fixes #3450
Solution
Apply the suggested solution to both
AxisSettings
positive/negative values andButtonAxisSettings