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
3#include <vector>
4#include <string>
6#include <openxr/openxr.h>
8
9namespace EngineCore {
10 class Engine;
11 class Headset;
13}
14
15
16
17namespace Input {
18
19#define RIGHT_HAND_DECLARATION(varName) \
20 static const std::string r_##varName;
21
22#define LEFT_HAND_DECLARATION(varName) \
23 static const std::string l_##varName;
24
25#define BOTH_HAND_DECLARATION(varName) \
26 RIGHT_HAND_DECLARATION(varName) \
27 LEFT_HAND_DECLARATION(varName);
28
36 protected:
37
38 static const std::string handLeft;
39 static const std::string handRight;
40
42 static const std::string simpleControllerInteractionProfile;
43 static const std::string oculusTouchInteractionProfile;
44 };
45
46 public:
47 virtual void suggestBindings() = 0;
48 };
49
57 public:
58 static const std::string actionProfile;
59
64
65 void suggestBindings() override;
66 };
67
75 public:
76 static const std::string actionProfile;
77
78 // left hand
84
85 // right hand
91
92 // both hands
93 BOTH_HAND_DECLARATION(squeeze_value)
94 BOTH_HAND_DECLARATION(trigger_value)
95 BOTH_HAND_DECLARATION(trigger_touch)
96 BOTH_HAND_DECLARATION(trigger_proximity)
97 BOTH_HAND_DECLARATION(thumb_resting_surfaces_proximity)
98 BOTH_HAND_DECLARATION(thumbstick_click)
99 BOTH_HAND_DECLARATION(thumbstick_touch)
100 BOTH_HAND_DECLARATION(thumbrest_touch)
103
104 // outputs
105 // both hands
107
108 public:
109
110 void suggestBindings() override;
111
112 };
113
114#undef RIGHT_HAND_DECLARATION
115#undef LEFT_HAND_DECLARATION
116#undef BOTH_HAND_DECLARATION
117
119 glm::mat4 matrix{};
121
122 XrPath handPath{};
123 XrSpace space = XR_NULL_HANDLE;
124 };
125
126 enum class Hand {
127 LEFT = 0,
129 };
130
132 public:
134
135 void syncInputs(XrSpace playerSpace, XrTime predictedDisplayTime);
136
137 XrSpace getLeftHandSpace();
138 XrSpace getRightHandSpace();
139
141
146 [[nodiscard]] glm::vec2 getRightThumbstick() const { return rightThumbstick_; }
147
152 [[nodiscard]] glm::vec2 getLeftThumbstick() const { return leftThumbstick_; }
153
157 [[nodiscard]] float getTriggerValue(Hand hand) const;
158
162 [[nodiscard]] float getGripValue(Hand hand) const;
163
164 std::vector<HandPoseInfo> handPoseInfos;
165
166 private:
167 XrActionSet defaultActionSet = XR_NULL_HANDLE;
168 std::vector<XrPath> handPaths;
169
170 XrAction aimPoseAction = XR_NULL_HANDLE;
171 XrAction aimPoseLeftHand = XR_NULL_HANDLE;
172
173 // Thumbstick actions
174 XrAction thumbstickAction_ = XR_NULL_HANDLE;
175
176 // Trigger and grip actions
177 XrAction triggerAction_ = XR_NULL_HANDLE;
178 XrAction gripAction_ = XR_NULL_HANDLE;
179
180 // Cached input values
181 glm::vec2 rightThumbstick_{0.0f};
182 glm::vec2 leftThumbstick_{0.0f};
183 float triggerValues_[2] = {0.0f, 0.0f}; // [LEFT, RIGHT]
184 float gripValues_[2] = {0.0f, 0.0f}; // [LEFT, RIGHT]
185
187
188 const EngineCore::Headset* headset = nullptr;
190 };
191}
#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.
The minimal input mapping implementation provided by open xr which should be supported on any openxr ...
static const std::string actionProfile
const EngineCore::Headset * headset
HandPoseInfo getHandPoseInfo(Hand hand) const
EngineCore::Engine * engine
std::vector< XrPath > handPaths
glm::vec2 getRightThumbstick() const
Gets the right thumbstick input for XZ plane movement.
glm::vec2 getLeftThumbstick() const
Gets the left thumbstick input.
const EngineCore::ApplicationContext * context
XrInputHandler(const EngineCore::Headset *headset, const EngineCore::ApplicationContext *context)
void syncInputs(XrSpace playerSpace, XrTime predictedDisplayTime)
std::vector< HandPoseInfo > handPoseInfos
Log category system implementation.
A glm based posef struct.
static const std::string simpleControllerInteractionProfile
static const std::string oculusTouchInteractionProfile
EngineCore::OpenXrHelper::posef handPose