reaction 0.2.0

Universal low-latency input handling for game engines
Documentation
use reaction::mapping::action::InputAction;
use reaction::mapping::binding::{BindingConfig, InputBinding};
use reaction::mapping::context::{ContextStack, InputContext};
use reaction::mapping::resolver::InputMap;
use reaction::prelude::*;

fn main() {
    let mut stack = ContextStack::new();

    // Base Gameplay Context
    let mut gameplay_map = InputMap::new();
    gameplay_map
        .bind(
            InputAction::Jump,
            BindingConfig::new(InputBinding::Key(KeyCode::Space)),
        )
        .unwrap();
    let gameplay_ctx = InputContext::new(0, gameplay_map);
    stack.push(gameplay_ctx);

    // Menu Context (Higher Priority)
    let mut menu_map = InputMap::new();
    menu_map
        .bind(
            InputAction::Confirm,
            BindingConfig::new(InputBinding::Key(KeyCode::Space)),
        )
        .unwrap(); // Space confirms in menu
    let mut menu_ctx = InputContext::new(10, menu_map);
    menu_ctx.blocks_lower_priority = true; // Block gameplay
    stack.push(menu_ctx);

    let mut input = AdvancedInputState::new();
    input.keyboard.press(KeyCode::Space, 0.0, 1);

    // Resolve
    let jump_val = stack.resolve(InputAction::Jump, &input, None);
    let confirm_val = stack.resolve(InputAction::Confirm, &input, None);

    println!("Jump: {}, Confirm: {}", jump_val, confirm_val);

    if confirm_val > 0.0 {
        println!("Menu Confirm Triggered (Space)");
    }
    if jump_val > 0.0 {
        println!("Jump Triggered");
    } else {
        println!("Jump BLOCKED by Menu Context");
    }
}