bami 0.1.0

Basic amethyst input library
Documentation

bami

The basic amethyst input library. Offers simple abstractions for common input requirements when using the amethyst crate.

Controller support can be added through the gilrs feature.

This crate is a work in progress, some controller bindings may not yet be supported.

Usage

use bami::{Input};

impl<'s> System<'s> for MySystem {
    type SystemData = (
        ...
        // Replace `StringBindings` if needed
        Read<'s, Input<StringBindings>>,
        ...
    );
    
    fn run(&mut self, (..., input, ...): Self::SystemData) {
        let action = String::from("jump");
        let axis = String::from("horizontal");

        // Only true the first frame an input is pressed
        let pressed_this_frame = input.actions.single_press(action.clone()).is_down;

        // The current state of the action
        let being_held_down: bool = input.actions.status(action.clone()).is_down;

        // Value between [-1.0, 1.0]
        let walk_speed: f32 = input.axes.status(axis.clone()).axis;

        // For every action, there is also the possibility to query the axis value.
        // If the queried behaviour would return `is_down = false`, the axis value will be `0.0`.
        let pressed_this_frame = input.actions.single_press(action.clone()).axis; 
    }
}

Setup input wrapper:

use bami::{InputManagementSystem};

// Add this to your dispatcher
dispatcher_builder.add(
    // Replace `StringBindings` if needed
    InputManagementSystem::<StringBindings>::default(),
    "input_management_system",
    &[],
);

Setup gilrs controller support:

use bami::{gilrs::GilRsControllerSystem};

// Add this to your dispatcher BEFORE the `InputManagementSystem`
dispatcher_builder.add(
    // Replace `StringBindings` if needed
    GilRsControllerSystem::<StringBindings>::default(),
    "gilrs_system",
    &[],
);

Run tests:

cargo test --features amethyst/empty