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 vr::IServerTrackedDeviceProvider *provider;
107 inline vr::VRInputComponentHandle_t
110 vr::VRInputComponentHandle_t h = handles.size() + 1;
111 handles.push_back(h);
126 [[nodiscard]]
static std::shared_ptr<Context>
127 create(
const std::string &steam_install,
128 const std::string &steamvr_install,
129 vr::IServerTrackedDeviceProvider *p);
132 maybe_run_frame(uint64_t new_frame);
135 add_haptic_event(vr::VREvent_HapticVibration_t event);
138 Log(
const char *pchLogMessage)
override;
143 GetGenericInterface(
const char *pchInterfaceVersion, vr::EVRInitError *peError)
override;
146 GetDriverHandle()
override;
150 TrackedDeviceAdded(
const char *pchDeviceSerialNumber,
151 vr::ETrackedDeviceClass eDeviceClass,
152 vr::ITrackedDeviceServerDriver *pDriver)
override;
155 TrackedDevicePoseUpdated(uint32_t unWhichDevice,
156 const vr::DriverPose_t &newPose,
157 uint32_t unPoseStructSize)
override;
160 VsyncEvent(
double vsyncTimeOffsetSeconds)
override;
163 VendorSpecificEvent(uint32_t unWhichDevice,
164 vr::EVREventType eventType,
165 const vr::VREvent_Data_t &eventData,
166 double eventTimeOffset)
override;
169 IsExiting()
override;
172 PollNextEvent(vr::VREvent_t *pEvent, uint32_t uncbVREvent)
override;
175 GetRawTrackedDevicePoses(
float fPredictedSecondsFromNow,
176 vr::TrackedDevicePose_t *pTrackedDevicePoseArray,
177 uint32_t unTrackedDevicePoseArrayCount)
override;
180 RequestRestart(
const char *pchLocalizedReason,
181 const char *pchExecutableToStart,
182 const char *pchArguments,
183 const char *pchWorkingDirectory)
override;
186 GetFrameTimings(vr::Compositor_FrameTiming *pTiming, uint32_t nFrames)
override;
189 SetDisplayEyeToHead(uint32_t unWhichDevice,
190 const vr::HmdMatrix34_t &eyeToHeadLeft,
191 const vr::HmdMatrix34_t &eyeToHeadRight)
override;
194 SetDisplayProjectionRaw(uint32_t unWhichDevice,
195 const vr::HmdRect2_t &eyeLeft,
196 const vr::HmdRect2_t &eyeRight)
override;
199 SetRecommendedRenderTargetSize(uint32_t unWhichDevice, uint32_t nWidth, uint32_t nHeight)
override;
204 CreateBooleanComponent(vr::PropertyContainerHandle_t ulContainer,
206 vr::VRInputComponentHandle_t *pHandle)
override;
209 UpdateBooleanComponent(vr::VRInputComponentHandle_t ulComponent,
bool bNewValue,
double fTimeOffset)
override;
212 CreateScalarComponent(vr::PropertyContainerHandle_t ulContainer,
214 vr::VRInputComponentHandle_t *pHandle,
215 vr::EVRScalarType eType,
216 vr::EVRScalarUnits eUnits)
override;
219 UpdateScalarComponent(vr::VRInputComponentHandle_t ulComponent,
float fNewValue,
double fTimeOffset)
override;
222 CreateHapticComponent(vr::PropertyContainerHandle_t ulContainer,
224 vr::VRInputComponentHandle_t *pHandle)
override;
227 CreateSkeletonComponent(vr::PropertyContainerHandle_t ulContainer,
229 const char *pchSkeletonPath,
230 const char *pchBasePosePath,
231 vr::EVRSkeletalTrackingLevel eSkeletalTrackingLevel,
232 const vr::VRBoneTransform_t *pGripLimitTransforms,
233 uint32_t unGripLimitTransformCount,
234 vr::VRInputComponentHandle_t *pHandle)
override;
237 UpdateSkeletonComponent(vr::VRInputComponentHandle_t ulComponent,
238 vr::EVRSkeletalMotionRange eMotionRange,
239 const vr::VRBoneTransform_t *pTransforms,
240 uint32_t unTransformCount)
override;
244 vr::ETrackedPropertyError
245 ReadPropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
246 vr::PropertyRead_t *pBatch,
247 uint32_t unBatchEntryCount)
override;
249 vr::ETrackedPropertyError
250 WritePropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
251 vr::PropertyWrite_t *pBatch,
252 uint32_t unBatchEntryCount)
override;
255 GetPropErrorNameFromEnum(vr::ETrackedPropertyError error)
override;
257 vr::PropertyContainerHandle_t
258 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, vr::IServerTrackedDeviceProvider *p)
Since only the devices will live after our get_devices function is called, we make our Context a shar...
Definition: steamvr_lh.cpp:71
Definition: device.hpp:149
Definition: device.hpp:40
Definition: driver_manager.hpp:15
Definition: device.hpp:95
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:40
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:242
A tracking system or device origin.
Definition: xrt_tracking.h:71
char name[256]
For debugging.
Definition: xrt_tracking.h:73
struct xrt_pose offset
Read and written to by the state-tracker using the device(s) this tracking system is tracking.
Definition: xrt_tracking.h:82
Header defining the tracking system integration in Monado.