-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Add Gamepads resource #3257
Conversation
Looks great! Thanks for tackling this :) I would like to see some basic docs, since this is part of the public API now, but otherwise this LGTM. |
I've added the |
Thinking about this a bit further, I think that |
Great! You have my approval :) @CrazyRoka, you should click "Resolve Comment" on the comments that I've left so this PR's state is easier to follow for future reviewers. |
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.
I don't really like the name GamepadLobby, but I can't figure out anything better either. Otherwise, looks good to me.
@alice-i-cecile @MinerSebas Can you review my updates? |
crates/bevy_input/src/gamepad.rs
Outdated
/// | ||
/// [Gamepad]s are registered and deregistered in [gamepad_connection_system] | ||
pub struct GamepadLobby { | ||
pub gamepads: HashSet<Gamepad>, |
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 is an implementation detail that we shouldn't expose directly to users (who could accidentally remove "active" gamepad and break guarantees that this list contains "active" gamepads). Instead, lets make this private and implement a method like GamepadLobby::contains(index: usize)
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.
Eh actually we should probably accept the Gamepad
type for consistency with other apis, but I think we should consider making the index private to encourage people to treat Gamepad
as an opaque type that must be queried for. And if we don't want that behavior (and want user-specified ids to be a part of our api), then we should consider removing the Gamepad
wrapper type.
Also, lets add GamepadLobby::iter()
so users can iterate active gamepads.
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.
- Made this field private
- Added
contains(gamepad: Gamepad)
method - Added
iter()
method - Replaced usages with these methods
- Added
register
andderegister
private methods
crates/bevy_input/src/gamepad.rs
Outdated
/// Container of unique connected [Gamepad]s | ||
/// | ||
/// [Gamepad]s are registered and deregistered in [gamepad_connection_system] | ||
pub struct GamepadLobby { |
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.
I agree that GamepadLobby isn't the best name for this. Lets use the more descriptive ActiveGamepads
unless someone can think of something 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.
Or maybe just Gamepads
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.
Yeah I like Gamepads more because it is terser
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.
Renamed it to Gamepads
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
bors r+ |
Canceled. |
bors r+ |
# Objective Fixes #3245 ## Solution - Move GamepadLobby to lib - Add connection_system to InputPlugin - Updated gamepad_input example Co-authored-by: CrazyRoka <rokarostuk@gmail.com> Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Build failed: |
bors r+ |
# Objective Fixes #3245 ## Solution - Move GamepadLobby to lib - Add connection_system to InputPlugin - Updated gamepad_input example Co-authored-by: CrazyRoka <rokarostuk@gmail.com> Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Objective
Fixes #3245
Solution