-
-
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
Added gamepad support using Gilrs #280
Conversation
3f3d604
to
2114a18
Compare
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.
First, thanks! This looks fantastic and I'm going to try it out more in a personal project this weekend.
Second, some feedback! I tested this out on macOS. It appears to mostly work as advertised. I've only casually skimmed through the code, so don't consider this a thorough review. Here's what I noticed:
- gilrs support on macOS is incomplete. If there isn't a better alternative, investing in contributions to gilrs may be necessary to gain feature parity across the OS's Bevy supports.
- Most importantly, the dpad isn't yet supported since gilrs doesn't yet support hat events on macOS.
- Force feedback is not supported
- Power information is not supported
RightZ
andLeftZ
axes were not detected, thoughRightTrigger2
andLeftTrigger2
buttons worked fine. So the analog portion of triggers isn't working -- this might be another macOS difference, but I haven't been able to confirm that yet, which is why it isn't included above as a sub-item.- I quite like the overall design of the separate Bevy gamepad layer vs the gilrs driver layer.
- Notwithstanding the previous point, I suggest that
bevy_gilrs
be refactored into a submodule ofbevy_input
. I don't think the gilrs part even needs to bepub
, much less be in the top-level. - This appears to add about 14 dependencies on macOS, based off of a quick comparison of the number of crates compiled during
cargo run --example gamepad_input
on this branch vscargo run --example keyboard_input
on master. Is that an okay amount of dependencies to add for the one-time portion of compiling? I don't have a suggestion here, I'm just asking the question. (I'm guessing yes, it's okay.)
Finally, gilrs
is a terrible name because Google autocorrects it to "girls" and gives you irrelevent results. 😝
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 think this is ready to go as soon as we merge #227 and update this.
@cart If gilrs seems heavy, then there is gilrs-core. However we have to implement a high amount of gilrs code in bevy but that would give us the flexibility to implement that in a way most suitable for bevy. |
c0013a4
to
c9ef1ab
Compare
i think using the We can pare it down later if we need to. |
FYI, I've been playing with this branch on a little project and it is working pretty well. I've almost got a patch for gilrs dpad support on mac working--I've plumbed a response all the way through to Bevy, but I've still got to differentiate the directions. @simpuid The force pushes after my review make it difficult for me to tell exactly what changed since the last time I reviewed the code without reading the entire pull request again. 😢 I'll look for some time to re-review later this week. |
I was following the 1 commit per PR rule, sorry I should have squashed the commits at the end of the merge. The changes I have made are:
I think we can merge this PR after rebasing it over the 'Axis API` PR. After that we can focus on controller rumble feature. |
I think I'm just going to merge this directly, rather than merging the axis pr. I'm not super convinced we should throw mouse state into the axis api. I'd prefer it if we can make the assumption that an axis is normalized to |
Alright then, do you have any suggestions for the |
I dont think it needs to be fancy for now. If anything, I think we might want to remove the |
I want this in the |
There is no |
Co-authored-by: Carter Anderson <[email protected]>
Implements #94
Partially implements/uses a temporary implementation for #59
I have added crate
bevy_gilrs
which contains the system to:Event<GamepadEvent>
Input<GamepadButton>
Axis<GamepadAxis>
Added a temporary implementation of
Axis<T>
as there are other PRs open for that. (I will rebase this PR after they are merged or should I implement them here?)Added
Gamepad
,GamepadButton
,GamepadAxis
,GamepadEvent
,GamepadEventType
,ButtonCode
andAxisCode
to cratebevy_input
. These structs are exposed to the user. These structs are modified/generated using the systems insidebevy_gilrs
.Suggestions Needed:
gilrs::Gilrs
struct implements!Send
, so I wrapped it inside anArc<Mutex<T>>
and implements Send unsafely. Are there any other approach to addgilrs::Gilrs
as aResource
?Check the example
examples/input/gamepad_input.rs
for usage.Note: Need more polish before merge(comments), until then, review it.