|
Vulkan Schnee 0.0.1 (22840dc8)
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::Actions::XrRightAButton | bool | Right controller A button pressed state |
| Input::Actions::XrRightBButton | bool | Right controller B button pressed state |
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() |
Bind methods return Input::InputManager::ProviderHandle. Callback methods return Input::InputManager::CallbackHandle.
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. For button edges, register callbacks directly on the built-in button action instead of binding a bool action that reads another bool action.
Register gameplay actions in beginPlay(). Store provider and callback handles in Input::InputBindingScope.
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.
Use InputBindingScope for gameplay-owned providers and callbacks. The scope removes callbacks and then removes providers when reset() runs or the scope is destroyed. Provider removal is generation-checked, so an old scope cannot clear a newer provider registered under the same action name.
Do not capture temporary objects in providers or callbacks. Prefer providers that read engine-owned actions from InputManager instead of raw XrInputHandler state.
Engine::EngineKern owns the input objects.
Actors store raw pointers only as cached access. They do not delete input objects.