Expand description
Frame input state, fed by whichever shell hosts the engine (editor or player). Besides raw keys it supports named actions (“Jump”) bound to keys / mouse buttons. Bindings come from the project settings and can be changed from scripts at run time.
The shell calls Input::update once before each runtime tick. Pressed and
released edges describe differences from the previous shell snapshot; reading
an edge does not consume it. Input::reset handles focus loss.
use kvas_engine::input::{Input, Key};
use glam::Vec2;
let mut input = Input::default();
input.rebind("Jump", &["Space"]);
input.update([Key::Space].into_iter().collect(), Default::default(), Vec2::ZERO, 0.0);
assert!(input.action_pressed("Jump"));
input.update(Default::default(), Default::default(), Vec2::ZERO, 0.0);
assert!(input.action_released("Jump"));Structs§
- Binding
- Named action and its alternative physical inputs (logical OR).
- Hud
- On-screen text a game can show; the shell (editor Play view or player) draws it.
- Input
- Input snapshot, editable action bindings and shell requests.
Enums§
- Key
- Physical keyboard keys accepted by the engine shells.
- Mouse
Button - Supported physical pointer buttons.
- Scene
Request - A scene change asked for by a script (see
ScriptCtx::load_scene). - Source
- One physical input an action can be bound to.