Expand description

ezinput

GitHub crates.io GitHub Actions GitHub Actions
A powerful input-agnostic library targeting complete support to axis and button handling for the Bevy game engine.

Table of contents

  1. About
  2. Branches
  3. Getting started
  4. Examples

About

Input is relative; the library itself currently implements by default keyboard, mouse and gamepad support, but this is subject to change. Please feel free to contribute to the library by submitting pull requests. Touch support is stil planned, but not yet implemented.

ezinput strives to be simple as possible, while still being powerful and flexible without using any unsafe code.

All bindings are stored in a InputView struct, which is passed as a component to your ECS entity. To allow an input method to be handled, you need to add a service marker component (MouseMarker, KeyboardMarker or GamepadMarker) to the ECS entity. You aren’t limited to one marker, since you can use multiple markers to handle multiple input methods. An advantage of this implementation is that input views aren’t limited to specific input sources, so you can reutilize the same view for multiple input methods just by adding new input receivers to bindings.

Not everything is documented yet or documented with a high level of detail, so any feedback is appreciated. You can contact me on Discord or here on GitHub!

Limitations

  • Touch support is not implemented yet.
  • Input receivers are limited to implemented input sources only.
  • Input sources are a hard-coded enumeration (it might not be that bad in most cases though).

Branches

Branch Bevy version
master ^0.7
bevy_main git (https://github.com/bevyengine/bevy.git)

Getting started

Add the following to your Cargo.toml (replace ^0.3 with the latest version):

[dependencies]
ezinput = "^0.3"
  • use ezinput::prelude::*;
  • Create an input view by using the input! macro. You can see an example here. https://github.com/eexsty/ezinput/blob/master/src/macros.rs#L5-L45
  • Add the ezinput plugin to your application app.add_plugin(EZInputPlugin::<TheNameOfYourBindingsEnum>::default());
  • Add the input view components alongside markers to your ECS entities.
  • Done! You can handle input by using the InputView component! I recommend taking a look at the examples to get a feel for how to use it.

Modules

This module contains BindingTypeView and ActionBinding, in which they are used to implement the enumerated binding types and register the binding itself.

Definition of a ECS component bundle providing an input view and all supported input markers.

Full gamepad support for EZInput.

Full keyboard support for EZInput.

Quality of life macros, usually for reducing boilerplate.

Mouse button, location and delta support for EZInput.

The plugin that need to be registered in order to start receiving and handling input given by the bevy_input API.

All types of input accepted by default on ezinput. This doesn’t mean that you can´t implement your own input sources by your own.

The press state for a button or axis. Also useful methods for checking the elapsed time.

A view is a object where all input states are stored. It also has useful methods such checking if a key or axis for a BindingTypeView is pressed or released by proving the PressState.

Macros

A macro that generates input-related enumerations for easier use in ezinput.

Derive Macros