Blender V4.3
GHOST_XrAction.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9/* NOTE: Requires OpenXR headers to be included before this one for OpenXR types
10 * (XrSpace, XrPath, etc.). */
11
12#pragma once
13
14#include <map>
15#include <memory>
16#include <string>
17
18#include "GHOST_Util.hh"
19
20/* -------------------------------------------------------------------- */
21
23 public:
24 GHOST_XrActionSpace() = delete; /* Default constructor for map storage. */
25 GHOST_XrActionSpace(XrSession session,
26 XrAction action,
27 const char *action_name,
28 const char *profile_path,
29 XrPath subaction_path,
30 const char *subaction_path_str,
31 const GHOST_XrPose &pose);
33
34 XrSpace getSpace() const;
35
36 private:
37 XrSpace m_space = XR_NULL_HANDLE;
38};
39
40/* -------------------------------------------------------------------- */
41
42typedef struct GHOST_XrSubactionData {
43 XrPath subaction_path = XR_NULL_PATH;
46 std::unique_ptr<GHOST_XrActionSpace> space = nullptr;
48
49/* -------------------------------------------------------------------- */
50
52 public:
53 GHOST_XrActionProfile() = delete; /* Default constructor for map storage. */
54 GHOST_XrActionProfile(XrInstance instance,
55 XrSession session,
56 XrAction action,
57 GHOST_XrActionType type,
58 const GHOST_XrActionProfileInfo &info);
60
61 XrPath getProfile() const;
62 const GHOST_XrSubactionData *getSubaction(XrPath subaction_path) const;
63 void getBindings(XrAction action,
64 std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;
65
66 private:
67 XrPath m_profile = XR_NULL_PATH;
68
70 std::map<std::string, GHOST_XrSubactionData> m_subaction_data;
72 std::map<std::string, XrPath> m_bindings;
73};
74
75/* -------------------------------------------------------------------- */
76
78 public:
79 GHOST_XrAction() = delete; /* Default constructor for map storage. */
80 GHOST_XrAction(XrInstance instance, XrActionSet action_set, const GHOST_XrActionInfo &info);
82
83 bool createBinding(XrInstance instance,
84 XrSession session,
85 const GHOST_XrActionProfileInfo &info);
86 void destroyBinding(const char *profile_path);
87
88 void updateState(XrSession session,
89 const char *action_name,
90 XrSpace reference_space,
91 const XrTime &predicted_display_time);
92 void applyHapticFeedback(XrSession session,
93 const char *action_name,
94 const char *subaction_path_str,
95 const int64_t &duration,
96 const float &frequency,
97 const float &amplitude);
98 void stopHapticFeedback(XrSession session,
99 const char *action_name,
100 const char *subaction_path_str);
101
102 void *getCustomdata();
103 void getBindings(std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;
104
105 private:
106 using SubactionIndexMap = std::map<std::string, uint32_t>;
107
108 XrAction m_action = XR_NULL_HANDLE;
109 GHOST_XrActionType m_type;
110 SubactionIndexMap m_subaction_indices;
111 std::vector<XrPath> m_subaction_paths;
113 void *m_states;
115 float *m_float_thresholds;
116 int16_t *m_axis_flags;
117
118 std::unique_ptr<GHOST_C_CustomDataWrapper> m_custom_data_ = nullptr; /* wmXrAction */
119
121 std::map<std::string, GHOST_XrActionProfile> m_profiles;
122};
123
124/* -------------------------------------------------------------------- */
125
127 public:
128 GHOST_XrActionSet() = delete; /* Default constructor for map storage. */
129 GHOST_XrActionSet(XrInstance instance, const GHOST_XrActionSetInfo &info);
131
132 bool createAction(XrInstance instance, const GHOST_XrActionInfo &info);
133 void destroyAction(const char *action_name);
134 GHOST_XrAction *findAction(const char *action_name);
135
136 void updateStates(XrSession session,
137 XrSpace reference_space,
138 const XrTime &predicted_display_time);
139
140 XrActionSet getActionSet() const;
141 void *getCustomdata();
142 uint32_t getActionCount() const;
143 void getActionCustomdataArray(void **r_customdata_array);
144 void getBindings(std::map<XrPath, std::vector<XrActionSuggestedBinding>> &r_bindings) const;
145
146 private:
147 XrActionSet m_action_set = XR_NULL_HANDLE;
148
149 std::unique_ptr<GHOST_C_CustomDataWrapper> m_custom_data_ = nullptr; /* wmXrActionSet */
150
151 std::map<std::string, GHOST_XrAction> m_actions;
152};
153
154/* -------------------------------------------------------------------- */
struct GHOST_XrSubactionData GHOST_XrSubactionData
const GHOST_XrSubactionData * getSubaction(XrPath subaction_path) const
XrPath getProfile() const
~GHOST_XrActionProfile()=default
GHOST_XrActionProfile()=delete
void getBindings(XrAction action, std::map< XrPath, std::vector< XrActionSuggestedBinding > > &r_bindings) const
GHOST_XrActionSet()=delete
void updateStates(XrSession session, XrSpace reference_space, const XrTime &predicted_display_time)
GHOST_XrAction * findAction(const char *action_name)
bool createAction(XrInstance instance, const GHOST_XrActionInfo &info)
void getBindings(std::map< XrPath, std::vector< XrActionSuggestedBinding > > &r_bindings) const
XrActionSet getActionSet() const
void getActionCustomdataArray(void **r_customdata_array)
uint32_t getActionCount() const
void destroyAction(const char *action_name)
XrSpace getSpace() const
GHOST_XrActionSpace()=delete
bool createBinding(XrInstance instance, XrSession session, const GHOST_XrActionProfileInfo &info)
void updateState(XrSession session, const char *action_name, XrSpace reference_space, const XrTime &predicted_display_time)
void getBindings(std::map< XrPath, std::vector< XrActionSuggestedBinding > > &r_bindings) const
void destroyBinding(const char *profile_path)
void applyHapticFeedback(XrSession session, const char *action_name, const char *subaction_path_str, const int64_t &duration, const float &frequency, const float &amplitude)
void stopHapticFeedback(XrSession session, const char *action_name, const char *subaction_path_str)
GHOST_XrAction()=delete
signed short int16_t
Definition stdint.h:76
unsigned int uint32_t
Definition stdint.h:80
__int64 int64_t
Definition stdint.h:89