Skip to content

Commit

Permalink
Support for additional gamepad buttons and axis (bevyengine#5853)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
fishykins authored and james7132 committed Oct 28, 2022
1 parent 1291f6b commit cba805a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_input/src/gamepad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Other(u8),
}

/// A button of a [`Gamepad`].
Expand Down Expand Up @@ -341,6 +344,9 @@ pub enum GamepadAxisType {
RightStickY,
/// The value of the right `Z` button.
RightZ,

/// Non-standard support for other axis types (i.e. HOTAS sliders, potentiometers, etc).
Other(u8),
}

/// An axis of a [`Gamepad`].
Expand Down

0 comments on commit cba805a

Please sign in to comment.