Bevy supports the following inputs:
- Keyboard (detect when keys are pressed or released)
- Character (for text input; keyboard layout handled by the OS)
- Mouse (relative motion, buttons, scrolling)
- Touchscreen (with multi-touch)
- Gamepad (Controller, Joystick) (via the gilrs library)
The following notable input devices are not supported:
- Accelerometers and gyroscopes for device tilt
- Other sensors, like temperature sensors
- Tracking individual fingers on a multi-touch trackpad, like on a touchscreen
- Microphones and other audio input devices
- MIDI (musical instruments), but there is an unofficial plugin:
For most input types (where it makes sense), Bevy provides two ways of dealing with them:
Some inputs are only provided as events.
Checking state is done using resources such as
Input (for binary inputs like keys or buttons),
Axis (for analog inputs),
(for fingers on a touchscreen), etc. This way of handling input is very
convenient for implementing game logic. In these scenarios, you typically
only care about the specific inputs mapped to actions in your game. You can
check specific buttons/keys to see when they get pressed/released, or what
their current state is.
Bevy does not yet offer a built-in way to do input mapping (configure key bindings, etc). You need to come up with your own way of translating the inputs into logical actions in your game/app.
It may be a good idea to build your own abstractions specific to your game. For example, if you need to handle player movement, you might want to have a system for reading inputs and converting them to your own internal "movement intent/action events", and then another system acting on those internal events, to actually move the player. Make sure to use explicit system ordering to avoid lag / frame delays.
Using these in real games is not recommended, because you have to hard-code the keys, which makes it impossible to make user-configurable keybindings.
To support configurable keybindings, you can implement your own run conditions that check your keybindings from the user settings.