close
Skip to content

bevy_input: fix repeated gamepad events#1221

Merged
cart merged 1 commit into
bevyengine:masterfrom
jakobhellermann:fix-gamepad-threshold
Jan 7, 2021
Merged

bevy_input: fix repeated gamepad events#1221
cart merged 1 commit into
bevyengine:masterfrom
jakobhellermann:fix-gamepad-threshold

Conversation

@jakobhellermann
Copy link
Copy Markdown
Contributor

Previously, if the actual value of LeftStickX was e.g. 0.034 and fluctuated a little
bit (less than the threshold) it would repeatedly send out events,
because it compared the value to the filtered old one - 0.0 - which is
more then 0.01 (the threshold) away.

The is fixed by first doing the deadzone and then comparing to the old
value.
Another possible solution would be to store both the actual old value
and the filtered one, but that would add complexity.

Copy link
Copy Markdown
Member

@cart cart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me!

Comment thread crates/bevy_input/src/gamepad.rs Outdated
Previously, if the actual value of LeftStickX was e.g. 0.034 and fluctuated a little
bit (less than the threshold) it would repeatedly send out events,
because it compared the value to the *filtered* old one - 0.0 - which is
more then `0.01` (the threshold) away.

The is fixed by first doing the deadzone and then comparing to the old
value.
Another possible solution would be to store both the actual old value
and the filtered one, but that would add complexity.
@cart cart merged commit 599f381 into bevyengine:master Jan 7, 2021
rparrett pushed a commit to rparrett/bevy that referenced this pull request Jan 27, 2021
Previously, if the actual value of LeftStickX was e.g. 0.034 and fluctuated a little
bit (less than the threshold) it would repeatedly send out events,
because it compared the value to the *filtered* old one - 0.0 - which is
more then `0.01` (the threshold) away.

The is fixed by first doing the deadzone and then comparing to the old
value.
Another possible solution would be to store both the actual old value
and the filtered one, but that would add complexity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants