The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

external: Add OpenVR driver header

authored by

Jakob Bornecrantz and committed by
Christoph Haag
b6c34753 9d894ab5

+3039
+3
src/external/CMakeLists.txt
··· 4 4 # Catch2 5 5 add_library(xrt-external-catch2 INTERFACE) 6 6 target_include_directories(xrt-external-catch2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Catch2) 7 + add_library(xrt-external-openvr INTERFACE) 8 + target_include_directories(xrt-external-openvr INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/openvr_includes) 9 + 7 10 8 11 # cJSON 9 12 add_library(xrt-external-cjson INTERFACE)
+1
src/external/meson.build
··· 1 1 # Copyright 2019-2020, Collabora, Ltd. 2 2 # SPDX-License-Identifier: BSL-1.0 3 3 4 + openvr_include = include_directories('openvr_includes') 4 5 cjson_include = include_directories('cjson') 5 6 flexkalman_include = include_directories('flexkalman') 6 7 glad_include = include_directories('glad/include')
+3
src/external/openvr_includes/CHANGELOG.md
··· 1 + # Current version 2 + 3 + * Synced on 2020-06-10 `OpenVR SDK 1.12.5`
+27
src/external/openvr_includes/LICENSE
··· 1 + Copyright (c) 2015, Valve Corporation 2 + All rights reserved. 3 + 4 + Redistribution and use in source and binary forms, with or without modification, 5 + are permitted provided that the following conditions are met: 6 + 7 + 1. Redistributions of source code must retain the above copyright notice, this 8 + list of conditions and the following disclaimer. 9 + 10 + 2. Redistributions in binary form must reproduce the above copyright notice, 11 + this list of conditions and the following disclaimer in the documentation and/or 12 + other materials provided with the distribution. 13 + 14 + 3. Neither the name of the copyright holder nor the names of its contributors 15 + may be used to endorse or promote products derived from this software without 16 + specific prior written permission. 17 + 18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+3005
src/external/openvr_includes/openvr_driver.h
··· 1 + #pragma once 2 + 3 + // openvr_driver.h 4 + //========= Copyright Valve Corporation ============// 5 + // Dynamically generated file. Do not modify this file directly. 6 + 7 + #ifndef _OPENVR_DRIVER_API 8 + #define _OPENVR_DRIVER_API 9 + 10 + #include <stdint.h> 11 + 12 + 13 + 14 + // vrtypes.h 15 + #ifndef _INCLUDE_VRTYPES_H 16 + #define _INCLUDE_VRTYPES_H 17 + 18 + // Forward declarations to avoid requiring vulkan.h 19 + struct VkDevice_T; 20 + struct VkPhysicalDevice_T; 21 + struct VkInstance_T; 22 + struct VkQueue_T; 23 + 24 + // Forward declarations to avoid requiring d3d12.h 25 + struct ID3D12Resource; 26 + struct ID3D12CommandQueue; 27 + 28 + namespace vr 29 + { 30 + #pragma pack( push, 8 ) 31 + 32 + typedef void* glSharedTextureHandle_t; 33 + typedef int32_t glInt_t; 34 + typedef uint32_t glUInt_t; 35 + 36 + // right-handed system 37 + // +y is up 38 + // +x is to the right 39 + // -z is forward 40 + // Distance unit is meters 41 + struct HmdMatrix34_t 42 + { 43 + float m[3][4]; 44 + }; 45 + 46 + struct HmdMatrix44_t 47 + { 48 + float m[4][4]; 49 + }; 50 + 51 + struct HmdVector3_t 52 + { 53 + float v[3]; 54 + }; 55 + 56 + struct HmdVector4_t 57 + { 58 + float v[4]; 59 + }; 60 + 61 + struct HmdVector3d_t 62 + { 63 + double v[3]; 64 + }; 65 + 66 + struct HmdVector2_t 67 + { 68 + float v[2]; 69 + }; 70 + 71 + struct HmdQuaternion_t 72 + { 73 + double w, x, y, z; 74 + }; 75 + 76 + struct HmdColor_t 77 + { 78 + float r, g, b, a; 79 + }; 80 + 81 + struct HmdQuad_t 82 + { 83 + HmdVector3_t vCorners[ 4 ]; 84 + }; 85 + 86 + struct HmdRect2_t 87 + { 88 + HmdVector2_t vTopLeft; 89 + HmdVector2_t vBottomRight; 90 + }; 91 + 92 + /** Used to return the post-distortion UVs for each color channel. 93 + * UVs range from 0 to 1 with 0,0 in the upper left corner of the 94 + * source render target. The 0,0 to 1,1 range covers a single eye. */ 95 + struct DistortionCoordinates_t 96 + { 97 + float rfRed[2]; 98 + float rfGreen[2]; 99 + float rfBlue[2]; 100 + }; 101 + 102 + enum EVREye 103 + { 104 + Eye_Left = 0, 105 + Eye_Right = 1 106 + }; 107 + 108 + enum ETextureType 109 + { 110 + TextureType_DirectX = 0, // Handle is an ID3D11Texture 111 + TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags 112 + TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure 113 + TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef 114 + TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure 115 + TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets. 116 + // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it 117 + }; 118 + 119 + enum EColorSpace 120 + { 121 + ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants. 122 + ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format). 123 + ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm. 124 + }; 125 + 126 + struct Texture_t 127 + { 128 + void* handle; // See ETextureType definition above 129 + ETextureType eType; 130 + EColorSpace eColorSpace; 131 + }; 132 + 133 + // Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource). 134 + typedef uint64_t SharedTextureHandle_t; 135 + #define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0) 136 + 137 + enum ETrackingResult 138 + { 139 + TrackingResult_Uninitialized = 1, 140 + 141 + TrackingResult_Calibrating_InProgress = 100, 142 + TrackingResult_Calibrating_OutOfRange = 101, 143 + 144 + TrackingResult_Running_OK = 200, 145 + TrackingResult_Running_OutOfRange = 201, 146 + }; 147 + 148 + typedef uint32_t DriverId_t; 149 + static const uint32_t k_nDriverNone = 0xFFFFFFFF; 150 + 151 + static const uint32_t k_unMaxDriverDebugResponseSize = 32768; 152 + 153 + /** Used to pass device IDs to API calls */ 154 + typedef uint32_t TrackedDeviceIndex_t; 155 + static const uint32_t k_unTrackedDeviceIndex_Hmd = 0; 156 + static const uint32_t k_unMaxTrackedDeviceCount = 64; 157 + static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE; 158 + static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF; 159 + 160 + /** Describes what kind of object is being tracked at a given ID */ 161 + enum ETrackedDeviceClass 162 + { 163 + TrackedDeviceClass_Invalid = 0, // the ID was not valid. 164 + TrackedDeviceClass_HMD = 1, // Head-Mounted Displays 165 + TrackedDeviceClass_Controller = 2, // Tracked controllers 166 + TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers 167 + TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points 168 + TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices 169 + }; 170 + 171 + 172 + /** Describes what specific role associated with a tracked device */ 173 + enum ETrackedControllerRole 174 + { 175 + TrackedControllerRole_Invalid = 0, // Invalid value for controller type 176 + TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand 177 + TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand 178 + TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection 179 + TrackedControllerRole_Max = 4 180 + }; 181 + 182 + 183 + /** describes a single pose for a tracked object */ 184 + struct TrackedDevicePose_t 185 + { 186 + HmdMatrix34_t mDeviceToAbsoluteTracking; 187 + HmdVector3_t vVelocity; // velocity in tracker space in m/s 188 + HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?) 189 + ETrackingResult eTrackingResult; 190 + bool bPoseIsValid; 191 + 192 + // This indicates that there is a device connected for this spot in the pose array. 193 + // It could go from true to false if the user unplugs the device. 194 + bool bDeviceIsConnected; 195 + }; 196 + 197 + /** Identifies which style of tracking origin the application wants to use 198 + * for the poses it is requesting */ 199 + enum ETrackingUniverseOrigin 200 + { 201 + TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose 202 + TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user 203 + TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one. 204 + }; 205 + 206 + typedef uint64_t WebConsoleHandle_t; 207 + #define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0) 208 + 209 + // Refers to a single container of properties 210 + typedef uint64_t PropertyContainerHandle_t; 211 + typedef uint32_t PropertyTypeTag_t; 212 + 213 + static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0; 214 + static const PropertyTypeTag_t k_unInvalidPropertyTag = 0; 215 + 216 + typedef PropertyContainerHandle_t DriverHandle_t; 217 + static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0; 218 + 219 + // Use these tags to set/get common types as struct properties 220 + static const PropertyTypeTag_t k_unFloatPropertyTag = 1; 221 + static const PropertyTypeTag_t k_unInt32PropertyTag = 2; 222 + static const PropertyTypeTag_t k_unUint64PropertyTag = 3; 223 + static const PropertyTypeTag_t k_unBoolPropertyTag = 4; 224 + static const PropertyTypeTag_t k_unStringPropertyTag = 5; 225 + 226 + static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20; 227 + static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21; 228 + static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22; 229 + static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23; 230 + 231 + static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30; 232 + static const PropertyTypeTag_t k_unPathHandleInfoTag = 31; 233 + static const PropertyTypeTag_t k_unActionPropertyTag = 32; 234 + static const PropertyTypeTag_t k_unInputValuePropertyTag = 33; 235 + static const PropertyTypeTag_t k_unWildcardPropertyTag = 34; 236 + static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35; 237 + 238 + static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; 239 + static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; 240 + 241 + 242 + /** Each entry in this enum represents a property that can be retrieved about a 243 + * tracked device. Many fields are only valid for one ETrackedDeviceClass. */ 244 + enum ETrackedDeviceProperty 245 + { 246 + Prop_Invalid = 0, 247 + 248 + // general properties that apply to all device classes 249 + Prop_TrackingSystemName_String = 1000, 250 + Prop_ModelNumber_String = 1001, 251 + Prop_SerialNumber_String = 1002, 252 + Prop_RenderModelName_String = 1003, 253 + Prop_WillDriftInYaw_Bool = 1004, 254 + Prop_ManufacturerName_String = 1005, 255 + Prop_TrackingFirmwareVersion_String = 1006, 256 + Prop_HardwareRevision_String = 1007, 257 + Prop_AllWirelessDongleDescriptions_String = 1008, 258 + Prop_ConnectedWirelessDongle_String = 1009, 259 + Prop_DeviceIsWireless_Bool = 1010, 260 + Prop_DeviceIsCharging_Bool = 1011, 261 + Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full 262 + Prop_StatusDisplayTransform_Matrix34 = 1013, 263 + Prop_Firmware_UpdateAvailable_Bool = 1014, 264 + Prop_Firmware_ManualUpdate_Bool = 1015, 265 + Prop_Firmware_ManualUpdateURL_String = 1016, 266 + Prop_HardwareRevision_Uint64 = 1017, 267 + Prop_FirmwareVersion_Uint64 = 1018, 268 + Prop_FPGAVersion_Uint64 = 1019, 269 + Prop_VRCVersion_Uint64 = 1020, 270 + Prop_RadioVersion_Uint64 = 1021, 271 + Prop_DongleVersion_Uint64 = 1022, 272 + Prop_BlockServerShutdown_Bool = 1023, 273 + Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024, 274 + Prop_ContainsProximitySensor_Bool = 1025, 275 + Prop_DeviceProvidesBatteryStatus_Bool = 1026, 276 + Prop_DeviceCanPowerOff_Bool = 1027, 277 + Prop_Firmware_ProgrammingTarget_String = 1028, 278 + Prop_DeviceClass_Int32 = 1029, 279 + Prop_HasCamera_Bool = 1030, 280 + Prop_DriverVersion_String = 1031, 281 + Prop_Firmware_ForceUpdateRequired_Bool = 1032, 282 + Prop_ViveSystemButtonFixRequired_Bool = 1033, 283 + Prop_ParentDriver_Uint64 = 1034, 284 + Prop_ResourceRoot_String = 1035, 285 + Prop_RegisteredDeviceType_String = 1036, 286 + Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided 287 + Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design 288 + Prop_NumCameras_Int32 = 1039, 289 + Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value 290 + 291 + // Properties that are unique to TrackedDeviceClass_HMD 292 + Prop_ReportsTimeSinceVSync_Bool = 2000, 293 + Prop_SecondsFromVsyncToPhotons_Float = 2001, 294 + Prop_DisplayFrequency_Float = 2002, 295 + Prop_UserIpdMeters_Float = 2003, 296 + Prop_CurrentUniverseId_Uint64 = 2004, 297 + Prop_PreviousUniverseId_Uint64 = 2005, 298 + Prop_DisplayFirmwareVersion_Uint64 = 2006, 299 + Prop_IsOnDesktop_Bool = 2007, 300 + Prop_DisplayMCType_Int32 = 2008, 301 + Prop_DisplayMCOffset_Float = 2009, 302 + Prop_DisplayMCScale_Float = 2010, 303 + Prop_EdidVendorID_Int32 = 2011, 304 + Prop_DisplayMCImageLeft_String = 2012, 305 + Prop_DisplayMCImageRight_String = 2013, 306 + Prop_DisplayGCBlackClamp_Float = 2014, 307 + Prop_EdidProductID_Int32 = 2015, 308 + Prop_CameraToHeadTransform_Matrix34 = 2016, 309 + Prop_DisplayGCType_Int32 = 2017, 310 + Prop_DisplayGCOffset_Float = 2018, 311 + Prop_DisplayGCScale_Float = 2019, 312 + Prop_DisplayGCPrescale_Float = 2020, 313 + Prop_DisplayGCImage_String = 2021, 314 + Prop_LensCenterLeftU_Float = 2022, 315 + Prop_LensCenterLeftV_Float = 2023, 316 + Prop_LensCenterRightU_Float = 2024, 317 + Prop_LensCenterRightV_Float = 2025, 318 + Prop_UserHeadToEyeDepthMeters_Float = 2026, 319 + Prop_CameraFirmwareVersion_Uint64 = 2027, 320 + Prop_CameraFirmwareDescription_String = 2028, 321 + Prop_DisplayFPGAVersion_Uint64 = 2029, 322 + Prop_DisplayBootloaderVersion_Uint64 = 2030, 323 + Prop_DisplayHardwareVersion_Uint64 = 2031, 324 + Prop_AudioFirmwareVersion_Uint64 = 2032, 325 + Prop_CameraCompatibilityMode_Int32 = 2033, 326 + Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, 327 + Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, 328 + Prop_DisplaySuppressed_Bool = 2036, 329 + Prop_DisplayAllowNightMode_Bool = 2037, 330 + Prop_DisplayMCImageWidth_Int32 = 2038, 331 + Prop_DisplayMCImageHeight_Int32 = 2039, 332 + Prop_DisplayMCImageNumChannels_Int32 = 2040, 333 + Prop_DisplayMCImageData_Binary = 2041, 334 + Prop_SecondsFromPhotonsToVblank_Float = 2042, 335 + Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, 336 + Prop_DisplayDebugMode_Bool = 2044, 337 + Prop_GraphicsAdapterLuid_Uint64 = 2045, 338 + Prop_DriverProvidedChaperonePath_String = 2048, 339 + Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for 340 + Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for 341 + Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded 342 + Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded 343 + Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded 344 + Prop_DoNotApplyPrediction_Bool = 2054, 345 + Prop_CameraToHeadTransforms_Matrix34_Array = 2055, 346 + Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion 347 + Prop_DriverIsDrawingControllers_Bool = 2057, 348 + Prop_DriverRequestsApplicationPause_Bool = 2058, 349 + Prop_DriverRequestsReducedRendering_Bool = 2059, 350 + Prop_MinimumIpdStepMeters_Float = 2060, 351 + Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, 352 + Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, 353 + 354 + // Properties that are unique to TrackedDeviceClass_Controller 355 + Prop_AttachedDeviceId_String = 3000, 356 + Prop_SupportedButtons_Uint64 = 3001, 357 + Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType 358 + Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType 359 + Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType 360 + Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType 361 + Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType 362 + Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole 363 + 364 + // Properties that are unique to TrackedDeviceClass_TrackingReference 365 + Prop_FieldOfViewLeftDegrees_Float = 4000, 366 + Prop_FieldOfViewRightDegrees_Float = 4001, 367 + Prop_FieldOfViewTopDegrees_Float = 4002, 368 + Prop_FieldOfViewBottomDegrees_Float = 4003, 369 + Prop_TrackingRangeMinimumMeters_Float = 4004, 370 + Prop_TrackingRangeMaximumMeters_Float = 4005, 371 + Prop_ModeLabel_String = 4006, 372 + 373 + // Properties that are used for user interface like icons names 374 + Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties. 375 + Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 376 + Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 377 + Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 378 + Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 379 + Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 380 + Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 381 + Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 382 + Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others 383 + 384 + // Properties that are used by helpers, but are opaque to applications 385 + Prop_DisplayHiddenArea_Binary_Start = 5100, 386 + Prop_DisplayHiddenArea_Binary_End = 5150, 387 + Prop_ParentContainer = 5151, 388 + 389 + // Properties that are unique to drivers 390 + Prop_UserConfigPath_String = 6000, 391 + Prop_InstallPath_String = 6001, 392 + Prop_HasDisplayComponent_Bool = 6002, 393 + Prop_HasControllerComponent_Bool = 6003, 394 + Prop_HasCameraComponent_Bool = 6004, 395 + Prop_HasDriverDirectModeComponent_Bool = 6005, 396 + Prop_HasVirtualDisplayComponent_Bool = 6006, 397 + 398 + // Properties that are set internally based on other information provided by drivers 399 + Prop_ControllerType_String = 7000, 400 + Prop_LegacyInputProfile_String = 7001, 401 + 402 + // Vendors are free to expose private debug data in this reserved region 403 + Prop_VendorSpecific_Reserved_Start = 10000, 404 + Prop_VendorSpecific_Reserved_End = 10999, 405 + 406 + Prop_TrackedDeviceProperty_Max = 1000000, 407 + }; 408 + 409 + /** No string property will ever be longer than this length */ 410 + static const uint32_t k_unMaxPropertyStringSize = 32 * 1024; 411 + 412 + /** Used to return errors that occur when reading properties. */ 413 + enum ETrackedPropertyError 414 + { 415 + TrackedProp_Success = 0, 416 + TrackedProp_WrongDataType = 1, 417 + TrackedProp_WrongDeviceClass = 2, 418 + TrackedProp_BufferTooSmall = 3, 419 + TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever). 420 + TrackedProp_InvalidDevice = 5, 421 + TrackedProp_CouldNotContactServer = 6, 422 + TrackedProp_ValueNotProvidedByDevice = 7, 423 + TrackedProp_StringExceedsMaximumLength = 8, 424 + TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later. 425 + TrackedProp_PermissionDenied = 10, 426 + TrackedProp_InvalidOperation = 11, 427 + TrackedProp_CannotWriteToWildcards = 12, 428 + }; 429 + 430 + /** Allows the application to control what part of the provided texture will be used in the 431 + * frame buffer. */ 432 + struct VRTextureBounds_t 433 + { 434 + float uMin, vMin; 435 + float uMax, vMax; 436 + }; 437 + 438 + /** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */ 439 + struct VRTextureWithPose_t : public Texture_t 440 + { 441 + HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures. 442 + }; 443 + 444 + struct VRTextureDepthInfo_t 445 + { 446 + void* handle; // See ETextureType definition above 447 + HmdMatrix44_t mProjection; 448 + HmdVector2_t vRange; // 0..1 449 + }; 450 + 451 + struct VRTextureWithDepth_t : public Texture_t 452 + { 453 + VRTextureDepthInfo_t depth; 454 + }; 455 + 456 + struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t 457 + { 458 + VRTextureDepthInfo_t depth; 459 + }; 460 + 461 + /** Allows the application to control how scene textures are used by the compositor when calling Submit. */ 462 + enum EVRSubmitFlags 463 + { 464 + // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied. 465 + Submit_Default = 0x00, 466 + 467 + // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear 468 + // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by 469 + // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit(). 470 + Submit_LensDistortionAlreadyApplied = 0x01, 471 + 472 + // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag. 473 + Submit_GlRenderBuffer = 0x02, 474 + 475 + // Do not use 476 + Submit_Reserved = 0x04, 477 + 478 + // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t. 479 + // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t. 480 + Submit_TextureWithPose = 0x08, 481 + 482 + // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t. 483 + // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t. 484 + Submit_TextureWithDepth = 0x10, 485 + }; 486 + 487 + /** Data required for passing Vulkan textures to IVRCompositor::Submit. 488 + * Be sure to call OpenVR_Shutdown before destroying these resources. */ 489 + struct VRVulkanTextureData_t 490 + { 491 + uint64_t m_nImage; // VkImage 492 + VkDevice_T *m_pDevice; 493 + VkPhysicalDevice_T *m_pPhysicalDevice; 494 + VkInstance_T *m_pInstance; 495 + VkQueue_T *m_pQueue; 496 + uint32_t m_nQueueFamilyIndex; 497 + uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount; 498 + }; 499 + 500 + /** Data required for passing D3D12 textures to IVRCompositor::Submit. 501 + * Be sure to call OpenVR_Shutdown before destroying these resources. */ 502 + struct D3D12TextureData_t 503 + { 504 + ID3D12Resource *m_pResource; 505 + ID3D12CommandQueue *m_pCommandQueue; 506 + uint32_t m_nNodeMask; 507 + }; 508 + 509 + /** Status of the overall system or tracked objects */ 510 + enum EVRState 511 + { 512 + VRState_Undefined = -1, 513 + VRState_Off = 0, 514 + VRState_Searching = 1, 515 + VRState_Searching_Alert = 2, 516 + VRState_Ready = 3, 517 + VRState_Ready_Alert = 4, 518 + VRState_NotReady = 5, 519 + VRState_Standby = 6, 520 + VRState_Ready_Alert_Low = 7, 521 + }; 522 + 523 + /** The types of events that could be posted (and what the parameters mean for each event type) */ 524 + enum EVREventType 525 + { 526 + VREvent_None = 0, 527 + 528 + VREvent_TrackedDeviceActivated = 100, 529 + VREvent_TrackedDeviceDeactivated = 101, 530 + VREvent_TrackedDeviceUpdated = 102, 531 + VREvent_TrackedDeviceUserInteractionStarted = 103, 532 + VREvent_TrackedDeviceUserInteractionEnded = 104, 533 + VREvent_IpdChanged = 105, 534 + VREvent_EnterStandbyMode = 106, 535 + VREvent_LeaveStandbyMode = 107, 536 + VREvent_TrackedDeviceRoleChanged = 108, 537 + VREvent_WatchdogWakeUpRequested = 109, 538 + VREvent_LensDistortionChanged = 110, 539 + VREvent_PropertyChanged = 111, 540 + VREvent_WirelessDisconnect = 112, 541 + VREvent_WirelessReconnect = 113, 542 + 543 + VREvent_ButtonPress = 200, // data is controller 544 + VREvent_ButtonUnpress = 201, // data is controller 545 + VREvent_ButtonTouch = 202, // data is controller 546 + VREvent_ButtonUntouch = 203, // data is controller 547 + 548 + VREvent_DualAnalog_Press = 250, // data is dualAnalog 549 + VREvent_DualAnalog_Unpress = 251, // data is dualAnalog 550 + VREvent_DualAnalog_Touch = 252, // data is dualAnalog 551 + VREvent_DualAnalog_Untouch = 253, // data is dualAnalog 552 + VREvent_DualAnalog_Move = 254, // data is dualAnalog 553 + VREvent_DualAnalog_ModeSwitch1 = 255, // data is dualAnalog 554 + VREvent_DualAnalog_ModeSwitch2 = 256, // data is dualAnalog 555 + VREvent_DualAnalog_Cancel = 257, // data is dualAnalog 556 + 557 + VREvent_MouseMove = 300, // data is mouse 558 + VREvent_MouseButtonDown = 301, // data is mouse 559 + VREvent_MouseButtonUp = 302, // data is mouse 560 + VREvent_FocusEnter = 303, // data is overlay 561 + VREvent_FocusLeave = 304, // data is overlay 562 + VREvent_Scroll = 305, // data is mouse 563 + VREvent_TouchPadMove = 306, // data is mouse 564 + VREvent_OverlayFocusChanged = 307, // data is overlay, global event 565 + 566 + VREvent_InputFocusCaptured = 400, // data is process DEPRECATED 567 + VREvent_InputFocusReleased = 401, // data is process DEPRECATED 568 + VREvent_SceneFocusLost = 402, // data is process 569 + VREvent_SceneFocusGained = 403, // data is process 570 + VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor) 571 + VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene 572 + VREvent_InputFocusChanged = 406, // data is process 573 + VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process 574 + VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process 575 + VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for 576 + 577 + VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily 578 + VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility 579 + 580 + VREvent_ConsoleOpened = 420, 581 + VREvent_ConsoleClosed = 421, 582 + 583 + VREvent_OverlayShown = 500, 584 + VREvent_OverlayHidden = 501, 585 + VREvent_DashboardActivated = 502, 586 + VREvent_DashboardDeactivated = 503, 587 + VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay 588 + VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay 589 + VREvent_ResetDashboard = 506, // Send to the overlay manager 590 + VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID 591 + VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading 592 + VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it 593 + VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it 594 + VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it 595 + VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else 596 + VREvent_OverlaySharedTextureChanged = 513, 597 + //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent 598 + //VREvent_DashboardGuideButtonUp = 515, 599 + VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot 600 + VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load 601 + VREvent_DashboardOverlayCreated = 518, 602 + VREvent_SwitchGamepadFocus = 519, 603 + 604 + // Screenshot API 605 + VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot 606 + VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken 607 + VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken 608 + VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted 609 + VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted 610 + 611 + VREvent_PrimaryDashboardDeviceChanged = 525, 612 + VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled 613 + VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled 614 + 615 + VREvent_Notification_Shown = 600, 616 + VREvent_Notification_Hidden = 601, 617 + VREvent_Notification_BeginInteraction = 602, 618 + VREvent_Notification_Destroyed = 603, 619 + 620 + VREvent_Quit = 700, // data is process 621 + VREvent_ProcessQuit = 701, // data is process 622 + VREvent_QuitAborted_UserPrompt = 702, // data is process 623 + VREvent_QuitAcknowledged = 703, // data is process 624 + VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down 625 + 626 + VREvent_ChaperoneDataHasChanged = 800, 627 + VREvent_ChaperoneUniverseHasChanged = 801, 628 + VREvent_ChaperoneTempDataHasChanged = 802, 629 + VREvent_ChaperoneSettingsHaveChanged = 803, 630 + VREvent_SeatedZeroPoseReset = 804, 631 + 632 + VREvent_AudioSettingsHaveChanged = 820, 633 + 634 + VREvent_BackgroundSettingHasChanged = 850, 635 + VREvent_CameraSettingsHaveChanged = 851, 636 + VREvent_ReprojectionSettingHasChanged = 852, 637 + VREvent_ModelSkinSettingsHaveChanged = 853, 638 + VREvent_EnvironmentSettingsHaveChanged = 854, 639 + VREvent_PowerSettingsHaveChanged = 855, 640 + VREvent_EnableHomeAppSettingsHaveChanged = 856, 641 + VREvent_SteamVRSectionSettingChanged = 857, 642 + VREvent_LighthouseSectionSettingChanged = 858, 643 + VREvent_NullSectionSettingChanged = 859, 644 + VREvent_UserInterfaceSectionSettingChanged = 860, 645 + VREvent_NotificationsSectionSettingChanged = 861, 646 + VREvent_KeyboardSectionSettingChanged = 862, 647 + VREvent_PerfSectionSettingChanged = 863, 648 + VREvent_DashboardSectionSettingChanged = 864, 649 + VREvent_WebInterfaceSectionSettingChanged = 865, 650 + 651 + VREvent_StatusUpdate = 900, 652 + 653 + VREvent_WebInterface_InstallDriverCompleted = 950, 654 + 655 + VREvent_MCImageUpdated = 1000, 656 + 657 + VREvent_FirmwareUpdateStarted = 1100, 658 + VREvent_FirmwareUpdateFinished = 1101, 659 + 660 + VREvent_KeyboardClosed = 1200, 661 + VREvent_KeyboardCharInput = 1201, 662 + VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard 663 + 664 + VREvent_ApplicationTransitionStarted = 1300, 665 + VREvent_ApplicationTransitionAborted = 1301, 666 + VREvent_ApplicationTransitionNewAppStarted = 1302, 667 + VREvent_ApplicationListUpdated = 1303, 668 + VREvent_ApplicationMimeTypeLoad = 1304, 669 + VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, 670 + VREvent_ProcessConnected = 1306, 671 + VREvent_ProcessDisconnected = 1307, 672 + 673 + VREvent_Compositor_MirrorWindowShown = 1400, 674 + VREvent_Compositor_MirrorWindowHidden = 1401, 675 + VREvent_Compositor_ChaperoneBoundsShown = 1410, 676 + VREvent_Compositor_ChaperoneBoundsHidden = 1411, 677 + 678 + VREvent_TrackedCamera_StartVideoStream = 1500, 679 + VREvent_TrackedCamera_StopVideoStream = 1501, 680 + VREvent_TrackedCamera_PauseVideoStream = 1502, 681 + VREvent_TrackedCamera_ResumeVideoStream = 1503, 682 + VREvent_TrackedCamera_EditingSurface = 1550, 683 + 684 + VREvent_PerformanceTest_EnableCapture = 1600, 685 + VREvent_PerformanceTest_DisableCapture = 1601, 686 + VREvent_PerformanceTest_FidelityLevel = 1602, 687 + 688 + VREvent_MessageOverlay_Closed = 1650, 689 + VREvent_MessageOverlayCloseRequested = 1651, 690 + 691 + VREvent_Input_HapticVibration = 1700, // data is hapticVibration 692 + 693 + // Vendors are free to expose private events in this reserved region 694 + VREvent_VendorSpecific_Reserved_Start = 10000, 695 + VREvent_VendorSpecific_Reserved_End = 19999, 696 + }; 697 + 698 + 699 + /** Level of Hmd activity */ 700 + // UserInteraction_Timeout means the device is in the process of timing out. 701 + // InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout ) 702 + // VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction. 703 + // VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle 704 + enum EDeviceActivityLevel 705 + { 706 + k_EDeviceActivityLevel_Unknown = -1, 707 + k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds 708 + k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now 709 + k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds 710 + k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management) 711 + }; 712 + 713 + 714 + /** VR controller button and axis IDs */ 715 + enum EVRButtonId 716 + { 717 + k_EButton_System = 0, 718 + k_EButton_ApplicationMenu = 1, 719 + k_EButton_Grip = 2, 720 + k_EButton_DPad_Left = 3, 721 + k_EButton_DPad_Up = 4, 722 + k_EButton_DPad_Right = 5, 723 + k_EButton_DPad_Down = 6, 724 + k_EButton_A = 7, 725 + 726 + k_EButton_ProximitySensor = 31, 727 + 728 + k_EButton_Axis0 = 32, 729 + k_EButton_Axis1 = 33, 730 + k_EButton_Axis2 = 34, 731 + k_EButton_Axis3 = 35, 732 + k_EButton_Axis4 = 36, 733 + 734 + // aliases for well known controllers 735 + k_EButton_SteamVR_Touchpad = k_EButton_Axis0, 736 + k_EButton_SteamVR_Trigger = k_EButton_Axis1, 737 + 738 + k_EButton_Dashboard_Back = k_EButton_Grip, 739 + 740 + k_EButton_Max = 64 741 + }; 742 + 743 + inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; } 744 + 745 + /** used for controller button events */ 746 + struct VREvent_Controller_t 747 + { 748 + uint32_t button; // EVRButtonId enum 749 + }; 750 + 751 + 752 + /** used for simulated mouse events in overlay space */ 753 + enum EVRMouseButton 754 + { 755 + VRMouseButton_Left = 0x0001, 756 + VRMouseButton_Right = 0x0002, 757 + VRMouseButton_Middle = 0x0004, 758 + }; 759 + 760 + 761 + /** used for simulated mouse events in overlay space */ 762 + struct VREvent_Mouse_t 763 + { 764 + float x, y; // co-ords are in GL space, bottom left of the texture is 0,0 765 + uint32_t button; // EVRMouseButton enum 766 + }; 767 + 768 + /** used for simulated mouse wheel scroll in overlay space */ 769 + struct VREvent_Scroll_t 770 + { 771 + float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe 772 + uint32_t repeatCount; 773 + }; 774 + 775 + /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger 776 + is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents 777 + flag set. 778 + **/ 779 + struct VREvent_TouchPadMove_t 780 + { 781 + // true if the users finger is detected on the touch pad 782 + bool bFingerDown; 783 + 784 + // How long the finger has been down in seconds 785 + float flSecondsFingerDown; 786 + 787 + // These values indicate the starting finger position (so you can do some basic swipe stuff) 788 + float fValueXFirst; 789 + float fValueYFirst; 790 + 791 + // This is the raw sampled coordinate without deadzoning 792 + float fValueXRaw; 793 + float fValueYRaw; 794 + }; 795 + 796 + /** notification related events. Details will still change at this point */ 797 + struct VREvent_Notification_t 798 + { 799 + uint64_t ulUserValue; 800 + uint32_t notificationId; 801 + }; 802 + 803 + /** Used for events about processes */ 804 + struct VREvent_Process_t 805 + { 806 + uint32_t pid; 807 + uint32_t oldPid; 808 + bool bForced; 809 + }; 810 + 811 + 812 + /** Used for a few events about overlays */ 813 + struct VREvent_Overlay_t 814 + { 815 + uint64_t overlayHandle; 816 + uint64_t devicePath; 817 + }; 818 + 819 + 820 + /** Used for a few events about overlays */ 821 + struct VREvent_Status_t 822 + { 823 + uint32_t statusState; // EVRState enum 824 + }; 825 + 826 + /** Used for keyboard events **/ 827 + struct VREvent_Keyboard_t 828 + { 829 + char cNewInput[8]; // Up to 11 bytes of new input 830 + uint64_t uUserValue; // Possible flags about the new input 831 + }; 832 + 833 + struct VREvent_Ipd_t 834 + { 835 + float ipdMeters; 836 + }; 837 + 838 + struct VREvent_Chaperone_t 839 + { 840 + uint64_t m_nPreviousUniverse; 841 + uint64_t m_nCurrentUniverse; 842 + }; 843 + 844 + /** Not actually used for any events */ 845 + struct VREvent_Reserved_t 846 + { 847 + uint64_t reserved0; 848 + uint64_t reserved1; 849 + uint64_t reserved2; 850 + uint64_t reserved3; 851 + }; 852 + 853 + struct VREvent_PerformanceTest_t 854 + { 855 + uint32_t m_nFidelityLevel; 856 + }; 857 + 858 + struct VREvent_SeatedZeroPoseReset_t 859 + { 860 + bool bResetBySystemMenu; 861 + }; 862 + 863 + struct VREvent_Screenshot_t 864 + { 865 + uint32_t handle; 866 + uint32_t type; 867 + }; 868 + 869 + struct VREvent_ScreenshotProgress_t 870 + { 871 + float progress; 872 + }; 873 + 874 + struct VREvent_ApplicationLaunch_t 875 + { 876 + uint32_t pid; 877 + uint32_t unArgsHandle; 878 + }; 879 + 880 + struct VREvent_EditingCameraSurface_t 881 + { 882 + uint64_t overlayHandle; 883 + uint32_t nVisualMode; 884 + }; 885 + 886 + struct VREvent_MessageOverlay_t 887 + { 888 + uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum 889 + }; 890 + 891 + struct VREvent_Property_t 892 + { 893 + PropertyContainerHandle_t container; 894 + ETrackedDeviceProperty prop; 895 + }; 896 + 897 + enum EDualAnalogWhich 898 + { 899 + k_EDualAnalog_Left = 0, 900 + k_EDualAnalog_Right = 1, 901 + }; 902 + 903 + struct VREvent_DualAnalog_t 904 + { 905 + float x, y; // coordinates are -1..1 analog values 906 + float transformedX, transformedY; // transformed by the center and radius numbers provided by the overlay 907 + EDualAnalogWhich which; 908 + }; 909 + 910 + struct VREvent_HapticVibration_t 911 + { 912 + uint64_t containerHandle; // property container handle of the device with the haptic component 913 + uint64_t componentHandle; // Which haptic component needs to vibrate 914 + float fDurationSeconds; 915 + float fFrequency; 916 + float fAmplitude; 917 + }; 918 + 919 + struct VREvent_WebConsole_t 920 + { 921 + WebConsoleHandle_t webConsoleHandle; 922 + }; 923 + 924 + /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ 925 + typedef union 926 + { 927 + VREvent_Reserved_t reserved; 928 + VREvent_Controller_t controller; 929 + VREvent_Mouse_t mouse; 930 + VREvent_Scroll_t scroll; 931 + VREvent_Process_t process; 932 + VREvent_Notification_t notification; 933 + VREvent_Overlay_t overlay; 934 + VREvent_Status_t status; 935 + VREvent_Keyboard_t keyboard; 936 + VREvent_Ipd_t ipd; 937 + VREvent_Chaperone_t chaperone; 938 + VREvent_PerformanceTest_t performanceTest; 939 + VREvent_TouchPadMove_t touchPadMove; 940 + VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; 941 + VREvent_Screenshot_t screenshot; 942 + VREvent_ScreenshotProgress_t screenshotProgress; 943 + VREvent_ApplicationLaunch_t applicationLaunch; 944 + VREvent_EditingCameraSurface_t cameraSurface; 945 + VREvent_MessageOverlay_t messageOverlay; 946 + VREvent_Property_t property; 947 + VREvent_DualAnalog_t dualAnalog; 948 + VREvent_HapticVibration_t hapticVibration; 949 + VREvent_WebConsole_t webConsole; 950 + } VREvent_Data_t; 951 + 952 + 953 + #if defined(__linux__) || defined(__APPLE__) 954 + // This structure was originally defined mis-packed on Linux, preserved for 955 + // compatibility. 956 + #pragma pack( push, 4 ) 957 + #endif 958 + 959 + /** An event posted by the server to all running applications */ 960 + struct VREvent_t 961 + { 962 + uint32_t eventType; // EVREventType enum 963 + TrackedDeviceIndex_t trackedDeviceIndex; 964 + float eventAgeSeconds; 965 + // event data must be the end of the struct as its size is variable 966 + VREvent_Data_t data; 967 + }; 968 + 969 + #if defined(__linux__) || defined(__APPLE__) 970 + #pragma pack( pop ) 971 + #endif 972 + 973 + enum EVRInputError 974 + { 975 + VRInputError_None = 0, 976 + VRInputError_NameNotFound = 1, 977 + VRInputError_WrongType = 2, 978 + VRInputError_InvalidHandle = 3, 979 + VRInputError_InvalidParam = 4, 980 + VRInputError_NoSteam = 5, 981 + VRInputError_MaxCapacityReached = 6, 982 + VRInputError_IPCError = 7, 983 + VRInputError_NoActiveActionSet = 8, 984 + VRInputError_InvalidDevice = 9, 985 + }; 986 + 987 + 988 + /** The mesh to draw into the stencil (or depth) buffer to perform 989 + * early stencil (or depth) kills of pixels that will never appear on the HMD. 990 + * This mesh draws on all the pixels that will be hidden after distortion. 991 + * 992 + * If the HMD does not provide a visible area mesh pVertexData will be 993 + * NULL and unTriangleCount will be 0. */ 994 + struct HiddenAreaMesh_t 995 + { 996 + const HmdVector2_t *pVertexData; 997 + uint32_t unTriangleCount; 998 + }; 999 + 1000 + 1001 + enum EHiddenAreaMeshType 1002 + { 1003 + k_eHiddenAreaMesh_Standard = 0, 1004 + k_eHiddenAreaMesh_Inverse = 1, 1005 + k_eHiddenAreaMesh_LineLoop = 2, 1006 + 1007 + k_eHiddenAreaMesh_Max = 3, 1008 + }; 1009 + 1010 + 1011 + /** Identifies what kind of axis is on the controller at index n. Read this type 1012 + * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n ); 1013 + */ 1014 + enum EVRControllerAxisType 1015 + { 1016 + k_eControllerAxis_None = 0, 1017 + k_eControllerAxis_TrackPad = 1, 1018 + k_eControllerAxis_Joystick = 2, 1019 + k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis 1020 + }; 1021 + 1022 + 1023 + /** contains information about one axis on the controller */ 1024 + struct VRControllerAxis_t 1025 + { 1026 + float x; // Ranges from -1.0 to 1.0 for joysticks and track pads. Ranges from 0.0 to 1.0 for triggers were 0 is fully released. 1027 + float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers. 1028 + }; 1029 + 1030 + 1031 + /** the number of axes in the controller state */ 1032 + static const uint32_t k_unControllerStateAxisCount = 5; 1033 + 1034 + 1035 + #if defined(__linux__) || defined(__APPLE__) 1036 + // This structure was originally defined mis-packed on Linux, preserved for 1037 + // compatibility. 1038 + #pragma pack( push, 4 ) 1039 + #endif 1040 + 1041 + /** Holds all the state of a controller at one moment in time. */ 1042 + struct VRControllerState001_t 1043 + { 1044 + // If packet num matches that on your prior call, then the controller state hasn't been changed since 1045 + // your last call and there is no need to process it 1046 + uint32_t unPacketNum; 1047 + 1048 + // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask 1049 + uint64_t ulButtonPressed; 1050 + uint64_t ulButtonTouched; 1051 + 1052 + // Axis data for the controller's analog inputs 1053 + VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ]; 1054 + }; 1055 + #if defined(__linux__) || defined(__APPLE__) 1056 + #pragma pack( pop ) 1057 + #endif 1058 + 1059 + 1060 + typedef VRControllerState001_t VRControllerState_t; 1061 + 1062 + 1063 + /** determines how to provide output to the application of various event processing functions. */ 1064 + enum EVRControllerEventOutputType 1065 + { 1066 + ControllerEventOutput_OSEvents = 0, 1067 + ControllerEventOutput_VREvents = 1, 1068 + }; 1069 + 1070 + 1071 + 1072 + /** Collision Bounds Style */ 1073 + enum ECollisionBoundsStyle 1074 + { 1075 + COLLISION_BOUNDS_STYLE_BEGINNER = 0, 1076 + COLLISION_BOUNDS_STYLE_INTERMEDIATE, 1077 + COLLISION_BOUNDS_STYLE_SQUARES, 1078 + COLLISION_BOUNDS_STYLE_ADVANCED, 1079 + COLLISION_BOUNDS_STYLE_NONE, 1080 + 1081 + COLLISION_BOUNDS_STYLE_COUNT 1082 + }; 1083 + 1084 + /** Allows the application to customize how the overlay appears in the compositor */ 1085 + struct Compositor_OverlaySettings 1086 + { 1087 + uint32_t size; // sizeof(Compositor_OverlaySettings) 1088 + bool curved, antialias; 1089 + float scale, distance, alpha; 1090 + float uOffset, vOffset, uScale, vScale; 1091 + float gridDivs, gridWidth, gridScale; 1092 + HmdMatrix44_t transform; 1093 + }; 1094 + 1095 + /** used to refer to a single VR overlay */ 1096 + typedef uint64_t VROverlayHandle_t; 1097 + 1098 + static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0; 1099 + 1100 + /** Errors that can occur around VR overlays */ 1101 + enum EVROverlayError 1102 + { 1103 + VROverlayError_None = 0, 1104 + 1105 + VROverlayError_UnknownOverlay = 10, 1106 + VROverlayError_InvalidHandle = 11, 1107 + VROverlayError_PermissionDenied = 12, 1108 + VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist 1109 + VROverlayError_WrongVisibilityType = 14, 1110 + VROverlayError_KeyTooLong = 15, 1111 + VROverlayError_NameTooLong = 16, 1112 + VROverlayError_KeyInUse = 17, 1113 + VROverlayError_WrongTransformType = 18, 1114 + VROverlayError_InvalidTrackedDevice = 19, 1115 + VROverlayError_InvalidParameter = 20, 1116 + VROverlayError_ThumbnailCantBeDestroyed = 21, 1117 + VROverlayError_ArrayTooSmall = 22, 1118 + VROverlayError_RequestFailed = 23, 1119 + VROverlayError_InvalidTexture = 24, 1120 + VROverlayError_UnableToLoadFile = 25, 1121 + VROverlayError_KeyboardAlreadyInUse = 26, 1122 + VROverlayError_NoNeighbor = 27, 1123 + VROverlayError_TooManyMaskPrimitives = 29, 1124 + VROverlayError_BadMaskPrimitive = 30, 1125 + VROverlayError_TextureAlreadyLocked = 31, 1126 + VROverlayError_TextureLockCapacityReached = 32, 1127 + VROverlayError_TextureNotLocked = 33, 1128 + }; 1129 + 1130 + /** enum values to pass in to VR_Init to identify whether the application will 1131 + * draw a 3D scene. */ 1132 + enum EVRApplicationType 1133 + { 1134 + VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries 1135 + VRApplication_Scene = 1, // Application will submit 3D frames 1136 + VRApplication_Overlay = 2, // Application only interacts with overlays 1137 + VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not 1138 + // keep it running if everything else quits. 1139 + VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility 1140 + // interfaces (like IVRSettings and IVRApplications) but not hardware. 1141 + VRApplication_VRMonitor = 5, // Reserved for vrmonitor 1142 + VRApplication_SteamWatchdog = 6,// Reserved for Steam 1143 + VRApplication_Bootstrapper = 7, // Start up SteamVR 1144 + 1145 + VRApplication_Max 1146 + }; 1147 + 1148 + 1149 + /** error codes for firmware */ 1150 + enum EVRFirmwareError 1151 + { 1152 + VRFirmwareError_None = 0, 1153 + VRFirmwareError_Success = 1, 1154 + VRFirmwareError_Fail = 2, 1155 + }; 1156 + 1157 + 1158 + /** error codes for notifications */ 1159 + enum EVRNotificationError 1160 + { 1161 + VRNotificationError_OK = 0, 1162 + VRNotificationError_InvalidNotificationId = 100, 1163 + VRNotificationError_NotificationQueueFull = 101, 1164 + VRNotificationError_InvalidOverlayHandle = 102, 1165 + VRNotificationError_SystemWithUserValueAlreadyExists = 103, 1166 + }; 1167 + 1168 + 1169 + /** error codes returned by Vr_Init */ 1170 + 1171 + // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp 1172 + enum EVRInitError 1173 + { 1174 + VRInitError_None = 0, 1175 + VRInitError_Unknown = 1, 1176 + 1177 + VRInitError_Init_InstallationNotFound = 100, 1178 + VRInitError_Init_InstallationCorrupt = 101, 1179 + VRInitError_Init_VRClientDLLNotFound = 102, 1180 + VRInitError_Init_FileNotFound = 103, 1181 + VRInitError_Init_FactoryNotFound = 104, 1182 + VRInitError_Init_InterfaceNotFound = 105, 1183 + VRInitError_Init_InvalidInterface = 106, 1184 + VRInitError_Init_UserConfigDirectoryInvalid = 107, 1185 + VRInitError_Init_HmdNotFound = 108, 1186 + VRInitError_Init_NotInitialized = 109, 1187 + VRInitError_Init_PathRegistryNotFound = 110, 1188 + VRInitError_Init_NoConfigPath = 111, 1189 + VRInitError_Init_NoLogPath = 112, 1190 + VRInitError_Init_PathRegistryNotWritable = 113, 1191 + VRInitError_Init_AppInfoInitFailed = 114, 1192 + VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver 1193 + VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup 1194 + VRInitError_Init_AnotherAppLaunching = 117, 1195 + VRInitError_Init_SettingsInitFailed = 118, 1196 + VRInitError_Init_ShuttingDown = 119, 1197 + VRInitError_Init_TooManyObjects = 120, 1198 + VRInitError_Init_NoServerForBackgroundApp = 121, 1199 + VRInitError_Init_NotSupportedWithCompositor = 122, 1200 + VRInitError_Init_NotAvailableToUtilityApps = 123, 1201 + VRInitError_Init_Internal = 124, 1202 + VRInitError_Init_HmdDriverIdIsNone = 125, 1203 + VRInitError_Init_HmdNotFoundPresenceFailed = 126, 1204 + VRInitError_Init_VRMonitorNotFound = 127, 1205 + VRInitError_Init_VRMonitorStartupFailed = 128, 1206 + VRInitError_Init_LowPowerWatchdogNotSupported = 129, 1207 + VRInitError_Init_InvalidApplicationType = 130, 1208 + VRInitError_Init_NotAvailableToWatchdogApps = 131, 1209 + VRInitError_Init_WatchdogDisabledInSettings = 132, 1210 + VRInitError_Init_VRDashboardNotFound = 133, 1211 + VRInitError_Init_VRDashboardStartupFailed = 134, 1212 + VRInitError_Init_VRHomeNotFound = 135, 1213 + VRInitError_Init_VRHomeStartupFailed = 136, 1214 + VRInitError_Init_RebootingBusy = 137, 1215 + VRInitError_Init_FirmwareUpdateBusy = 138, 1216 + VRInitError_Init_FirmwareRecoveryBusy = 139, 1217 + VRInitError_Init_USBServiceBusy = 140, 1218 + VRInitError_Init_VRWebHelperStartupFailed = 141, 1219 + 1220 + VRInitError_Driver_Failed = 200, 1221 + VRInitError_Driver_Unknown = 201, 1222 + VRInitError_Driver_HmdUnknown = 202, 1223 + VRInitError_Driver_NotLoaded = 203, 1224 + VRInitError_Driver_RuntimeOutOfDate = 204, 1225 + VRInitError_Driver_HmdInUse = 205, 1226 + VRInitError_Driver_NotCalibrated = 206, 1227 + VRInitError_Driver_CalibrationInvalid = 207, 1228 + VRInitError_Driver_HmdDisplayNotFound = 208, 1229 + VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, 1230 + // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons 1231 + VRInitError_Driver_HmdDriverIdOutOfBounds = 211, 1232 + VRInitError_Driver_HmdDisplayMirrored = 212, 1233 + 1234 + VRInitError_IPC_ServerInitFailed = 300, 1235 + VRInitError_IPC_ConnectFailed = 301, 1236 + VRInitError_IPC_SharedStateInitFailed = 302, 1237 + VRInitError_IPC_CompositorInitFailed = 303, 1238 + VRInitError_IPC_MutexInitFailed = 304, 1239 + VRInitError_IPC_Failed = 305, 1240 + VRInitError_IPC_CompositorConnectFailed = 306, 1241 + VRInitError_IPC_CompositorInvalidConnectResponse = 307, 1242 + VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, 1243 + 1244 + VRInitError_Compositor_Failed = 400, 1245 + VRInitError_Compositor_D3D11HardwareRequired = 401, 1246 + VRInitError_Compositor_FirmwareRequiresUpdate = 402, 1247 + VRInitError_Compositor_OverlayInitFailed = 403, 1248 + VRInitError_Compositor_ScreenshotsInitFailed = 404, 1249 + VRInitError_Compositor_UnableToCreateDevice = 405, 1250 + 1251 + VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, 1252 + VRInitError_VendorSpecific_WindowsNotInDevMode = 1001, 1253 + 1254 + VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, 1255 + VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, 1256 + VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103, 1257 + VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104, 1258 + VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105, 1259 + VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106, 1260 + VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107, 1261 + VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108, 1262 + VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109, 1263 + VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110, 1264 + VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111, 1265 + VRInitError_VendorSpecific_HmdFound_UserDataError = 1112, 1266 + VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, 1267 + 1268 + VRInitError_Steam_SteamInstallationNotFound = 2000, 1269 + }; 1270 + 1271 + enum EVRScreenshotType 1272 + { 1273 + VRScreenshotType_None = 0, 1274 + VRScreenshotType_Mono = 1, // left eye only 1275 + VRScreenshotType_Stereo = 2, 1276 + VRScreenshotType_Cubemap = 3, 1277 + VRScreenshotType_MonoPanorama = 4, 1278 + VRScreenshotType_StereoPanorama = 5 1279 + }; 1280 + 1281 + enum EVRScreenshotPropertyFilenames 1282 + { 1283 + VRScreenshotPropertyFilenames_Preview = 0, 1284 + VRScreenshotPropertyFilenames_VR = 1, 1285 + }; 1286 + 1287 + enum EVRTrackedCameraError 1288 + { 1289 + VRTrackedCameraError_None = 0, 1290 + VRTrackedCameraError_OperationFailed = 100, 1291 + VRTrackedCameraError_InvalidHandle = 101, 1292 + VRTrackedCameraError_InvalidFrameHeaderVersion = 102, 1293 + VRTrackedCameraError_OutOfHandles = 103, 1294 + VRTrackedCameraError_IPCFailure = 104, 1295 + VRTrackedCameraError_NotSupportedForThisDevice = 105, 1296 + VRTrackedCameraError_SharedMemoryFailure = 106, 1297 + VRTrackedCameraError_FrameBufferingFailure = 107, 1298 + VRTrackedCameraError_StreamSetupFailure = 108, 1299 + VRTrackedCameraError_InvalidGLTextureId = 109, 1300 + VRTrackedCameraError_InvalidSharedTextureHandle = 110, 1301 + VRTrackedCameraError_FailedToGetGLTextureId = 111, 1302 + VRTrackedCameraError_SharedTextureFailure = 112, 1303 + VRTrackedCameraError_NoFrameAvailable = 113, 1304 + VRTrackedCameraError_InvalidArgument = 114, 1305 + VRTrackedCameraError_InvalidFrameBufferSize = 115, 1306 + }; 1307 + 1308 + enum EVRTrackedCameraFrameLayout 1309 + { 1310 + EVRTrackedCameraFrameLayout_Mono = 0x0001, 1311 + EVRTrackedCameraFrameLayout_Stereo = 0x0002, 1312 + EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right) 1313 + EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right 1314 + }; 1315 + 1316 + enum EVRTrackedCameraFrameType 1317 + { 1318 + VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted. 1319 + VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly. 1320 + VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions. 1321 + MAX_CAMERA_FRAME_TYPES 1322 + }; 1323 + 1324 + typedef uint64_t TrackedCameraHandle_t; 1325 + #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0) 1326 + 1327 + struct CameraVideoStreamFrameHeader_t 1328 + { 1329 + EVRTrackedCameraFrameType eFrameType; 1330 + 1331 + uint32_t nWidth; 1332 + uint32_t nHeight; 1333 + uint32_t nBytesPerPixel; 1334 + 1335 + uint32_t nFrameSequence; 1336 + 1337 + TrackedDevicePose_t standingTrackedDevicePose; 1338 + }; 1339 + 1340 + // Screenshot types 1341 + typedef uint32_t ScreenshotHandle_t; 1342 + 1343 + static const uint32_t k_unScreenshotHandleInvalid = 0; 1344 + 1345 + /** Frame timing data provided by direct mode drivers. */ 1346 + struct DriverDirectMode_FrameTiming 1347 + { 1348 + uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming ) 1349 + uint32_t m_nNumFramePresents; // number of times frame was presented 1350 + uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to 1351 + uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync) 1352 + uint32_t m_nReprojectionFlags; 1353 + }; 1354 + 1355 + enum EVSync 1356 + { 1357 + VSync_None, 1358 + VSync_WaitRender, // block following render work until vsync 1359 + VSync_NoWaitRender, // do not block following render work (allow to get started early) 1360 + }; 1361 + 1362 + #pragma pack( pop ) 1363 + 1364 + // figure out how to import from the VR API dll 1365 + #if defined(_WIN32) 1366 + 1367 + #ifdef VR_API_EXPORT 1368 + #define VR_INTERFACE extern "C" __declspec( dllexport ) 1369 + #else 1370 + #define VR_INTERFACE extern "C" __declspec( dllimport ) 1371 + #endif 1372 + 1373 + #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__) 1374 + 1375 + #ifdef VR_API_EXPORT 1376 + #define VR_INTERFACE extern "C" __attribute__((visibility("default"))) 1377 + #else 1378 + #define VR_INTERFACE extern "C" 1379 + #endif 1380 + 1381 + #else 1382 + #error "Unsupported Platform." 1383 + #endif 1384 + 1385 + 1386 + #if defined( _WIN32 ) 1387 + #define VR_CALLTYPE __cdecl 1388 + #else 1389 + #define VR_CALLTYPE 1390 + #endif 1391 + 1392 + } // namespace vr 1393 + 1394 + #endif // _INCLUDE_VRTYPES_H 1395 + 1396 + 1397 + // vrannotation.h 1398 + #ifdef API_GEN 1399 + # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR ))) 1400 + #else 1401 + # define VR_CLANG_ATTR(ATTR) 1402 + #endif 1403 + 1404 + #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" ) 1405 + #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" ) 1406 + #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" ) 1407 + #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" ) 1408 + #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" ) 1409 + #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" ) 1410 + #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" ) 1411 + #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC ) 1412 + #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" ) 1413 + #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" ) 1414 + #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" ) 1415 + 1416 + // vrtrackedcameratypes.h 1417 + #ifndef _VRTRACKEDCAMERATYPES_H 1418 + #define _VRTRACKEDCAMERATYPES_H 1419 + 1420 + namespace vr 1421 + { 1422 + 1423 + #pragma pack( push, 8 ) 1424 + 1425 + enum ECameraVideoStreamFormat 1426 + { 1427 + CVS_FORMAT_UNKNOWN = 0, 1428 + CVS_FORMAT_RAW10 = 1, // 10 bits per pixel 1429 + CVS_FORMAT_NV12 = 2, // 12 bits per pixel 1430 + CVS_FORMAT_RGB24 = 3, // 24 bits per pixel 1431 + CVS_FORMAT_NV12_2 = 4, // 12 bits per pixel, 2x height 1432 + CVS_MAX_FORMATS 1433 + }; 1434 + 1435 + enum ECameraCompatibilityMode 1436 + { 1437 + CAMERA_COMPAT_MODE_BULK_DEFAULT = 0, 1438 + CAMERA_COMPAT_MODE_BULK_64K_DMA, 1439 + CAMERA_COMPAT_MODE_BULK_16K_DMA, 1440 + CAMERA_COMPAT_MODE_BULK_8K_DMA, 1441 + CAMERA_COMPAT_MODE_ISO_52FPS, 1442 + CAMERA_COMPAT_MODE_ISO_50FPS, 1443 + CAMERA_COMPAT_MODE_ISO_48FPS, 1444 + CAMERA_COMPAT_MODE_ISO_46FPS, 1445 + CAMERA_COMPAT_MODE_ISO_44FPS, 1446 + CAMERA_COMPAT_MODE_ISO_42FPS, 1447 + CAMERA_COMPAT_MODE_ISO_40FPS, 1448 + CAMERA_COMPAT_MODE_ISO_35FPS, 1449 + CAMERA_COMPAT_MODE_ISO_30FPS, 1450 + MAX_CAMERA_COMPAT_MODES 1451 + }; 1452 + 1453 + enum ETrackedCameraRoomViewMode 1454 + { 1455 + TRACKED_CAMERA_ROOMVIEW_MODE_DEFAULT = 0, 1456 + TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_A, 1457 + TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_B, 1458 + TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_TRANSLUSCENT, 1459 + TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_OPAQUE, 1460 + TRACKED_CAMERA_ROOMVIEW_MODE_COUNT, 1461 + }; 1462 + 1463 + #ifdef _MSC_VER 1464 + #define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) ) 1465 + #else 1466 + #define VR_CAMERA_DECL_ALIGN( x ) // 1467 + #endif 1468 + 1469 + #define MAX_CAMERA_FRAME_SHARED_HANDLES 4 1470 + 1471 + VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t 1472 + { 1473 + ECameraVideoStreamFormat m_nStreamFormat; 1474 + 1475 + uint32_t m_nWidth; 1476 + uint32_t m_nHeight; 1477 + 1478 + uint32_t m_nImageDataSize; // Based on stream format, width, height 1479 + 1480 + uint32_t m_nFrameSequence; // Starts from 0 when stream starts. 1481 + 1482 + uint32_t m_nBufferIndex; // Identifies which buffer the image data is hosted 1483 + uint32_t m_nBufferCount; // Total number of configured buffers 1484 + 1485 + uint32_t m_nExposureTime; 1486 + 1487 + uint32_t m_nISPFrameTimeStamp; // Driver provided time stamp per driver centric time base 1488 + uint32_t m_nISPReferenceTimeStamp; 1489 + uint32_t m_nSyncCounter; 1490 + 1491 + uint32_t m_nCamSyncEvents; 1492 + uint32_t m_nISPSyncEvents; 1493 + 1494 + double m_flReferenceCamSyncTime; 1495 + 1496 + double m_flFrameElapsedTime; // Starts from 0 when stream starts. In seconds. 1497 + double m_flFrameDeliveryRate; 1498 + 1499 + double m_flFrameCaptureTime_DriverAbsolute; // In USB time, via AuxEvent 1500 + double m_flFrameCaptureTime_ServerRelative; // In System time within the server 1501 + uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks within the server 1502 + double m_flFrameCaptureTime_ClientRelative; // At the client, relative to when the frame was exposed/captured. 1503 + 1504 + double m_flSyncMarkerError; 1505 + 1506 + TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by HMD layer when used as a tracked camera 1507 + 1508 + uint64_t m_pImageData; 1509 + }; 1510 + 1511 + #pragma pack( pop ) 1512 + 1513 + } 1514 + 1515 + #endif // _VRTRACKEDCAMERATYPES_H 1516 + // ivrsettings.h 1517 + namespace vr 1518 + { 1519 + enum EVRSettingsError 1520 + { 1521 + VRSettingsError_None = 0, 1522 + VRSettingsError_IPCFailed = 1, 1523 + VRSettingsError_WriteFailed = 2, 1524 + VRSettingsError_ReadFailed = 3, 1525 + VRSettingsError_JsonParseFailed = 4, 1526 + VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set 1527 + }; 1528 + 1529 + // The maximum length of a settings key 1530 + static const uint32_t k_unMaxSettingsKeyLength = 128; 1531 + 1532 + class IVRSettings 1533 + { 1534 + public: 1535 + virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0; 1536 + 1537 + // Returns true if file sync occurred (force or settings dirty) 1538 + virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0; 1539 + 1540 + virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; 1541 + virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; 1542 + virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; 1543 + virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0; 1544 + 1545 + // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory 1546 + // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or "" 1547 + virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; 1548 + virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; 1549 + virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; 1550 + virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0; 1551 + 1552 + virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0; 1553 + virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; 1554 + }; 1555 + 1556 + //----------------------------------------------------------------------------- 1557 + static const char * const IVRSettings_Version = "IVRSettings_002"; 1558 + 1559 + //----------------------------------------------------------------------------- 1560 + // steamvr keys 1561 + static const char * const k_pch_SteamVR_Section = "steamvr"; 1562 + static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd"; 1563 + static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; 1564 + static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; 1565 + static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; 1566 + static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; 1567 + static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; 1568 + static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; 1569 + static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps"; 1570 + static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel"; 1571 + static const char * const k_pch_SteamVR_IPD_Float = "ipd"; 1572 + static const char * const k_pch_SteamVR_Background_String = "background"; 1573 + static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; 1574 + static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; 1575 + static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; 1576 + static const char * const k_pch_SteamVR_GridColor_String = "gridColor"; 1577 + static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; 1578 + static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage"; 1579 + static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; 1580 + static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode"; 1581 + static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid"; 1582 + static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid"; 1583 + static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; 1584 + static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; 1585 + static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement"; 1586 + static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; 1587 + static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; 1588 + static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection"; 1589 + static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection"; 1590 + static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection"; 1591 + static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; 1592 + static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView"; 1593 + static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView"; 1594 + static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; 1595 + static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; 1596 + static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; 1597 + static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; 1598 + static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; 1599 + static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; 1600 + static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; 1601 + static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; 1602 + static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; 1603 + static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; 1604 + static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; 1605 + static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; 1606 + static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; 1607 + static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; 1608 + static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; 1609 + static const char * const k_pch_SteamVR_DebugInput = "debugInput"; 1610 + static const char * const k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding"; 1611 + 1612 + //----------------------------------------------------------------------------- 1613 + // lighthouse keys 1614 + static const char * const k_pch_Lighthouse_Section = "driver_lighthouse"; 1615 + static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; 1616 + static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; 1617 + static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; 1618 + static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; 1619 + static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; 1620 + static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; 1621 + static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; 1622 + static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; 1623 + 1624 + //----------------------------------------------------------------------------- 1625 + // null keys 1626 + static const char * const k_pch_Null_Section = "driver_null"; 1627 + static const char * const k_pch_Null_SerialNumber_String = "serialNumber"; 1628 + static const char * const k_pch_Null_ModelNumber_String = "modelNumber"; 1629 + static const char * const k_pch_Null_WindowX_Int32 = "windowX"; 1630 + static const char * const k_pch_Null_WindowY_Int32 = "windowY"; 1631 + static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth"; 1632 + static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight"; 1633 + static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth"; 1634 + static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight"; 1635 + static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; 1636 + static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency"; 1637 + 1638 + //----------------------------------------------------------------------------- 1639 + // user interface keys 1640 + static const char * const k_pch_UserInterface_Section = "userinterface"; 1641 + static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; 1642 + static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; 1643 + static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots"; 1644 + static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; 1645 + 1646 + //----------------------------------------------------------------------------- 1647 + // notification keys 1648 + static const char * const k_pch_Notifications_Section = "notifications"; 1649 + static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; 1650 + 1651 + //----------------------------------------------------------------------------- 1652 + // keyboard keys 1653 + static const char * const k_pch_Keyboard_Section = "keyboard"; 1654 + static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions"; 1655 + static const char * const k_pch_Keyboard_ScaleX = "ScaleX"; 1656 + static const char * const k_pch_Keyboard_ScaleY = "ScaleY"; 1657 + static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX"; 1658 + static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX"; 1659 + static const char * const k_pch_Keyboard_OffsetY = "OffsetY"; 1660 + static const char * const k_pch_Keyboard_Smoothing = "Smoothing"; 1661 + 1662 + //----------------------------------------------------------------------------- 1663 + // perf keys 1664 + static const char * const k_pch_Perf_Section = "perfcheck"; 1665 + static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive"; 1666 + static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; 1667 + static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce"; 1668 + static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; 1669 + static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; 1670 + static const char * const k_pch_Perf_TestData_Float = "perfTestData"; 1671 + static const char * const k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling"; 1672 + 1673 + //----------------------------------------------------------------------------- 1674 + // collision bounds keys 1675 + static const char * const k_pch_CollisionBounds_Section = "collisionBounds"; 1676 + static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; 1677 + static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; 1678 + static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; 1679 + static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; 1680 + static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; 1681 + static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; 1682 + static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; 1683 + static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; 1684 + static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; 1685 + 1686 + //----------------------------------------------------------------------------- 1687 + // camera keys 1688 + static const char * const k_pch_Camera_Section = "camera"; 1689 + static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera"; 1690 + static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard"; 1691 + static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds"; 1692 + static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView"; 1693 + static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR"; 1694 + static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; 1695 + static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; 1696 + static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; 1697 + static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; 1698 + static const char * const k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode"; 1699 + 1700 + //----------------------------------------------------------------------------- 1701 + // audio keys 1702 + static const char * const k_pch_audio_Section = "audio"; 1703 + static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice"; 1704 + static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice"; 1705 + static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; 1706 + static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice"; 1707 + static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice"; 1708 + static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; 1709 + 1710 + //----------------------------------------------------------------------------- 1711 + // power management keys 1712 + static const char * const k_pch_Power_Section = "power"; 1713 + static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; 1714 + static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; 1715 + static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; 1716 + static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; 1717 + static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; 1718 + static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; 1719 + 1720 + //----------------------------------------------------------------------------- 1721 + // dashboard keys 1722 + static const char * const k_pch_Dashboard_Section = "dashboard"; 1723 + static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; 1724 + static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; 1725 + static const char * const k_pch_Dashboard_EnableWebUI = "webUI"; 1726 + static const char * const k_pch_Dashboard_EnableWebUIDevTools = "webUIDevTools"; 1727 + 1728 + //----------------------------------------------------------------------------- 1729 + // model skin keys 1730 + static const char * const k_pch_modelskin_Section = "modelskins"; 1731 + 1732 + //----------------------------------------------------------------------------- 1733 + // driver keys - These could be checked in any driver_<name> section 1734 + static const char * const k_pch_Driver_Enable_Bool = "enable"; 1735 + 1736 + //----------------------------------------------------------------------------- 1737 + // web interface keys 1738 + static const char* const k_pch_WebInterface_Section = "WebInterface"; 1739 + static const char* const k_pch_WebInterface_WebPort_String = "WebPort"; 1740 + 1741 + } // namespace vr 1742 + 1743 + // iservertrackeddevicedriver.h 1744 + namespace vr 1745 + { 1746 + 1747 + 1748 + struct DriverPoseQuaternion_t 1749 + { 1750 + double w, x, y, z; 1751 + }; 1752 + 1753 + struct DriverPose_t 1754 + { 1755 + /* Time offset of this pose, in seconds from the actual time of the pose, 1756 + * relative to the time of the PoseUpdated() call made by the driver. 1757 + */ 1758 + double poseTimeOffset; 1759 + 1760 + /* Generally, the pose maintained by a driver 1761 + * is in an inertial coordinate system different 1762 + * from the world system of x+ right, y+ up, z+ back. 1763 + * Also, the driver is not usually tracking the "head" position, 1764 + * but instead an internal IMU or another reference point in the HMD. 1765 + * The following two transforms transform positions and orientations 1766 + * to app world space from driver world space, 1767 + * and to HMD head space from driver local body space. 1768 + * 1769 + * We maintain the driver pose state in its internal coordinate system, 1770 + * so we can do the pose prediction math without having to 1771 + * use angular acceleration. A driver's angular acceleration is generally not measured, 1772 + * and is instead calculated from successive samples of angular velocity. 1773 + * This leads to a noisy angular acceleration values, which are also 1774 + * lagged due to the filtering required to reduce noise to an acceptable level. 1775 + */ 1776 + vr::HmdQuaternion_t qWorldFromDriverRotation; 1777 + double vecWorldFromDriverTranslation[ 3 ]; 1778 + 1779 + vr::HmdQuaternion_t qDriverFromHeadRotation; 1780 + double vecDriverFromHeadTranslation[ 3 ]; 1781 + 1782 + /* State of driver pose, in meters and radians. */ 1783 + /* Position of the driver tracking reference in driver world space 1784 + * +[0] (x) is right 1785 + * +[1] (y) is up 1786 + * -[2] (z) is forward 1787 + */ 1788 + double vecPosition[ 3 ]; 1789 + 1790 + /* Velocity of the pose in meters/second */ 1791 + double vecVelocity[ 3 ]; 1792 + 1793 + /* Acceleration of the pose in meters/second */ 1794 + double vecAcceleration[ 3 ]; 1795 + 1796 + /* Orientation of the tracker, represented as a quaternion */ 1797 + vr::HmdQuaternion_t qRotation; 1798 + 1799 + /* Angular velocity of the pose in axis-angle 1800 + * representation. The direction is the angle of 1801 + * rotation and the magnitude is the angle around 1802 + * that axis in radians/second. */ 1803 + double vecAngularVelocity[ 3 ]; 1804 + 1805 + /* Angular acceleration of the pose in axis-angle 1806 + * representation. The direction is the angle of 1807 + * rotation and the magnitude is the angle around 1808 + * that axis in radians/second^2. */ 1809 + double vecAngularAcceleration[ 3 ]; 1810 + 1811 + ETrackingResult result; 1812 + 1813 + bool poseIsValid; 1814 + bool willDriftInYaw; 1815 + bool shouldApplyHeadModel; 1816 + bool deviceIsConnected; 1817 + }; 1818 + 1819 + 1820 + // ---------------------------------------------------------------------------------------------- 1821 + // Purpose: Represents a single tracked device in a driver 1822 + // ---------------------------------------------------------------------------------------------- 1823 + class ITrackedDeviceServerDriver 1824 + { 1825 + public: 1826 + 1827 + // ------------------------------------ 1828 + // Management Methods 1829 + // ------------------------------------ 1830 + /** This is called before an HMD is returned to the application. It will always be 1831 + * called before any display or tracking methods. Memory and processor use by the 1832 + * ITrackedDeviceServerDriver object should be kept to a minimum until it is activated. 1833 + * The pose listener is guaranteed to be valid until Deactivate is called, but 1834 + * should not be used after that point. */ 1835 + virtual EVRInitError Activate( uint32_t unObjectId ) = 0; 1836 + 1837 + /** This is called when The VR system is switching from this Hmd being the active display 1838 + * to another Hmd being the active display. The driver should clean whatever memory 1839 + * and thread use it can when it is deactivated */ 1840 + virtual void Deactivate() = 0; 1841 + 1842 + /** Handles a request from the system to put this device into standby mode. What that means is defined per-device. */ 1843 + virtual void EnterStandby() = 0; 1844 + 1845 + /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL 1846 + * if the requested interface or version is not supported. */ 1847 + virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0; 1848 + 1849 + /** A VR Client has made this debug request of the driver. The set of valid requests is entirely 1850 + * up to the driver and the client to figure out, as is the format of the response. Responses that 1851 + * exceed the length of the supplied buffer should be truncated and null terminated */ 1852 + virtual void DebugRequest( const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; 1853 + 1854 + // ------------------------------------ 1855 + // Tracking Methods 1856 + // ------------------------------------ 1857 + virtual DriverPose_t GetPose() = 0; 1858 + }; 1859 + 1860 + 1861 + 1862 + static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_005"; 1863 + 1864 + } 1865 + // ivrdisplaycomponent.h 1866 + namespace vr 1867 + { 1868 + 1869 + 1870 + // ---------------------------------------------------------------------------------------------- 1871 + // Purpose: The display component on a single tracked device 1872 + // ---------------------------------------------------------------------------------------------- 1873 + class IVRDisplayComponent 1874 + { 1875 + public: 1876 + 1877 + // ------------------------------------ 1878 + // Display Methods 1879 + // ------------------------------------ 1880 + 1881 + /** Size and position that the window needs to be on the VR display. */ 1882 + virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; 1883 + 1884 + /** Returns true if the display is extending the desktop. */ 1885 + virtual bool IsDisplayOnDesktop( ) = 0; 1886 + 1887 + /** Returns true if the display is real and not a fictional display. */ 1888 + virtual bool IsDisplayRealDisplay( ) = 0; 1889 + 1890 + /** Suggested size for the intermediate render target that the distortion pulls from. */ 1891 + virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0; 1892 + 1893 + /** Gets the viewport in the frame buffer to draw the output of the distortion into */ 1894 + virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; 1895 + 1896 + /** The components necessary to build your own projection matrix in case your 1897 + * application is doing something fancy like infinite Z */ 1898 + virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0; 1899 + 1900 + /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in 1901 + * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */ 1902 + virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0; 1903 + 1904 + }; 1905 + 1906 + static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_002"; 1907 + 1908 + } 1909 + 1910 + // ivrdriverdirectmodecomponent.h 1911 + namespace vr 1912 + { 1913 + 1914 + 1915 + // ---------------------------------------------------------------------------------------------- 1916 + // Purpose: This component is used for drivers that implement direct mode entirely on their own 1917 + // without allowing the VR Compositor to own the window/device. Chances are you don't 1918 + // need to implement this component in your driver. 1919 + // ---------------------------------------------------------------------------------------------- 1920 + class IVRDriverDirectModeComponent 1921 + { 1922 + public: 1923 + 1924 + // ----------------------------------- 1925 + // Direct mode methods 1926 + // ----------------------------------- 1927 + 1928 + /** Specific to Oculus compositor support, textures supplied must be created using this method. */ 1929 + struct SwapTextureSetDesc_t 1930 + { 1931 + uint32_t nWidth; 1932 + uint32_t nHeight; 1933 + uint32_t nFormat; 1934 + uint32_t nSampleCount; 1935 + }; 1936 + virtual void CreateSwapTextureSet( uint32_t unPid, const SwapTextureSetDesc_t *pSwapTextureSetDesc, vr::SharedTextureHandle_t( *pSharedTextureHandles )[ 3 ] ) {} 1937 + 1938 + /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */ 1939 + virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sharedTextureHandle ) {} 1940 + 1941 + /** Used to purge all texture sets for a given process. */ 1942 + virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {} 1943 + 1944 + /** After Present returns, calls this to get the next index to use for rendering. */ 1945 + virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {} 1946 + 1947 + /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created 1948 + * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */ 1949 + struct SubmitLayerPerEye_t 1950 + { 1951 + // Shared texture handles (depth not always provided). 1952 + vr::SharedTextureHandle_t hTexture, hDepthTexture; 1953 + 1954 + // Valid region of provided texture (and depth). 1955 + vr::VRTextureBounds_t bounds; 1956 + 1957 + // Projection matrix used to render the depth buffer. 1958 + vr::HmdMatrix44_t mProjection; 1959 + }; 1960 + virtual void SubmitLayer( const SubmitLayerPerEye_t( &perEye )[ 2 ], const vr::HmdMatrix34_t *pPose ) {} 1961 + 1962 + /** Submits queued layers for display. */ 1963 + virtual void Present( vr::SharedTextureHandle_t syncTexture ) {} 1964 + 1965 + /** Called after Present to allow driver to take more time until vsync after they've successfully acquired the sync texture in Present.*/ 1966 + virtual void PostPresent() {} 1967 + 1968 + /** Called to get additional frame timing stats from driver. Check m_nSize for versioning (new members will be added to end only). */ 1969 + virtual void GetFrameTiming( DriverDirectMode_FrameTiming *pFrameTiming ) {} 1970 + }; 1971 + 1972 + static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_005"; 1973 + 1974 + } 1975 + 1976 + // ivrcameracomponent.h 1977 + namespace vr 1978 + { 1979 + //----------------------------------------------------------------------------- 1980 + //----------------------------------------------------------------------------- 1981 + class ICameraVideoSinkCallback 1982 + { 1983 + public: 1984 + virtual void OnCameraVideoSinkCallback() = 0; 1985 + }; 1986 + 1987 + // ---------------------------------------------------------------------------------------------- 1988 + // Purpose: The camera on a single tracked device 1989 + // ---------------------------------------------------------------------------------------------- 1990 + class IVRCameraComponent 1991 + { 1992 + public: 1993 + // ------------------------------------ 1994 + // Camera Methods 1995 + // ------------------------------------ 1996 + virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFormat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0; 1997 + virtual bool GetCameraFrameBufferingRequirements( int *pDefaultFrameQueueSize, uint32_t *pFrameBufferDataSize ) = 0; 1998 + virtual bool SetCameraFrameBuffering( int nFrameBufferCount, void **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0; 1999 + virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamFormat nVideoStreamFormat ) = 0; 2000 + virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat() = 0; 2001 + virtual bool StartVideoStream() = 0; 2002 + virtual void StopVideoStream() = 0; 2003 + virtual bool IsVideoStreamActive( bool *pbPaused, float *pflElapsedTime ) = 0; 2004 + virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame() = 0; 2005 + virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStreamFrame_t *pFrameImage ) = 0; 2006 + virtual bool SetAutoExposure( bool bEnable ) = 0; 2007 + virtual bool PauseVideoStream() = 0; 2008 + virtual bool ResumeVideoStream() = 0; 2009 + virtual bool GetCameraDistortion( float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0; 2010 + virtual bool GetCameraProjection( vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; 2011 + virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0; 2012 + virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0; 2013 + virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0; 2014 + virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0; 2015 + virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0; 2016 + virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0; 2017 + }; 2018 + 2019 + static const char *IVRCameraComponent_Version = "IVRCameraComponent_002"; 2020 + } 2021 + // itrackeddevicedriverprovider.h 2022 + namespace vr 2023 + { 2024 + 2025 + class ITrackedDeviceServerDriver; 2026 + struct TrackedDeviceDriverInfo_t; 2027 + struct DriverPose_t; 2028 + 2029 + /** This interface is provided by vrserver to allow the driver to notify 2030 + * the system when something changes about a device. These changes must 2031 + * not change the serial number or class of the device because those values 2032 + * are permanently associated with the device's index. */ 2033 + class IVRDriverContext 2034 + { 2035 + public: 2036 + /** Returns the requested interface. If the interface was not available it will return NULL and fill 2037 + * out the error. */ 2038 + virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError = nullptr ) = 0; 2039 + 2040 + /** Returns the property container handle for this driver */ 2041 + virtual DriverHandle_t GetDriverHandle() = 0; 2042 + }; 2043 + 2044 + 2045 + /** This interface must be implemented in each driver. It will be loaded in vrserver.exe */ 2046 + class IServerTrackedDeviceProvider 2047 + { 2048 + public: 2049 + /** initializes the driver. This will be called before any other methods are called. 2050 + * If Init returns anything other than VRInitError_None the driver DLL will be unloaded. 2051 + * 2052 + * pDriverHost will never be NULL, and will always be a pointer to a IServerDriverHost interface 2053 + * 2054 + * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user 2055 + * config files. 2056 + * pchDriverInstallDir - The absolute path of the root directory for the driver. 2057 + */ 2058 + virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; 2059 + 2060 + /** cleans up the driver right before it is unloaded */ 2061 + virtual void Cleanup() = 0; 2062 + 2063 + /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */ 2064 + virtual const char * const *GetInterfaceVersions() = 0; 2065 + 2066 + /** Allows the driver do to some work in the main loop of the server. */ 2067 + virtual void RunFrame() = 0; 2068 + 2069 + 2070 + // ------------ Power State Functions ----------------------- // 2071 + 2072 + /** Returns true if the driver wants to block Standby mode. */ 2073 + virtual bool ShouldBlockStandbyMode() = 0; 2074 + 2075 + /** Called when the system is entering Standby mode. The driver should switch itself into whatever sort of low-power 2076 + * state it has. */ 2077 + virtual void EnterStandby() = 0; 2078 + 2079 + /** Called when the system is leaving Standby mode. The driver should switch itself back to 2080 + full operation. */ 2081 + virtual void LeaveStandby() = 0; 2082 + 2083 + }; 2084 + 2085 + 2086 + static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_004"; 2087 + 2088 + 2089 + 2090 + 2091 + /** This interface must be implemented in each driver. It will be loaded in vrclient.dll */ 2092 + class IVRWatchdogProvider 2093 + { 2094 + public: 2095 + /** initializes the driver in watchdog mode. */ 2096 + virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; 2097 + 2098 + /** cleans up the driver right before it is unloaded */ 2099 + virtual void Cleanup() = 0; 2100 + }; 2101 + 2102 + static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001"; 2103 + 2104 + } 2105 + // ivrproperties.h 2106 + #include <string> 2107 + #include <vector> 2108 + 2109 + namespace vr 2110 + { 2111 + 2112 + enum EPropertyWriteType 2113 + { 2114 + PropertyWrite_Set = 0, 2115 + PropertyWrite_Erase = 1, 2116 + PropertyWrite_SetError = 2 2117 + }; 2118 + 2119 + struct PropertyWrite_t 2120 + { 2121 + ETrackedDeviceProperty prop; 2122 + EPropertyWriteType writeType; 2123 + ETrackedPropertyError eSetError; 2124 + void *pvBuffer; 2125 + uint32_t unBufferSize; 2126 + PropertyTypeTag_t unTag; 2127 + ETrackedPropertyError eError; 2128 + }; 2129 + 2130 + struct PropertyRead_t 2131 + { 2132 + ETrackedDeviceProperty prop; 2133 + void *pvBuffer; 2134 + uint32_t unBufferSize; 2135 + PropertyTypeTag_t unTag; 2136 + uint32_t unRequiredBufferSize; 2137 + ETrackedPropertyError eError; 2138 + }; 2139 + 2140 + 2141 + class IVRProperties 2142 + { 2143 + public: 2144 + 2145 + /** Reads a set of properties atomically. See the PropertyReadBatch_t struct for more information. */ 2146 + virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0; 2147 + 2148 + /** Writes a set of properties atomically. See the PropertyWriteBatch_t struct for more information. */ 2149 + virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0; 2150 + 2151 + /** returns a string that corresponds with the specified property error. The string will be the name 2152 + * of the error enum value for all valid error codes */ 2153 + virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0; 2154 + 2155 + /** Returns a container handle given a tracked device index */ 2156 + virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) = 0; 2157 + 2158 + }; 2159 + 2160 + static const char * const IVRProperties_Version = "IVRProperties_001"; 2161 + 2162 + class CVRPropertyHelpers 2163 + { 2164 + public: 2165 + CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProperties ) {} 2166 + 2167 + /** Returns a scaler property. If the device index is not valid or the property value type does not match, 2168 + * this function will return false. */ 2169 + bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); 2170 + float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); 2171 + int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); 2172 + uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); 2173 + 2174 + /** Returns a single typed property. If the device index is not valid or the property is not a string type this function will 2175 + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing 2176 + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ 2177 + uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L ); 2178 + 2179 + 2180 + /** Returns a string property. If the device index is not valid or the property is not a string type this function will 2181 + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing 2182 + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ 2183 + uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ); 2184 + 2185 + /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will 2186 + * return an empty string. */ 2187 + std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr ); 2188 + 2189 + /** Reads a std::vector of data from a property. */ 2190 + template< typename T> 2191 + ETrackedPropertyError GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults ); 2192 + 2193 + /** Sets a scaler property. The new value will be returned on any subsequent call to get this property in any process. */ 2194 + ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue ); 2195 + ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue ); 2196 + ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ); 2197 + ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue ); 2198 + 2199 + /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */ 2200 + ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue ); 2201 + 2202 + /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */ 2203 + ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag ); 2204 + 2205 + /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */ 2206 + ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError ); 2207 + 2208 + /** Clears any value or error set for the property. */ 2209 + ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop ); 2210 + 2211 + /* Turns a device index into a property container handle. */ 2212 + PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDevice ); } 2213 + 2214 + /** Sets a std::vector of typed data to a property. */ 2215 + template< typename T> 2216 + ETrackedPropertyError SetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *vecProperties ); 2217 + 2218 + /** Returns true if the specified property is set on the specified container */ 2219 + bool IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError = nullptr ); 2220 + private: 2221 + template<typename T> 2222 + T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag ); 2223 + 2224 + IVRProperties *m_pProperties; 2225 + }; 2226 + 2227 + 2228 + inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError ) 2229 + { 2230 + PropertyRead_t batch; 2231 + batch.prop = prop; 2232 + batch.pvBuffer = pvBuffer; 2233 + batch.unBufferSize = unBufferSize; 2234 + 2235 + m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 ); 2236 + 2237 + if ( pError ) 2238 + { 2239 + *pError = batch.eError; 2240 + } 2241 + 2242 + if ( punTag ) 2243 + { 2244 + *punTag = batch.unTag; 2245 + } 2246 + 2247 + return batch.unRequiredBufferSize; 2248 + } 2249 + 2250 + 2251 + /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */ 2252 + inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag ) 2253 + { 2254 + PropertyWrite_t batch; 2255 + batch.writeType = PropertyWrite_Set; 2256 + batch.prop = prop; 2257 + batch.pvBuffer = pvNewValue; 2258 + batch.unBufferSize = unNewValueSize; 2259 + batch.unTag = unTag; 2260 + 2261 + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); 2262 + 2263 + return batch.eError; 2264 + } 2265 + 2266 + 2267 + /** Returns a string property. If the device index is not valid or the property is not a string type this function will 2268 + * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing 2269 + * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */ 2270 + inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError ) 2271 + { 2272 + PropertyTypeTag_t unTag; 2273 + ETrackedPropertyError error; 2274 + uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue, unBufferSize, &unTag, &error ); 2275 + if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success ) 2276 + { 2277 + error = TrackedProp_WrongDataType; 2278 + } 2279 + 2280 + if ( pError ) 2281 + { 2282 + *pError = error; 2283 + } 2284 + 2285 + if ( error != TrackedProp_Success ) 2286 + { 2287 + if ( pchValue && unBufferSize ) 2288 + { 2289 + *pchValue = '\0'; 2290 + } 2291 + } 2292 + 2293 + return unRequiredSize; 2294 + } 2295 + 2296 + 2297 + /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will 2298 + * return an empty string. */ 2299 + inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError ) 2300 + { 2301 + char buf[1024]; 2302 + vr::ETrackedPropertyError err; 2303 + uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf, sizeof(buf), &err ); 2304 + 2305 + std::string sResult; 2306 + 2307 + if ( err == TrackedProp_Success ) 2308 + { 2309 + sResult = buf; 2310 + } 2311 + else if ( err == TrackedProp_BufferTooSmall ) 2312 + { 2313 + char *pchBuffer = new char[unRequiredBufferLen]; 2314 + unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchBuffer, unRequiredBufferLen, &err ); 2315 + sResult = pchBuffer; 2316 + delete[] pchBuffer; 2317 + } 2318 + 2319 + if ( peError ) 2320 + { 2321 + *peError = err; 2322 + } 2323 + 2324 + return sResult; 2325 + } 2326 + 2327 + 2328 + /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */ 2329 + inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue ) 2330 + { 2331 + if ( !pchNewValue ) 2332 + return TrackedProp_InvalidOperation; 2333 + 2334 + // this is strlen without the dependency on string.h 2335 + const char *pchCurr = pchNewValue; 2336 + while ( *pchCurr ) 2337 + { 2338 + pchCurr++; 2339 + } 2340 + 2341 + return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint32_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag ); 2342 + } 2343 + 2344 + 2345 + template<typename T> 2346 + inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag ) 2347 + { 2348 + T bValue; 2349 + ETrackedPropertyError eError; 2350 + PropertyTypeTag_t unReadTag; 2351 + GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unReadTag, &eError ); 2352 + if ( unReadTag != unTypeTag && eError == TrackedProp_Success ) 2353 + { 2354 + eError = TrackedProp_WrongDataType; 2355 + }; 2356 + 2357 + if ( pError ) 2358 + *pError = eError; 2359 + if ( eError != TrackedProp_Success ) 2360 + { 2361 + return bDefault; 2362 + } 2363 + else 2364 + { 2365 + return bValue; 2366 + } 2367 + } 2368 + 2369 + 2370 + inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) 2371 + { 2372 + return GetPropertyHelper<bool>( ulContainerHandle, prop, pError, false, k_unBoolPropertyTag ); 2373 + } 2374 + 2375 + 2376 + inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) 2377 + { 2378 + return GetPropertyHelper<float>( ulContainerHandle, prop, pError, 0.f, k_unFloatPropertyTag ); 2379 + } 2380 + 2381 + inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) 2382 + { 2383 + return GetPropertyHelper<int32_t>( ulContainerHandle, prop, pError, 0, k_unInt32PropertyTag ); 2384 + } 2385 + 2386 + inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) 2387 + { 2388 + return GetPropertyHelper<uint64_t>( ulContainerHandle, prop, pError, 0, k_unUint64PropertyTag ); 2389 + } 2390 + 2391 + inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue ) 2392 + { 2393 + return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewValue ), k_unBoolPropertyTag ); 2394 + } 2395 + 2396 + inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue ) 2397 + { 2398 + return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unFloatPropertyTag ); 2399 + } 2400 + 2401 + inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ) 2402 + { 2403 + return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewValue ), k_unInt32PropertyTag ); 2404 + } 2405 + 2406 + inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue ) 2407 + { 2408 + return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewValue ), k_unUint64PropertyTag ); 2409 + } 2410 + 2411 + /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */ 2412 + inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError ) 2413 + { 2414 + PropertyWrite_t batch; 2415 + batch.writeType = PropertyWrite_SetError; 2416 + batch.prop = prop; 2417 + batch.eSetError = eError; 2418 + 2419 + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); 2420 + 2421 + return batch.eError; 2422 + } 2423 + 2424 + /** Clears any value or error set for the property. */ 2425 + inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop ) 2426 + { 2427 + PropertyWrite_t batch; 2428 + batch.writeType = PropertyWrite_Erase; 2429 + batch.prop = prop; 2430 + 2431 + m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); 2432 + 2433 + return batch.eError; 2434 + 2435 + } 2436 + 2437 + template< typename T > 2438 + ETrackedPropertyError CVRPropertyHelpers::SetPropertyVector(PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, PropertyTypeTag_t unTag, std::vector<T> *pvecProperties) 2439 + { 2440 + return SetProperty( ulContainer, prop, &(*pvecProperties)[0], (uint32_t)(pvecProperties->size() * sizeof( T )), unTag ); 2441 + } 2442 + 2443 + template< typename T > 2444 + ETrackedPropertyError CVRPropertyHelpers::GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults ) 2445 + { 2446 + ETrackedPropertyError err; 2447 + PropertyTypeTag_t unTag; 2448 + uint32_t unNeeded; 2449 + if ( pvecResults->empty() ) 2450 + unNeeded = GetProperty( ulContainer, prop, nullptr, 0, &unTag, &err ); 2451 + else 2452 + unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err ); 2453 + uint32_t unFound = unNeeded / sizeof( T ); 2454 + if ( err == TrackedProp_Success ) 2455 + { 2456 + if ( unTag != unExpectedTag && unFound > 0 ) 2457 + { 2458 + return TrackedProp_WrongDataType; 2459 + } 2460 + 2461 + pvecResults->resize( unFound ); 2462 + return TrackedProp_Success; 2463 + } 2464 + else if ( err == TrackedProp_BufferTooSmall ) 2465 + { 2466 + pvecResults->resize( unFound ); 2467 + unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err ); 2468 + unFound = unNeeded / sizeof( T ); 2469 + 2470 + if ( err == TrackedProp_Success ) 2471 + { 2472 + if ( unTag != unExpectedTag ) 2473 + { 2474 + return TrackedProp_WrongDataType; 2475 + } 2476 + 2477 + pvecResults->resize( unFound ); 2478 + return TrackedProp_Success; 2479 + } 2480 + } 2481 + return err; 2482 + } 2483 + 2484 + inline bool CVRPropertyHelpers::IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError ) 2485 + { 2486 + ETrackedPropertyError error; 2487 + GetProperty( ulContainer, prop, nullptr, 0, nullptr, &error ); 2488 + if ( peError ) 2489 + *peError = error; 2490 + return error == TrackedProp_Success || error == TrackedProp_BufferTooSmall; 2491 + } 2492 + 2493 + } 2494 + 2495 + 2496 + 2497 + // ivrdriverinput.h 2498 + namespace vr 2499 + { 2500 + 2501 + typedef uint64_t VRInputComponentHandle_t; 2502 + static const VRInputComponentHandle_t k_ulInvalidInputComponentHandle = 0; 2503 + 2504 + enum EVRScalarType 2505 + { 2506 + VRScalarType_Absolute = 0, 2507 + VRScalarType_Relative = 1, 2508 + }; 2509 + 2510 + 2511 + enum EVRScalarUnits 2512 + { 2513 + VRScalarUnits_NormalizedOneSided = 0, // Value ranges from 0 to 1 2514 + VRScalarUnits_NormalizedTwoSided = 1, // Value ranges from -1 to 1 2515 + }; 2516 + 2517 + class IVRDriverInput 2518 + { 2519 + public: 2520 + 2521 + /** Creates a boolean input component for the device */ 2522 + virtual EVRInputError CreateBooleanComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0; 2523 + 2524 + /** Updates a boolean component */ 2525 + virtual EVRInputError UpdateBooleanComponent( VRInputComponentHandle_t ulComponent, bool bNewValue, double fTimeOffset ) = 0; 2526 + 2527 + /** Creates a scalar input component for the device */ 2528 + virtual EVRInputError CreateScalarComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle, EVRScalarType eType, EVRScalarUnits eUnits ) = 0; 2529 + 2530 + /** Updates a boolean component */ 2531 + virtual EVRInputError UpdateScalarComponent( VRInputComponentHandle_t ulComponent, float fNewValue, double fTimeOffset ) = 0; 2532 + 2533 + /** Creates a haptic component for the device */ 2534 + virtual EVRInputError CreateHapticComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0; 2535 + 2536 + }; 2537 + 2538 + static const char * const IVRDriverInput_Version = "IVRDriverInput_001"; 2539 + 2540 + } // namespace vr 2541 + 2542 + // ivrdriverlog.h 2543 + namespace vr 2544 + { 2545 + 2546 + class IVRDriverLog 2547 + { 2548 + public: 2549 + /** Writes a log message to the log file prefixed with the driver name */ 2550 + virtual void Log( const char *pchLogMessage ) = 0; 2551 + }; 2552 + 2553 + 2554 + static const char *IVRDriverLog_Version = "IVRDriverLog_001"; 2555 + 2556 + } 2557 + // ivrserverdriverhost.h 2558 + namespace vr 2559 + { 2560 + 2561 + class ITrackedDeviceServerDriver; 2562 + struct TrackedDeviceDriverInfo_t; 2563 + struct DriverPose_t; 2564 + 2565 + /** This interface is provided by vrserver to allow the driver to notify 2566 + * the system when something changes about a device. These changes must 2567 + * not change the serial number or class of the device because those values 2568 + * are permanently associated with the device's index. */ 2569 + class IVRServerDriverHost 2570 + { 2571 + public: 2572 + /** Notifies the server that a tracked device has been added. If this function returns true 2573 + * the server will call Activate on the device. If it returns false some kind of error 2574 + * has occurred and the device will not be activated. */ 2575 + virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETrackedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0; 2576 + 2577 + /** Notifies the server that a tracked device's pose has been updated */ 2578 + virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose, uint32_t unPoseStructSize ) = 0; 2579 + 2580 + /** Notifies the server that vsync has occurred on the the display attached to the device. This is 2581 + * only permitted on devices of the HMD class. */ 2582 + virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0; 2583 + 2584 + /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */ 2585 + virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0; 2586 + 2587 + /** Returns true if SteamVR is exiting */ 2588 + virtual bool IsExiting() = 0; 2589 + 2590 + /** Returns true and fills the event with the next event on the queue if there is one. If there are no events 2591 + * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */ 2592 + virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0; 2593 + 2594 + /** Provides access to device poses for drivers. Poses are in their "raw" tracking space which is uniquely 2595 + * defined by each driver providing poses for its devices. It is up to clients of this function to correlate 2596 + * poses across different drivers. Poses are indexed by their device id, and their associated driver and 2597 + * other properties can be looked up via IVRProperties. */ 2598 + virtual void GetRawTrackedDevicePoses( float fPredictedSecondsFromNow, TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0; 2599 + 2600 + /** Notifies the server that a tracked device's display component transforms have been updated. */ 2601 + virtual void TrackedDeviceDisplayTransformUpdated( uint32_t unWhichDevice, HmdMatrix34_t eyeToHeadLeft, HmdMatrix34_t eyeToHeadRight ) = 0; 2602 + }; 2603 + 2604 + static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_005"; 2605 + 2606 + } 2607 + 2608 + // ivrhiddenarea.h 2609 + namespace vr 2610 + { 2611 + 2612 + class CVRHiddenAreaHelpers 2613 + { 2614 + public: 2615 + CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pProperties ) {} 2616 + 2617 + /** Stores a hidden area mesh in a property */ 2618 + ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount ); 2619 + 2620 + /** retrieves a hidden area mesh from a property. Returns the vert count read out of the property. */ 2621 + uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError ); 2622 + 2623 + private: 2624 + ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType type ) 2625 + { 2626 + return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_Start + ((int)type * 2) + (int)eEye); 2627 + } 2628 + 2629 + IVRProperties *m_pProperties; 2630 + }; 2631 + 2632 + 2633 + inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount ) 2634 + { 2635 + ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); 2636 + CVRPropertyHelpers propHelpers( m_pProperties ); 2637 + return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVertCount, k_unHiddenAreaPropertyTag ); 2638 + } 2639 + 2640 + 2641 + inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError ) 2642 + { 2643 + ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); 2644 + CVRPropertyHelpers propHelpers( m_pProperties ); 2645 + ETrackedPropertyError propError; 2646 + PropertyTypeTag_t unTag; 2647 + uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t )*unVertCount, &unTag, &propError ); 2648 + if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaPropertyTag ) 2649 + { 2650 + propError = TrackedProp_WrongDataType; 2651 + unBytesNeeded = 0; 2652 + } 2653 + 2654 + if ( peError ) 2655 + { 2656 + *peError = propError; 2657 + } 2658 + 2659 + return unBytesNeeded / sizeof( HmdVector2_t ); 2660 + } 2661 + 2662 + } 2663 + // ivrwatchdoghost.h 2664 + namespace vr 2665 + { 2666 + 2667 + /** This interface is provided by vrclient to allow the driver to make everything wake up */ 2668 + class IVRWatchdogHost 2669 + { 2670 + public: 2671 + /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should 2672 + * cause SteamVR to start */ 2673 + virtual void WatchdogWakeUp() = 0; 2674 + }; 2675 + 2676 + static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001"; 2677 + 2678 + } 2679 + 2680 + 2681 + 2682 + // ivrvirtualdisplay.h 2683 + namespace vr 2684 + { 2685 + struct PresentInfo_t 2686 + { 2687 + SharedTextureHandle_t backbufferTextureHandle; 2688 + EVSync vsync; 2689 + uint64_t nFrameId; 2690 + double flVSyncTimeInSeconds; 2691 + }; 2692 + 2693 + // ---------------------------------------------------------------------------------------------- 2694 + // Purpose: This component is used for drivers that implement a virtual display (e.g. wireless). 2695 + // ---------------------------------------------------------------------------------------------- 2696 + class IVRVirtualDisplay 2697 + { 2698 + public: 2699 + 2700 + /** Submits final backbuffer for display. */ 2701 + virtual void Present( const PresentInfo_t *pPresentInfo, uint32_t unPresentInfoSize ) = 0; 2702 + 2703 + /** Block until the last presented buffer start scanning out. */ 2704 + virtual void WaitForPresent() = 0; 2705 + 2706 + /** Provides timing data for synchronizing with display. */ 2707 + virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0; 2708 + }; 2709 + 2710 + static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_002"; 2711 + 2712 + /** Returns the current IVRVirtualDisplay pointer or NULL the interface could not be found. */ 2713 + VR_INTERFACE vr::IVRVirtualDisplay *VR_CALLTYPE VRVirtualDisplay(); 2714 + } 2715 + 2716 + 2717 + // ivrresources.h 2718 + namespace vr 2719 + { 2720 + 2721 + class IVRResources 2722 + { 2723 + public: 2724 + 2725 + // ------------------------------------ 2726 + // Shared Resource Methods 2727 + // ------------------------------------ 2728 + 2729 + /** Loads the specified resource into the provided buffer if large enough. 2730 + * Returns the size in bytes of the buffer required to hold the specified resource. */ 2731 + virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0; 2732 + 2733 + /** Provides the full path to the specified resource. Resource names can include named directories for 2734 + * drivers and other things, and this resolves all of those and returns the actual physical path. 2735 + * pchResourceTypeDirectory is the subdirectory of resources to look in. */ 2736 + virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0; 2737 + }; 2738 + 2739 + static const char * const IVRResources_Version = "IVRResources_001"; 2740 + 2741 + 2742 + } 2743 + // ivrdrivermanager.h 2744 + namespace vr 2745 + { 2746 + 2747 + class IVRDriverManager 2748 + { 2749 + public: 2750 + virtual uint32_t GetDriverCount() const = 0; 2751 + 2752 + /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */ 2753 + virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0; 2754 + 2755 + virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0; 2756 + }; 2757 + 2758 + static const char * const IVRDriverManager_Version = "IVRDriverManager_001"; 2759 + 2760 + } // namespace vr 2761 + 2762 + 2763 + 2764 + 2765 + 2766 + namespace vr 2767 + { 2768 + static const char * const k_InterfaceVersions[] = 2769 + { 2770 + IVRSettings_Version, 2771 + ITrackedDeviceServerDriver_Version, 2772 + IVRDisplayComponent_Version, 2773 + IVRDriverDirectModeComponent_Version, 2774 + IVRCameraComponent_Version, 2775 + IServerTrackedDeviceProvider_Version, 2776 + IVRWatchdogProvider_Version, 2777 + IVRVirtualDisplay_Version, 2778 + IVRDriverManager_Version, 2779 + IVRResources_Version, 2780 + nullptr 2781 + }; 2782 + 2783 + inline IVRDriverContext *&VRDriverContext() 2784 + { 2785 + static IVRDriverContext *pHost; 2786 + return pHost; 2787 + } 2788 + 2789 + class COpenVRDriverContext 2790 + { 2791 + public: 2792 + COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAreaHelpers(nullptr) { Clear(); } 2793 + void Clear(); 2794 + 2795 + EVRInitError InitServer(); 2796 + EVRInitError InitWatchdog(); 2797 + 2798 + IVRSettings *VRSettings() 2799 + { 2800 + if ( m_pVRSettings == nullptr ) 2801 + { 2802 + EVRInitError eError; 2803 + m_pVRSettings = (IVRSettings *)VRDriverContext()->GetGenericInterface( IVRSettings_Version, &eError ); 2804 + } 2805 + return m_pVRSettings; 2806 + } 2807 + 2808 + IVRProperties *VRPropertiesRaw() 2809 + { 2810 + if ( m_pVRProperties == nullptr ) 2811 + { 2812 + EVRInitError eError; 2813 + m_pVRProperties = (IVRProperties *)VRDriverContext()->GetGenericInterface( IVRProperties_Version, &eError ); 2814 + m_propertyHelpers = CVRPropertyHelpers( m_pVRProperties ); 2815 + m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pVRProperties ); 2816 + } 2817 + return m_pVRProperties; 2818 + } 2819 + 2820 + CVRPropertyHelpers *VRProperties() 2821 + { 2822 + VRPropertiesRaw(); 2823 + return &m_propertyHelpers; 2824 + } 2825 + 2826 + CVRHiddenAreaHelpers *VRHiddenArea() 2827 + { 2828 + VRPropertiesRaw(); 2829 + return &m_hiddenAreaHelpers; 2830 + } 2831 + 2832 + IVRServerDriverHost *VRServerDriverHost() 2833 + { 2834 + if ( m_pVRServerDriverHost == nullptr ) 2835 + { 2836 + EVRInitError eError; 2837 + m_pVRServerDriverHost = (IVRServerDriverHost *)VRDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError ); 2838 + } 2839 + return m_pVRServerDriverHost; 2840 + } 2841 + 2842 + IVRWatchdogHost *VRWatchdogHost() 2843 + { 2844 + if ( m_pVRWatchdogHost == nullptr ) 2845 + { 2846 + EVRInitError eError; 2847 + m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverContext()->GetGenericInterface( IVRWatchdogHost_Version, &eError ); 2848 + } 2849 + return m_pVRWatchdogHost; 2850 + } 2851 + 2852 + IVRDriverLog *VRDriverLog() 2853 + { 2854 + if ( m_pVRDriverLog == nullptr ) 2855 + { 2856 + EVRInitError eError; 2857 + m_pVRDriverLog = (IVRDriverLog *)VRDriverContext()->GetGenericInterface( IVRDriverLog_Version, &eError ); 2858 + } 2859 + return m_pVRDriverLog; 2860 + } 2861 + 2862 + DriverHandle_t VR_CALLTYPE VRDriverHandle() 2863 + { 2864 + return VRDriverContext()->GetDriverHandle(); 2865 + } 2866 + 2867 + IVRDriverManager *VRDriverManager() 2868 + { 2869 + if ( !m_pVRDriverManager ) 2870 + { 2871 + EVRInitError eError; 2872 + m_pVRDriverManager = (IVRDriverManager *)VRDriverContext()->GetGenericInterface( IVRDriverManager_Version, &eError ); 2873 + } 2874 + return m_pVRDriverManager; 2875 + } 2876 + 2877 + IVRResources *VRResources() 2878 + { 2879 + if ( !m_pVRResources ) 2880 + { 2881 + EVRInitError eError; 2882 + m_pVRResources = (IVRResources *)VRDriverContext()->GetGenericInterface( IVRResources_Version, &eError ); 2883 + } 2884 + return m_pVRResources; 2885 + } 2886 + 2887 + IVRDriverInput *VRDriverInput() 2888 + { 2889 + if ( !m_pVRDriverInput ) 2890 + { 2891 + EVRInitError eError; 2892 + m_pVRDriverInput = (IVRDriverInput *)VRDriverContext()->GetGenericInterface( IVRDriverInput_Version, &eError ); 2893 + } 2894 + return m_pVRDriverInput; 2895 + } 2896 + 2897 + private: 2898 + CVRPropertyHelpers m_propertyHelpers; 2899 + CVRHiddenAreaHelpers m_hiddenAreaHelpers; 2900 + 2901 + IVRSettings *m_pVRSettings; 2902 + IVRProperties *m_pVRProperties; 2903 + IVRServerDriverHost *m_pVRServerDriverHost; 2904 + IVRWatchdogHost *m_pVRWatchdogHost; 2905 + IVRDriverLog *m_pVRDriverLog; 2906 + IVRDriverManager *m_pVRDriverManager; 2907 + IVRResources *m_pVRResources; 2908 + IVRDriverInput *m_pVRDriverInput; 2909 + }; 2910 + 2911 + inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext() 2912 + { 2913 + static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void * )]; 2914 + return *(COpenVRDriverContext *)ctx; // bypass zero-init constructor 2915 + } 2916 + 2917 + inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleServerDriverContext().VRSettings(); } 2918 + inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInternal_ModuleServerDriverContext().VRPropertiesRaw(); } 2919 + inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInternal_ModuleServerDriverContext().VRProperties(); } 2920 + inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRInternal_ModuleServerDriverContext().VRHiddenArea(); } 2921 + inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_ModuleServerDriverContext().VRDriverLog(); } 2922 + inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRServerDriverHost(); } 2923 + inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInternal_ModuleServerDriverContext().VRWatchdogHost(); } 2924 + inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRInternal_ModuleServerDriverContext().VRDriverHandle(); } 2925 + inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleServerDriverContext().VRDriverManager(); } 2926 + inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleServerDriverContext().VRResources(); } 2927 + inline IVRDriverInput *VR_CALLTYPE VRDriverInput() { return OpenVRInternal_ModuleServerDriverContext().VRDriverInput(); } 2928 + 2929 + inline void COpenVRDriverContext::Clear() 2930 + { 2931 + m_pVRSettings = nullptr; 2932 + m_pVRProperties = nullptr; 2933 + m_pVRServerDriverHost = nullptr; 2934 + m_pVRDriverLog = nullptr; 2935 + m_pVRWatchdogHost = nullptr; 2936 + m_pVRDriverManager = nullptr; 2937 + m_pVRResources = nullptr; 2938 + m_pVRDriverInput = nullptr; 2939 + } 2940 + 2941 + inline EVRInitError COpenVRDriverContext::InitServer() 2942 + { 2943 + Clear(); 2944 + if ( !VRServerDriverHost() 2945 + || !VRSettings() 2946 + || !VRProperties() 2947 + || !VRDriverLog() 2948 + || !VRDriverManager() 2949 + || !VRResources() ) 2950 + return VRInitError_Init_InterfaceNotFound; 2951 + return VRInitError_None; 2952 + } 2953 + 2954 + inline EVRInitError COpenVRDriverContext::InitWatchdog() 2955 + { 2956 + Clear(); 2957 + if ( !VRWatchdogHost() 2958 + || !VRSettings() 2959 + || !VRDriverLog() ) 2960 + return VRInitError_Init_InterfaceNotFound; 2961 + return VRInitError_None; 2962 + } 2963 + 2964 + inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext ) 2965 + { 2966 + VRDriverContext() = pContext; 2967 + return OpenVRInternal_ModuleServerDriverContext().InitServer(); 2968 + } 2969 + 2970 + inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContext ) 2971 + { 2972 + VRDriverContext() = pContext; 2973 + return OpenVRInternal_ModuleServerDriverContext().InitWatchdog(); 2974 + } 2975 + 2976 + inline void CleanupDriverContext() 2977 + { 2978 + VRDriverContext() = nullptr; 2979 + OpenVRInternal_ModuleServerDriverContext().Clear(); 2980 + } 2981 + 2982 + #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \ 2983 + { \ 2984 + vr::EVRInitError eError = vr::InitServerDriverContext( pContext ); \ 2985 + if( eError != vr::VRInitError_None ) \ 2986 + return eError; \ 2987 + } 2988 + 2989 + #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \ 2990 + vr::CleanupDriverContext(); 2991 + 2992 + #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \ 2993 + { \ 2994 + vr::EVRInitError eError = vr::InitWatchdogDriverContext( pContext ); \ 2995 + if( eError != vr::VRInitError_None ) \ 2996 + return eError; \ 2997 + } 2998 + 2999 + #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \ 3000 + vr::CleanupDriverContext(); 3001 + } 3002 + // End 3003 + 3004 + #endif // _OPENVR_DRIVER_API 3005 +