Ocean
Loading...
Searching...
No Matches
Ocean::Platform::OpenXR::ActionSet Class Referencefinal

This class implements a wrapper for an OpenXR action set. More...

#include <ActionSet.h>

Public Types

typedef uint32_t ActionId
 Definition of an id for an action.
 
typedef std::unordered_map< ActionId, XrAction > ActionIdMap
 Definition of an unordered map mapping action ids to XrAction objects.
 
typedef std::vector< std::string > Paths
 Definition of a vector holding strings.
 

Public Member Functions

 ActionSet () noexcept=default
 Default constructor.
 
 ActionSet (ActionSet &&actionSet) noexcept
 Move constructor.
 
 ~ActionSet ()
 Destructs this action set and releases all resources.
 
bool initialize (const XrInstance &xrInstance, const std::string &name, const std::string &description, const uint32_t priority=0u)
 Initializes the action set.
 
ActionId createAction (const XrActionType xrActionType, const std::string &name, const std::string &description, const ActionId actionId=invalidActionId_)
 Creates a new action.
 
ActionId createAction (const XrActionType xrActionType, const std::string &name, const std::string &description, const Paths &subactionPaths, const ActionId actionId=invalidActionId_)
 Creates a new action.
 
ActionId createAction (const XrActionType xrActionType, const std::string &name, const std::string &description, const XrPaths &xrSubactionPaths, const ActionId actionId=invalidActionId_)
 Creates a new action.
 
ActionId createActionWithBinding (const XrActionType xrActionType, const std::string &name, const std::string &description, const std::string &path, const ActionId actionId=invalidActionId_)
 Creates a new action and directly adds an action binding.
 
bool addActionBinding (const ActionId actionId, const std::string &path)
 Adds an action binding.
 
bool addActionBinding (const ActionId actionId, const XrPath &xrPath)
 Adds an action binding.
 
bool suggestActionBindings (const XrInstance &xrInstance, const std::string &interactionProfile)
 Suggests the actions of this set as binding.
 
bool suggestActionBindings (const XrInstance &xrInstance, const XrPath &xrInteractionProfilePath)
 Suggests the actions of this set as binding.
 
XrAction action (const ActionId actionId) const
 Returns an action of this set.
 
template<typename T >
bool actionState (const XrSession &xrSession, const ActionId actionId, T &state) const
 Determines the state of an action.
 
void release ()
 Explicitly releases the action set and all associated actions and resources.
 
bool actionBindingsSuggested () const
 Returns true whether the actions have been set as applicated-suggested bindings.
 
bool isValid () const
 Returns whether this object holds a valid OpenXR action set.
 
 operator XrActionSet () const
 Returns the wrapped OpenXR action set.
 
 operator bool () const
 Returns whether this object holds a valid OpenXR action set.
 
ActionSetoperator= (ActionSet &&actionSet) noexcept
 Move operator.
 
template<>
bool actionState (const XrSession &xrSession, const XrAction &xrAction, XrActionStateBoolean &state)
 
template<>
bool actionState (const XrSession &xrSession, const XrAction &xrAction, XrActionStateFloat &state)
 
template<>
bool actionState (const XrSession &xrSession, const XrAction &xrAction, XrActionStateVector2f &state)
 
template<>
bool actionState (const XrSession &xrSession, const XrAction &xrAction, XrActionStatePose &state)
 

Static Public Member Functions

template<typename T >
static bool actionState (const XrSession &xrSession, const XrAction &xrAction, T &state)
 Determines the state of an action.
 

Static Public Attributes

static constexpr ActionId invalidActionId_ = ActionId(-1)
 An invalid action id.
 

Protected Types

typedef std::vector< XrActionSuggestedBinding > XrActionSuggestedBindings
 Definition of a vector holding XrActionSuggestedBinding objects.
 

Protected Member Functions

 ActionSet (const ActionSet &)=delete
 Disabled copy constructor.
 
ActionSetoperator= (const ActionSet &)=delete
 Disabled assign operator.
 

Protected Attributes

