-
-
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
Add some missing features from the gamepads-as-entities change that were needed to update leafwing-input-manager
.
#15685
Conversation
needed to update `leafwing-input-manager`. The gamepads-as-entities change caused several regressions. This patch fixes each of them: 1. After that PR, there was no stable unique identifier available for gamepads. To fix this, this PR introduces several new fields on `GamepadInfo`: `uuid`, `vendor_id`, and `product_id`, as well as associated methods. These fields are simply mirrored from the `gilrs` library. The UUID is the preferred way to identify gamepads across app invocations. 2. That PR removed the methods that allowed iterating over all pressed and released buttons, as well as the method that allowed iterating over the axis values. (It was still technically possible to do so by using reflection to access the private fields of `Gamepad`.) 3. The `Gamepad` component wasn't marked reflectable. This PR fixes that problem. These changes allowed me to forward port `leafwing-input-manager`.
ed9b2e7
to
b44a95f
Compare
@s-puig can I get your review here? |
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 to me! Just a mild bikeshed-style question around whether these methods should be named iter_x
instead of get_x
.
/// Returns an iterator over all digital [button]s that are pressed. | ||
/// | ||
/// [button]: GamepadButton | ||
pub fn get_pressed(&self) -> impl Iterator<Item = &GamepadButton> { |
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.
Non-blocking bikeshed question: Should these iterator methods instead be called iter_pressed
, iter_just_pressed
etc.?
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 should be consistent with the ButtonInput API: https://docs.rs/bevy/latest/bevy/input/struct.ButtonInput.html#method.
I do think this might be nice to change, but it should be done all at once.
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.
Perfectly reasonable!
…ere needed to update `leafwing-input-manager`. (#15685) The gamepads-as-entities change caused several regressions. This patch fixes each of them: 1. After that PR, there was no stable unique identifier available for gamepads. To fix this, this PR introduces several new fields on `GamepadInfo`: `uuid`, `vendor_id`, and `product_id`, as well as associated methods. These fields are simply mirrored from the `gilrs` library. The UUID is the preferred way to identify gamepads across app invocations. 2. That PR removed the methods that allowed iterating over all pressed and released buttons, as well as the method that allowed iterating over the axis values. (It was still technically possible to do so by using reflection to access the private fields of `Gamepad`.) 3. The `Gamepad` component wasn't marked reflectable. This PR fixes that problem. These changes allowed me to forward port `leafwing-input-manager`.
Uuid isn't Reflect, so we either need to ignore it for Reflection or do some remote reflect nonsense. I vote the former, but actually the latter may be needed for serialization. |
It should be? Might need to add the feature? |
I will take a proper look later, but we should avoid |
@s-puig Do you want me to not expose the UUID entirely or just stop recommending it? |
I would rather not expose it. It's just that broken. |
Most of the work here was fallout from the gamepads-as-entities change (bevyengine/bevy#12770), as well as the `PartialReflect` changes. This relies on bevyengine/bevy#15685. That PR must be applied to Bevy for this to build. The most recent upstream commit is 4bf647ff3b0ca7c8ca47496db9cfe03702328473.
Most of the work here was fallout from the gamepads-as-entities change (bevyengine/bevy#12770), as well as the `PartialReflect` changes. This relies on bevyengine/bevy#15685. That PR must be applied to Bevy for this to build. The most recent upstream commit is 4bf647ff3b0ca7c8ca47496db9cfe03702328473.
* Upgrade to Bevy 0.15.0-dev. Most of the work here was fallout from the gamepads-as-entities change (bevyengine/bevy#12770), as well as the `PartialReflect` changes. This relies on bevyengine/bevy#15685. That PR must be applied to Bevy for this to build. The most recent upstream commit is 4bf647ff3b0ca7c8ca47496db9cfe03702328473. * Switch to upstream AccumulatedFoo * Try (unsuccessfully) to fix the failing tests * Bumps bevy_egui requirement from 0.30 to 0.31 * Sets bevy requirement to 0.15.0 * Replaces deprecated SpriteBundle * Applies system ordering suggestion * Use AccumulatedMouseScroll and AccumulatedMouseMotion from bevy * Fixes merge issues * Runs formatter * Gets button value from SpecificGamepadButton * Ignores tests * Fixes compilation issues * Fixes docs --------- Co-authored-by: Patrick Walton <pcwalton@mimiga.net>
The gamepads-as-entities change caused several regressions. This patch fixes each of them:
This PR introduces two new fields on
GamepadInfo
:vendor_id
, andproduct_id
, as well as associated methods. These fields are simply mirrored from thegilrs
library.That PR removed the methods that allowed iterating over all pressed and released buttons, as well as the method that allowed iterating over the axis values. (It was still technically possible to do so by using reflection to access the private fields of
Gamepad
.)The
Gamepad
component wasn't marked reflectable. This PR fixes that problem.These changes allowed me to forward port
leafwing-input-manager
.