Skip to content

Type-level disparity between keyboard and gamepad input APIs #3224

@alice-i-cecile

Description

@alice-i-cecile

What problem does this solve or what need does it fill?

Keyboard inputs are accessed with Res<Input<KeyCode>>, and their associated variant enum is KeyCode.

Gamepad inputs are accessed with Res<Input<GamePadButton>>, and their associated variant enum is GamePadButtonType.

This makes writing code which abstracts over both keyboards and gamepads (such as input mapping or UI navigation) frustrating.

What solution would you like?

Create a GamepadButtonType input resource, which assumes a single controller.

What alternative(s) have you considered?

Merge GamepadButton and GamepadButtonType, likely with the former's name and latter's functionality.

Work around this in end-user code, likely with associated types or additional optional generics.

Make keyboard input behave the same way as gamepad input, supporting multiple input devices.

Additional context

The fundamental reason for this divergence in API is that the gamepad version stores both which gamepad a button is coming from, as well as its button type. The keyboard API by contrast assumes a single input device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions