12#include <unordered_map>
19#include "openvr_driver.h"
35 public vr::IVRDriverContext,
36 public vr::IVRServerDriverHost,
37 public vr::IVRDriverInput,
38 public vr::IVRProperties,
39 public vr::IVRDriverLog,
40 public std::enable_shared_from_this<Context>
54 uint64_t current_frame{0};
56 std::vector<vr::VRInputComponentHandle_t> handles;
57 std::unordered_map<vr::VRInputComponentHandle_t, xrt_input *> handle_to_input;
60 vr::VRInputComponentHandle_t x;
61 vr::VRInputComponentHandle_t y;
63 std::unordered_map<vr::VRInputComponentHandle_t, Vec2Components *> vec2_inputs;
64 std::unordered_map<xrt_input *, std::unique_ptr<Vec2Components>> vec2_input_to_components;
65 std::unordered_map<vr::VRInputComponentHandle_t, ControllerDevice *> skeleton_to_controller;
69 std::chrono::steady_clock::time_point insert_time;
72 std::deque<Event> events;
73 std::mutex event_queue_mut;
76 prop_container_to_device(vr::PropertyContainerHandle_t handle);
79 create_component_common(vr::PropertyContainerHandle_t container,
81 vr::VRInputComponentHandle_t *handle);
84 update_component_common(vr::VRInputComponentHandle_t handle,
86 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now());
89 setup_hmd(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
92 setup_controller(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
93 std::vector<vr::IServerTrackedDeviceProvider *> providers;
95 inline vr::VRInputComponentHandle_t
98 vr::VRInputComponentHandle_t h = handles.size() + 1;
113 [[nodiscard]]
static std::shared_ptr<Context>
114 create(
const std::string &steam_install,
115 const std::string &steamvr_install,
116 std::vector<vr::IServerTrackedDeviceProvider *> providers);
122 maybe_run_frame(uint64_t new_frame);
125 add_haptic_event(vr::VREvent_HapticVibration_t event);
128 add_vendor_event(vr::EVREventType
type,
const vr::VREvent_Data_t &data = {})
130 VendorSpecificEvent(0,
type, data, 0);
134 Log(
const char *pchLogMessage)
override;
139 GetGenericInterface(
const char *pchInterfaceVersion, vr::EVRInitError *peError)
override;
142 GetDriverHandle()
override;
146 TrackedDeviceAdded(
const char *pchDeviceSerialNumber,
147 vr::ETrackedDeviceClass eDeviceClass,
148 vr::ITrackedDeviceServerDriver *pDriver)
override;
151 TrackedDevicePoseUpdated(uint32_t unWhichDevice,
152 const vr::DriverPose_t &newPose,
153 uint32_t unPoseStructSize)
override;
156 VsyncEvent(
double vsyncTimeOffsetSeconds)
override;
159 VendorSpecificEvent(uint32_t unWhichDevice,
160 vr::EVREventType eventType,
161 const vr::VREvent_Data_t &eventData,
162 double eventTimeOffset)
override;
165 IsExiting()
override;
168 PollNextEvent(vr::VREvent_t *pEvent, uint32_t uncbVREvent)
override;
171 GetRawTrackedDevicePoses(
float fPredictedSecondsFromNow,
172 vr::TrackedDevicePose_t *pTrackedDevicePoseArray,
173 uint32_t unTrackedDevicePoseArrayCount)
override;
176 RequestRestart(
const char *pchLocalizedReason,
177 const char *pchExecutableToStart,
178 const char *pchArguments,
179 const char *pchWorkingDirectory)
override;
182 GetFrameTimings(vr::Compositor_FrameTiming *pTiming, uint32_t nFrames)
override;
185 SetDisplayEyeToHead(uint32_t unWhichDevice,
186 const vr::HmdMatrix34_t &eyeToHeadLeft,
187 const vr::HmdMatrix34_t &eyeToHeadRight)
override;
190 SetDisplayProjectionRaw(uint32_t unWhichDevice,
191 const vr::HmdRect2_t &eyeLeft,
192 const vr::HmdRect2_t &eyeRight)
override;
195 SetRecommendedRenderTargetSize(uint32_t unWhichDevice, uint32_t nWidth, uint32_t nHeight)
override;
200 CreateBooleanComponent(vr::PropertyContainerHandle_t ulContainer,
202 vr::VRInputComponentHandle_t *pHandle)
override;
205 UpdateBooleanComponent(vr::VRInputComponentHandle_t ulComponent,
bool bNewValue,
double fTimeOffset)
override;
208 CreateScalarComponent(vr::PropertyContainerHandle_t ulContainer,
210 vr::VRInputComponentHandle_t *pHandle,
211 vr::EVRScalarType eType,
212 vr::EVRScalarUnits eUnits)
override;
215 UpdateScalarComponent(vr::VRInputComponentHandle_t ulComponent,
float fNewValue,
double fTimeOffset)
override;
218 CreateHapticComponent(vr::PropertyContainerHandle_t ulContainer,
220 vr::VRInputComponentHandle_t *pHandle)
override;
223 CreateSkeletonComponent(vr::PropertyContainerHandle_t ulContainer,
225 const char *pchSkeletonPath,
226 const char *pchBasePosePath,
227 vr::EVRSkeletalTrackingLevel eSkeletalTrackingLevel,
228 const vr::VRBoneTransform_t *pGripLimitTransforms,
229 uint32_t unGripLimitTransformCount,
230 vr::VRInputComponentHandle_t *pHandle)
override;
233 UpdateSkeletonComponent(vr::VRInputComponentHandle_t ulComponent,
234 vr::EVRSkeletalMotionRange eMotionRange,
235 const vr::VRBoneTransform_t *pTransforms,
236 uint32_t unTransformCount)
override;
240 vr::ETrackedPropertyError
241 ReadPropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
242 vr::PropertyRead_t *pBatch,
243 uint32_t unBatchEntryCount)
override;
245 vr::ETrackedPropertyError
246 WritePropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
247 vr::PropertyWrite_t *pBatch,
248 uint32_t unBatchEntryCount)
override;
251 GetPropErrorNameFromEnum(vr::ETrackedPropertyError error)
override;
253 vr::PropertyContainerHandle_t
254 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:42
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:109
Definition: device.hpp:228
Definition: device.hpp:68
Definition: driver_manager.hpp:15
Definition: device.hpp:149
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:18
OpenVR IVRDriverManager interface header.
u_logging_level
Logging level enum.
Definition: u_logging.h:45
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:321
A tracking system or device origin.
Definition: xrt_tracking.h:75
char name[256]
For debugging.
Definition: xrt_tracking.h:77
enum xrt_tracking_type type
What can the state tracker expect from this tracking system.
Definition: xrt_tracking.h:80
Header defining the tracking system integration in Monado.