|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Input handling has two layers. Input::XrInputHandler samples raw OpenXR state, and Input::InputManager exposes named actions for gameplay code.
Use Input::InputManager from actors and components. Use Input::XrInputHandler only when adding a new device binding or raw OpenXR action.
Input is sampled once per frame before logic tick.
Callbacks dispatch after XrRig resolves tracked poses. Callback code can read current-frame world-space hand poses.
Polling reads the sampled input snapshot for the current frame. Poll from tick() when the code needs continuous values.
The engine binds these actions in Engine::EngineKern::createInputManager().
| Action | Type | Value |
|---|---|---|
| Input::Actions::XrLeftTrigger | float | Left trigger value, 0.0 to 1.0 |
| Input::Actions::XrRightTrigger | float | Right trigger value, 0.0 to 1.0 |
| Input::Actions::XrLeftGrip | float | Left grip value, 0.0 to 1.0 |
| Input::Actions::XrRightGrip | float | Right grip value, 0.0 to 1.0 |
| Input::Actions::XrLeftThumbstick | glm::vec2 | Left thumbstick axis |
| Input::Actions::XrRightThumbstick | glm::vec2 | Right thumbstick axis |
Input::InputManager supports three value types.
| Type | Bind method | Poll method | Callback method |
|---|---|---|---|
| bool | bindBoolAction() | getBoolAction() | onBoolAction() |
| float | bindFloatAction() | getFloatAction() | onFloatAction() |
| glm::vec2 | bindVec2Action() | getVec2Action() | onVec2Action() |
Boolean actions also have edge helpers:
| Rule | bool | float | glm::vec2 |
|---|---|---|---|
| EveryFrame | Dispatches every frame | Dispatches every frame | Dispatches every frame |
| Changed | Dispatches when value changes | Dispatches when value changes by more than 0.0001 | Dispatches when squared delta is greater than 0.000001 |
| Pressed | Dispatches on false-to-true edge | Not used | Not used |
| Released | Dispatches on true-to-false edge | Not used | Not used |
Use bool actions for edges. Derive them from analog inputs when the game needs thresholds.
Register gameplay actions in beginPlay(). Remove callback handles in endPlay().
Use polling for movement, aiming, charging, and debug UI.
Callbacks dispatch after XrRig resolves tracked poses. Read hand poses from XrRig, not from XrInputHandler.
Actions are named strings. Use a subsystem prefix to avoid collisions.
Bindings are providers. beginFrame() calls each provider and stores previous and current values.
Do not capture temporary objects in providers or callbacks. Remove callbacks when the owning actor ends play.
Engine::EngineKern owns the input objects.
Actors store raw pointers only as cached access. They do not delete input objects.