70 typedef std::vector<std::string>
Paths;
108 bool initialize(const XrInstance& xrInstance, const std::
string& name, const std::
string& description, const uint32_t priority = 0u);
119 ActionId createAction(const XrActionType xrActionType, const std::
string& name, const std::
string& description, const
ActionId actionId = invalidActionId_);
131 ActionId createAction(const XrActionType xrActionType, const std::
string& name, const std::
string& description, const
Paths& subactionPaths, const
ActionId actionId = invalidActionId_);
143 ActionId createAction(const XrActionType xrActionType, const std::
string& name, const std::
string& description, const
XrPaths& xrSubactionPaths, const
ActionId actionId = invalidActionId_);
155 inline
ActionId createActionWithBinding(const XrActionType xrActionType, const std::
string& name, const std::
string& description, const std::
string& path, const
ActionId actionId = invalidActionId_);
163 bool addActionBinding(const
ActionId actionId, const std::
string& path);
171 bool addActionBinding(const
ActionId actionId, const XrPath& xrPath);
180 inline
bool suggestActionBindings(const XrInstance& xrInstance, const std::
string& interactionProfile);
189 bool suggestActionBindings(const XrInstance& xrInstance, const XrPath& xrInteractionProfilePath);
206 template <typename T>
207 bool actionState(const XrSession& xrSession, const
ActionId actionId, T& state) const;
220 bool actionBindingsSuggested() const;
227 bool isValid() const;
234 inline operator XrActionSet() const;
241 explicit inline operator
bool() const;
258 template <typename T>
259 static
bool actionState(const XrSession& xrSession, const XrAction& xrAction, T& state);
277 XrInstance xrInstance_ = XR_NULL_HANDLE;
280 XrActionSet xrActionSet_ = XR_NULL_HANDLE;
292 bool actionBindingsSuggested_ = false;
303inline ActionSet::ActionId ActionSet::createActionWithBinding(
const XrActionType xrActionType,
const std::string& name,
const std::string& description,
const std::string& path,
const ActionId actionId)
305 const ActionId id = createAction(xrActionType, name, description, actionId);
306 ocean_assert(
id != invalidActionId_);
308 if (
id != invalidActionId_ && addActionBinding(
id, path))
313 return invalidActionId_;
316inline bool ActionSet::suggestActionBindings(
const XrInstance& xrInstance,
const std::string& interactionProfile)
318 ocean_assert(xrInstance != XR_NULL_HANDLE);
319 ocean_assert(!interactionProfile.empty());
321 return suggestActionBindings(xrInstance, Utilities::translatePath(xrInstance, interactionProfile));
325bool ActionSet::actionState(
const XrSession& xrSession,
const ActionId actionId, T& state)
const
327 ocean_assert(xrSession != XR_NULL_HANDLE);
328 ocean_assert(actionId != invalidActionId_);
332 const ActionIdMap::const_iterator iAction = actionIdMap_.find(actionId);
334 if (iAction == actionIdMap_.cend())
336 ocean_assert(
false &&
"Unknown action id");
340 return actionState<T>(xrSession, iAction->second, state);
344inline bool ActionSet::actionState(
const XrSession& xrSession,
const XrAction& xrAction, XrActionStateBoolean& state)
346 ocean_assert(xrSession != XR_NULL_HANDLE);
347 ocean_assert(xrAction != XR_NULL_HANDLE);
349 state = XrActionStateBoolean{XR_TYPE_ACTION_STATE_BOOLEAN};
351 XrActionStateGetInfo xrActionStateGetInfo{XR_TYPE_ACTION_STATE_GET_INFO};
352 xrActionStateGetInfo.action = xrAction;
354 const XrResult xrResult = xrGetActionStateBoolean(xrSession, &xrActionStateGetInfo, &state);
355 ocean_assert(xrResult == XR_SUCCESS);
357 return xrResult == XR_SUCCESS;
361inline bool ActionSet::actionState(
const XrSession& xrSession,
const XrAction& xrAction, XrActionStateFloat& state)
363 ocean_assert(xrSession != XR_NULL_HANDLE);
364 ocean_assert(xrAction != XR_NULL_HANDLE);
366 state = XrActionStateFloat{XR_TYPE_ACTION_STATE_FLOAT};
368 XrActionStateGetInfo xrActionStateGetInfo{XR_TYPE_ACTION_STATE_GET_INFO};
369 xrActionStateGetInfo.action = xrAction;
371 const XrResult xrResult = xrGetActionStateFloat(xrSession, &xrActionStateGetInfo, &state);
372 ocean_assert(xrResult == XR_SUCCESS);
374 return xrResult == XR_SUCCESS;
378inline bool ActionSet::actionState(
const XrSession& xrSession,
const XrAction& xrAction, XrActionStateVector2f& state)
380 ocean_assert(xrSession != XR_NULL_HANDLE);
381 ocean_assert(xrAction != XR_NULL_HANDLE);
383 state = XrActionStateVector2f{XR_TYPE_ACTION_STATE_VECTOR2F};
385 XrActionStateGetInfo xrActionStateGetInfo{XR_TYPE_ACTION_STATE_GET_INFO};
386 xrActionStateGetInfo.action = xrAction;
388 const XrResult xrResult = xrGetActionStateVector2f(xrSession, &xrActionStateGetInfo, &state);
389 ocean_assert(xrResult == XR_SUCCESS);
391 return xrResult == XR_SUCCESS;
395inline bool ActionSet::actionState(
const XrSession& xrSession,
const XrAction& xrAction, XrActionStatePose& state)
397 ocean_assert(xrSession != XR_NULL_HANDLE);
398 ocean_assert(xrAction != XR_NULL_HANDLE);
400 state = XrActionStatePose{XR_TYPE_ACTION_STATE_POSE};
402 XrActionStateGetInfo xrActionStateGetInfo{XR_TYPE_ACTION_STATE_GET_INFO};
403 xrActionStateGetInfo.action = xrAction;
405 const XrResult xrResult = xrGetActionStatePose(xrSession, &xrActionStateGetInfo, &state);
406 ocean_assert(xrResult == XR_SUCCESS);
408 return xrResult == XR_SUCCESS;