Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
XrInputHandler.h
Go to the documentation of this file.
1#pragma once
2
5#include <openxr/openxr.h>
6#include <string>
7#include <vector>
8
9namespace Engine
10{
11 class EngineKern;
12}
13
14namespace Input
15{
16
17#define RIGHT_HAND_DECLARATION( varName ) static const std::string r_##varName;
18
19#define LEFT_HAND_DECLARATION( varName ) static const std::string l_##varName;
20
21#define BOTH_HAND_DECLARATION( varName ) \
22 RIGHT_HAND_DECLARATION( varName ) \
23 LEFT_HAND_DECLARATION( varName );
24
29 {
30 protected:
31 static const std::string handLeft;
32 static const std::string handRight;
33
35 {
36 static const std::string simpleControllerInteractionProfile;
37 static const std::string oculusTouchInteractionProfile;
38 };
39
40 public:
41 virtual void suggestBindings() = 0;
42 };
43
48 {
49 public:
50 static const std::string actionProfile;
51
52 BOTH_HAND_DECLARATION( select_click )
56
57 void suggestBindings() override;
58 };
59
64 {
65 public:
66 static const std::string actionProfile;
67
68 // left hand
74
75 // right hand
80 RIGHT_HAND_DECLARATION( system_click )
81
82 // both hands
83 BOTH_HAND_DECLARATION( squeeze_value )
84 BOTH_HAND_DECLARATION( trigger_value )
85 BOTH_HAND_DECLARATION( trigger_touch )
86 BOTH_HAND_DECLARATION( trigger_proximity )
87 BOTH_HAND_DECLARATION( thumb_resting_surfaces_proximity )
88 BOTH_HAND_DECLARATION( thumbstick_click )
89 BOTH_HAND_DECLARATION( thumbstick_touch )
90 BOTH_HAND_DECLARATION( thumbrest_touch )
93
94 // outputs
95 // both hands
97
98 public:
99 void suggestBindings() override;
100 };
101
102#undef RIGHT_HAND_DECLARATION
103#undef LEFT_HAND_DECLARATION
104#undef BOTH_HAND_DECLARATION
105
107 {
108 glm::mat4 matrix{};
110
111 XrPath handPath{};
112 XrSpace space = XR_NULL_HANDLE;
113 };
114
115 enum class Hand
116 {
117 LEFT = 0,
119 };
120
125 {
126 public:
130 );
131
137 void syncInputs( XrSpace playerSpace, XrTime predictedDisplayTime );
138
143
148
154 [[nodiscard]] HandPoseInfo getHandPoseInfo( Hand hand ) const;
155
160 [[nodiscard]] glm::vec2 getRightThumbstick() const
161 {
162 return rightThumbstick_;
163 }
164
169 [[nodiscard]] glm::vec2 getLeftThumbstick() const
170 {
171 return leftThumbstick_;
172 }
173
177 [[nodiscard]] float getTriggerValue( Hand hand ) const;
178
182 [[nodiscard]] float getGripValue( Hand hand ) const;
183
184 std::vector<HandPoseInfo> handPoseInfos;
185
186 private:
187 XrActionSet defaultActionSet = XR_NULL_HANDLE;
188 std::vector<XrPath> handPaths;
189
190 XrAction aimPoseAction = XR_NULL_HANDLE;
191 XrAction aimPoseLeftHand = XR_NULL_HANDLE;
192
193 // Thumbstick actions
194 XrAction thumbstickAction_ = XR_NULL_HANDLE;
195
196 // Trigger and grip actions
197 XrAction triggerAction_ = XR_NULL_HANDLE;
198 XrAction gripAction_ = XR_NULL_HANDLE;
199
200 // Cached input values
201 glm::vec2 rightThumbstick_{ 0.0f };
202 glm::vec2 leftThumbstick_{ 0.0f };
203 float triggerValues_[2] = { 0.0f, 0.0f }; // [LEFT, RIGHT]
204 float gripValues_[2] = { 0.0f, 0.0f }; // [LEFT, RIGHT]
205
207
210 };
211} // namespace Input
#define BOTH_HAND_DECLARATION(varName)
#define LEFT_HAND_DECLARATION(varName)
#define RIGHT_HAND_DECLARATION(varName)
The application context is the core class which stores the basic openxr and vulkan objects.
The base profile for controller support of any device.
static const std::string handRight
static const std::string handLeft
virtual void suggestBindings()=0
Input mapping implementation for oculus touch devices.
Minimal input mapping supported on any OpenXR compatible device.
static const std::string actionProfile
XrInputHandler(const Engine::Rendering::Headset *headset, const Engine::Core::ApplicationContext *context)
HandPoseInfo getHandPoseInfo(Hand hand) const
Gets pose info for the specified hand.
const Engine::Rendering::Headset * headset
Engine::EngineKern * engine
float getTriggerValue(Hand hand) const
Gets the trigger value for the specified hand (0.0 to 1.0)
float getGripValue(Hand hand) const
Gets the grip/squeeze value for the specified hand (0.0 to 1.0)
std::vector< XrPath > handPaths
glm::vec2 getRightThumbstick() const
Gets the right thumbstick input for XZ plane movement.
XrSpace getLeftHandSpace()
Getter.
glm::vec2 getLeftThumbstick() const
Gets the left thumbstick input.
const Engine::Core::ApplicationContext * context
void syncInputs(XrSpace playerSpace, XrTime predictedDisplayTime)
Updates input state from OpenXR runtime.
std::vector< HandPoseInfo > handPoseInfos
XrSpace getRightHandSpace()
Getter.
A glm based posef struct.
static const std::string simpleControllerInteractionProfile
static const std::string oculusTouchInteractionProfile
Engine::OpenXrHelper::posef handPose