XrInstance xrInstance_ = XR_NULL_HANDLE
 The OpenXR instance associated with this action set.
 
XrActionSet xrActionSet_ = XR_NULL_HANDLE
 The action OpenXR action set.
 
ActionIdMap actionIdMap_
 The actions of this action set.
 
ActionId actionIdCounter_ = 0u
 The counter of unique action ids.
 
XrActionSuggestedBindings xrActionSuggestedBindings_
 The XrActionSuggestedBindings of this action set.
 
bool actionBindingsSuggested_ = false
 True, if the actions have been set as applicated-suggested bindings.
 
Lock lock_
 The action set's lock.
 

Detailed Description

This class implements a wrapper for an OpenXR action set.

Member Typedef Documentation

◆ ActionId

Definition of an id for an action.

◆ ActionIdMap

typedef std::unordered_map<ActionId, XrAction> Ocean::Platform::OpenXR::ActionSet::ActionIdMap

Definition of an unordered map mapping action ids to XrAction objects.

◆ Paths

typedef std::vector<std::string> Ocean::Platform::OpenXR::ActionSet::Paths

Definition of a vector holding strings.

◆ XrActionSuggestedBindings

typedef std::vector<XrActionSuggestedBinding> Ocean::Platform::OpenXR::ActionSet::XrActionSuggestedBindings
protected

Definition of a vector holding XrActionSuggestedBinding objects.

Constructor & Destructor Documentation

◆ ActionSet() [1/3]

Ocean::Platform::OpenXR::ActionSet::ActionSet ( )
defaultnoexcept

Default constructor.

◆ ActionSet() [2/3]

Ocean::Platform::OpenXR::ActionSet::ActionSet ( ActionSet &&  actionSet)
inlinenoexcept

Move constructor.

Parameters
actionSetThe action set to be moved

◆ ~ActionSet()

Ocean::Platform::OpenXR::ActionSet::~ActionSet ( )

Destructs this action set and releases all resources.

◆ ActionSet() [3/3]

Ocean::Platform::OpenXR::ActionSet::ActionSet ( const ActionSet )
protecteddelete

Disabled copy constructor.

Member Function Documentation

◆ action()

XrAction Ocean::Platform::OpenXR::ActionSet::action ( const ActionId  actionId) const

Returns an action of this set.

Parameters
actionIdThe id of the action, must be valid
Returns
The requested action, XR_NULL_HANDLE if unknown

◆ actionBindingsSuggested()

bool Ocean::Platform::OpenXR::ActionSet::actionBindingsSuggested ( ) const

Returns true whether the actions have been set as applicated-suggested bindings.

Returns
True, if so
See also
suggestActionBindings().

◆ actionState() [1/6]

template<typename T >
bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const ActionId  actionId,
T &  state 
) const

Determines the state of an action.

Parameters
xrSessionThe session to which the action belongs (is synchronized), must be valid
actionIdThe id of the action, must be valid
stateThe resulting state
Returns
True, if succeeded
Template Parameters
TThe data type of the state, either 'XrActionStateBoolean', 'xrGetActionStateFloat', 'XrActionStateVector2f', or 'xrGetActionStatePose'

◆ actionState() [2/6]

template<typename T >
static bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const XrAction &  xrAction,
T &  state 
)
static

Determines the state of an action.

Parameters
xrSessionThe session to which the action belongs (is synchronized), must be valid
xrActionThe action for which the state will be returned, must be valid
stateThe resulting state
Returns
True, if succeeded
Template Parameters
TThe data type of the state, either 'XrActionStateBoolean', 'xrGetActionStateFloat', 'XrActionStateVector2f', or 'xrGetActionStatePose'

◆ actionState() [3/6]

template<>
bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const XrAction &  xrAction,
XrActionStateBoolean &  state 
)
inline

◆ actionState() [4/6]

template<>
bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const XrAction &  xrAction,
XrActionStateFloat &  state 
)
inline

◆ actionState() [5/6]

template<>
bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const XrAction &  xrAction,
XrActionStatePose &  state 
)
inline

