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>
 
   69        uint64_t current_frame{0};
 
   71        std::vector<vr::VRInputComponentHandle_t> handles;
 
   72        std::unordered_map<vr::VRInputComponentHandle_t, xrt_input *> handle_to_input;
 
   73        std::unordered_map<vr::VRInputComponentHandle_t, IndexFingerInput *> handle_to_finger;
 
   76                vr::VRInputComponentHandle_t x;
 
   77                vr::VRInputComponentHandle_t y;
 
   79        std::unordered_map<vr::VRInputComponentHandle_t, Vec2Components *> vec2_inputs;
 
   80        std::unordered_map<xrt_input *, std::unique_ptr<Vec2Components>> vec2_input_to_components;
 
   84                std::chrono::steady_clock::time_point insert_time;
 
   87        std::deque<Event> events;
 
   88        std::mutex event_queue_mut;
 
   91        prop_container_to_device(vr::PropertyContainerHandle_t handle);
 
   94        create_component_common(vr::PropertyContainerHandle_t container,
 
   96                                vr::VRInputComponentHandle_t *handle);
 
   99        update_component_common(vr::VRInputComponentHandle_t handle,
 
  101                                std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now());
 
  104        setup_hmd(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
 
  107        setup_controller(
const char *serial, vr::ITrackedDeviceServerDriver *driver);
 
  108        std::vector<vr::IServerTrackedDeviceProvider *> providers;
 
  110        inline vr::VRInputComponentHandle_t
 
  113                vr::VRInputComponentHandle_t h = handles.size() + 1;
 
  114                handles.push_back(h);
 
  128        [[nodiscard]] 
static std::shared_ptr<Context>
 
  129        create(
const std::string &steam_install,
 
  130               const std::string &steamvr_install,
 
  131               std::vector<vr::IServerTrackedDeviceProvider *> providers);
 
  137        maybe_run_frame(uint64_t new_frame);
 
  140        add_haptic_event(vr::VREvent_HapticVibration_t event);
 
  143        add_vendor_event(vr::EVREventType 
type, 
const vr::VREvent_Data_t &data = {})
 
  145                VendorSpecificEvent(0, 
type, data, 0);
 
  149        Log(
const char *pchLogMessage) 
override;
 
  154        GetGenericInterface(
const char *pchInterfaceVersion, vr::EVRInitError *peError) 
override;
 
  157        GetDriverHandle() 
override;
 
  161        TrackedDeviceAdded(
const char *pchDeviceSerialNumber,
 
  162                           vr::ETrackedDeviceClass eDeviceClass,
 
  163                           vr::ITrackedDeviceServerDriver *pDriver) 
override;
 
  166        TrackedDevicePoseUpdated(uint32_t unWhichDevice,
 
  167                                 const vr::DriverPose_t &newPose,
 
  168                                 uint32_t unPoseStructSize) 
override;
 
  171        VsyncEvent(
double vsyncTimeOffsetSeconds) 
override;
 
  174        VendorSpecificEvent(uint32_t unWhichDevice,
 
  175                            vr::EVREventType eventType,
 
  176                            const vr::VREvent_Data_t &eventData,
 
  177                            double eventTimeOffset) 
override;
 
  180        IsExiting() 
override;
 
  183        PollNextEvent(vr::VREvent_t *pEvent, uint32_t uncbVREvent) 
override;
 
  186        GetRawTrackedDevicePoses(
float fPredictedSecondsFromNow,
 
  187                                 vr::TrackedDevicePose_t *pTrackedDevicePoseArray,
 
  188                                 uint32_t unTrackedDevicePoseArrayCount) 
override;
 
  191        RequestRestart(
const char *pchLocalizedReason,
 
  192                       const char *pchExecutableToStart,
 
  193                       const char *pchArguments,
 
  194                       const char *pchWorkingDirectory) 
override;
 
  197        GetFrameTimings(vr::Compositor_FrameTiming *pTiming, uint32_t nFrames) 
override;
 
  200        SetDisplayEyeToHead(uint32_t unWhichDevice,
 
  201                            const vr::HmdMatrix34_t &eyeToHeadLeft,
 
  202                            const vr::HmdMatrix34_t &eyeToHeadRight) 
override;
 
  205        SetDisplayProjectionRaw(uint32_t unWhichDevice,
 
  206                                const vr::HmdRect2_t &eyeLeft,
 
  207                                const vr::HmdRect2_t &eyeRight) 
override;
 
  210        SetRecommendedRenderTargetSize(uint32_t unWhichDevice, uint32_t nWidth, uint32_t nHeight) 
override;
 
  215        CreateBooleanComponent(vr::PropertyContainerHandle_t ulContainer,
 
  217                               vr::VRInputComponentHandle_t *pHandle) 
override;
 
  220        UpdateBooleanComponent(vr::VRInputComponentHandle_t ulComponent, 
bool bNewValue, 
double fTimeOffset) 
override;
 
  223        CreateScalarComponent(vr::PropertyContainerHandle_t ulContainer,
 
  225                              vr::VRInputComponentHandle_t *pHandle,
 
  226                              vr::EVRScalarType eType,
 
  227                              vr::EVRScalarUnits eUnits) 
override;
 
  230        UpdateScalarComponent(vr::VRInputComponentHandle_t ulComponent, 
float fNewValue, 
double fTimeOffset) 
override;
 
  233        CreateHapticComponent(vr::PropertyContainerHandle_t ulContainer,
 
  235                              vr::VRInputComponentHandle_t *pHandle) 
override;
 
  238        CreateSkeletonComponent(vr::PropertyContainerHandle_t ulContainer,
 
  240                                const char *pchSkeletonPath,
 
  241                                const char *pchBasePosePath,
 
  242                                vr::EVRSkeletalTrackingLevel eSkeletalTrackingLevel,
 
  243                                const vr::VRBoneTransform_t *pGripLimitTransforms,
 
  244                                uint32_t unGripLimitTransformCount,
 
  245                                vr::VRInputComponentHandle_t *pHandle) 
override;
 
  248        UpdateSkeletonComponent(vr::VRInputComponentHandle_t ulComponent,
 
  249                                vr::EVRSkeletalMotionRange eMotionRange,
 
  250                                const vr::VRBoneTransform_t *pTransforms,
 
  251                                uint32_t unTransformCount) 
override;
 
  255        vr::ETrackedPropertyError
 
  256        ReadPropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
 
  257                          vr::PropertyRead_t *pBatch,
 
  258                          uint32_t unBatchEntryCount) 
override;
 
  260        vr::ETrackedPropertyError
 
  261        WritePropertyBatch(vr::PropertyContainerHandle_t ulContainerHandle,
 
  262                           vr::PropertyWrite_t *pBatch,
 
  263                           uint32_t unBatchEntryCount) 
override;
 
  266        GetPropErrorNameFromEnum(vr::ETrackedPropertyError error) 
override;
 
  268        vr::PropertyContainerHandle_t
 
  269        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:109
Definition: device.hpp:220
Definition: device.hpp:64
Definition: driver_manager.hpp:15
Definition: device.hpp:145
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:44
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:294
A tracking system or device origin.
Definition: xrt_tracking.h:71
char name[256]
For debugging.
Definition: xrt_tracking.h:73
enum xrt_tracking_type type
What can the state tracker expect from this tracking system.
Definition: xrt_tracking.h:76
Header defining the tracking system integration in Monado.