bevyengine / bevyengine/bevy

Type-level disparity between keyboard and gamepad input APIs

Open
#3,224 1 comment 0 reactions 0 assignees View on GitHub
A-Input C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

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

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

Gamepad inputs are accessed with ` Res>`, 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.