◆ actionState() [6/6]

template<>
bool Ocean::Platform::OpenXR::ActionSet::actionState ( const XrSession &  xrSession,
const XrAction &  xrAction,
XrActionStateVector2f &  state 
)
inline

◆ addActionBinding() [1/2]

bool Ocean::Platform::OpenXR::ActionSet::addActionBinding ( const ActionId  actionId,
const std::string &  path 
)

Adds an action binding.

Parameters
actionIdThe id of the action to bind, must be valid
pathThe OpenXR path to which the action will be bound, must be valid
Returns
True, if succeeded

◆ addActionBinding() [2/2]

bool Ocean::Platform::OpenXR::ActionSet::addActionBinding ( const ActionId  actionId,
const XrPath &  xrPath 
)

Adds an action binding.

Parameters
actionIdThe id of the action to bind, must be valid
xrPathThe OpenXR path to which the action will be bound, must be valid
Returns
True, if succeeded

◆ createAction() [1/3]

ActionId Ocean::Platform::OpenXR::ActionSet::createAction ( const XrActionType  xrActionType,
const std::string &  name,
const std::string &  description,
const ActionId  actionId = invalidActionId_ 
)

Creates a new action.

In case an external managed id is provided, the id must be unique and must not be associated with an existing id already.

Parameters
xrActionTypeThe type of the action to be created, must be valid
nameThe name of the action, must be valid
descriptionThe description of the action, must be valid
actionIdThe id of the action, an explicit (externally managed id), or invalidActionId_ to use an internally managed id
Returns
The id of the created action, invalidActionId_ if the action could not be created

◆ createAction() [2/3]

ActionId Ocean::Platform::OpenXR::ActionSet::createAction ( const XrActionType  xrActionType,
const std::string &  name,
const std::string &  description,
const Paths subactionPaths,
const ActionId  actionId = invalidActionId_ 
)

Creates a new action.

In case an external managed id is provided, the id must be unique and must not be associated with an existing id already.

Parameters
xrActionTypeThe type of the action to be created, must be valid
nameThe name of the action, must be valid
descriptionThe description of the action, must be valid
subactionPathsOptional sub-action paths
actionIdThe id of the action, an explicit (externally managed id), or invalidActionId_ to use an internally managed id
Returns
The id of the created action, invalidActionId_ if the action could not be created

◆ createAction() [3/3]

ActionId Ocean::Platform::OpenXR::ActionSet::createAction ( const XrActionType  xrActionType,
const std::string &  name,
const std::string &  description,
const XrPaths xrSubactionPaths,
const ActionId  actionId = invalidActionId_ 
)

Creates a new action.

In case an external managed id is provided, the id must be unique and must not be associated with an existing id already.

Parameters
xrActionTypeThe type of the action to be created, must be valid
nameThe name of the action, must be valid
descriptionThe description of the action, must be valid
xrSubactionPathsOptional sub-action paths
actionIdThe id of the action, an explicit (externally managed id), or invalidActionId_ to use an internally managed id
Returns
The id of the created action, invalidActionId_ if the action could not be created

◆ createActionWithBinding()

ActionSet::ActionId Ocean::Platform::OpenXR::ActionSet::createActionWithBinding ( const XrActionType  xrActionType,
const std::string &  name,
const std::string &  description,
const std::string &  path,
const ActionId  actionId = invalidActionId_ 
)
inline

Creates a new action and directly adds an action binding.

In case an external managed id is provided, the id must be unique and must not be associated with an existing id already.

Parameters
xrActionTypeThe type of the action to be created, must be valid
nameThe name of the action, must be valid
descriptionThe description of the action, must be valid
pathThe OpenXR path to which the action will be bound, must be valid
actionIdThe id of the action, an explicit (externally managed id), or invalidActionId_ to use an internally managed id
Returns
The id of the created action, invalidActionId_ if the action could not be created

◆ initialize()

bool Ocean::Platform::OpenXR::ActionSet::initialize ( const XrInstance &  xrInstance,
const std::string &  name,
const std::string &  description,
const uint32_t  priority = 0u 
)

