|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Creates OpenXR controller actions from the profile registry and samples the input state. More...
#include <XrInputHandler.h>
Classes | |
| struct | XrActionCache |
| Cached sampled state for one subaction path of an action. More... | |
| struct | XrActionInfo |
| Runtime state for one created OpenXR action. More... | |
Public Member Functions | |
| XrInputHandler () | |
| ~XrInputHandler () | |
| Destroys the OpenXR action set. | |
| void | bindForSession () |
| Creates actions, suggests profile bindings, attaches the action set, and detects the active profile. | |
| void | rebind () |
| Re-detects the active interaction profile after the runtime reports a profile change. | |
| void | syncInputs () |
| Samples all created OpenXR actions and updates cached poses, axes, analog values, and button states. | |
| XrSpace | getLeftHandSpace () |
| Returns the left hand aim-pose action space. | |
| XrSpace | getRightHandSpace () |
| Returns the right hand aim-pose action space. | |
| HandPoseInfo | getHandPoseInfo (Hand hand) const |
| Returns the latest raw pose snapshot for the specified hand. | |
| glm::vec2 | getRightThumbstick () const |
| Returns the latest right thumbstick axis value. | |
| glm::vec2 | getLeftThumbstick () const |
| Returns the latest left thumbstick axis value. | |
| float | getTriggerValue (Hand hand) const |
| Returns the latest trigger analog value for a hand. | |
| float | getGripValue (Hand hand) const |
| Returns the latest grip or squeeze analog value for a hand. | |
| bool | getAButtonPressed () const |
| Returns whether the right controller A button is currently pressed. | |
| bool | getBButtonPressed () const |
| Returns whether the right controller B button is currently pressed. | |
| bool | getXButtonPressed () const |
| Returns whether the left controller X button is currently pressed. | |
| bool | getYButtonPressed () const |
| Returns whether the left controller Y button is currently pressed. | |
| bool | getBool (const std::string &suffix, Hand hand) const |
| Returns the latest boolean value for a profile component for a hand. | |
| float | getFloat (const std::string &suffix, Hand hand) const |
| Returns the latest float value for a profile component for a hand. | |
| glm::vec2 | getVec2 (const std::string &suffix, Hand hand) const |
| Returns the latest vector2 value for a profile component for a hand. | |
| void | triggerHaptic (Hand hand, float amplitude, float durationSeconds) |
| Triggers a short vibration pulse on a hand's haptic output. | |
Public Attributes | |
| std::vector< HandPoseInfo > | handPoseInfos |
| Raw pose snapshots for left and right hands. Prefer getHandPoseInfo() for indexed access. | |
Private Member Functions | |
| void | createActions () |
| Creates the action set and all actions from the profile registry. | |
| void | suggestAllBindings () |
| Suggests interaction profile bindings for every known profile. | |
| void | attachActionSet () |
| Attaches the action set to the current session. | |
| void | createPoseSpaces () |
| Creates action spaces for pose inputs of the created actions. | |
| void | detectActiveProfiles () |
| Queries the runtime for the currently active interaction profiles. | |
| void | updateAimPoseSpaces () |
| Points handPoseInfos at the active profile's aim pose action spaces. | |
| const XrActionInfo * | findAction (const std::string &suffix, Hand hand, size_t &cacheIndex) const |
| Finds the action for a component suffix and hand. | |
Private Attributes | |
| XrActionSet | defaultActionSet = XR_NULL_HANDLE |
| The single action set owned by the handler. | |
| std::vector< XrPath > | handPaths |
| User hand paths for /user/hand/left and /user/hand/right. | |
| std::unordered_map< std::string, XrActionInfo > | actions_ |
| Created actions keyed by full action name. | |
| std::vector< const XrProfileDef * > | activeProfiles_ |
| Profiles reported active by the runtime. | |
| bool | actionsCreated_ = false |
| True once createActions() succeeded. | |
| bool | actionSetAttached_ = false |
| True once the action set was attached to the session. | |
| Engine::EngineKern * | engine = nullptr |
| Owning engine module. | |
| const Engine::Rendering::Headset * | headset_ = nullptr |
| Headset that owns the session. | |
| const Engine::Core::ApplicationContext * | context_ = nullptr |
| Application context that owns the OpenXR instance. | |
Creates OpenXR controller actions from the profile registry and samples the input state.
The handler owns a single action set attached to the headset session. Bindings are suggested when the session becomes ready (bindForSession()) and re-resolved when the runtime reports an interaction profile change (rebind()). Call syncInputs() once per frame before reading values. Poses are raw OpenXR poses in the supplied player space; XrRig converts them to engine world-space poses.
This is the OpenXR implementation for the OpenXR-SDK release-1.0.28 (see code/Engine/CMakeLists.txt). The engine stays strictly on OpenXR 1.0 and requests XR_CURRENT_API_VERSION (= XR_API_VERSION_1_0), so runtimes that only certify OpenXR 1.0 (e.g. SteamVR and Monado) remain supported. Interaction profiles that are only "provided by XR_VERSION_1_1" are therefore not reported by such runtimes for a 1.0 application.
Definition at line 76 of file XrInputHandler.h.
| Input::XrInputHandler::XrInputHandler | ( | ) |
| Input::XrInputHandler::~XrInputHandler | ( | ) |
Destroys the OpenXR action set.
|
private |
Attaches the action set to the current session.
| void Input::XrInputHandler::bindForSession | ( | ) |
Creates actions, suggests profile bindings, attaches the action set, and detects the active profile.
Call when the XR session reaches the ready state. Safe to call multiple times.
|
private |
Creates the action set and all actions from the profile registry.
|
private |
Creates action spaces for pose inputs of the created actions.
|
private |
Queries the runtime for the currently active interaction profiles.
|
private |
Finds the action for a component suffix and hand.
| suffix | Component suffix to match. | |
| hand | Hand to match against the action's subaction paths. | |
| [out] | cacheIndex | Receives the cache index for the matched hand. |
|
inlinenodiscard |
Returns whether the right controller A button is currently pressed.
Definition at line 163 of file XrInputHandler.h.
References getBool(), and Input::RIGHT.
|
inlinenodiscard |
Returns whether the right controller B button is currently pressed.
Definition at line 171 of file XrInputHandler.h.
References getBool(), and Input::RIGHT.
|
nodiscard |
Returns the latest boolean value for a profile component for a hand.
| suffix | Component name suffix, e.g. "menu", "a_button", "select". |
| hand | Hand to query. |
Referenced by getAButtonPressed(), getBButtonPressed(), getXButtonPressed(), and getYButtonPressed().
|
nodiscard |
Returns the latest float value for a profile component for a hand.
| suffix | Component name suffix, e.g. "trigger_value", "grip_value". |
| hand | Hand to query. |
Referenced by getGripValue(), and getTriggerValue().
|
inlinenodiscard |
Returns the latest grip or squeeze analog value for a hand.
| hand | Hand to query. |
Definition at line 155 of file XrInputHandler.h.
References getFloat().
|
nodiscard |
Returns the latest raw pose snapshot for the specified hand.
| hand | Hand to query. |
| XrSpace Input::XrInputHandler::getLeftHandSpace | ( | ) |
Returns the left hand aim-pose action space.
|
inlinenodiscard |
Returns the latest left thumbstick axis value.
Definition at line 135 of file XrInputHandler.h.
References getVec2(), and Input::LEFT.
| XrSpace Input::XrInputHandler::getRightHandSpace | ( | ) |
Returns the right hand aim-pose action space.
|
inlinenodiscard |
Returns the latest right thumbstick axis value.
Definition at line 126 of file XrInputHandler.h.
References getVec2(), and Input::RIGHT.
|
inlinenodiscard |
Returns the latest trigger analog value for a hand.
| hand | Hand to query. |
Definition at line 145 of file XrInputHandler.h.
References getFloat().
|
nodiscard |
Returns the latest vector2 value for a profile component for a hand.
| suffix | Component name suffix, e.g. "thumbstick", "trackpad". |
| hand | Hand to query. |
Referenced by getLeftThumbstick(), and getRightThumbstick().
|
inlinenodiscard |
Returns whether the left controller X button is currently pressed.
Definition at line 179 of file XrInputHandler.h.
References getBool(), and Input::LEFT.
|
inlinenodiscard |
Returns whether the left controller Y button is currently pressed.
Definition at line 187 of file XrInputHandler.h.
References getBool(), and Input::LEFT.
| void Input::XrInputHandler::rebind | ( | ) |
Re-detects the active interaction profile after the runtime reports a profile change.
|
private |
Suggests interaction profile bindings for every known profile.
The runtime only reports a profile it has suggested bindings for, so all profiles are suggested; profiles the runtime does not know return XR_ERROR_PATH_UNSUPPORTED and are logged but ignored.
| void Input::XrInputHandler::syncInputs | ( | ) |
Samples all created OpenXR actions and updates cached poses, axes, analog values, and button states.
| void Input::XrInputHandler::triggerHaptic | ( | Hand | hand, |
| float | amplitude, | ||
| float | durationSeconds ) |
Triggers a short vibration pulse on a hand's haptic output.
| hand | Hand to vibrate. |
| amplitude | Vibration amplitude in the range [0.0, 1.0]. |
| durationSeconds | Duration of the pulse in seconds. |
|
private |
Points handPoseInfos at the active profile's aim pose action spaces.
|
private |
Created actions keyed by full action name.
Definition at line 305 of file XrInputHandler.h.
|
private |
True once createActions() succeeded.
Definition at line 308 of file XrInputHandler.h.
|
private |
True once the action set was attached to the session.
Definition at line 309 of file XrInputHandler.h.
|
private |
Profiles reported active by the runtime.
Definition at line 306 of file XrInputHandler.h.
|
private |
Application context that owns the OpenXR instance.
Definition at line 313 of file XrInputHandler.h.
|
private |
The single action set owned by the handler.
Definition at line 302 of file XrInputHandler.h.
|
private |
Owning engine module.
Definition at line 311 of file XrInputHandler.h.
|
private |
User hand paths for /user/hand/left and /user/hand/right.
Definition at line 303 of file XrInputHandler.h.
| std::vector<HandPoseInfo> Input::XrInputHandler::handPoseInfos |
Raw pose snapshots for left and right hands. Prefer getHandPoseInfo() for indexed access.
Definition at line 228 of file XrInputHandler.h.
|
private |
Headset that owns the session.
Definition at line 312 of file XrInputHandler.h.