gramods
|
Initializer for OpenVR. More...
#include <OpenVR.hh>
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... | |
![]() | |
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 |
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.
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.
|
static |
Convert from OpenVR matrix format to Eigen 4x4 matrix.
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.
|
inlineoverridevirtual |
Returns the default key, in Configuration, for the Object.
Reimplemented from gramods::gmCore::Object.
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.
Updateable::clock::time_point gramods::gmCore::OpenVR::getLastTime | ( | ) |
Returns the last time this instance was updated.
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.
vr::ETrackedControllerRole gramods::gmCore::OpenVR::getRole | ( | size_t | idx | ) |
Retrieves the role of the tracked device with the specified index.
std::string gramods::gmCore::OpenVR::getSerial | ( | size_t | idx | ) |
Retrieves the serial number of the tracked device with the specified index.
vr::ETrackedDeviceClass gramods::gmCore::OpenVR::getType | ( | size_t | idx | ) |
Retrieves the device type (class) of the tracked device with the specified index.
|
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.
vr::IVRSystem * gramods::gmCore::OpenVR::ptr | ( | ) |
Retrieve a pointer to the OpenVR system.
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.
|
static |
Convert device role to string, e.g.
for print-out.
void gramods::gmCore::OpenVR::setActionSet | ( | std::string | name | ) |
Set which action set to read out data from.
XML-attribute: actionSet
void gramods::gmCore::OpenVR::setManifestPath | ( | std::filesystem::path | path | ) |
Set path to manifest file, necessary for analog and button input.
XML-attribute: manifestPath
void gramods::gmCore::OpenVR::setUseVideo | ( | bool | on | ) |
|
static |
Convert device type (class) to string, e.g.
for print-out.