Initializes the action set.

Parameters
xrInstanceThe OpenXR instance for which the action set will be created, must be valid
nameThe action set's name, must be valid
descriptionThe action set's description, must be valid
priorityThe action set's priority, with range [0, infinity)
Returns
True, if succeeded

◆ isValid()

bool Ocean::Platform::OpenXR::ActionSet::isValid ( ) const

Returns whether this object holds a valid OpenXR action set.

Returns
True, if so
See also
initialize().

◆ operator bool()

Ocean::Platform::OpenXR::ActionSet::operator bool ( ) const
inlineexplicit

Returns whether this object holds a valid OpenXR action set.

Returns
True, if so
See also
isValid().

◆ operator XrActionSet()

Ocean::Platform::OpenXR::ActionSet::operator XrActionSet ( ) const
inline

Returns the wrapped OpenXR action set.

Returns
The actual action set, nullptr if not initialized
See also
isValid().

◆ operator=() [1/2]

ActionSet & Ocean::Platform::OpenXR::ActionSet::operator= ( ActionSet &&  actionSet)
noexcept

Move operator.

Parameters
actionSetThe action set object to be moved
Returns
The reference to this object

◆ operator=() [2/2]

ActionSet & Ocean::Platform::OpenXR::ActionSet::operator= ( const ActionSet )
protecteddelete

Disabled assign operator.

Returns
The reference to this object

◆ release()

void Ocean::Platform::OpenXR::ActionSet::release ( )

Explicitly releases the action set and all associated actions and resources.

See also
initialize().

◆ suggestActionBindings() [1/2]

bool Ocean::Platform::OpenXR::ActionSet::suggestActionBindings ( const XrInstance &  xrInstance,
const std::string &  interactionProfile 
)
inline

Suggests the actions of this set as binding.

Parameters
xrInstanceThe OpenXR instance for which the action set will be created, must be valid
interactionProfileThe interaction profile to be used, must be valid
Returns
True, if succeeded
See also
actionBindingsSuggested().

◆ suggestActionBindings() [2/2]

bool Ocean::Platform::OpenXR::ActionSet::suggestActionBindings ( const XrInstance &  xrInstance,
const XrPath &  xrInteractionProfilePath 
)

Suggests the actions of this set as binding.

Parameters
xrInstanceThe OpenXR instance for which the action set will be created, must be valid
xrInteractionProfilePathThe interaction profile to be used, must be valid
Returns
True, if succeeded
See also
actionBindingsSuggested().

Field Documentation

◆ actionBindingsSuggested_

bool Ocean::Platform::OpenXR::ActionSet::actionBindingsSuggested_ = false
protected

True, if the actions have been set as applicated-suggested bindings.

◆ actionIdCounter_

ActionId Ocean::Platform::OpenXR::ActionSet::actionIdCounter_ = 0u
protected

The counter of unique action ids.

◆ actionIdMap_

ActionIdMap Ocean::Platform::OpenXR::ActionSet::actionIdMap_
protected

The actions of this action set.

◆ invalidActionId_

constexpr ActionId Ocean::Platform::OpenXR::ActionSet::invalidActionId_ = ActionId(-1)
staticconstexpr

An invalid action id.

◆ lock_

Lock Ocean::Platform::OpenXR::ActionSet::lock_
mutableprotected

The action set's lock.

◆ xrActionSet_

XrActionSet Ocean::Platform::OpenXR::ActionSet::xrActionSet_ = XR_NULL_HANDLE
protected

The action OpenXR action set.

◆ xrActionSuggestedBindings_

XrActionSuggestedBindings Ocean::Platform::OpenXR::ActionSet::xrActionSuggestedBindings_
protected

The XrActionSuggestedBindings of this action set.

◆ xrInstance_

XrInstance Ocean::Platform::OpenXR::ActionSet::xrInstance_ = XR_NULL_HANDLE
protected

The OpenXR instance associated with this action set.


The documentation for this class was generated from the following file: