euv-core 0.48.2

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Fixed-size 256-bit zero-allocation keyboard state bitset supporting `Copy` snapshots without heap sets.
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, PartialEq)]
pub struct KeyBitset {
    /// Four 64-bit words storing bits `0..256` mapped from `KeyCode`.
    #[get(type(copy))]
    pub(crate) words: [u64; 4],
}

/// Fixed-size 16-bit zero-allocation pointer button bitset supporting `Copy` snapshots without heap sets.
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, PartialEq)]
pub struct ButtonBitset {
    /// Compact 16-bit mask storing pressed `PointerButton` states.
    #[get(type(copy))]
    pub(crate) mask: u16,
}

/// Zero-allocation `Copy` polled keyboard, pointer, and scroll input state for games and interactive viewports.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct InputState {
    /// Bitset of keys currently held down.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) keys_down: KeyBitset,
    /// Bitset of keys pressed during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) keys_just_pressed: KeyBitset,
    /// Bitset of keys released during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) keys_just_released: KeyBitset,
    /// Bitset of pointer buttons currently held down.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) buttons_down: ButtonBitset,
    /// Bitset of pointer buttons pressed during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) buttons_just_pressed: ButtonBitset,
    /// Bitset of pointer buttons released during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) buttons_just_released: ButtonBitset,
    /// Latest logical pointer coordinates.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) pointer_position: Point,
    /// Accumulated logical pointer movement delta during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) pointer_delta: Point,
    /// Accumulated scroll delta during the current frame.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) scroll_delta: Point,
    /// Virtual analog movement stick `(-1.0..=1.0, -1.0..=1.0)` fed by touch drag-joysticks or gamepads.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) virtual_axis: Point,
    /// Virtual touch/gamepad primary fire trigger state.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) virtual_fire: bool,
    /// Virtual touch/gamepad dash/boost trigger state.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) virtual_dash: bool,
    /// Latest keyboard modifier flags reported by key or pointer events.
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) modifiers: Modifiers,
}

/// Declarative multi-key and pointer-button binding table mapping physical inputs to `GameAction`s.
#[derive(Clone, Data, Debug)]
pub struct ActionMap {
    /// Keyboard bindings grouped by semantic `GameAction`.
    pub(crate) key_bindings: HashMap<GameAction, Vec<KeyCode>>,
    /// Pointer button bindings grouped by semantic `GameAction`.
    pub(crate) button_bindings: HashMap<GameAction, Vec<PointerButton>>,
}