bevy_input_bindings 0.0.2

High level, flexible and shareable input binding library for the Bevy game engine
Documentation
use bevy::prelude::*;

use bevy_input_bindings::ots::ui::*;
use bevy_input_bindings::prelude::*;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            // Add the OTS UI plugins
            OtsUiGamepadPlugin::new(),
            OtsUiKeyboardPlugin::new(),
        ))
        // Add an observer to print the inputs. It will catch events for the `OtsUiActions` actions,
        // find the `ControllerInterface` that sent it, and print the event data.
        .add_observer(
            |action: On<ActionEvent<OtsUiActions>>, controllers: Query<&ControllerInterface>| {
                // Find the controller that sent the event
                let Ok(controller) = controllers.get(action.controller()) else {
                    return;
                };
                // Print data about this action
                println!(
                    "Action from {}({:?}): {:?}",
                    action.controller(),
                    controller.layout(),
                    action.key()
                );
            },
        )
        // Add a startup system to setup a camera. The Gamepad binders will be automatically added
        // at gamepad connection.
        .add_systems(Startup, |mut commands: Commands| {
            commands.spawn(Camera2d::default());
            commands.spawn(OtsUiKeyboardBinding::new());
        })
        .run();
}