12#include <unordered_map>
19#include "openvr_driver.h"
50 public vr::IVRDriverContext,
51 public vr::IVRServerDriverHost,
52 public vr::IVRDriverInput,
53 public vr::IVRProperties,
54 public vr::IVRDriverLog,
55 public std::enable_shared_from_this<Context>
66 uint64_t current_frame{0};
68 std::vector<vr::VRInputComponentHandle_t> handles;
69 std::unordered_map<vr::VRInputComponentHandle_t, xrt_input *> handle_to_input;
70 std::unordered_map<vr::VRInputComponentHandle_t, IndexFingerInput *> handle_to_finger;
73 vr::VRInputComponentHandle_t x;
74 vr::VRInputComponentHandle_t y;
76 std::unordered_map<vr::VRInputComponentHandle_t, Vec2Components *> vec2_inputs;
77 std::unordered_map<xrt_input *, std::unique_ptr<Vec2Components>> vec2_input_to_components;
81 std::chrono::steady_clock::time_point insert_time;
84 std::deque<Event> events;
85 std::mutex event_queue_mut;
88 prop_container_to_device(vr::PropertyContainerHandle_t handle);
91 create_component_common(vr::PropertyContainerHandle_t container,
93 vr::VRInputComponentHandle_t *handle);
96 update_component_common(vr::VRInputComponentHandle_t handle,
98 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now());
101 setup_hmd(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
104 setup_controller(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
105 std::vector<vr::IServerTrackedDeviceProvider *> providers;
107 inline vr::VRInputComponentHandle_t
110 vr::VRInputComponentHandle_t h = handles.size() + 1;
111 handles.push_back(h);
125 [[nodiscard]]
static std::shared_ptr<Context>
126 create(
const std::string &steam_install,
127 const std::string &steamvr_install,
128 std::vector<vr::IServerTrackedDeviceProvider *> providers);
134 maybe_run_frame(uint64_t new_frame);
137 add_haptic_event(vr::VREvent_HapticVibration_t event);
140 Log(
const char *pchLogMessage)
override;
145 GetGenericInterface(
const char *pchInterfaceVersion, vr::EVRInitError *peError)
override;
148 GetDriverHandle()
override;
152 TrackedDeviceAdded(
const char *pchDeviceSerialNumber,
153 vr::ETrackedDeviceClass eDeviceClass,
154 vr::ITrackedDeviceServerDriver *pDriver)
override;
157 TrackedDevicePoseUpdated(uint32_t unWhichDevice,
158 const vr::DriverPose_t &newPose,
159 uint32_t unPoseStructSize)
override;
162 VsyncEvent(
double vsyncTimeOffsetSeconds)
override;
165 VendorSpecificEvent(uint32_t unWhichDevice,
166 vr::EVREventType eventType,
167 const vr::VREvent_Data_t &eventData,
168 double eventTimeOffset)
override;
171 IsExiting()
override;
174 PollNextEvent(vr::VREvent_t *pEvent, uint32_t uncbVREvent)
override;
177 GetRawTrackedDevicePoses(
float fPredictedSecondsFromNow,
178 vr::TrackedDevicePose_t *pTrackedDevicePoseArray,
179 uint32_t unTrackedDevicePoseArrayCount)
override;
182 RequestRestart(
const char *pchLocalizedReason,
183 const char *pchExecutableToStart,
184 const char *pchArguments,
185 const char *pchWorkingDirectory)
override;
188 GetFrameTimings(vr::Compositor_FrameTiming *pTiming, uint32_t nFrames)
override;
191 SetDisplayEyeToHead(uint32_t unWhichDevice,
192 const vr::HmdMatrix34_t &eyeToHeadLeft,
193 const vr::HmdMatrix34_t &eyeToHeadRight)
override;
196 SetDisplayProjectionRaw(uint32_t unWhichDevice,
197 const vr::HmdRect2_t &eyeLeft,
198 const vr::HmdRect2_t &eyeRight)
override;
201 SetRecommendedRenderTargetSize(uint32_t unWhichDevice, uint32_t nWidth, uint32_t nHeight)
override;
206 CreateBooleanComponent(vr::PropertyContainerHandle_t ulContainer,
208 vr::VRInputComponentHandle_t *pHandle)
override;
211 UpdateBooleanComponent(vr::VRInputComponentHandle_t ulComponent,
bool bNewValue,
double fTimeOffset)
override;
214 CreateScalarComponent(vr::PropertyContainerHandle_t ulContainer,
216 vr::VRInputComponentHandle_t *pHandle,
217 vr::EVRScalarType eType,
218 vr::EVRScalarUnits eUnits)
override;
221 UpdateScalarComponent(vr::VRInputComponentHandle_t ulComponent,
float fNewValue,
double fTimeOffset)
override;
224 CreateHapticComponent(vr::PropertyContainerHandle_t ulContainer,
226 vr::VRInputComponentHandle_t *pHandle)
override;
229 CreateSkeletonComponent(vr::PropertyContainerHandle_t ulContainer,
231 const char *pchSkeletonPath,
232 const char *pchBasePosePath,
233 vr::EVRSkeletalTrackingLevel eSkeletalTrackingLevel,
234 const vr::VRBoneTransform_t *pGripLimitTransforms,
235 uint32_t unGripLimitTransformCount,
236 vr::VRInputComponentHandle_t *pHandle)
override;
239 UpdateSkeletonComponent(vr::VRInputComponentHandle_t ulComponent,
240 vr::EVRSkeletalMotionRange eMotionRange,
241 const vr::VRBoneTransform_t *pTransforms,
242 uint32_t unTransformCount)
override;
246 vr::ETrackedPropertyError
247 ReadPropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
248 vr::PropertyRead_t *pBatch,
249 uint32_t unBatchEntryCount)
override;
251 vr::ETrackedPropertyError
252 WritePropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
253 vr::PropertyWrite_t *pBatch,
254 uint32_t unBatchEntryCount)
override;
257 GetPropErrorNameFromEnum(vr::ETrackedPropertyError error)
override;
259 vr::PropertyContainerHandle_t
260 TrackedDeviceToPropertyContainer(vr::TrackedDeviceIndex_t nDevice)
override;
OpenVR IVRBlockQueue interface header.
This interface is missing in the C++ header but present in the C one, and the lighthouse driver requi...
Definition: blockqueue.hpp:43
Definition: context.hpp:57
static std::shared_ptr< Context > create(const std::string &steam_install, const std::string &steamvr_install, std::vector< vr::IServerTrackedDeviceProvider * > providers)
Since only the devices will live after our get_devices function is called, we make our Context a shar...
Definition: steamvr_lh.cpp:93
Definition: device.hpp:161
Definition: device.hpp:48
Definition: driver_manager.hpp:15
Definition: device.hpp:107
Definition: iobuffer.hpp:15
This interface is missing in the C++ header but present in the C one, and the lighthouse driver requi...
Definition: paths.hpp:21
Definition: resources.hpp:16
An internal interface utilized by the lighthouse driver.
Definition: server.hpp:15
Definition: settings.hpp:16
OpenVR IVRDriverManager interface header.
u_logging_level
Logging level enum.
Definition: u_logging.h:43
OpenVR IVRIOBuffer interface header.
OpenVR IVRPaths interface header.
OpenVR IVRResources interface header.
OpenVR IVRServer internal interface header.
OpenVR IVRSettings interface header.
struct xrt_hmd_parts * hmd
Null if this device does not interface with the users head.
Definition: xrt_device.h:253
A tracking system or device origin.
Definition: xrt_tracking.h:71
char name[256]
For debugging.
Definition: xrt_tracking.h:73
Header defining the tracking system integration in Monado.