gramods
Loading...
Searching...
No Matches
OpenVR.hh
1
2#ifndef GRAMODS_CORE_OPENVR
3#define GRAMODS_CORE_OPENVR
4
5#include <gmCore/config.hh>
6
7#ifdef gramods_ENABLE_OpenVR
8
9#include <gmCore/Object.hh>
10#include <gmCore/OFactory.hh>
11#include <gmCore/Updateable.hh>
12
13#include <openvr.h>
14
15#include <Eigen/Eigen>
16
17#include <memory>
18#include <array>
19#include <optional>
20
21BEGIN_NAMESPACE_GMCORE;
22
30class OpenVR : public gmCore::Object {
31
32public:
33
39
51 virtual bool processEvent(const vr::VREvent_t *event, bool is_consumed) = 0;
52 };
53
54 typedef std::array<vr::TrackedDevicePose_t, vr::k_unMaxTrackedDeviceCount>
55 pose_list_t;
56
57 OpenVR();
58 ~OpenVR();
59
66 void setUseVideo(bool on);
67
73 void setManifestPath(std::filesystem::path);
74
80 void setActionSet(std::string name);
81
82 void initialize() override;
83
88 std::string getDefaultKey() override { return "openVR"; }
89
95 std::optional<pose_list_t> &getPoseList();
96
103 void addEventConsumer(std::weak_ptr<EventConsumer> ec);
104
110 void removeEventConsumer(EventConsumer *ec);
111
115 Updateable::clock::time_point getLastTime();
116
120 std::optional<vr::InputAnalogActionData_t>
121 getAnalog(std::string action,
122 vr::VRInputValueHandle_t device = vr::k_ulInvalidInputValueHandle);
123
127 std::optional<vr::InputDigitalActionData_t>
128 getDigital(std::string action,
129 vr::VRInputValueHandle_t device = vr::k_ulInvalidInputValueHandle);
130
135 vr::ETrackedDeviceClass getType(size_t);
136
141 vr::ETrackedControllerRole getRole(size_t);
142
147 std::string getSerial(size_t);
148
152 vr::IVRSystem *ptr();
153
157 static Eigen::Matrix4f convert(const vr::HmdMatrix34_t &m);
158
162 static std::string typeToString(vr::ETrackedDeviceClass type);
163
167 static std::string roleToString(vr::ETrackedControllerRole role);
168
169 GM_OFI_DECLARE;
170
171private:
172 struct Impl;
173 std::unique_ptr<Impl> _impl;
174};
175
176END_NAMESPACE_GMCORE;
177
178#endif
179#endif
Base type for objects in the Gramods package for standardized handling of construction,...
Definition Object.hh:42
Initializer for OpenVR.
Definition OpenVR.hh:30
std::string getDefaultKey() override
Returns the default key, in Configuration, for the Object.
Definition OpenVR.hh:88
Interface for event consumers that can be registered with the OpenVR instance.
Definition OpenVR.hh:38
virtual bool processEvent(const vr::VREvent_t *event, bool is_consumed)=0
Process an incoming OpenVR event and return true if the event was acted upon.