OLD | NEW |
(Empty) | |
| 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 |
| 31 #if defined(__linux__) || defined(__APPLE__) |
| 32 // The 32-bit version of gcc has the alignment requirement for uint64 an
d double set to |
| 33 // 4 meaning that even with #pragma pack(8) these types will only be fou
r-byte aligned. |
| 34 // The 64-bit version of gcc has the alignment requirement for these typ
es set to |
| 35 // 8 meaning that unless we use #pragma pack(4) our structures will get
bigger. |
| 36 // The 64-bit structure packing has to match the 32-bit structure packin
g for each platform. |
| 37 #pragma pack( push, 4 ) |
| 38 #else |
| 39 #pragma pack( push, 8 ) |
| 40 #endif |
| 41 |
| 42 typedef void* glSharedTextureHandle_t; |
| 43 typedef int32_t glInt_t; |
| 44 typedef uint32_t glUInt_t; |
| 45 |
| 46 // right-handed system |
| 47 // +y is up |
| 48 // +x is to the right |
| 49 // -z is going away from you |
| 50 // Distance unit is meters |
| 51 struct HmdMatrix34_t |
| 52 { |
| 53 float m[3][4]; |
| 54 }; |
| 55 |
| 56 struct HmdMatrix44_t |
| 57 { |
| 58 float m[4][4]; |
| 59 }; |
| 60 |
| 61 struct HmdVector3_t |
| 62 { |
| 63 float v[3]; |
| 64 }; |
| 65 |
| 66 struct HmdVector4_t |
| 67 { |
| 68 float v[4]; |
| 69 }; |
| 70 |
| 71 struct HmdVector3d_t |
| 72 { |
| 73 double v[3]; |
| 74 }; |
| 75 |
| 76 struct HmdVector2_t |
| 77 { |
| 78 float v[2]; |
| 79 }; |
| 80 |
| 81 struct HmdQuaternion_t |
| 82 { |
| 83 double w, x, y, z; |
| 84 }; |
| 85 |
| 86 struct HmdColor_t |
| 87 { |
| 88 float r, g, b, a; |
| 89 }; |
| 90 |
| 91 struct HmdQuad_t |
| 92 { |
| 93 HmdVector3_t vCorners[ 4 ]; |
| 94 }; |
| 95 |
| 96 struct HmdRect2_t |
| 97 { |
| 98 HmdVector2_t vTopLeft; |
| 99 HmdVector2_t vBottomRight; |
| 100 }; |
| 101 |
| 102 /** Used to return the post-distortion UVs for each color channel. |
| 103 * UVs range from 0 to 1 with 0,0 in the upper left corner of the |
| 104 * source render target. The 0,0 to 1,1 range covers a single eye. */ |
| 105 struct DistortionCoordinates_t |
| 106 { |
| 107 float rfRed[2]; |
| 108 float rfGreen[2]; |
| 109 float rfBlue[2]; |
| 110 }; |
| 111 |
| 112 enum EVREye |
| 113 { |
| 114 Eye_Left = 0, |
| 115 Eye_Right = 1 |
| 116 }; |
| 117 |
| 118 enum ETextureType |
| 119 { |
| 120 TextureType_DirectX = 0, // Handle is an ID3D11Texture |
| 121 TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenG
L render buffer name, depending on submit flags |
| 122 TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_
t structure |
| 123 TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable I
OSurface |
| 124 TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_
t structure |
| 125 }; |
| 126 |
| 127 enum EColorSpace |
| 128 { |
| 129 ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component forma
ts, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants
. |
| 130 ColorSpace_Gamma = 1, // Texture data can be displayed directly on the
display without any conversion (a.k.a. display native format). |
| 131 ColorSpace_Linear = 2, // Same as gamma but has been converted to a lin
ear representation using DXGI's sRGB conversion algorithm. |
| 132 }; |
| 133 |
| 134 struct Texture_t |
| 135 { |
| 136 void* handle; // See ETextureType definition above |
| 137 ETextureType eType; |
| 138 EColorSpace eColorSpace; |
| 139 }; |
| 140 |
| 141 // Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResour
ce). |
| 142 typedef uint64_t SharedTextureHandle_t; |
| 143 #define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0) |
| 144 |
| 145 enum ETrackingResult |
| 146 { |
| 147 TrackingResult_Uninitialized = 1, |
| 148 |
| 149 TrackingResult_Calibrating_InProgress = 100, |
| 150 TrackingResult_Calibrating_OutOfRange = 101, |
| 151 |
| 152 TrackingResult_Running_OK = 200, |
| 153 TrackingResult_Running_OutOfRange = 201, |
| 154 }; |
| 155 |
| 156 static const uint32_t k_unMaxDriverDebugResponseSize = 32768; |
| 157 |
| 158 /** Used to pass device IDs to API calls */ |
| 159 typedef uint32_t TrackedDeviceIndex_t; |
| 160 static const uint32_t k_unTrackedDeviceIndex_Hmd = 0; |
| 161 static const uint32_t k_unMaxTrackedDeviceCount = 16; |
| 162 static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE; |
| 163 static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF; |
| 164 |
| 165 /** Describes what kind of object is being tracked at a given ID */ |
| 166 enum ETrackedDeviceClass |
| 167 { |
| 168 TrackedDeviceClass_Invalid = 0, // the ID was no
t valid. |
| 169 TrackedDeviceClass_HMD = 1, // Head-
Mounted Displays |
| 170 TrackedDeviceClass_Controller = 2, // Tracked contr
ollers |
| 171 TrackedDeviceClass_GenericTracker = 3, // Generic trackers, sim
ilar to controllers |
| 172 TrackedDeviceClass_TrackingReference = 4, // Camera and base stati
ons that serve as tracking reference points |
| 173 }; |
| 174 |
| 175 |
| 176 /** Describes what specific role associated with a tracked device */ |
| 177 enum ETrackedControllerRole |
| 178 { |
| 179 TrackedControllerRole_Invalid = 0,
// Invalid value for controller type |
| 180 TrackedControllerRole_LeftHand = 1,
// Tracked device associated with the left hand |
| 181 TrackedControllerRole_RightHand = 2, // Track
ed device associated with the right hand |
| 182 }; |
| 183 |
| 184 |
| 185 /** describes a single pose for a tracked object */ |
| 186 struct TrackedDevicePose_t |
| 187 { |
| 188 HmdMatrix34_t mDeviceToAbsoluteTracking; |
| 189 HmdVector3_t vVelocity; // velocity in tracker s
pace in m/s |
| 190 HmdVector3_t vAngularVelocity; // angular velocity in radians/s
(?) |
| 191 ETrackingResult eTrackingResult; |
| 192 bool bPoseIsValid; |
| 193 |
| 194 // This indicates that there is a device connected for this spot in the
pose array. |
| 195 // It could go from true to false if the user unplugs the device. |
| 196 bool bDeviceIsConnected; |
| 197 }; |
| 198 |
| 199 /** Identifies which style of tracking origin the application wants to use |
| 200 * for the poses it is requesting */ |
| 201 enum ETrackingUniverseOrigin |
| 202 { |
| 203 TrackingUniverseSeated = 0, // Poses are provided relative t
o the seated zero pose |
| 204 TrackingUniverseStanding = 1, // Poses are provided relative to the sa
fe bounds configured by the user |
| 205 TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coo
rdinate 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. |
| 206 }; |
| 207 |
| 208 // Refers to a single container of properties |
| 209 typedef uint64_t PropertyContainerHandle_t; |
| 210 typedef uint32_t PropertyTypeTag_t; |
| 211 |
| 212 static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0; |
| 213 static const PropertyTypeTag_t k_unInvalidPropertyTag = 0; |
| 214 |
| 215 // Use these tags to set/get common types as struct properties |
| 216 static const PropertyTypeTag_t k_unFloatPropertyTag = 1; |
| 217 static const PropertyTypeTag_t k_unInt32PropertyTag = 2; |
| 218 static const PropertyTypeTag_t k_unUint64PropertyTag = 3; |
| 219 static const PropertyTypeTag_t k_unBoolPropertyTag = 4; |
| 220 static const PropertyTypeTag_t k_unStringPropertyTag = 5; |
| 221 |
| 222 static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20; |
| 223 static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21; |
| 224 static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22; |
| 225 static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23; |
| 226 |
| 227 static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30; |
| 228 |
| 229 static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000; |
| 230 static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000; |
| 231 |
| 232 |
| 233 /** Each entry in this enum represents a property that can be retrieved about a |
| 234 * tracked device. Many fields are only valid for one ETrackedDeviceClass. */ |
| 235 enum ETrackedDeviceProperty |
| 236 { |
| 237 Prop_Invalid
= 0, |
| 238 |
| 239 // general properties that apply to all device classes |
| 240 Prop_TrackingSystemName_String = 1000, |
| 241 Prop_ModelNumber_String = 1001, |
| 242 Prop_SerialNumber_String = 1002, |
| 243 Prop_RenderModelName_String = 1003, |
| 244 Prop_WillDriftInYaw_Bool = 1004, |
| 245 Prop_ManufacturerName_String = 1005, |
| 246 Prop_TrackingFirmwareVersion_String = 1006, |
| 247 Prop_HardwareRevision_String = 1007, |
| 248 Prop_AllWirelessDongleDescriptions_String = 1008, |
| 249 Prop_ConnectedWirelessDongle_String = 1009, |
| 250 Prop_DeviceIsWireless_Bool = 1010, |
| 251 Prop_DeviceIsCharging_Bool = 1011, |
| 252 Prop_DeviceBatteryPercentage_Float = 1012, // 0 is
empty, 1 is full |
| 253 Prop_StatusDisplayTransform_Matrix34 = 1013, |
| 254 Prop_Firmware_UpdateAvailable_Bool = 1014, |
| 255 Prop_Firmware_ManualUpdate_Bool = 1015, |
| 256 Prop_Firmware_ManualUpdateURL_String = 1016, |
| 257 Prop_HardwareRevision_Uint64 = 1017, |
| 258 Prop_FirmwareVersion_Uint64 = 1018, |
| 259 Prop_FPGAVersion_Uint64 = 1019, |
| 260 Prop_VRCVersion_Uint64 = 1020, |
| 261 Prop_RadioVersion_Uint64 = 1021, |
| 262 Prop_DongleVersion_Uint64 = 1022, |
| 263 Prop_BlockServerShutdown_Bool = 1023, |
| 264 Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024, |
| 265 Prop_ContainsProximitySensor_Bool = 1025, |
| 266 Prop_DeviceProvidesBatteryStatus_Bool = 1026, |
| 267 Prop_DeviceCanPowerOff_Bool = 1027, |
| 268 Prop_Firmware_ProgrammingTarget_String = 1028, |
| 269 Prop_DeviceClass_Int32 = 1029, |
| 270 Prop_HasCamera_Bool
= 1030, |
| 271 Prop_DriverVersion_String = 1031, |
| 272 Prop_Firmware_ForceUpdateRequired_Bool = 1032, |
| 273 Prop_ViveSystemButtonFixRequired_Bool = 1033, |
| 274 Prop_ParentDriver_Uint64 = 1034, |
| 275 |
| 276 |
| 277 // Properties that are unique to TrackedDeviceClass_HMD |
| 278 Prop_ReportsTimeSinceVSync_Bool = 2000, |
| 279 Prop_SecondsFromVsyncToPhotons_Float = 2001, |
| 280 Prop_DisplayFrequency_Float = 2002, |
| 281 Prop_UserIpdMeters_Float = 2003, |
| 282 Prop_CurrentUniverseId_Uint64 = 2004, |
| 283 Prop_PreviousUniverseId_Uint64 = 2005, |
| 284 Prop_DisplayFirmwareVersion_Uint64 = 2006, |
| 285 Prop_IsOnDesktop_Bool = 2007, |
| 286 Prop_DisplayMCType_Int32 = 2008, |
| 287 Prop_DisplayMCOffset_Float = 2009, |
| 288 Prop_DisplayMCScale_Float = 2010, |
| 289 Prop_EdidVendorID_Int32 = 2011, |
| 290 Prop_DisplayMCImageLeft_String = 2012, |
| 291 Prop_DisplayMCImageRight_String = 2013, |
| 292 Prop_DisplayGCBlackClamp_Float = 2014, |
| 293 Prop_EdidProductID_Int32 = 2015, |
| 294 Prop_CameraToHeadTransform_Matrix34 = 2016, |
| 295 Prop_DisplayGCType_Int32 = 2017, |
| 296 Prop_DisplayGCOffset_Float = 2018, |
| 297 Prop_DisplayGCScale_Float = 2019, |
| 298 Prop_DisplayGCPrescale_Float = 2020, |
| 299 Prop_DisplayGCImage_String = 2021, |
| 300 Prop_LensCenterLeftU_Float = 2022, |
| 301 Prop_LensCenterLeftV_Float = 2023, |
| 302 Prop_LensCenterRightU_Float = 2024, |
| 303 Prop_LensCenterRightV_Float = 2025, |
| 304 Prop_UserHeadToEyeDepthMeters_Float = 2026, |
| 305 Prop_CameraFirmwareVersion_Uint64 = 2027, |
| 306 Prop_CameraFirmwareDescription_String = 2028, |
| 307 Prop_DisplayFPGAVersion_Uint64 = 2029, |
| 308 Prop_DisplayBootloaderVersion_Uint64 = 2030, |
| 309 Prop_DisplayHardwareVersion_Uint64 = 2031, |
| 310 Prop_AudioFirmwareVersion_Uint64 = 2032, |
| 311 Prop_CameraCompatibilityMode_Int32 = 2033, |
| 312 Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, |
| 313 Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, |
| 314 Prop_DisplaySuppressed_Bool = 2036, |
| 315 Prop_DisplayAllowNightMode_Bool = 2037, |
| 316 Prop_DisplayMCImageWidth_Int32 = 2038, |
| 317 Prop_DisplayMCImageHeight_Int32 = 2039, |
| 318 Prop_DisplayMCImageNumChannels_Int32 = 2040, |
| 319 Prop_DisplayMCImageData_Binary = 2041, |
| 320 Prop_UsesDriverDirectMode_Bool = 2042, |
| 321 |
| 322 // Properties that are unique to TrackedDeviceClass_Controller |
| 323 Prop_AttachedDeviceId_String = 3000, |
| 324 Prop_SupportedButtons_Uint64 = 3001, |
| 325 Prop_Axis0Type_Int32 = 3002,
// Return value is of type EVRControllerAxisType |
| 326 Prop_Axis1Type_Int32 = 3003,
// Return value is of type EVRControllerAxisType |
| 327 Prop_Axis2Type_Int32 = 3004,
// Return value is of type EVRControllerAxisType |
| 328 Prop_Axis3Type_Int32 = 3005,
// Return value is of type EVRControllerAxisType |
| 329 Prop_Axis4Type_Int32 = 3006,
// Return value is of type EVRControllerAxisType |
| 330 Prop_ControllerRoleHint_Int32 = 3007, // Retur
n value is of type ETrackedControllerRole |
| 331 |
| 332 // Properties that are unique to TrackedDeviceClass_TrackingReference |
| 333 Prop_FieldOfViewLeftDegrees_Float = 4000, |
| 334 Prop_FieldOfViewRightDegrees_Float = 4001, |
| 335 Prop_FieldOfViewTopDegrees_Float = 4002, |
| 336 Prop_FieldOfViewBottomDegrees_Float = 4003, |
| 337 Prop_TrackingRangeMinimumMeters_Float = 4004, |
| 338 Prop_TrackingRangeMaximumMeters_Float = 4005, |
| 339 Prop_ModeLabel_String = 4006, |
| 340 |
| 341 // Properties that are used for user interface like icons names |
| 342 Prop_IconPathName_String
= 5000, // usually a directory named "icons" |
| 343 Prop_NamedIconPathDeviceOff_String = 5001,
// PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for o
thers |
| 344 Prop_NamedIconPathDeviceSearching_String = 5002, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 345 Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // PNG for stati
c icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 346 Prop_NamedIconPathDeviceReady_String = 5004, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 347 Prop_NamedIconPathDeviceReadyAlert_String = 5005, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 348 Prop_NamedIconPathDeviceNotReady_String = 5006, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 349 Prop_NamedIconPathDeviceStandby_String = 5007, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 350 Prop_NamedIconPathDeviceAlertLow_String = 5008, // PNG f
or static icon, or GIF for animation, 50x32 for headsets and 32x32 for others |
| 351 |
| 352 // Properties that are used by helpers, but are opaque to applications |
| 353 Prop_DisplayHiddenArea_Binary_Start = 5100, |
| 354 Prop_DisplayHiddenArea_Binary_End = 5150, |
| 355 |
| 356 // Properties that are unique to drivers |
| 357 Prop_UserConfigPath_String = 6000, |
| 358 Prop_InstallPath_String = 6001, |
| 359 |
| 360 // Vendors are free to expose private debug data in this reserved region |
| 361 Prop_VendorSpecific_Reserved_Start = 10000, |
| 362 Prop_VendorSpecific_Reserved_End = 10999, |
| 363 }; |
| 364 |
| 365 /** No string property will ever be longer than this length */ |
| 366 static const uint32_t k_unMaxPropertyStringSize = 32 * 1024; |
| 367 |
| 368 /** Used to return errors that occur when reading properties. */ |
| 369 enum ETrackedPropertyError |
| 370 { |
| 371 TrackedProp_Success = 0, |
| 372 TrackedProp_WrongDataType = 1, |
| 373 TrackedProp_WrongDeviceClass = 2, |
| 374 TrackedProp_BufferTooSmall = 3, |
| 375 TrackedProp_UnknownProperty = 4, // Driver h
as not set the property (and may not ever). |
| 376 TrackedProp_InvalidDevice = 5, |
| 377 TrackedProp_CouldNotContactServer = 6, |
| 378 TrackedProp_ValueNotProvidedByDevice = 7, |
| 379 TrackedProp_StringExceedsMaximumLength = 8, |
| 380 TrackedProp_NotYetAvailable = 9, // The prop
erty value isn't known yet, but is expected soon. Call again later. |
| 381 TrackedProp_PermissionDenied = 10, |
| 382 TrackedProp_InvalidOperation = 11, |
| 383 }; |
| 384 |
| 385 /** Allows the application to control what part of the provided texture will be
used in the |
| 386 * frame buffer. */ |
| 387 struct VRTextureBounds_t |
| 388 { |
| 389 float uMin, vMin; |
| 390 float uMax, vMax; |
| 391 }; |
| 392 |
| 393 |
| 394 /** Allows the application to control how scene textures are used by the composi
tor when calling Submit. */ |
| 395 enum EVRSubmitFlags |
| 396 { |
| 397 // Simple render path. App submits rendered left and right eye images wi
th no lens distortion correction applied. |
| 398 Submit_Default = 0x00, |
| 399 |
| 400 // App submits final left and right eye images with lens distortion alre
ady applied (lens distortion makes the images appear |
| 401 // barrel distorted with chromatic aberration correction applied). The a
pp would have used the data returned by |
| 402 // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to
the rendered images before calling Submit(). |
| 403 Submit_LensDistortionAlreadyApplied = 0x01, |
| 404 |
| 405 // If the texture pointer passed in is actually a renderbuffer (e.g. for
MSAA in OpenGL) then set this flag. |
| 406 Submit_GlRenderBuffer = 0x02, |
| 407 |
| 408 // Do not use |
| 409 Submit_Reserved = 0x04, |
| 410 }; |
| 411 |
| 412 /** Data required for passing Vulkan textures to IVRCompositor::Submit. |
| 413 * Be sure to call OpenVR_Shutdown before destroying these resources. */ |
| 414 struct VRVulkanTextureData_t |
| 415 { |
| 416 uint64_t m_nImage; // VkImage |
| 417 VkDevice_T *m_pDevice; |
| 418 VkPhysicalDevice_T *m_pPhysicalDevice; |
| 419 VkInstance_T *m_pInstance; |
| 420 VkQueue_T *m_pQueue; |
| 421 uint32_t m_nQueueFamilyIndex; |
| 422 uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount; |
| 423 }; |
| 424 |
| 425 /** Data required for passing D3D12 textures to IVRCompositor::Submit. |
| 426 * Be sure to call OpenVR_Shutdown before destroying these resources. */ |
| 427 struct D3D12TextureData_t |
| 428 { |
| 429 ID3D12Resource *m_pResource; |
| 430 ID3D12CommandQueue *m_pCommandQueue; |
| 431 uint32_t m_nNodeMask; |
| 432 }; |
| 433 |
| 434 /** Status of the overall system or tracked objects */ |
| 435 enum EVRState |
| 436 { |
| 437 VRState_Undefined = -1, |
| 438 VRState_Off = 0, |
| 439 VRState_Searching = 1, |
| 440 VRState_Searching_Alert = 2, |
| 441 VRState_Ready = 3, |
| 442 VRState_Ready_Alert = 4, |
| 443 VRState_NotReady = 5, |
| 444 VRState_Standby = 6, |
| 445 VRState_Ready_Alert_Low = 7, |
| 446 }; |
| 447 |
| 448 /** The types of events that could be posted (and what the parameters mean for e
ach event type) */ |
| 449 enum EVREventType |
| 450 { |
| 451 VREvent_None = 0, |
| 452 |
| 453 VREvent_TrackedDeviceActivated = 100, |
| 454 VREvent_TrackedDeviceDeactivated = 101, |
| 455 VREvent_TrackedDeviceUpdated = 102, |
| 456 VREvent_TrackedDeviceUserInteractionStarted = 103, |
| 457 VREvent_TrackedDeviceUserInteractionEnded = 104, |
| 458 VREvent_IpdChanged = 105, |
| 459 VREvent_EnterStandbyMode = 106, |
| 460 VREvent_LeaveStandbyMode = 107, |
| 461 VREvent_TrackedDeviceRoleChanged = 108, |
| 462 VREvent_WatchdogWakeUpRequested = 109, |
| 463 VREvent_LensDistortionChanged = 110, |
| 464 VREvent_PropertyChanged = 111, |
| 465 |
| 466 VREvent_ButtonPress = 200, // data i
s controller |
| 467 VREvent_ButtonUnpress = 201, // data is contro
ller |
| 468 VREvent_ButtonTouch = 202, // data i
s controller |
| 469 VREvent_ButtonUntouch = 203, // data is contro
ller |
| 470 |
| 471 VREvent_MouseMove = 300, // data i
s mouse |
| 472 VREvent_MouseButtonDown = 301, // data is mouse |
| 473 VREvent_MouseButtonUp = 302, // data is mouse |
| 474 VREvent_FocusEnter = 303, // data i
s overlay |
| 475 VREvent_FocusLeave = 304, // data i
s overlay |
| 476 VREvent_Scroll = 305, // data i
s mouse |
| 477 VREvent_TouchPadMove = 306, // data is mouse |
| 478 VREvent_OverlayFocusChanged = 307, // data is overla
y, global event |
| 479 |
| 480 VREvent_InputFocusCaptured = 400, // data is proces
s DEPRECATED |
| 481 VREvent_InputFocusReleased = 401, // data is proces
s DEPRECATED |
| 482 VREvent_SceneFocusLost = 402, // data is proces
s |
| 483 VREvent_SceneFocusGained = 403, // data is proces
s |
| 484 VREvent_SceneApplicationChanged = 404, // data is process - The
App actually drawing the scene changed (usually to or from the compositor) |
| 485 VREvent_SceneFocusChanged = 405, // data is proces
s - New app got access to draw the scene |
| 486 VREvent_InputFocusChanged = 406, // data is proces
s |
| 487 VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is proc
ess |
| 488 |
| 489 VREvent_HideRenderModels = 410, // Sent to the sc
ene application to request hiding render models temporarily |
| 490 VREvent_ShowRenderModels = 411, // Sent to the sc
ene application to request restoring render model visibility |
| 491 |
| 492 VREvent_OverlayShown = 500, |
| 493 VREvent_OverlayHidden = 501, |
| 494 VREvent_DashboardActivated = 502, |
| 495 VREvent_DashboardDeactivated = 503, |
| 496 VREvent_DashboardThumbSelected = 504, // Sent to the overlay ma
nager - data is overlay |
| 497 VREvent_DashboardRequested = 505, // Sent to the ov
erlay manager - data is overlay |
| 498 VREvent_ResetDashboard = 506, // Send to the ov
erlay manager |
| 499 VREvent_RenderToast = 507, // Send t
o the dashboard to render a toast - data is the notification ID |
| 500 VREvent_ImageLoaded = 508, // Sent t
o overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading |
| 501 VREvent_ShowKeyboard = 509, // Sent to keyboa
rd renderer in the dashboard to invoke it |
| 502 VREvent_HideKeyboard = 510, // Sent to keyboa
rd renderer in the dashboard to hide it |
| 503 VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay whe
n IVROverlay::SetFocusOverlay is called on it |
| 504 VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay whe
n it previously had focus and IVROverlay::SetFocusOverlay is called on something
else |
| 505 VREvent_OverlaySharedTextureChanged = 513, |
| 506 VREvent_DashboardGuideButtonDown = 514, |
| 507 VREvent_DashboardGuideButtonUp = 515, |
| 508 VREvent_ScreenshotTriggered = 516, // Screenshot but
ton combo was pressed, Dashboard should request a screenshot |
| 509 VREvent_ImageFailed = 517, // Sent t
o overlays when a SetOverlayRaw or SetOverlayfromFail fails to load |
| 510 VREvent_DashboardOverlayCreated = 518, |
| 511 |
| 512 // Screenshot API |
| 513 VREvent_RequestScreenshot = 520, // Sent b
y vrclient application to compositor to take a screenshot |
| 514 VREvent_ScreenshotTaken = 521, // Sent b
y compositor to the application that the screenshot has been taken |
| 515 VREvent_ScreenshotFailed = 522, // Sent b
y compositor to the application that the screenshot failed to be taken |
| 516 VREvent_SubmitScreenshotToDashboard = 523, // Sent by compos
itor to the dashboard that a completed screenshot was submitted |
| 517 VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to
the dashboard that a completed screenshot was submitted |
| 518 |
| 519 VREvent_PrimaryDashboardDeviceChanged = 525, |
| 520 |
| 521 VREvent_Notification_Shown = 600, |
| 522 VREvent_Notification_Hidden = 601, |
| 523 VREvent_Notification_BeginInteraction = 602, |
| 524 VREvent_Notification_Destroyed = 603, |
| 525 |
| 526 VREvent_Quit = 700, /
/ data is process |
| 527 VREvent_ProcessQuit = 701, /
/ data is process |
| 528 VREvent_QuitAborted_UserPrompt = 702, // data is proces
s |
| 529 VREvent_QuitAcknowledged = 703, // data i
s process |
| 530 VREvent_DriverRequestedQuit = 704, // The dr
iver has requested that SteamVR shut down |
| 531 |
| 532 VREvent_ChaperoneDataHasChanged = 800, |
| 533 VREvent_ChaperoneUniverseHasChanged = 801, |
| 534 VREvent_ChaperoneTempDataHasChanged = 802, |
| 535 VREvent_ChaperoneSettingsHaveChanged = 803, |
| 536 VREvent_SeatedZeroPoseReset = 804, |
| 537 |
| 538 VREvent_AudioSettingsHaveChanged = 820, |
| 539 |
| 540 VREvent_BackgroundSettingHasChanged = 850, |
| 541 VREvent_CameraSettingsHaveChanged = 851, |
| 542 VREvent_ReprojectionSettingHasChanged = 852, |
| 543 VREvent_ModelSkinSettingsHaveChanged = 853, |
| 544 VREvent_EnvironmentSettingsHaveChanged = 854, |
| 545 VREvent_PowerSettingsHaveChanged = 855, |
| 546 |
| 547 VREvent_StatusUpdate = 900, |
| 548 |
| 549 VREvent_MCImageUpdated = 1000, |
| 550 |
| 551 VREvent_FirmwareUpdateStarted = 1100, |
| 552 VREvent_FirmwareUpdateFinished = 1101, |
| 553 |
| 554 VREvent_KeyboardClosed = 1200, |
| 555 VREvent_KeyboardCharInput = 1201, |
| 556 VREvent_KeyboardDone = 1202, // Sent
when DONE button clicked on keyboard |
| 557 |
| 558 VREvent_ApplicationTransitionStarted = 1300, |
| 559 VREvent_ApplicationTransitionAborted = 1301, |
| 560 VREvent_ApplicationTransitionNewAppStarted = 1302, |
| 561 VREvent_ApplicationListUpdated = 1303, |
| 562 VREvent_ApplicationMimeTypeLoad = 1304, |
| 563 VREvent_ApplicationTransitionNewAppLaunchComplete = 1305, |
| 564 |
| 565 VREvent_Compositor_MirrorWindowShown = 1400, |
| 566 VREvent_Compositor_MirrorWindowHidden = 1401, |
| 567 VREvent_Compositor_ChaperoneBoundsShown = 1410, |
| 568 VREvent_Compositor_ChaperoneBoundsHidden = 1411, |
| 569 |
| 570 VREvent_TrackedCamera_StartVideoStream = 1500, |
| 571 VREvent_TrackedCamera_StopVideoStream = 1501, |
| 572 VREvent_TrackedCamera_PauseVideoStream = 1502, |
| 573 VREvent_TrackedCamera_ResumeVideoStream = 1503, |
| 574 VREvent_TrackedCamera_EditingSurface = 1550, |
| 575 |
| 576 VREvent_PerformanceTest_EnableCapture = 1600, |
| 577 VREvent_PerformanceTest_DisableCapture = 1601, |
| 578 VREvent_PerformanceTest_FidelityLevel = 1602, |
| 579 |
| 580 VREvent_MessageOverlay_Closed = 1650, |
| 581 |
| 582 // Vendors are free to expose private events in this reserved region |
| 583 VREvent_VendorSpecific_Reserved_Start = 10000, |
| 584 VREvent_VendorSpecific_Reserved_End = 19999, |
| 585 }; |
| 586 |
| 587 |
| 588 /** Level of Hmd activity */ |
| 589 enum EDeviceActivityLevel |
| 590 { |
| 591 k_EDeviceActivityLevel_Unknown = -1, |
| 592 k_EDeviceActivityLevel_Idle = 0, |
| 593 k_EDeviceActivityLevel_UserInteraction = 1, |
| 594 k_EDeviceActivityLevel_UserInteraction_Timeout = 2, |
| 595 k_EDeviceActivityLevel_Standby = 3, |
| 596 }; |
| 597 |
| 598 |
| 599 /** VR controller button and axis IDs */ |
| 600 enum EVRButtonId |
| 601 { |
| 602 k_EButton_System = 0, |
| 603 k_EButton_ApplicationMenu = 1, |
| 604 k_EButton_Grip = 2, |
| 605 k_EButton_DPad_Left = 3, |
| 606 k_EButton_DPad_Up = 4, |
| 607 k_EButton_DPad_Right = 5, |
| 608 k_EButton_DPad_Down = 6, |
| 609 k_EButton_A = 7, |
| 610 |
| 611 k_EButton_ProximitySensor = 31, |
| 612 |
| 613 k_EButton_Axis0 = 32, |
| 614 k_EButton_Axis1 = 33, |
| 615 k_EButton_Axis2 = 34, |
| 616 k_EButton_Axis3 = 35, |
| 617 k_EButton_Axis4 = 36, |
| 618 |
| 619 // aliases for well known controllers |
| 620 k_EButton_SteamVR_Touchpad = k_EButton_Axis0, |
| 621 k_EButton_SteamVR_Trigger = k_EButton_Axis1, |
| 622 |
| 623 k_EButton_Dashboard_Back = k_EButton_Grip, |
| 624 |
| 625 k_EButton_Max = 64 |
| 626 }; |
| 627 |
| 628 inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; } |
| 629 |
| 630 /** used for controller button events */ |
| 631 struct VREvent_Controller_t |
| 632 { |
| 633 uint32_t button; // EVRButtonId enum |
| 634 }; |
| 635 |
| 636 |
| 637 /** used for simulated mouse events in overlay space */ |
| 638 enum EVRMouseButton |
| 639 { |
| 640 VRMouseButton_Left = 0x0001, |
| 641 VRMouseButton_Right = 0x0002, |
| 642 VRMouseButton_Middle = 0x0004, |
| 643 }; |
| 644 |
| 645 |
| 646 /** used for simulated mouse events in overlay space */ |
| 647 struct VREvent_Mouse_t |
| 648 { |
| 649 float x, y; // co-ords are in GL space, bottom left of the texture is 0,
0 |
| 650 uint32_t button; // EVRMouseButton enum |
| 651 }; |
| 652 |
| 653 /** used for simulated mouse wheel scroll in overlay space */ |
| 654 struct VREvent_Scroll_t |
| 655 { |
| 656 float xdelta, ydelta; // movement in fraction of the pad traversed since
last delta, 1.0 for a full swipe |
| 657 uint32_t repeatCount; |
| 658 }; |
| 659 |
| 660 /** when in mouse input mode you can receive data from the touchpad, these event
s are only sent if the users finger |
| 661 is on the touchpad (or just released from it) |
| 662 **/ |
| 663 struct VREvent_TouchPadMove_t |
| 664 { |
| 665 // true if the users finger is detected on the touch pad |
| 666 bool bFingerDown; |
| 667 |
| 668 // How long the finger has been down in seconds |
| 669 float flSecondsFingerDown; |
| 670 |
| 671 // These values indicate the starting finger position (so you can do som
e basic swipe stuff) |
| 672 float fValueXFirst; |
| 673 float fValueYFirst; |
| 674 |
| 675 // This is the raw sampled coordinate without deadzoning |
| 676 float fValueXRaw; |
| 677 float fValueYRaw; |
| 678 }; |
| 679 |
| 680 /** notification related events. Details will still change at this point */ |
| 681 struct VREvent_Notification_t |
| 682 { |
| 683 uint64_t ulUserValue; |
| 684 uint32_t notificationId; |
| 685 }; |
| 686 |
| 687 /** Used for events about processes */ |
| 688 struct VREvent_Process_t |
| 689 { |
| 690 uint32_t pid; |
| 691 uint32_t oldPid; |
| 692 bool bForced; |
| 693 }; |
| 694 |
| 695 |
| 696 /** Used for a few events about overlays */ |
| 697 struct VREvent_Overlay_t |
| 698 { |
| 699 uint64_t overlayHandle; |
| 700 }; |
| 701 |
| 702 |
| 703 /** Used for a few events about overlays */ |
| 704 struct VREvent_Status_t |
| 705 { |
| 706 uint32_t statusState; // EVRState enum |
| 707 }; |
| 708 |
| 709 /** Used for keyboard events **/ |
| 710 struct VREvent_Keyboard_t |
| 711 { |
| 712 char cNewInput[8]; // Up to 11 bytes of new input |
| 713 uint64_t uUserValue; // Possible flags about the new input |
| 714 }; |
| 715 |
| 716 struct VREvent_Ipd_t |
| 717 { |
| 718 float ipdMeters; |
| 719 }; |
| 720 |
| 721 struct VREvent_Chaperone_t |
| 722 { |
| 723 uint64_t m_nPreviousUniverse; |
| 724 uint64_t m_nCurrentUniverse; |
| 725 }; |
| 726 |
| 727 /** Not actually used for any events */ |
| 728 struct VREvent_Reserved_t |
| 729 { |
| 730 uint64_t reserved0; |
| 731 uint64_t reserved1; |
| 732 }; |
| 733 |
| 734 struct VREvent_PerformanceTest_t |
| 735 { |
| 736 uint32_t m_nFidelityLevel; |
| 737 }; |
| 738 |
| 739 struct VREvent_SeatedZeroPoseReset_t |
| 740 { |
| 741 bool bResetBySystemMenu; |
| 742 }; |
| 743 |
| 744 struct VREvent_Screenshot_t |
| 745 { |
| 746 uint32_t handle; |
| 747 uint32_t type; |
| 748 }; |
| 749 |
| 750 struct VREvent_ScreenshotProgress_t |
| 751 { |
| 752 float progress; |
| 753 }; |
| 754 |
| 755 struct VREvent_ApplicationLaunch_t |
| 756 { |
| 757 uint32_t pid; |
| 758 uint32_t unArgsHandle; |
| 759 }; |
| 760 |
| 761 struct VREvent_EditingCameraSurface_t |
| 762 { |
| 763 uint64_t overlayHandle; |
| 764 uint32_t nVisualMode; |
| 765 }; |
| 766 |
| 767 struct VREvent_MessageOverlay_t |
| 768 { |
| 769 uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enu
m |
| 770 }; |
| 771 |
| 772 struct VREvent_Property_t |
| 773 { |
| 774 PropertyContainerHandle_t container; |
| 775 ETrackedDeviceProperty prop; |
| 776 }; |
| 777 |
| 778 /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */ |
| 779 typedef union |
| 780 { |
| 781 VREvent_Reserved_t reserved; |
| 782 VREvent_Controller_t controller; |
| 783 VREvent_Mouse_t mouse; |
| 784 VREvent_Scroll_t scroll; |
| 785 VREvent_Process_t process; |
| 786 VREvent_Notification_t notification; |
| 787 VREvent_Overlay_t overlay; |
| 788 VREvent_Status_t status; |
| 789 VREvent_Keyboard_t keyboard; |
| 790 VREvent_Ipd_t ipd; |
| 791 VREvent_Chaperone_t chaperone; |
| 792 VREvent_PerformanceTest_t performanceTest; |
| 793 VREvent_TouchPadMove_t touchPadMove; |
| 794 VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; |
| 795 VREvent_Screenshot_t screenshot; |
| 796 VREvent_ScreenshotProgress_t screenshotProgress; |
| 797 VREvent_ApplicationLaunch_t applicationLaunch; |
| 798 VREvent_EditingCameraSurface_t cameraSurface; |
| 799 VREvent_MessageOverlay_t messageOverlay; |
| 800 VREvent_Property_t property; |
| 801 } VREvent_Data_t; |
| 802 |
| 803 /** An event posted by the server to all running applications */ |
| 804 struct VREvent_t |
| 805 { |
| 806 uint32_t eventType; // EVREventType enum |
| 807 TrackedDeviceIndex_t trackedDeviceIndex; |
| 808 float eventAgeSeconds; |
| 809 // event data must be the end of the struct as its size is variable |
| 810 VREvent_Data_t data; |
| 811 }; |
| 812 |
| 813 |
| 814 /** The mesh to draw into the stencil (or depth) buffer to perform |
| 815 * early stencil (or depth) kills of pixels that will never appear on the HMD. |
| 816 * This mesh draws on all the pixels that will be hidden after distortion. |
| 817 * |
| 818 * If the HMD does not provide a visible area mesh pVertexData will be |
| 819 * NULL and unTriangleCount will be 0. */ |
| 820 struct HiddenAreaMesh_t |
| 821 { |
| 822 const HmdVector2_t *pVertexData; |
| 823 uint32_t unTriangleCount; |
| 824 }; |
| 825 |
| 826 |
| 827 enum EHiddenAreaMeshType |
| 828 { |
| 829 k_eHiddenAreaMesh_Standard = 0, |
| 830 k_eHiddenAreaMesh_Inverse = 1, |
| 831 k_eHiddenAreaMesh_LineLoop = 2, |
| 832 |
| 833 k_eHiddenAreaMesh_Max = 3, |
| 834 }; |
| 835 |
| 836 |
| 837 /** Identifies what kind of axis is on the controller at index n. Read this type
|
| 838 * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n ); |
| 839 */ |
| 840 enum EVRControllerAxisType |
| 841 { |
| 842 k_eControllerAxis_None = 0, |
| 843 k_eControllerAxis_TrackPad = 1, |
| 844 k_eControllerAxis_Joystick = 2, |
| 845 k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis |
| 846 }; |
| 847 |
| 848 |
| 849 /** contains information about one axis on the controller */ |
| 850 struct VRControllerAxis_t |
| 851 { |
| 852 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. |
| 853 float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is alw
ays 0.0 for triggers. |
| 854 }; |
| 855 |
| 856 |
| 857 /** the number of axes in the controller state */ |
| 858 static const uint32_t k_unControllerStateAxisCount = 5; |
| 859 |
| 860 |
| 861 /** Holds all the state of a controller at one moment in time. */ |
| 862 struct VRControllerState001_t |
| 863 { |
| 864 // If packet num matches that on your prior call, then the controller st
ate hasn't been changed since |
| 865 // your last call and there is no need to process it |
| 866 uint32_t unPacketNum; |
| 867 |
| 868 // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID
into a mask |
| 869 uint64_t ulButtonPressed; |
| 870 uint64_t ulButtonTouched; |
| 871 |
| 872 // Axis data for the controller's analog inputs |
| 873 VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ]; |
| 874 }; |
| 875 |
| 876 |
| 877 typedef VRControllerState001_t VRControllerState_t; |
| 878 |
| 879 |
| 880 /** determines how to provide output to the application of various event process
ing functions. */ |
| 881 enum EVRControllerEventOutputType |
| 882 { |
| 883 ControllerEventOutput_OSEvents = 0, |
| 884 ControllerEventOutput_VREvents = 1, |
| 885 }; |
| 886 |
| 887 |
| 888 |
| 889 /** Collision Bounds Style */ |
| 890 enum ECollisionBoundsStyle |
| 891 { |
| 892 COLLISION_BOUNDS_STYLE_BEGINNER = 0, |
| 893 COLLISION_BOUNDS_STYLE_INTERMEDIATE, |
| 894 COLLISION_BOUNDS_STYLE_SQUARES, |
| 895 COLLISION_BOUNDS_STYLE_ADVANCED, |
| 896 COLLISION_BOUNDS_STYLE_NONE, |
| 897 |
| 898 COLLISION_BOUNDS_STYLE_COUNT |
| 899 }; |
| 900 |
| 901 /** Allows the application to customize how the overlay appears in the composito
r */ |
| 902 struct Compositor_OverlaySettings |
| 903 { |
| 904 uint32_t size; // sizeof(Compositor_OverlaySettings) |
| 905 bool curved, antialias; |
| 906 float scale, distance, alpha; |
| 907 float uOffset, vOffset, uScale, vScale; |
| 908 float gridDivs, gridWidth, gridScale; |
| 909 HmdMatrix44_t transform; |
| 910 }; |
| 911 |
| 912 /** used to refer to a single VR overlay */ |
| 913 typedef uint64_t VROverlayHandle_t; |
| 914 |
| 915 static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0; |
| 916 |
| 917 /** Errors that can occur around VR overlays */ |
| 918 enum EVROverlayError |
| 919 { |
| 920 VROverlayError_None = 0, |
| 921 |
| 922 VROverlayError_UnknownOverlay = 10, |
| 923 VROverlayError_InvalidHandle = 11, |
| 924 VROverlayError_PermissionDenied = 12, |
| 925 VROverlayError_OverlayLimitExceeded = 13, // No more overlay
s could be created because the maximum number already exist |
| 926 VROverlayError_WrongVisibilityType = 14, |
| 927 VROverlayError_KeyTooLong = 15, |
| 928 VROverlayError_NameTooLong = 16, |
| 929 VROverlayError_KeyInUse = 17, |
| 930 VROverlayError_WrongTransformType = 18, |
| 931 VROverlayError_InvalidTrackedDevice = 19, |
| 932 VROverlayError_InvalidParameter = 20, |
| 933 VROverlayError_ThumbnailCantBeDestroyed = 21, |
| 934 VROverlayError_ArrayTooSmall = 22, |
| 935 VROverlayError_RequestFailed = 23, |
| 936 VROverlayError_InvalidTexture = 24, |
| 937 VROverlayError_UnableToLoadFile = 25, |
| 938 VROverlayError_KeyboardAlreadyInUse = 26, |
| 939 VROverlayError_NoNeighbor = 27, |
| 940 VROverlayError_TooManyMaskPrimitives = 29, |
| 941 VROverlayError_BadMaskPrimitive = 30, |
| 942 }; |
| 943 |
| 944 /** enum values to pass in to VR_Init to identify whether the application will |
| 945 * draw a 3D scene. */ |
| 946 enum EVRApplicationType |
| 947 { |
| 948 VRApplication_Other = 0, // Some other kind of applicatio
n that isn't covered by the other entries |
| 949 VRApplication_Scene = 1, // Application will submit 3D fr
ames |
| 950 VRApplication_Overlay = 2, // Application only interacts wi
th overlays |
| 951 VRApplication_Background = 3, // Application should not start SteamVR
if it's not already running, and should not |
| 952 // keep
it running if everything else quits. |
| 953 VRApplication_Utility = 4, // Init should not try to load a
ny drivers. The application needs access to utility |
| 954 // inter
faces (like IVRSettings and IVRApplications) but not hardware. |
| 955 VRApplication_VRMonitor = 5, // Reserved for vrmonitor |
| 956 VRApplication_SteamWatchdog = 6,// Reserved for Steam |
| 957 |
| 958 VRApplication_Max |
| 959 }; |
| 960 |
| 961 |
| 962 /** error codes for firmware */ |
| 963 enum EVRFirmwareError |
| 964 { |
| 965 VRFirmwareError_None = 0, |
| 966 VRFirmwareError_Success = 1, |
| 967 VRFirmwareError_Fail = 2, |
| 968 }; |
| 969 |
| 970 |
| 971 /** error codes for notifications */ |
| 972 enum EVRNotificationError |
| 973 { |
| 974 VRNotificationError_OK = 0, |
| 975 VRNotificationError_InvalidNotificationId = 100, |
| 976 VRNotificationError_NotificationQueueFull = 101, |
| 977 VRNotificationError_InvalidOverlayHandle = 102, |
| 978 VRNotificationError_SystemWithUserValueAlreadyExists = 103, |
| 979 }; |
| 980 |
| 981 |
| 982 /** error codes returned by Vr_Init */ |
| 983 |
| 984 // Please add adequate error description to https://developer.valvesoftware.com/
w/index.php?title=Category:SteamVRHelp |
| 985 enum EVRInitError |
| 986 { |
| 987 VRInitError_None = 0, |
| 988 VRInitError_Unknown = 1, |
| 989 |
| 990 VRInitError_Init_InstallationNotFound = 100, |
| 991 VRInitError_Init_InstallationCorrupt = 101, |
| 992 VRInitError_Init_VRClientDLLNotFound = 102, |
| 993 VRInitError_Init_FileNotFound = 103, |
| 994 VRInitError_Init_FactoryNotFound = 104, |
| 995 VRInitError_Init_InterfaceNotFound = 105, |
| 996 VRInitError_Init_InvalidInterface = 106, |
| 997 VRInitError_Init_UserConfigDirectoryInvalid = 107, |
| 998 VRInitError_Init_HmdNotFound = 108, |
| 999 VRInitError_Init_NotInitialized = 109, |
| 1000 VRInitError_Init_PathRegistryNotFound = 110, |
| 1001 VRInitError_Init_NoConfigPath = 111, |
| 1002 VRInitError_Init_NoLogPath = 112, |
| 1003 VRInitError_Init_PathRegistryNotWritable = 113, |
| 1004 VRInitError_Init_AppInfoInitFailed = 114, |
| 1005 VRInitError_Init_Retry = 115, /
/ Used internally to cause retries to vrserver |
| 1006 VRInitError_Init_InitCanceledByUser = 116, // The ca
lling application should silently exit. The user canceled app startup |
| 1007 VRInitError_Init_AnotherAppLaunching = 117, |
| 1008 VRInitError_Init_SettingsInitFailed = 118, |
| 1009 VRInitError_Init_ShuttingDown = 119, |
| 1010 VRInitError_Init_TooManyObjects = 120, |
| 1011 VRInitError_Init_NoServerForBackgroundApp = 121, |
| 1012 VRInitError_Init_NotSupportedWithCompositor = 122, |
| 1013 VRInitError_Init_NotAvailableToUtilityApps = 123, |
| 1014 VRInitError_Init_Internal = 124, |
| 1015 VRInitError_Init_HmdDriverIdIsNone = 125, |
| 1016 VRInitError_Init_HmdNotFoundPresenceFailed = 126, |
| 1017 VRInitError_Init_VRMonitorNotFound = 127, |
| 1018 VRInitError_Init_VRMonitorStartupFailed = 128, |
| 1019 VRInitError_Init_LowPowerWatchdogNotSupported = 129, |
| 1020 VRInitError_Init_InvalidApplicationType = 130, |
| 1021 VRInitError_Init_NotAvailableToWatchdogApps = 131, |
| 1022 VRInitError_Init_WatchdogDisabledInSettings = 132, |
| 1023 VRInitError_Init_VRDashboardNotFound = 133, |
| 1024 VRInitError_Init_VRDashboardStartupFailed = 134, |
| 1025 |
| 1026 VRInitError_Driver_Failed = 200, |
| 1027 VRInitError_Driver_Unknown = 201, |
| 1028 VRInitError_Driver_HmdUnknown = 202, |
| 1029 VRInitError_Driver_NotLoaded = 203, |
| 1030 VRInitError_Driver_RuntimeOutOfDate = 204, |
| 1031 VRInitError_Driver_HmdInUse = 205, |
| 1032 VRInitError_Driver_NotCalibrated = 206, |
| 1033 VRInitError_Driver_CalibrationInvalid = 207, |
| 1034 VRInitError_Driver_HmdDisplayNotFound = 208, |
| 1035 VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, |
| 1036 // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not n
eeded: here for historic reasons |
| 1037 VRInitError_Driver_HmdDriverIdOutOfBounds = 211, |
| 1038 VRInitError_Driver_HmdDisplayMirrored = 212, |
| 1039 |
| 1040 VRInitError_IPC_ServerInitFailed = 300, |
| 1041 VRInitError_IPC_ConnectFailed = 301, |
| 1042 VRInitError_IPC_SharedStateInitFailed = 302, |
| 1043 VRInitError_IPC_CompositorInitFailed = 303, |
| 1044 VRInitError_IPC_MutexInitFailed = 304, |
| 1045 VRInitError_IPC_Failed = 305, |
| 1046 VRInitError_IPC_CompositorConnectFailed = 306, |
| 1047 VRInitError_IPC_CompositorInvalidConnectResponse = 307, |
| 1048 VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, |
| 1049 |
| 1050 VRInitError_Compositor_Failed = 400, |
| 1051 VRInitError_Compositor_D3D11HardwareRequired = 401, |
| 1052 VRInitError_Compositor_FirmwareRequiresUpdate = 402, |
| 1053 VRInitError_Compositor_OverlayInitFailed = 403, |
| 1054 VRInitError_Compositor_ScreenshotsInitFailed = 404, |
| 1055 |
| 1056 VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, |
| 1057 |
| 1058 VRInitError_VendorSpecific_HmdFound_CantOpenDevice
= 1101, |
| 1059 VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, |
| 1060 VRInitError_VendorSpecific_HmdFound_NoStoredConfig
= 1103, |
| 1061 VRInitError_VendorSpecific_HmdFound_ConfigTooBig
= 1104, |
| 1062 VRInitError_VendorSpecific_HmdFound_ConfigTooSmall
= 1105, |
| 1063 VRInitError_VendorSpecific_HmdFound_UnableToInitZLib
= 1106, |
| 1064 VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107, |
| 1065 VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108, |
| 1066 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109, |
| 1067 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext
= 1110, |
| 1068 VRInitError_VendorSpecific_HmdFound_UserDataAddressRange
= 1111, |
| 1069 VRInitError_VendorSpecific_HmdFound_UserDataError
= 1112, |
| 1070 VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck
= 1113, |
| 1071 |
| 1072 VRInitError_Steam_SteamInstallationNotFound = 2000, |
| 1073 }; |
| 1074 |
| 1075 enum EVRScreenshotType |
| 1076 { |
| 1077 VRScreenshotType_None = 0, |
| 1078 VRScreenshotType_Mono = 1, // left eye only |
| 1079 VRScreenshotType_Stereo = 2, |
| 1080 VRScreenshotType_Cubemap = 3, |
| 1081 VRScreenshotType_MonoPanorama = 4, |
| 1082 VRScreenshotType_StereoPanorama = 5 |
| 1083 }; |
| 1084 |
| 1085 enum EVRScreenshotPropertyFilenames |
| 1086 { |
| 1087 VRScreenshotPropertyFilenames_Preview = 0, |
| 1088 VRScreenshotPropertyFilenames_VR = 1, |
| 1089 }; |
| 1090 |
| 1091 enum EVRTrackedCameraError |
| 1092 { |
| 1093 VRTrackedCameraError_None = 0, |
| 1094 VRTrackedCameraError_OperationFailed = 100, |
| 1095 VRTrackedCameraError_InvalidHandle = 101, |
| 1096 VRTrackedCameraError_InvalidFrameHeaderVersion = 102, |
| 1097 VRTrackedCameraError_OutOfHandles = 103, |
| 1098 VRTrackedCameraError_IPCFailure = 104, |
| 1099 VRTrackedCameraError_NotSupportedForThisDevice = 105, |
| 1100 VRTrackedCameraError_SharedMemoryFailure = 106, |
| 1101 VRTrackedCameraError_FrameBufferingFailure = 107, |
| 1102 VRTrackedCameraError_StreamSetupFailure = 108, |
| 1103 VRTrackedCameraError_InvalidGLTextureId = 109, |
| 1104 VRTrackedCameraError_InvalidSharedTextureHandle = 110, |
| 1105 VRTrackedCameraError_FailedToGetGLTextureId = 111, |
| 1106 VRTrackedCameraError_SharedTextureFailure = 112, |
| 1107 VRTrackedCameraError_NoFrameAvailable = 113, |
| 1108 VRTrackedCameraError_InvalidArgument = 114, |
| 1109 VRTrackedCameraError_InvalidFrameBufferSize = 115, |
| 1110 }; |
| 1111 |
| 1112 enum EVRTrackedCameraFrameType |
| 1113 { |
| 1114 VRTrackedCameraFrameType_Distorted = 0, // This is the c
amera video frame size in pixels, still distorted. |
| 1115 VRTrackedCameraFrameType_Undistorted, // In pixels, an
undistorted inscribed rectangle region without invalid regions. This size is su
bject to changes shortly. |
| 1116 VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum un
distorted with invalid regions. Non zero alpha component identifies valid region
s. |
| 1117 MAX_CAMERA_FRAME_TYPES |
| 1118 }; |
| 1119 |
| 1120 typedef uint64_t TrackedCameraHandle_t; |
| 1121 #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0) |
| 1122 |
| 1123 struct CameraVideoStreamFrameHeader_t |
| 1124 { |
| 1125 EVRTrackedCameraFrameType eFrameType; |
| 1126 |
| 1127 uint32_t nWidth; |
| 1128 uint32_t nHeight; |
| 1129 uint32_t nBytesPerPixel; |
| 1130 |
| 1131 uint32_t nFrameSequence; |
| 1132 |
| 1133 TrackedDevicePose_t standingTrackedDevicePose; |
| 1134 }; |
| 1135 |
| 1136 // Screenshot types |
| 1137 typedef uint32_t ScreenshotHandle_t; |
| 1138 |
| 1139 static const uint32_t k_unScreenshotHandleInvalid = 0; |
| 1140 |
| 1141 #pragma pack( pop ) |
| 1142 |
| 1143 // figure out how to import from the VR API dll |
| 1144 #if defined(_WIN32) |
| 1145 |
| 1146 #ifdef VR_API_EXPORT |
| 1147 #define VR_INTERFACE extern "C" __declspec( dllexport ) |
| 1148 #else |
| 1149 #define VR_INTERFACE extern "C" __declspec( dllimport ) |
| 1150 #endif |
| 1151 |
| 1152 #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__) |
| 1153 |
| 1154 #ifdef VR_API_EXPORT |
| 1155 #define VR_INTERFACE extern "C" __attribute__((visibility("default"))) |
| 1156 #else |
| 1157 #define VR_INTERFACE extern "C" |
| 1158 #endif |
| 1159 |
| 1160 #else |
| 1161 #error "Unsupported Platform." |
| 1162 #endif |
| 1163 |
| 1164 |
| 1165 #if defined( _WIN32 ) |
| 1166 #define VR_CALLTYPE __cdecl |
| 1167 #else |
| 1168 #define VR_CALLTYPE |
| 1169 #endif |
| 1170 |
| 1171 } // namespace vr |
| 1172 |
| 1173 #endif // _INCLUDE_VRTYPES_H |
| 1174 |
| 1175 |
| 1176 // vrannotation.h |
| 1177 #ifdef API_GEN |
| 1178 # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR ))) |
| 1179 #else |
| 1180 # define VR_CLANG_ATTR(ATTR) |
| 1181 #endif |
| 1182 |
| 1183 #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" ) |
| 1184 #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" ) |
| 1185 #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" ) |
| 1186 #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" ) |
| 1187 #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_cal
l:" #COUNTER "," #FUNCTION "," #PARAMS ";" ) |
| 1188 #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER "
;" ) |
| 1189 #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" ) |
| 1190 #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER "
;desc:" #DESC ) |
| 1191 #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" ) |
| 1192 #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER
";" ) |
| 1193 #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER
";" ) |
| 1194 |
| 1195 // vrtrackedcameratypes.h |
| 1196 #ifndef _VRTRACKEDCAMERATYPES_H |
| 1197 #define _VRTRACKEDCAMERATYPES_H |
| 1198 |
| 1199 namespace vr |
| 1200 { |
| 1201 |
| 1202 #if defined(__linux__) || defined(__APPLE__) |
| 1203 // The 32-bit version of gcc has the alignment requirement for uint64 an
d double set to |
| 1204 // 4 meaning that even with #pragma pack(8) these types will only be fou
r-byte aligned. |
| 1205 // The 64-bit version of gcc has the alignment requirement for these typ
es set to |
| 1206 // 8 meaning that unless we use #pragma pack(4) our structures will get
bigger. |
| 1207 // The 64-bit structure packing has to match the 32-bit structure packin
g for each platform. |
| 1208 #pragma pack( push, 4 ) |
| 1209 #else |
| 1210 #pragma pack( push, 8 ) |
| 1211 #endif |
| 1212 |
| 1213 enum ECameraVideoStreamFormat |
| 1214 { |
| 1215 CVS_FORMAT_UNKNOWN = 0, |
| 1216 CVS_FORMAT_RAW10 = 1, // 10 bits per pixel |
| 1217 CVS_FORMAT_NV12 = 2, // 12 bits per pixel |
| 1218 CVS_FORMAT_RGB24 = 3, // 24 bits per pixel |
| 1219 CVS_MAX_FORMATS |
| 1220 }; |
| 1221 |
| 1222 enum ECameraCompatibilityMode |
| 1223 { |
| 1224 CAMERA_COMPAT_MODE_BULK_DEFAULT = 0, |
| 1225 CAMERA_COMPAT_MODE_BULK_64K_DMA, |
| 1226 CAMERA_COMPAT_MODE_BULK_16K_DMA, |
| 1227 CAMERA_COMPAT_MODE_BULK_8K_DMA, |
| 1228 CAMERA_COMPAT_MODE_ISO_52FPS, |
| 1229 CAMERA_COMPAT_MODE_ISO_50FPS, |
| 1230 CAMERA_COMPAT_MODE_ISO_48FPS, |
| 1231 CAMERA_COMPAT_MODE_ISO_46FPS, |
| 1232 CAMERA_COMPAT_MODE_ISO_44FPS, |
| 1233 CAMERA_COMPAT_MODE_ISO_42FPS, |
| 1234 CAMERA_COMPAT_MODE_ISO_40FPS, |
| 1235 CAMERA_COMPAT_MODE_ISO_35FPS, |
| 1236 CAMERA_COMPAT_MODE_ISO_30FPS, |
| 1237 MAX_CAMERA_COMPAT_MODES |
| 1238 }; |
| 1239 |
| 1240 #ifdef _MSC_VER |
| 1241 #define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) ) |
| 1242 #else |
| 1243 #define VR_CAMERA_DECL_ALIGN( x ) // |
| 1244 #endif |
| 1245 |
| 1246 #define MAX_CAMERA_FRAME_SHARED_HANDLES 4 |
| 1247 |
| 1248 VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t |
| 1249 { |
| 1250 ECameraVideoStreamFormat m_nStreamFormat; |
| 1251 |
| 1252 uint32_t m_nWidth; |
| 1253 uint32_t m_nHeight; |
| 1254 |
| 1255 uint32_t m_nImageDataSize;
// Based on stream format, width, height |
| 1256 |
| 1257 uint32_t m_nFrameSequence;
// Starts from 0 when stream starts. |
| 1258 |
| 1259 uint32_t m_nBufferIndex;
// Identifies which buffer the image data is hosted |
| 1260 uint32_t m_nBufferCount;
// Total number of configured buffers |
| 1261 |
| 1262 uint32_t m_nExposureTime; |
| 1263 |
| 1264 uint32_t m_nISPFrameTimeStamp; // Drive
r provided time stamp per driver centric time base |
| 1265 uint32_t m_nISPReferenceTimeStamp; |
| 1266 uint32_t m_nSyncCounter; |
| 1267 |
| 1268 uint32_t m_nCamSyncEvents; |
| 1269 uint32_t m_nISPSyncEvents; |
| 1270 |
| 1271 double m_flReferenceCamSyncTime; |
| 1272 |
| 1273 double m_flFrameElapsedTime; // Start
s from 0 when stream starts. In seconds. |
| 1274 double m_flFrameDeliveryRate; |
| 1275 |
| 1276 double m_flFrameCaptureTime_DriverAbsolute; // In USB time,
via AuxEvent |
| 1277 double m_flFrameCaptureTime_ServerRelative; // In System tim
e within the server |
| 1278 uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks withi
n the server |
| 1279 double m_flFrameCaptureTime_ClientRelative; // At the client
, relative to when the frame was exposed/captured. |
| 1280 |
| 1281 double m_flSyncMarkerError; |
| 1282 |
| 1283 TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by H
MD layer when used as a tracked camera |
| 1284 |
| 1285 uint64_t m_pImageData; |
| 1286 }; |
| 1287 |
| 1288 #pragma pack( pop ) |
| 1289 |
| 1290 } |
| 1291 |
| 1292 #endif // _VRTRACKEDCAMERATYPES_H |
| 1293 // ivrsettings.h |
| 1294 namespace vr |
| 1295 { |
| 1296 enum EVRSettingsError |
| 1297 { |
| 1298 VRSettingsError_None = 0, |
| 1299 VRSettingsError_IPCFailed = 1, |
| 1300 VRSettingsError_WriteFailed = 2, |
| 1301 VRSettingsError_ReadFailed = 3, |
| 1302 VRSettingsError_JsonParseFailed = 4, |
| 1303 VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be re
turned if the setting does not appear in the appropriate default file and has no
t been set |
| 1304 }; |
| 1305 |
| 1306 // The maximum length of a settings key |
| 1307 static const uint32_t k_unMaxSettingsKeyLength = 128; |
| 1308 |
| 1309 class IVRSettings |
| 1310 { |
| 1311 public: |
| 1312 virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsErr
or eError ) = 0; |
| 1313 |
| 1314 // Returns true if file sync occurred (force or settings dirty) |
| 1315 virtual bool Sync( bool bForce = false, EVRSettingsError *peErro
r = nullptr ) = 0; |
| 1316 |
| 1317 virtual void SetBool( const char *pchSection, const char *pchSet
tingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0; |
| 1318 virtual void SetInt32( const char *pchSection, const char *pchSe
ttingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0; |
| 1319 virtual void SetFloat( const char *pchSection, const char *pchSe
ttingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0; |
| 1320 virtual void SetString( const char *pchSection, const char *pchS
ettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0; |
| 1321 |
| 1322 // Users of the system need to provide a proper default in defau
lt.vrsettings in the resources/settings/ directory |
| 1323 // of either the runtime or the driver_xxx directory. Otherwise
the default will be false, 0, 0.0 or "" |
| 1324 virtual bool GetBool( const char *pchSection, const char *pchSet
tingsKey, EVRSettingsError *peError = nullptr ) = 0; |
| 1325 virtual int32_t GetInt32( const char *pchSection, const char *pc
hSettingsKey, EVRSettingsError *peError = nullptr ) = 0; |
| 1326 virtual float GetFloat( const char *pchSection, const char *pchS
ettingsKey, EVRSettingsError *peError = nullptr ) = 0; |
| 1327 virtual void GetString( const char *pchSection, const char *pchS
ettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsErro
r *peError = nullptr ) = 0; |
| 1328 |
| 1329 virtual void RemoveSection( const char *pchSection, EVRSettingsE
rror *peError = nullptr ) = 0; |
| 1330 virtual void RemoveKeyInSection( const char *pchSection, const c
har *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0; |
| 1331 }; |
| 1332 |
| 1333 //----------------------------------------------------------------------
------- |
| 1334 static const char * const IVRSettings_Version = "IVRSettings_002"; |
| 1335 |
| 1336 //----------------------------------------------------------------------
------- |
| 1337 // steamvr keys |
| 1338 static const char * const k_pch_SteamVR_Section = "steamvr"; |
| 1339 static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd"
; |
| 1340 static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forced
Driver"; |
| 1341 static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd
"; |
| 1342 static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebu
g"; |
| 1343 static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debug
ProcessPipe"; |
| 1344 static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableD
istortion"; |
| 1345 static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDe
bugX"; |
| 1346 static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDe
bugY"; |
| 1347 static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool=
"sendSystemButtonToAllApps"; |
| 1348 static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel"; |
| 1349 static const char * const k_pch_SteamVR_IPD_Float = "ipd"; |
| 1350 static const char * const k_pch_SteamVR_Background_String = "background"
; |
| 1351 static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool
= "backgroundUseDomeProjection"; |
| 1352 static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "
backgroundCameraHeight"; |
| 1353 static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "ba
ckgroundDomeRadius"; |
| 1354 static const char * const k_pch_SteamVR_GridColor_String = "gridColor"; |
| 1355 static const char * const k_pch_SteamVR_PlayAreaColor_String = "playArea
Color"; |
| 1356 static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage"; |
| 1357 static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "
activateMultipleDrivers"; |
| 1358 static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode"; |
| 1359 static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "direc
tModeEdidVid"; |
| 1360 static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "direc
tModeEdidPid"; |
| 1361 static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeak
ers"; |
| 1362 static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_
Float = "speakersForwardYawOffsetDegrees"; |
| 1363 static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool
= "basestationPowerManagement"; |
| 1364 static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "never
KillProcesses"; |
| 1365 static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "
renderTargetMultiplier"; |
| 1366 static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "a
llowAsyncReprojection"; |
| 1367 static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowI
nterleavedReprojection"; |
| 1368 static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceR
eprojection"; |
| 1369 static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "f
orceFadeOnBadTracking"; |
| 1370 static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defau
ltMirrorView"; |
| 1371 static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirro
rView"; |
| 1372 static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mir
rorViewGeometry"; |
| 1373 static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "sta
rtMonitorFromAppLaunch"; |
| 1374 static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Boo
l = "startCompositorFromAppLaunch"; |
| 1375 static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool
= "startDashboardFromAppLaunch"; |
| 1376 static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bo
ol = "startOverlayAppsFromDashboard"; |
| 1377 static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; |
| 1378 static const char * const k_pch_SteamVR_SetInitialDefaultHomeApp = "setI
nitialDefaultHomeApp"; |
| 1379 static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int3
2 = "CycleBackgroundImageTimeSec"; |
| 1380 static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; |
| 1381 static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; |
| 1382 |
| 1383 //----------------------------------------------------------------------
------- |
| 1384 // lighthouse keys |
| 1385 static const char * const k_pch_Lighthouse_Section = "driver_lighthouse"
; |
| 1386 static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu
"; |
| 1387 static const char * const k_pch_Lighthouse_UseDisambiguation_String = "u
sedisambiguation"; |
| 1388 static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "
disambiguationdebug"; |
| 1389 static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "p
rimarybasestation"; |
| 1390 static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; |
| 1391 |
| 1392 //----------------------------------------------------------------------
------- |
| 1393 // null keys |
| 1394 static const char * const k_pch_Null_Section = "driver_null"; |
| 1395 static const char * const k_pch_Null_SerialNumber_String = "serialNumber
"; |
| 1396 static const char * const k_pch_Null_ModelNumber_String = "modelNumber"; |
| 1397 static const char * const k_pch_Null_WindowX_Int32 = "windowX"; |
| 1398 static const char * const k_pch_Null_WindowY_Int32 = "windowY"; |
| 1399 static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth"; |
| 1400 static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight"
; |
| 1401 static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth"; |
| 1402 static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight"
; |
| 1403 static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "
secondsFromVsyncToPhotons"; |
| 1404 static const char * const k_pch_Null_DisplayFrequency_Float = "displayFr
equency"; |
| 1405 |
| 1406 //----------------------------------------------------------------------
------- |
| 1407 // user interface keys |
| 1408 static const char * const k_pch_UserInterface_Section = "userinterface"; |
| 1409 static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "
StatusAlwaysOnTop"; |
| 1410 static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "Min
imizeToTray"; |
| 1411 static const char * const k_pch_UserInterface_Screenshots_Bool = "screen
shots"; |
| 1412 static const char * const k_pch_UserInterface_ScreenshotType_Int = "scre
enshotType"; |
| 1413 |
| 1414 //----------------------------------------------------------------------
------- |
| 1415 // notification keys |
| 1416 static const char * const k_pch_Notifications_Section = "notifications"; |
| 1417 static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNot
Disturb"; |
| 1418 |
| 1419 //----------------------------------------------------------------------
------- |
| 1420 // keyboard keys |
| 1421 static const char * const k_pch_Keyboard_Section = "keyboard"; |
| 1422 static const char * const k_pch_Keyboard_TutorialCompletions = "Tutorial
Completions"; |
| 1423 static const char * const k_pch_Keyboard_ScaleX = "ScaleX"; |
| 1424 static const char * const k_pch_Keyboard_ScaleY = "ScaleY"; |
| 1425 static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX"; |
| 1426 static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX"; |
| 1427 static const char * const k_pch_Keyboard_OffsetY = "OffsetY"; |
| 1428 static const char * const k_pch_Keyboard_Smoothing = "Smoothing"; |
| 1429 |
| 1430 //----------------------------------------------------------------------
------- |
| 1431 // perf keys |
| 1432 static const char * const k_pch_Perf_Section = "perfcheck"; |
| 1433 static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicAc
tive"; |
| 1434 static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD"; |
| 1435 static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce
"; |
| 1436 static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimin
gStore"; |
| 1437 static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimin
gsOnExit"; |
| 1438 static const char * const k_pch_Perf_TestData_Float = "perfTestData"; |
| 1439 |
| 1440 //----------------------------------------------------------------------
------- |
| 1441 // collision bounds keys |
| 1442 static const char * const k_pch_CollisionBounds_Section = "collisionBoun
ds"; |
| 1443 static const char * const k_pch_CollisionBounds_Style_Int32 = "Collision
BoundsStyle"; |
| 1444 static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool =
"CollisionBoundsGroundPerimeterOn"; |
| 1445 static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "C
ollisionBoundsCenterMarkerOn"; |
| 1446 static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "Coll
isionBoundsPlaySpaceOn"; |
| 1447 static const char * const k_pch_CollisionBounds_FadeDistance_Float = "Co
llisionBoundsFadeDistance"; |
| 1448 static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "Col
lisionBoundsColorGammaR"; |
| 1449 static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "Col
lisionBoundsColorGammaG"; |
| 1450 static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "Col
lisionBoundsColorGammaB"; |
| 1451 static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "Col
lisionBoundsColorGammaA"; |
| 1452 |
| 1453 //----------------------------------------------------------------------
------- |
| 1454 // camera keys |
| 1455 static const char * const k_pch_Camera_Section = "camera"; |
| 1456 static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera
"; |
| 1457 static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "e
nableCameraInDashboard"; |
| 1458 static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bo
ol = "enableCameraForCollisionBounds"; |
| 1459 static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "e
nableCameraForRoomView"; |
| 1460 static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "camera
BoundsColorGammaR"; |
| 1461 static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "camera
BoundsColorGammaG"; |
| 1462 static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "camera
BoundsColorGammaB"; |
| 1463 static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "camera
BoundsColorGammaA"; |
| 1464 static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBou
ndsStrength"; |
| 1465 |
| 1466 //----------------------------------------------------------------------
------- |
| 1467 // audio keys |
| 1468 static const char * const k_pch_audio_Section = "audio"; |
| 1469 static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlayb
ackDevice"; |
| 1470 static const char * const k_pch_audio_OnRecordDevice_String = "onRecordD
evice"; |
| 1471 static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "o
nPlaybackMirrorDevice"; |
| 1472 static const char * const k_pch_audio_OffPlaybackDevice_String = "offPla
ybackDevice"; |
| 1473 static const char * const k_pch_audio_OffRecordDevice_String = "offRecor
dDevice"; |
| 1474 static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; |
| 1475 |
| 1476 //----------------------------------------------------------------------
------- |
| 1477 // power management keys |
| 1478 static const char * const k_pch_Power_Section = "power"; |
| 1479 static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnE
xit"; |
| 1480 static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "tur
nOffScreensTimeout"; |
| 1481 static const char * const k_pch_Power_TurnOffControllersTimeout_Float =
"turnOffControllersTimeout"; |
| 1482 static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "r
eturnToWatchdogTimeout"; |
| 1483 static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "
autoLaunchSteamVROnButtonPress"; |
| 1484 |
| 1485 //----------------------------------------------------------------------
------- |
| 1486 // dashboard keys |
| 1487 static const char * const k_pch_Dashboard_Section = "dashboard"; |
| 1488 static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enable
Dashboard"; |
| 1489 static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"
; |
| 1490 |
| 1491 //----------------------------------------------------------------------
------- |
| 1492 // model skin keys |
| 1493 static const char * const k_pch_modelskin_Section = "modelskins"; |
| 1494 |
| 1495 //----------------------------------------------------------------------
------- |
| 1496 // driver keys - These could be checked in any driver_<name> section |
| 1497 static const char * const k_pch_Driver_Enable_Bool = "enable"; |
| 1498 |
| 1499 } // namespace vr |
| 1500 |
| 1501 // iservertrackeddevicedriver.h |
| 1502 namespace vr |
| 1503 { |
| 1504 |
| 1505 |
| 1506 struct DriverPoseQuaternion_t |
| 1507 { |
| 1508 double w, x, y, z; |
| 1509 }; |
| 1510 |
| 1511 struct DriverPose_t |
| 1512 { |
| 1513 /* Time offset of this pose, in seconds from the actual time of the pose
, |
| 1514 * relative to the time of the PoseUpdated() call made by the driver. |
| 1515 */ |
| 1516 double poseTimeOffset; |
| 1517 |
| 1518 /* Generally, the pose maintained by a driver |
| 1519 * is in an inertial coordinate system different |
| 1520 * from the world system of x+ right, y+ up, z+ back. |
| 1521 * Also, the driver is not usually tracking the "head" position, |
| 1522 * but instead an internal IMU or another reference point in the HMD. |
| 1523 * The following two transforms transform positions and orientations |
| 1524 * to app world space from driver world space, |
| 1525 * and to HMD head space from driver local body space. |
| 1526 * |
| 1527 * We maintain the driver pose state in its internal coordinate system, |
| 1528 * so we can do the pose prediction math without having to |
| 1529 * use angular acceleration. A driver's angular acceleration is general
ly not measured, |
| 1530 * and is instead calculated from successive samples of angular velocity
. |
| 1531 * This leads to a noisy angular acceleration values, which are also |
| 1532 * lagged due to the filtering required to reduce noise to an acceptable
level. |
| 1533 */ |
| 1534 vr::HmdQuaternion_t qWorldFromDriverRotation; |
| 1535 double vecWorldFromDriverTranslation[ 3 ]; |
| 1536 |
| 1537 vr::HmdQuaternion_t qDriverFromHeadRotation; |
| 1538 double vecDriverFromHeadTranslation[ 3 ]; |
| 1539 |
| 1540 /* State of driver pose, in meters and radians. */ |
| 1541 /* Position of the driver tracking reference in driver world space |
| 1542 * +[0] (x) is right |
| 1543 * +[1] (y) is up |
| 1544 * -[2] (z) is forward |
| 1545 */ |
| 1546 double vecPosition[ 3 ]; |
| 1547 |
| 1548 /* Velocity of the pose in meters/second */ |
| 1549 double vecVelocity[ 3 ]; |
| 1550 |
| 1551 /* Acceleration of the pose in meters/second */ |
| 1552 double vecAcceleration[ 3 ]; |
| 1553 |
| 1554 /* Orientation of the tracker, represented as a quaternion */ |
| 1555 vr::HmdQuaternion_t qRotation; |
| 1556 |
| 1557 /* Angular velocity of the pose in axis-angle |
| 1558 * representation. The direction is the angle of |
| 1559 * rotation and the magnitude is the angle around |
| 1560 * that axis in radians/second. */ |
| 1561 double vecAngularVelocity[ 3 ]; |
| 1562 |
| 1563 /* Angular acceleration of the pose in axis-angle |
| 1564 * representation. The direction is the angle of |
| 1565 * rotation and the magnitude is the angle around |
| 1566 * that axis in radians/second^2. */ |
| 1567 double vecAngularAcceleration[ 3 ]; |
| 1568 |
| 1569 ETrackingResult result; |
| 1570 |
| 1571 bool poseIsValid; |
| 1572 bool willDriftInYaw; |
| 1573 bool shouldApplyHeadModel; |
| 1574 bool deviceIsConnected; |
| 1575 }; |
| 1576 |
| 1577 |
| 1578 // -----------------------------------------------------------------------------
----------------- |
| 1579 // Purpose: Represents a single tracked device in a driver |
| 1580 // -----------------------------------------------------------------------------
----------------- |
| 1581 class ITrackedDeviceServerDriver |
| 1582 { |
| 1583 public: |
| 1584 |
| 1585 // ------------------------------------ |
| 1586 // Management Methods |
| 1587 // ------------------------------------ |
| 1588 /** This is called before an HMD is returned to the application. It will
always be |
| 1589 * called before any display or tracking methods. Memory and processor us
e by the |
| 1590 * ITrackedDeviceServerDriver object should be kept to a minimum until it
is activated. |
| 1591 * The pose listener is guaranteed to be valid until Deactivate is called
, but |
| 1592 * should not be used after that point. */ |
| 1593 virtual EVRInitError Activate( uint32_t unObjectId ) = 0; |
| 1594 |
| 1595 /** This is called when The VR system is switching from this Hmd being t
he active display |
| 1596 * to another Hmd being the active display. The driver should clean whate
ver memory |
| 1597 * and thread use it can when it is deactivated */ |
| 1598 virtual void Deactivate() = 0; |
| 1599 |
| 1600 /** Handles a request from the system to put this device into standby mo
de. What that means is defined per-device. */ |
| 1601 virtual void EnterStandby() = 0; |
| 1602 |
| 1603 /** Requests a component interface of the driver for device-specific fun
ctionality. The driver should return NULL |
| 1604 * if the requested interface or version is not supported. */ |
| 1605 virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0
; |
| 1606 |
| 1607 /** A VR Client has made this debug request of the driver. The set of va
lid requests is entirely |
| 1608 * up to the driver and the client to figure out, as is the format of the
response. Responses that |
| 1609 * exceed the length of the supplied buffer should be truncated and null
terminated */ |
| 1610 virtual void DebugRequest( const char *pchRequest, char *pchResponseBuff
er, uint32_t unResponseBufferSize ) = 0; |
| 1611 |
| 1612 // ------------------------------------ |
| 1613 // Tracking Methods |
| 1614 // ------------------------------------ |
| 1615 virtual DriverPose_t GetPose() = 0; |
| 1616 }; |
| 1617 |
| 1618 |
| 1619 |
| 1620 static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDri
ver_005"; |
| 1621 |
| 1622 } |
| 1623 // ivrdisplaycomponent.h |
| 1624 namespace vr |
| 1625 { |
| 1626 |
| 1627 |
| 1628 // ---------------------------------------------------------------------
------------------------- |
| 1629 // Purpose: The display component on a single tracked device |
| 1630 // ---------------------------------------------------------------------
------------------------- |
| 1631 class IVRDisplayComponent |
| 1632 { |
| 1633 public: |
| 1634 |
| 1635 // ------------------------------------ |
| 1636 // Display Methods |
| 1637 // ------------------------------------ |
| 1638 |
| 1639 /** Size and position that the window needs to be on the VR disp
lay. */ |
| 1640 virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32
_t *pnWidth, uint32_t *pnHeight ) = 0; |
| 1641 |
| 1642 /** Returns true if the display is extending the desktop. */ |
| 1643 virtual bool IsDisplayOnDesktop( ) = 0; |
| 1644 |
| 1645 /** Returns true if the display is real and not a fictional disp
lay. */ |
| 1646 virtual bool IsDisplayRealDisplay( ) = 0; |
| 1647 |
| 1648 /** Suggested size for the intermediate render target that the d
istortion pulls from. */ |
| 1649 virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth,
uint32_t *pnHeight ) = 0; |
| 1650 |
| 1651 /** Gets the viewport in the frame buffer to draw the output of
the distortion into */ |
| 1652 virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, u
int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0; |
| 1653 |
| 1654 /** The components necessary to build your own projection matrix
in case your |
| 1655 * application is doing something fancy like infinite Z */ |
| 1656 virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float
*pfRight, float *pfTop, float *pfBottom ) = 0; |
| 1657 |
| 1658 /** Returns the result of the distortion function for the specif
ied eye and input UVs. UVs go from 0,0 in |
| 1659 * the upper left of that eye's viewport and 1,1 in the lower rig
ht of that eye's viewport. */ |
| 1660 virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye,
float fU, float fV ) = 0; |
| 1661 |
| 1662 }; |
| 1663 |
| 1664 static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_00
2"; |
| 1665 |
| 1666 } |
| 1667 |
| 1668 // ivrdriverdirectmodecomponent.h |
| 1669 namespace vr |
| 1670 { |
| 1671 |
| 1672 |
| 1673 // ---------------------------------------------------------------------
------------------------- |
| 1674 // Purpose: This component is used for drivers that implement direct mod
e entirely on their own |
| 1675 // without allowing the VR Compositor to own the wi
ndow/device. Chances are you don't |
| 1676 // need to implement this component in your driver. |
| 1677 // ---------------------------------------------------------------------
------------------------- |
| 1678 class IVRDriverDirectModeComponent |
| 1679 { |
| 1680 public: |
| 1681 |
| 1682 // ----------------------------------- |
| 1683 // Direct mode methods |
| 1684 // ----------------------------------- |
| 1685 |
| 1686 /** Specific to Oculus compositor support, textures supplied mus
t be created using this method. */ |
| 1687 virtual void CreateSwapTextureSet( uint32_t unPid, uint32_t unFo
rmat, uint32_t unWidth, uint32_t unHeight, vr::SharedTextureHandle_t( *pSharedTe
xtureHandles )[ 3 ] ) {} |
| 1688 |
| 1689 /** Used to textures created using CreateSwapTextureSet. Only o
ne of the set's handles needs to be used to destroy the entire set. */ |
| 1690 virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sh
aredTextureHandle ) {} |
| 1691 |
| 1692 /** Used to purge all texture sets for a given process. */ |
| 1693 virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {} |
| 1694 |
| 1695 /** After Present returns, calls this to get the next index to u
se for rendering. */ |
| 1696 virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle
_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {} |
| 1697 |
| 1698 /** Call once per layer to draw for this frame. One shared text
ure handle per eye. Textures must be created |
| 1699 * using CreateSwapTextureSet and should be alternated per frame.
Call Present once all layers have been submitted. */ |
| 1700 virtual void SubmitLayer( vr::SharedTextureHandle_t sharedTextur
eHandles[ 2 ], const vr::VRTextureBounds_t( &bounds )[ 2 ], const vr::HmdMatrix3
4_t *pPose ) {} |
| 1701 |
| 1702 /** Submits queued layers for display. */ |
| 1703 virtual void Present( vr::SharedTextureHandle_t syncTexture ) {} |
| 1704 |
| 1705 }; |
| 1706 |
| 1707 static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDire
ctModeComponent_002"; |
| 1708 |
| 1709 } |
| 1710 |
| 1711 // ivrcontrollercomponent.h |
| 1712 namespace vr |
| 1713 { |
| 1714 |
| 1715 |
| 1716 // ---------------------------------------------------------------------
------------------------- |
| 1717 // Purpose: Controller access on a single tracked device. |
| 1718 // ---------------------------------------------------------------------
------------------------- |
| 1719 class IVRControllerComponent |
| 1720 { |
| 1721 public: |
| 1722 |
| 1723 // ------------------------------------ |
| 1724 // Controller Methods |
| 1725 // ------------------------------------ |
| 1726 |
| 1727 /** Gets the current state of a controller. */ |
| 1728 virtual VRControllerState_t GetControllerState( ) = 0; |
| 1729 |
| 1730 /** Returns a uint64 property. If the property is not available
this function will return 0. */ |
| 1731 virtual bool TriggerHapticPulse( uint32_t unAxisId, uint16_t usP
ulseDurationMicroseconds ) = 0; |
| 1732 |
| 1733 }; |
| 1734 |
| 1735 |
| 1736 |
| 1737 static const char *IVRControllerComponent_Version = "IVRControllerCompon
ent_001"; |
| 1738 |
| 1739 } |
| 1740 // ivrcameracomponent.h |
| 1741 namespace vr |
| 1742 { |
| 1743 //----------------------------------------------------------------------
------- |
| 1744 //----------------------------------------------------------------------
------- |
| 1745 class ICameraVideoSinkCallback |
| 1746 { |
| 1747 public: |
| 1748 virtual void OnCameraVideoSinkCallback() = 0; |
| 1749 }; |
| 1750 |
| 1751 // ---------------------------------------------------------------------
------------------------- |
| 1752 // Purpose: The camera on a single tracked device |
| 1753 // ---------------------------------------------------------------------
------------------------- |
| 1754 class IVRCameraComponent |
| 1755 { |
| 1756 public: |
| 1757 // ------------------------------------ |
| 1758 // Camera Methods |
| 1759 // ------------------------------------ |
| 1760 virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFor
mat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0; |
| 1761 virtual bool GetCameraFrameBufferingRequirements( int *pDefaultF
rameQueueSize, uint32_t *pFrameBufferDataSize ) = 0; |
| 1762 virtual bool SetCameraFrameBuffering( int nFrameBufferCount, voi
d **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0; |
| 1763 virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamF
ormat nVideoStreamFormat ) = 0; |
| 1764 virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat(
) = 0; |
| 1765 virtual bool StartVideoStream() = 0; |
| 1766 virtual void StopVideoStream() = 0; |
| 1767 virtual bool IsVideoStreamActive( bool *pbPaused, float *pflElap
sedTime ) = 0; |
| 1768 virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame(
) = 0; |
| 1769 virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStrea
mFrame_t *pFrameImage ) = 0; |
| 1770 virtual bool SetAutoExposure( bool bEnable ) = 0; |
| 1771 virtual bool PauseVideoStream() = 0; |
| 1772 virtual bool ResumeVideoStream() = 0; |
| 1773 virtual bool GetCameraDistortion( float flInputU, float flInputV
, float *pflOutputU, float *pflOutputV ) = 0; |
| 1774 virtual bool GetCameraProjection( vr::EVRTrackedCameraFrameType
eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0; |
| 1775 virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRa
te ) = 0; |
| 1776 virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCal
lback *pCameraVideoSinkCallback ) = 0; |
| 1777 virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilit
yMode *pCameraCompatibilityMode ) = 0; |
| 1778 virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilit
yMode nCameraCompatibilityMode ) = 0; |
| 1779 virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType
eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeigh
t ) = 0; |
| 1780 virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType
eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0; |
| 1781 }; |
| 1782 |
| 1783 static const char *IVRCameraComponent_Version = "IVRCameraComponent_002"
; |
| 1784 } |
| 1785 // itrackeddevicedriverprovider.h |
| 1786 namespace vr |
| 1787 { |
| 1788 |
| 1789 class ITrackedDeviceServerDriver; |
| 1790 struct TrackedDeviceDriverInfo_t; |
| 1791 struct DriverPose_t; |
| 1792 typedef PropertyContainerHandle_t DriverHandle_t; |
| 1793 |
| 1794 /** This interface is provided by vrserver to allow the driver to notify |
| 1795 * the system when something changes about a device. These changes must |
| 1796 * not change the serial number or class of the device because those values |
| 1797 * are permanently associated with the device's index. */ |
| 1798 class IVRDriverContext |
| 1799 { |
| 1800 public: |
| 1801 /** Returns the requested interface. If the interface was not available
it will return NULL and fill |
| 1802 * out the error. */ |
| 1803 virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRI
nitError *peError = nullptr ) = 0; |
| 1804 |
| 1805 /** Returns the property container handle for this driver */ |
| 1806 virtual DriverHandle_t GetDriverHandle() = 0; |
| 1807 }; |
| 1808 |
| 1809 |
| 1810 /** This interface must be implemented in each driver. It will be loaded in vrse
rver.exe */ |
| 1811 class IServerTrackedDeviceProvider |
| 1812 { |
| 1813 public: |
| 1814 /** initializes the driver. This will be called before any other methods
are called. |
| 1815 * If Init returns anything other than VRInitError_None the driver DLL wi
ll be unloaded. |
| 1816 * |
| 1817 * pDriverHost will never be NULL, and will always be a pointer to a ISer
verDriverHost interface |
| 1818 * |
| 1819 * pchUserDriverConfigDir - The absolute path of the directory where the
driver should store user |
| 1820 * config files. |
| 1821 * pchDriverInstallDir - The absolute path of the root directory for the
driver. |
| 1822 */ |
| 1823 virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; |
| 1824 |
| 1825 /** cleans up the driver right before it is unloaded */ |
| 1826 virtual void Cleanup() = 0; |
| 1827 |
| 1828 /** Returns the version of the ITrackedDeviceServerDriver interface used
by this driver */ |
| 1829 virtual const char * const *GetInterfaceVersions() = 0; |
| 1830 |
| 1831 /** Allows the driver do to some work in the main loop of the server. */ |
| 1832 virtual void RunFrame() = 0; |
| 1833 |
| 1834 |
| 1835 // ------------ Power State Functions ----------------------- // |
| 1836 |
| 1837 /** Returns true if the driver wants to block Standby mode. */ |
| 1838 virtual bool ShouldBlockStandbyMode() = 0; |
| 1839 |
| 1840 /** Called when the system is entering Standby mode. The driver should s
witch itself into whatever sort of low-power |
| 1841 * state it has. */ |
| 1842 virtual void EnterStandby() = 0; |
| 1843 |
| 1844 /** Called when the system is leaving Standby mode. The driver should sw
itch itself back to |
| 1845 full operation. */ |
| 1846 virtual void LeaveStandby() = 0; |
| 1847 |
| 1848 }; |
| 1849 |
| 1850 |
| 1851 static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceP
rovider_004"; |
| 1852 |
| 1853 |
| 1854 |
| 1855 |
| 1856 /** This interface must be implemented in each driver. It will be loaded in vrcl
ient.dll */ |
| 1857 class IVRWatchdogProvider |
| 1858 { |
| 1859 public: |
| 1860 /** initializes the driver in watchdog mode. */ |
| 1861 virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0; |
| 1862 |
| 1863 /** cleans up the driver right before it is unloaded */ |
| 1864 virtual void Cleanup() = 0; |
| 1865 }; |
| 1866 |
| 1867 static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001"; |
| 1868 |
| 1869 } |
| 1870 // ivrproperties.h |
| 1871 #include <string> |
| 1872 |
| 1873 namespace vr |
| 1874 { |
| 1875 |
| 1876 enum EPropertyWriteType |
| 1877 { |
| 1878 PropertyWrite_Set = 0, |
| 1879 PropertyWrite_Erase = 1, |
| 1880 PropertyWrite_SetError = 2 |
| 1881 }; |
| 1882 |
| 1883 struct PropertyWrite_t |
| 1884 { |
| 1885 ETrackedDeviceProperty prop; |
| 1886 EPropertyWriteType writeType; |
| 1887 ETrackedPropertyError eSetError; |
| 1888 void *pvBuffer; |
| 1889 uint32_t unBufferSize; |
| 1890 PropertyTypeTag_t unTag; |
| 1891 ETrackedPropertyError eError; |
| 1892 }; |
| 1893 |
| 1894 struct PropertyRead_t |
| 1895 { |
| 1896 ETrackedDeviceProperty prop; |
| 1897 void *pvBuffer; |
| 1898 uint32_t unBufferSize; |
| 1899 PropertyTypeTag_t unTag; |
| 1900 uint32_t unRequiredBufferSize; |
| 1901 ETrackedPropertyError eError; |
| 1902 }; |
| 1903 |
| 1904 |
| 1905 class IVRProperties |
| 1906 { |
| 1907 public: |
| 1908 |
| 1909 /** Reads a set of properties atomically. See the PropertyReadBatch_t st
ruct for more information. */ |
| 1910 virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle
_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0; |
| 1911 |
| 1912 /** Writes a set of properties atomically. See the PropertyWriteBatch_t
struct for more information. */ |
| 1913 virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandl
e_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0
; |
| 1914 |
| 1915 /** returns a string that corresponds with the specified property error.
The string will be the name |
| 1916 * of the error enum value for all valid error codes */ |
| 1917 virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError erro
r ) = 0; |
| 1918 |
| 1919 /** Returns a container handle given a tracked device index */ |
| 1920 virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( Trac
kedDeviceIndex_t nDevice ) = 0; |
| 1921 |
| 1922 }; |
| 1923 |
| 1924 static const char * const IVRProperties_Version = "IVRProperties_001"; |
| 1925 |
| 1926 class CVRPropertyHelpers |
| 1927 { |
| 1928 public: |
| 1929 CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProp
erties ) {} |
| 1930 |
| 1931 /** Returns a scaler property. If the device index is not valid or the p
roperty value type does not match, |
| 1932 * this function will return false. */ |
| 1933 bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrac
kedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); |
| 1934 float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETr
ackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); |
| 1935 int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, E
TrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); |
| 1936 uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle,
ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ); |
| 1937 |
| 1938 /** Returns a single typed property. If the device index is not valid or
the property is not a string type this function will |
| 1939 * return 0. Otherwise it returns the length of the number of bytes neces
sary to hold this string including the trailing |
| 1940 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize
characters. */ |
| 1941 uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrac
kedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, P
ropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L ); |
| 1942 |
| 1943 |
| 1944 /** Returns a string property. If the device index is not valid or the p
roperty is not a string type this function will |
| 1945 * return 0. Otherwise it returns the length of the number of bytes neces
sary to hold this string including the trailing |
| 1946 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize
characters. */ |
| 1947 uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle,
ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferS
ize, ETrackedPropertyError *pError = 0L ); |
| 1948 |
| 1949 /** Returns a string property as a std::string. If the device index is n
ot valid or the property is not a string type this function will |
| 1950 * return an empty string. */ |
| 1951 std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer
, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr
); |
| 1952 |
| 1953 /** Sets a scaler property. The new value will be returned on any subseq
uent call to get this property in any process. */ |
| 1954 ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulConta
inerHandle, ETrackedDeviceProperty prop, bool bNewValue ); |
| 1955 ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulCont
ainerHandle, ETrackedDeviceProperty prop, float fNewValue ); |
| 1956 ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulCont
ainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ); |
| 1957 ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulCon
tainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue ); |
| 1958 |
| 1959 /** Sets a string property. The new value will be returned on any subseq
uent call to get this property in any process. */ |
| 1960 ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulCon
tainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue ); |
| 1961 |
| 1962 /** Sets a single typed property. The new value will be returned on any
subsequent call to get this property in any process. */ |
| 1963 ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainer
Handle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize,
PropertyTypeTag_t unTag ); |
| 1964 |
| 1965 /** Sets the error return value for a property. This value will be retur
ned on all subsequent requests to get the property */ |
| 1966 ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulCont
ainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError ); |
| 1967 |
| 1968 /** Clears any value or error set for the property. */ |
| 1969 ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContain
erHandle, ETrackedDeviceProperty prop ); |
| 1970 |
| 1971 /* Turns a device index into a property container handle. */ |
| 1972 PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDevic
eIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDe
vice ); } |
| 1973 |
| 1974 private: |
| 1975 template<typename T> |
| 1976 T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrack
edDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTa
g_t unTypeTag ); |
| 1977 |
| 1978 IVRProperties *m_pProperties; |
| 1979 }; |
| 1980 |
| 1981 |
| 1982 inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulCon
tainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint3
2_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError ) |
| 1983 { |
| 1984 PropertyRead_t batch; |
| 1985 batch.prop = prop; |
| 1986 batch.pvBuffer = pvBuffer; |
| 1987 batch.unBufferSize = unBufferSize; |
| 1988 |
| 1989 m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 ); |
| 1990 |
| 1991 if ( pError ) |
| 1992 { |
| 1993 *pError = batch.eError; |
| 1994 } |
| 1995 |
| 1996 if ( punTag ) |
| 1997 { |
| 1998 *punTag = batch.unTag; |
| 1999 } |
| 2000 |
| 2001 return batch.unRequiredBufferSize; |
| 2002 } |
| 2003 |
| 2004 |
| 2005 /** Sets a single typed property. The new value will be returned on any subseque
nt call to get this property in any process. */ |
| 2006 inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerH
andle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32
_t unNewValueSize, PropertyTypeTag_t unTag ) |
| 2007 { |
| 2008 PropertyWrite_t batch; |
| 2009 batch.writeType = PropertyWrite_Set; |
| 2010 batch.prop = prop; |
| 2011 batch.pvBuffer = pvNewValue; |
| 2012 batch.unBufferSize = unNewValueSize; |
| 2013 batch.unTag = unTag; |
| 2014 |
| 2015 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); |
| 2016 |
| 2017 return batch.eError; |
| 2018 } |
| 2019 |
| 2020 |
| 2021 /** Returns a string property. If the device index is not valid or the property
is not a string type this function will |
| 2022 * return 0. Otherwise it returns the length of the number of bytes necessary to
hold this string including the trailing |
| 2023 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characte
rs. */ |
| 2024 inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t
ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue,
uint32_t unBufferSize, ETrackedPropertyError *pError ) |
| 2025 { |
| 2026 PropertyTypeTag_t unTag; |
| 2027 ETrackedPropertyError error; |
| 2028 uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue
, unBufferSize, &unTag, &error ); |
| 2029 if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success ) |
| 2030 { |
| 2031 error = TrackedProp_WrongDataType; |
| 2032 } |
| 2033 |
| 2034 if ( pError ) |
| 2035 { |
| 2036 *pError = error; |
| 2037 } |
| 2038 |
| 2039 if ( error != TrackedProp_Success ) |
| 2040 { |
| 2041 if ( pchValue && unBufferSize ) |
| 2042 { |
| 2043 *pchValue = '\0'; |
| 2044 } |
| 2045 } |
| 2046 |
| 2047 return unRequiredSize; |
| 2048 } |
| 2049 |
| 2050 |
| 2051 /** 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 |
| 2052 * return an empty string. */ |
| 2053 inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerH
andle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError
*peError ) |
| 2054 { |
| 2055 char buf[1024]; |
| 2056 vr::ETrackedPropertyError err; |
| 2057 uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf
, sizeof(buf), &err ); |
| 2058 |
| 2059 std::string sResult; |
| 2060 |
| 2061 if ( err == TrackedProp_Success ) |
| 2062 { |
| 2063 sResult = buf; |
| 2064 } |
| 2065 else if ( err == TrackedProp_BufferTooSmall ) |
| 2066 { |
| 2067 char *pchBuffer = new char[unRequiredBufferLen]; |
| 2068 unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchB
uffer, unRequiredBufferLen, &err ); |
| 2069 sResult = pchBuffer; |
| 2070 delete[] pchBuffer; |
| 2071 } |
| 2072 |
| 2073 if ( peError ) |
| 2074 { |
| 2075 *peError = err; |
| 2076 } |
| 2077 |
| 2078 return sResult; |
| 2079 } |
| 2080 |
| 2081 |
| 2082 /** Sets a string property. The new value will be returned on any subsequent cal
l to get this property in any process. */ |
| 2083 inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyCont
ainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNew
Value ) |
| 2084 { |
| 2085 if ( !pchNewValue ) |
| 2086 return TrackedProp_InvalidOperation; |
| 2087 |
| 2088 // this is strlen without the dependency on string.h |
| 2089 const char *pchCurr = pchNewValue; |
| 2090 while ( *pchCurr ) |
| 2091 { |
| 2092 pchCurr++; |
| 2093 } |
| 2094 |
| 2095 return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint3
2_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag ); |
| 2096 } |
| 2097 |
| 2098 |
| 2099 template<typename T> |
| 2100 inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulCont
ainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefa
ult, PropertyTypeTag_t unTypeTag ) |
| 2101 { |
| 2102 T bValue; |
| 2103 ETrackedPropertyError eError; |
| 2104 PropertyTypeTag_t unReadTag; |
| 2105 GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unRead
Tag, &eError ); |
| 2106 if ( unReadTag != unTypeTag && eError == TrackedProp_Success ) |
| 2107 { |
| 2108 eError = TrackedProp_WrongDataType; |
| 2109 }; |
| 2110 |
| 2111 if ( pError ) |
| 2112 *pError = eError; |
| 2113 if ( eError != TrackedProp_Success ) |
| 2114 { |
| 2115 return bDefault; |
| 2116 } |
| 2117 else |
| 2118 { |
| 2119 return bValue; |
| 2120 } |
| 2121 } |
| 2122 |
| 2123 |
| 2124 inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulCon
tainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) |
| 2125 { |
| 2126 return GetPropertyHelper<bool>( ulContainerHandle, prop, pError, false,
k_unBoolPropertyTag ); |
| 2127 } |
| 2128 |
| 2129 |
| 2130 inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulC
ontainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) |
| 2131 { |
| 2132 return GetPropertyHelper<float>( ulContainerHandle, prop, pError, 0.f, k
_unFloatPropertyTag ); |
| 2133 } |
| 2134 |
| 2135 inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t u
lContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) |
| 2136 { |
| 2137 return GetPropertyHelper<int32_t>( ulContainerHandle, prop, pError, 0, k
_unInt32PropertyTag ); |
| 2138 } |
| 2139 |
| 2140 inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t
ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) |
| 2141 { |
| 2142 return GetPropertyHelper<uint64_t>( ulContainerHandle, prop, pError, 0,
k_unUint64PropertyTag ); |
| 2143 } |
| 2144 |
| 2145 inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContai
nerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue ) |
| 2146 { |
| 2147 return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewVal
ue ), k_unBoolPropertyTag ); |
| 2148 } |
| 2149 |
| 2150 inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyConta
inerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue ) |
| 2151 { |
| 2152 return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewVal
ue ), k_unFloatPropertyTag ); |
| 2153 } |
| 2154 |
| 2155 inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyConta
inerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue ) |
| 2156 { |
| 2157 return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewVal
ue ), k_unInt32PropertyTag ); |
| 2158 } |
| 2159 |
| 2160 inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyCont
ainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValu
e ) |
| 2161 { |
| 2162 return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewV
alue ), k_unUint64PropertyTag ); |
| 2163 } |
| 2164 |
| 2165 /** Sets the error return value for a property. This value will be returned on a
ll subsequent requests to get the property */ |
| 2166 inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyConta
inerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyErr
or eError ) |
| 2167 { |
| 2168 PropertyWrite_t batch; |
| 2169 batch.writeType = PropertyWrite_SetError; |
| 2170 batch.prop = prop; |
| 2171 batch.eSetError = eError; |
| 2172 |
| 2173 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); |
| 2174 |
| 2175 return batch.eError; |
| 2176 } |
| 2177 |
| 2178 /** Clears any value or error set for the property. */ |
| 2179 inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContaine
rHandle_t ulContainerHandle, ETrackedDeviceProperty prop ) |
| 2180 { |
| 2181 PropertyWrite_t batch; |
| 2182 batch.writeType = PropertyWrite_Erase; |
| 2183 batch.prop = prop; |
| 2184 |
| 2185 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 ); |
| 2186 |
| 2187 return batch.eError; |
| 2188 |
| 2189 } |
| 2190 |
| 2191 } |
| 2192 |
| 2193 |
| 2194 // ivrdriverlog.h |
| 2195 namespace vr |
| 2196 { |
| 2197 |
| 2198 class IVRDriverLog |
| 2199 { |
| 2200 public: |
| 2201 /** Writes a log message to the log file prefixed with the driver name *
/ |
| 2202 virtual void Log( const char *pchLogMessage ) = 0; |
| 2203 }; |
| 2204 |
| 2205 |
| 2206 static const char *IVRDriverLog_Version = "IVRDriverLog_001"; |
| 2207 |
| 2208 } |
| 2209 // ivrserverdriverhost.h |
| 2210 namespace vr |
| 2211 { |
| 2212 |
| 2213 class ITrackedDeviceServerDriver; |
| 2214 struct TrackedDeviceDriverInfo_t; |
| 2215 struct DriverPose_t; |
| 2216 |
| 2217 /** This interface is provided by vrserver to allow the driver to notify |
| 2218 * the system when something changes about a device. These changes must |
| 2219 * not change the serial number or class of the device because those values |
| 2220 * are permanently associated with the device's index. */ |
| 2221 class IVRServerDriverHost |
| 2222 { |
| 2223 public: |
| 2224 /** Notifies the server that a tracked device has been added. If this fu
nction returns true |
| 2225 * the server will call Activate on the device. If it returns false some
kind of error |
| 2226 * has occurred and the device will not be activated. */ |
| 2227 virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETra
ckedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0; |
| 2228 |
| 2229 /** Notifies the server that a tracked device's pose has been updated */ |
| 2230 virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const Dri
verPose_t & newPose, uint32_t unPoseStructSize ) = 0; |
| 2231 |
| 2232 /** Notifies the server that vsync has occurred on the the display attac
hed to the device. This is |
| 2233 * only permitted on devices of the HMD class. */ |
| 2234 virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0; |
| 2235 |
| 2236 /** notifies the server that the button was pressed */ |
| 2237 virtual void TrackedDeviceButtonPressed( uint32_t unWhichDevice, EVRButt
onId eButtonId, double eventTimeOffset ) = 0; |
| 2238 |
| 2239 /** notifies the server that the button was unpressed */ |
| 2240 virtual void TrackedDeviceButtonUnpressed( uint32_t unWhichDevice, EVRBu
ttonId eButtonId, double eventTimeOffset ) = 0; |
| 2241 |
| 2242 /** notifies the server that the button was pressed */ |
| 2243 virtual void TrackedDeviceButtonTouched( uint32_t unWhichDevice, EVRButt
onId eButtonId, double eventTimeOffset ) = 0; |
| 2244 |
| 2245 /** notifies the server that the button was unpressed */ |
| 2246 virtual void TrackedDeviceButtonUntouched( uint32_t unWhichDevice, EVRBu
ttonId eButtonId, double eventTimeOffset ) = 0; |
| 2247 |
| 2248 /** notifies the server than a controller axis changed */ |
| 2249 virtual void TrackedDeviceAxisUpdated( uint32_t unWhichDevice, uint32_t
unWhichAxis, const VRControllerAxis_t & axisState ) = 0; |
| 2250 |
| 2251 /** Notifies the server that the proximity sensor on the specified devic
e */ |
| 2252 virtual void ProximitySensorState( uint32_t unWhichDevice, bool bProximi
tySensorTriggered ) = 0; |
| 2253 |
| 2254 /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start
..VREvent_VendorSpecific_Reserved_End */ |
| 2255 virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventTy
pe eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0; |
| 2256 |
| 2257 /** Returns true if SteamVR is exiting */ |
| 2258 virtual bool IsExiting() = 0; |
| 2259 |
| 2260 /** Returns true and fills the event with the next event on the queue if
there is one. If there are no events |
| 2261 * this method returns false. uncbVREvent should be the size in bytes of
the VREvent_t struct */ |
| 2262 virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) =
0; |
| 2263 }; |
| 2264 |
| 2265 static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_004"; |
| 2266 |
| 2267 } |
| 2268 // ivrhiddenarea.h |
| 2269 namespace vr |
| 2270 { |
| 2271 |
| 2272 class CVRHiddenAreaHelpers |
| 2273 { |
| 2274 public: |
| 2275 CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pPro
perties ) {} |
| 2276 |
| 2277 /** Stores a hidden area mesh in a property */ |
| 2278 ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType ty
pe, HmdVector2_t *pVerts, uint32_t unVertCount ); |
| 2279 |
| 2280 /** retrieves a hidden area mesh from a property. Returns the vert count
read out of the property. */ |
| 2281 uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector
2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError ); |
| 2282 |
| 2283 private: |
| 2284 ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType
type ) |
| 2285 { |
| 2286 return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_St
art + ((int)type * 2) + (int)eEye); |
| 2287 } |
| 2288 |
| 2289 IVRProperties *m_pProperties; |
| 2290 }; |
| 2291 |
| 2292 |
| 2293 inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, E
HiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount ) |
| 2294 { |
| 2295 ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); |
| 2296 CVRPropertyHelpers propHelpers( m_pProperties ); |
| 2297 return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyConta
iner( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVer
tCount, k_unHiddenAreaPropertyTag ); |
| 2298 } |
| 2299 |
| 2300 |
| 2301 inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMes
hType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *p
eError ) |
| 2302 { |
| 2303 ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type ); |
| 2304 CVRPropertyHelpers propHelpers( m_pProperties ); |
| 2305 ETrackedPropertyError propError; |
| 2306 PropertyTypeTag_t unTag; |
| 2307 uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDev
iceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdV
ector2_t )*unVertCount, &unTag, &propError ); |
| 2308 if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaProperty
Tag ) |
| 2309 { |
| 2310 propError = TrackedProp_WrongDataType; |
| 2311 unBytesNeeded = 0; |
| 2312 } |
| 2313 |
| 2314 if ( peError ) |
| 2315 { |
| 2316 *peError = propError; |
| 2317 } |
| 2318 |
| 2319 return unBytesNeeded / sizeof( HmdVector2_t ); |
| 2320 } |
| 2321 |
| 2322 } |
| 2323 // ivrwatchdoghost.h |
| 2324 namespace vr |
| 2325 { |
| 2326 |
| 2327 /** This interface is provided by vrclient to allow the driver to make everythin
g wake up */ |
| 2328 class IVRWatchdogHost |
| 2329 { |
| 2330 public: |
| 2331 /** Client drivers in watchdog mode should call this when they have rece
ived a signal from hardware that should |
| 2332 * cause SteamVR to start */ |
| 2333 virtual void WatchdogWakeUp() = 0; |
| 2334 }; |
| 2335 |
| 2336 static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001"; |
| 2337 |
| 2338 }; |
| 2339 |
| 2340 |
| 2341 |
| 2342 |
| 2343 |
| 2344 |
| 2345 |
| 2346 namespace vr |
| 2347 { |
| 2348 static const char * const k_InterfaceVersions[] = |
| 2349 { |
| 2350 IVRSettings_Version, |
| 2351 ITrackedDeviceServerDriver_Version, |
| 2352 IVRDisplayComponent_Version, |
| 2353 IVRDriverDirectModeComponent_Version, |
| 2354 IVRControllerComponent_Version, |
| 2355 IVRCameraComponent_Version, |
| 2356 IServerTrackedDeviceProvider_Version, |
| 2357 IVRWatchdogProvider_Version, |
| 2358 nullptr |
| 2359 }; |
| 2360 |
| 2361 inline IVRDriverContext *&VRDriverContext() |
| 2362 { |
| 2363 static IVRDriverContext *pHost; |
| 2364 return pHost; |
| 2365 } |
| 2366 |
| 2367 class COpenVRDriverContext |
| 2368 { |
| 2369 public: |
| 2370 COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAre
aHelpers(nullptr) { Clear(); } |
| 2371 void Clear(); |
| 2372 |
| 2373 EVRInitError InitServer(); |
| 2374 EVRInitError InitWatchdog(); |
| 2375 |
| 2376 IVRSettings *VRSettings() |
| 2377 { |
| 2378 if ( m_pVRSettings == nullptr ) |
| 2379 { |
| 2380 EVRInitError eError; |
| 2381 m_pVRSettings = (IVRSettings *)VRDriverContext()
->GetGenericInterface( IVRSettings_Version, &eError ); |
| 2382 } |
| 2383 return m_pVRSettings; |
| 2384 } |
| 2385 |
| 2386 IVRProperties *VRPropertiesRaw() |
| 2387 { |
| 2388 if ( m_pVRProperties == nullptr ) |
| 2389 { |
| 2390 EVRInitError eError; |
| 2391 m_pVRProperties = (IVRProperties *)VRDriverConte
xt()->GetGenericInterface( IVRProperties_Version, &eError ); |
| 2392 m_propertyHelpers = CVRPropertyHelpers( m_pVRPro
perties ); |
| 2393 m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pV
RProperties ); |
| 2394 } |
| 2395 return m_pVRProperties; |
| 2396 } |
| 2397 |
| 2398 CVRPropertyHelpers *VRProperties() |
| 2399 { |
| 2400 VRPropertiesRaw(); |
| 2401 return &m_propertyHelpers; |
| 2402 } |
| 2403 |
| 2404 CVRHiddenAreaHelpers *VRHiddenArea() |
| 2405 { |
| 2406 VRPropertiesRaw(); |
| 2407 return &m_hiddenAreaHelpers; |
| 2408 } |
| 2409 |
| 2410 IVRServerDriverHost *VRServerDriverHost() |
| 2411 { |
| 2412 if ( m_pVRServerDriverHost == nullptr ) |
| 2413 { |
| 2414 EVRInitError eError; |
| 2415 m_pVRServerDriverHost = (IVRServerDriverHost *)V
RDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError ); |
| 2416 } |
| 2417 return m_pVRServerDriverHost; |
| 2418 } |
| 2419 |
| 2420 IVRWatchdogHost *VRWatchdogHost() |
| 2421 { |
| 2422 if ( m_pVRWatchdogHost == nullptr ) |
| 2423 { |
| 2424 EVRInitError eError; |
| 2425 m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverC
ontext()->GetGenericInterface( IVRWatchdogHost_Version, &eError ); |
| 2426 } |
| 2427 return m_pVRWatchdogHost; |
| 2428 } |
| 2429 |
| 2430 IVRDriverLog *VRDriverLog() |
| 2431 { |
| 2432 if ( m_pVRDriverLog == nullptr ) |
| 2433 { |
| 2434 EVRInitError eError; |
| 2435 m_pVRDriverLog = (IVRDriverLog *)VRDriverContext
()->GetGenericInterface( IVRDriverLog_Version, &eError ); |
| 2436 } |
| 2437 return m_pVRDriverLog; |
| 2438 } |
| 2439 |
| 2440 DriverHandle_t VR_CALLTYPE VRDriverHandle() |
| 2441 { |
| 2442 return VRDriverContext()->GetDriverHandle(); |
| 2443 } |
| 2444 |
| 2445 private: |
| 2446 IVRSettings *m_pVRSettings; |
| 2447 IVRProperties *m_pVRProperties; |
| 2448 CVRPropertyHelpers m_propertyHelpers; |
| 2449 CVRHiddenAreaHelpers m_hiddenAreaHelpers; |
| 2450 IVRServerDriverHost *m_pVRServerDriverHost; |
| 2451 IVRWatchdogHost *m_pVRWatchdogHost; |
| 2452 IVRDriverLog *m_pVRDriverLog; |
| 2453 }; |
| 2454 |
| 2455 inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext() |
| 2456 { |
| 2457 static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void *
)]; |
| 2458 return *(COpenVRDriverContext *)ctx; // bypass zero-init constru
ctor |
| 2459 } |
| 2460 |
| 2461 inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_Mod
uleServerDriverContext().VRSettings(); } |
| 2462 inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInter
nal_ModuleServerDriverContext().VRPropertiesRaw(); } |
| 2463 inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInt
ernal_ModuleServerDriverContext().VRProperties(); } |
| 2464 inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRI
nternal_ModuleServerDriverContext().VRHiddenArea(); } |
| 2465 inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_M
oduleServerDriverContext().VRDriverLog(); } |
| 2466 inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return Op
enVRInternal_ModuleServerDriverContext().VRServerDriverHost(); } |
| 2467 inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInte
rnal_ModuleServerDriverContext().VRWatchdogHost(); } |
| 2468 inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRIntern
al_ModuleServerDriverContext().VRDriverHandle(); } |
| 2469 inline void COpenVRDriverContext::Clear() |
| 2470 { |
| 2471 m_pVRSettings = nullptr; |
| 2472 m_pVRProperties = nullptr; |
| 2473 m_pVRServerDriverHost = nullptr; |
| 2474 m_pVRDriverLog = nullptr; |
| 2475 m_pVRWatchdogHost = nullptr; |
| 2476 } |
| 2477 |
| 2478 inline EVRInitError COpenVRDriverContext::InitServer() |
| 2479 { |
| 2480 Clear(); |
| 2481 if ( !VRServerDriverHost() |
| 2482 || !VRSettings() |
| 2483 || !VRProperties() |
| 2484 || !VRDriverLog() ) |
| 2485 return VRInitError_Init_InterfaceNotFound; |
| 2486 return VRInitError_None; |
| 2487 } |
| 2488 |
| 2489 inline EVRInitError COpenVRDriverContext::InitWatchdog() |
| 2490 { |
| 2491 Clear(); |
| 2492 if ( !VRWatchdogHost() |
| 2493 || !VRSettings() |
| 2494 || !VRDriverLog() ) |
| 2495 return VRInitError_Init_InterfaceNotFound; |
| 2496 return VRInitError_None; |
| 2497 } |
| 2498 |
| 2499 inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext
) |
| 2500 { |
| 2501 VRDriverContext() = pContext; |
| 2502 return OpenVRInternal_ModuleServerDriverContext().InitServer(); |
| 2503 } |
| 2504 |
| 2505 inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContex
t ) |
| 2506 { |
| 2507 VRDriverContext() = pContext; |
| 2508 return OpenVRInternal_ModuleServerDriverContext().InitWatchdog()
; |
| 2509 } |
| 2510 |
| 2511 inline void CleanupDriverContext() |
| 2512 { |
| 2513 VRDriverContext() = nullptr; |
| 2514 OpenVRInternal_ModuleServerDriverContext().Clear(); |
| 2515 } |
| 2516 |
| 2517 #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \ |
| 2518 { \ |
| 2519 vr::EVRInitError eError = vr::InitServerDriverContext( p
Context ); \ |
| 2520 if( eError != vr::VRInitError_None ) \ |
| 2521 return eError; \ |
| 2522 } |
| 2523 |
| 2524 #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \ |
| 2525 vr::CleanupDriverContext(); |
| 2526 |
| 2527 #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \ |
| 2528 { \ |
| 2529 vr::EVRInitError eError = vr::InitWatchdogDriverContext(
pContext ); \ |
| 2530 if( eError != vr::VRInitError_None ) \ |
| 2531 return eError; \ |
| 2532 } |
| 2533 |
| 2534 #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \ |
| 2535 vr::CleanupDriverContext(); |
| 2536 } |
| 2537 // End |
| 2538 |
| 2539 #endif // _OPENVR_DRIVER_API |
| 2540 |
| 2541 |
OLD | NEW |