gramods
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
gramods::gmCore::OpenVR Class Reference

Initializer for OpenVR. More...

#include <OpenVR.hh>

Inheritance diagram for gramods::gmCore::OpenVR:
Inheritance graph
[legend]
Collaboration diagram for gramods::gmCore::OpenVR:
Collaboration graph
[legend]

Classes

struct  EventConsumer
 Interface for event consumers that can be registered with the OpenVR instance. More...
 
struct  Impl
 

Public Types

typedef std::array< vr::TrackedDevicePose_t, vr::k_unMaxTrackedDeviceCount > pose_list_t
 

Public Member Functions

void setUseVideo (bool on)
 Enable or disable initialization of HMD composer. More...
 
void setManifestPath (std::filesystem::path)
 Set path to manifest file, necessary for analog and button input. More...
 
void setActionSet (std::string name)
 Set which action set to read out data from. More...
 
void initialize () override
 Called to initialize the Object. More...
 
std::string getDefaultKey () override
 Returns the default key, in Configuration, for the Object. More...
 
std::optional< pose_list_t > & getPoseList ()
 Retrieve immediate tracking data as a post list, without prediction. More...
 
void addEventConsumer (std::weak_ptr< EventConsumer > ec)
 Add an object to receive events from OpenVR. More...
 
void removeEventConsumer (EventConsumer *ec)
 Remove an object to receive events from OpenVR. More...
 
Updateable::clock::time_point getLastTime ()
 Returns the last time this instance was updated. More...
 
std::optional< vr::InputAnalogActionData_t > getAnalog (std::string action, vr::VRInputValueHandle_t device=vr::k_ulInvalidInputValueHandle)
 Returns the analog data associated with the specified action. More...
 
std::optional< vr::InputDigitalActionData_t > getDigital (std::string action, vr::VRInputValueHandle_t device=vr::k_ulInvalidInputValueHandle)
 Returns the digital data associated with the specified action. More...
 
vr::ETrackedDeviceClass getType (size_t)
 Retrieves the device type (class) of the tracked device with the specified index. More...
 
vr::ETrackedControllerRole getRole (size_t)
 Retrieves the role of the tracked device with the specified index. More...
 
std::string getSerial (size_t)
 Retrieves the serial number of the tracked device with the specified index. More...
 
vr::IVRSystem * ptr ()
 Retrieve a pointer to the OpenVR system. More...
 
- Public Member Functions inherited from gramods::gmCore::Object
 Object ()
 Initializes internal data. More...
 
virtual ~Object ()
 Cleaning up internal data. More...
 
virtual void accept (Visitor *visitor)
 Calls the visitors apply method with this as argument. More...
 
virtual void traverse (Visitor *visitor)
 Calls the child Object's accept method, if such exist. More...
 
bool isInitialized ()
 Returns true if the Object is initialized. More...
 

Static Public Member Functions

static Eigen::Matrix4f convert (const vr::HmdMatrix34_t &m)
 Convert from OpenVR matrix format to Eigen 4x4 matrix. More...
 
static std::string typeToString (vr::ETrackedDeviceClass type)
 Convert device type (class) to string, e.g. More...
 
static std::string roleToString (vr::ETrackedControllerRole role)
 Convert device role to string, e.g. More...
 

Static Public Attributes

static gramods::gmCore::OFactory::OFactoryInformation _gm_ofi
 

Detailed Description

Initializer for OpenVR.

Create one and share this between all components that require OpenVR. OpenVR will be initialized upon calling OpenVR::initialize (automatically called by Configuration) and deinitialized when all shared pointers are released and the object destroyed.

Member Function Documentation

◆ addEventConsumer()

void gramods::gmCore::OpenVR::addEventConsumer ( std::weak_ptr< EventConsumer ec)

Add an object to receive events from OpenVR.

This has no effect if the pointer is null or invalid or if the object has already been added. The event consumers will be called in the order the were added.

◆ convert()

Eigen::Matrix4f gramods::gmCore::OpenVR::convert ( const vr::HmdMatrix34_t &  m)
static

Convert from OpenVR matrix format to Eigen 4x4 matrix.

◆ getAnalog()

std::optional< vr::InputAnalogActionData_t > gramods::gmCore::OpenVR::getAnalog ( std::string  action,
vr::VRInputValueHandle_t  device = vr::k_ulInvalidInputValueHandle 
)

Returns the analog data associated with the specified action.

◆ getDefaultKey()

std::string gramods::gmCore::OpenVR::getDefaultKey ( )
inlineoverridevirtual

Returns the default key, in Configuration, for the Object.

Reimplemented from gramods::gmCore::Object.

◆ getDigital()

std::optional< vr::InputDigitalActionData_t > gramods::gmCore::OpenVR::getDigital ( std::string  action,
vr::VRInputValueHandle_t  device = vr::k_ulInvalidInputValueHandle 
)

Returns the digital data associated with the specified action.

◆ getLastTime()

Updateable::clock::time_point gramods::gmCore::OpenVR::getLastTime ( )

Returns the last time this instance was updated.

◆ getPoseList()

std::optional< OpenVR::pose_list_t > & gramods::gmCore::OpenVR::getPoseList ( )

Retrieve immediate tracking data as a post list, without prediction.

This is cached so multiple calls during one frame does not equate multiple calls to OpenVR.

◆ getRole()

vr::ETrackedControllerRole gramods::gmCore::OpenVR::getRole ( size_t  idx)

Retrieves the role of the tracked device with the specified index.

◆ getSerial()

std::string gramods::gmCore::OpenVR::getSerial ( size_t  idx)

Retrieves the serial number of the tracked device with the specified index.

◆ getType()

vr::ETrackedDeviceClass gramods::gmCore::OpenVR::getType ( size_t  idx)

Retrieves the device type (class) of the tracked device with the specified index.

◆ initialize()

void gramods::gmCore::OpenVR::initialize ( )
overridevirtual

Called to initialize the Object.

This should be called once only!

Sub classes should override this method to make use of set parameter data. They should also always call its base class' implementation as well.

Reimplemented from gramods::gmCore::Object.

◆ ptr()

vr::IVRSystem * gramods::gmCore::OpenVR::ptr ( )

Retrieve a pointer to the OpenVR system.

◆ removeEventConsumer()

void gramods::gmCore::OpenVR::removeEventConsumer ( EventConsumer ec)

Remove an object to receive events from OpenVR.

This has no effect if the pointer is null or if the object has not been added.

◆ roleToString()

std::string gramods::gmCore::OpenVR::roleToString ( vr::ETrackedControllerRole  role)
static

Convert device role to string, e.g.

for print-out.

◆ setActionSet()

void gramods::gmCore::OpenVR::setActionSet ( std::string  name)

Set which action set to read out data from.

XML-attribute: actionSet

◆ setManifestPath()

void gramods::gmCore::OpenVR::setManifestPath ( std::filesystem::path  path)

Set path to manifest file, necessary for analog and button input.

XML-attribute: manifestPath

◆ setUseVideo()

void gramods::gmCore::OpenVR::setUseVideo ( bool  on)

Enable or disable initialization of HMD composer.

Default is false.

XML-attribute: useVideo

◆ typeToString()

std::string gramods::gmCore::OpenVR::typeToString ( vr::ETrackedDeviceClass  type)
static

Convert device type (class) to string, e.g.

for print-out.


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