-
-
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
Improved Axis API #684
Improved Axis API #684
Conversation
e696e7d
to
dd4b37b
Compare
2b8b496
to
e6e727e
Compare
I'm a little hesitant about this one. If there are multiple "axis input events" in the same update, that would result in some of the delta being missed. I also think most axis use cases use absolute values / don't require deltas (ex: "how fast should I move this thing" and "is this axis past a certain threshold"), so I think I'm fine letting the user track this themselves. For use cases that need to track "did something happen since the last time we ran", I think exposing the axis events in an Events queue is a more generic approach. |
Actually the delta would be the sum of all the deltas
Events seems like a good approach to solve this problem. I shall open a new PR with Closing because it's redundant |
I don't thats true. If there are two EventType::AxisChanged events processed in the same frame (lets say with original value 0, new1 == 0.5, new2 == 0.75), this is what I'm pretty sure happens:
|
it would be previous() = 0, current() = 0.75 and delta() = 0.75
Whatever the case, the event approach looks better |
Oops yeah you're right. Thanks for bearing with me 😄 |
Added functions to get current value, previous value and delta value of
Axis<T>
previous value means the value before calling
Axis<T>::update
and current value means the value after callingAxis<T>::update
. delta value is the difference between current and previous values and it can be0.0f32
. delta would beNone
when axis' value is not set after callingAxis<T>::update
This will help to detect actual changes to axis value by the caller system easily, like in the updated
gamepad_input
example.The other way is to approx compare delta with
0.0f32
but that's tiring (see the first commit)