Skip to content
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] - Support for additional gamepad buttons and axis #5853

Closed
wants to merge 2 commits into from

Conversation

fishykins
Copy link
Contributor

Objective

Extend the scope of Gamepad to accommodate devices that have more inputs than a typical controller.

Solution

Add additional enum variants to both GamepadButtonType and GamepadAxisType that supports up to 255 more non-standard buttons/axis respectively.

Personal motivation

I have been writing an alternative to the GILRS crate, and with this simple change to the source code, It will be a trivial thing to direct new devices through the bevy systems, even when they do not always behave exactly like your typical controller.

@mockersf mockersf added the A-Input Player input via keyboard, mouse, gamepad, and more label Sep 1, 2022
Copy link
Contributor

@djeedai djeedai left a comment

Choose a reason for hiding this comment

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

Change looks good a priori, but I'd like @alice-i-cecile to have a look with the leafwing-input-manager experience, see if we're not missing anything by adding those extra buttons that way. Like, if we just add enum values but never use them in any built-in Bevy input system, who's going to use them? I assume the inputs gathered by Bevy internally will never return those new values. So how are those new buttons and axes ever triggered?

@@ -276,6 +276,9 @@ pub enum GamepadButtonType {
DPadLeft,
/// The right button of the D-Pad.
DPadRight,

/// Miscellaneous buttons, considered non-standard (i.e. Extra buttons on a flight stick that do not have a gamepad equivalent).
Button(u8),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not name that one Other like the axis one? It's a little confusing, as the other values in the enum are also buttons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if that makes more sense then that's totally fine, will switch it over.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Sep 1, 2022

So how are those new buttons and axes ever triggered?

My view is that this will be triggered a) synthetically or b) via gilrs like extension libraries for weird hardware.

This PR's approach should work seamlessly on the leafwing-input-manager side, although I'd also be open to eventually integrating "weird hardware" libraries more directly and adding more custom enum variants once that work has stabilized.

Alternatively, it may end up being correct to provide a collection of traits and let crates like bevy_gilrs and bevy_winit define the interface there for true extensibility, but I'd want to benchmark latency there and it's a much more involved refactor. This hits a sweet spot of "dead simple to implement but unblocks interesting use cases".

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Once Button -> Other has been changed, this LGTM and can be merged.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot pushed a commit that referenced this pull request Sep 2, 2022
# Objective

Extend the scope of Gamepad to accommodate devices that have more inputs than a typical controller.

## Solution

Add additional enum variants to both _GamepadButtonType_ and _GamepadAxisType_ that supports up to 255 more non-standard buttons/axis respectively. 

## Personal motivation

I have been writing an alternative to the GILRS crate, and with this simple change to the source code, It will be a trivial thing to direct new devices through the bevy systems, even when they do not always behave exactly like your typical controller.
@bors bors bot changed the title Support for additional gamepad buttons and axis [Merged by Bors] - Support for additional gamepad buttons and axis Sep 2, 2022
@bors bors bot closed this Sep 2, 2022
@djeedai
Copy link
Contributor

djeedai commented Sep 2, 2022

Ok thanks for the feedback @alice-i-cecile 👍

james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

Extend the scope of Gamepad to accommodate devices that have more inputs than a typical controller.

## Solution

Add additional enum variants to both _GamepadButtonType_ and _GamepadAxisType_ that supports up to 255 more non-standard buttons/axis respectively. 

## Personal motivation

I have been writing an alternative to the GILRS crate, and with this simple change to the source code, It will be a trivial thing to direct new devices through the bevy systems, even when they do not always behave exactly like your typical controller.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

Extend the scope of Gamepad to accommodate devices that have more inputs than a typical controller.

## Solution

Add additional enum variants to both _GamepadButtonType_ and _GamepadAxisType_ that supports up to 255 more non-standard buttons/axis respectively. 

## Personal motivation

I have been writing an alternative to the GILRS crate, and with this simple change to the source code, It will be a trivial thing to direct new devices through the bevy systems, even when they do not always behave exactly like your typical controller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants