The open source OpenXR runtime
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// version.h
15
16namespace vr
17{
18 static const uint32_t k_nSteamVRVersionMajor = 1;
19 static const uint32_t k_nSteamVRVersionMinor = 16;
20 static const uint32_t k_nSteamVRVersionBuild = 8;
21} // namespace vr
22
23// public_vrtypes.h
24
25#ifndef _INCLUDE_CORE_VRTYPES_PUBLIC_H
26#define _INCLUDE_CORE_VRTYPES_PUBLIC_H
27
28namespace vr
29{
30#pragma pack( push, 8 )
31
32// right-handed system
33// +y is up
34// +x is to the right
35// -z is forward
36// Distance unit is meters
37struct HmdMatrix34_t
38{
39 float m[3][4];
40};
41
42struct HmdMatrix33_t
43{
44 float m[3][3];
45};
46
47struct HmdMatrix44_t
48{
49 float m[4][4];
50};
51
52struct HmdVector3_t
53{
54 float v[3];
55};
56
57struct HmdVector4_t
58{
59 float v[4];
60};
61
62struct HmdVector3d_t
63{
64 double v[3];
65};
66
67struct HmdVector2_t
68{
69 float v[2];
70};
71
72struct HmdQuaternion_t
73{
74 double w, x, y, z;
75};
76
77struct HmdQuaternionf_t
78{
79 float w, x, y, z;
80};
81
82struct HmdColor_t
83{
84 float r, g, b, a;
85};
86
87struct HmdQuad_t
88{
89 HmdVector3_t vCorners[ 4 ];
90};
91
92struct HmdRect2_t
93{
94 HmdVector2_t vTopLeft;
95 HmdVector2_t vBottomRight;
96};
97
98/** Holds the transform for a single bone */
99struct VRBoneTransform_t
100{
101 HmdVector4_t position;
102 HmdQuaternionf_t orientation;
103};
104
105#pragma pack( pop )
106
107} // namespace vr
108
109#endif
110
111// vrtypes.h
112
113#ifndef _INCLUDE_VRTYPES_H
114#define _INCLUDE_VRTYPES_H
115
116// Forward declarations to avoid requiring vulkan.h
117struct VkDevice_T;
118struct VkPhysicalDevice_T;
119struct VkInstance_T;
120struct VkQueue_T;
121
122// Forward declarations to avoid requiring d3d12.h
123struct ID3D12Resource;
124struct ID3D12CommandQueue;
125
126namespace vr
127{
128#pragma pack( push, 8 )
129
130/** A handle for a spatial anchor. This handle is only valid during the session it was created in.
131* Anchors that live beyond one session should be saved by their string descriptors. */
132typedef uint32_t SpatialAnchorHandle_t;
133
134typedef void* glSharedTextureHandle_t;
135typedef int32_t glInt_t;
136typedef uint32_t glUInt_t;
137
138
139/** Used to return the post-distortion UVs for each color channel.
140* UVs range from 0 to 1 with 0,0 in the upper left corner of the
141* source render target. The 0,0 to 1,1 range covers a single eye. */
142struct DistortionCoordinates_t
143{
144 float rfRed[2];
145 float rfGreen[2];
146 float rfBlue[2];
147};
148
149enum EVREye
150{
151 Eye_Left = 0,
152 Eye_Right = 1
153};
154
155enum ETextureType
156{
157 TextureType_Invalid = -1, // Handle has been invalidated
158 TextureType_DirectX = 0, // Handle is an ID3D11Texture
159 TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags
160 TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure
161 TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef, deprecated in favor of TextureType_Metal on supported platforms
162 TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure
163 TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets.
164 // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it
165 TextureType_Metal = 6, // Handle is a MTLTexture conforming to the MTLSharedTexture protocol. Textures submitted to IVRCompositor::Submit which
166 // are of type MTLTextureType2DArray assume layer 0 is the left eye texture (vr::EVREye::Eye_left), layer 1 is the right
167 // eye texture (vr::EVREye::Eye_Right)
168};
169
170enum EColorSpace
171{
172 ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
173 ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
174 ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
175};
176
177struct Texture_t
178{
179 void* handle; // See ETextureType definition above
180 ETextureType eType;
181 EColorSpace eColorSpace;
182};
183
184// Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource).
185typedef uint64_t SharedTextureHandle_t;
186#define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0)
187
188enum ETrackingResult
189{
190 TrackingResult_Uninitialized = 1,
191
192 TrackingResult_Calibrating_InProgress = 100,
193 TrackingResult_Calibrating_OutOfRange = 101,
194
195 TrackingResult_Running_OK = 200,
196 TrackingResult_Running_OutOfRange = 201,
197
198 TrackingResult_Fallback_RotationOnly = 300,
199};
200
201typedef uint32_t DriverId_t;
202static const uint32_t k_nDriverNone = 0xFFFFFFFF;
203
204static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
205
206/** Used to pass device IDs to API calls */
207typedef uint32_t TrackedDeviceIndex_t;
208static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
209static const uint32_t k_unMaxTrackedDeviceCount = 64;
210static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
211static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
212
213/** Describes what kind of object is being tracked at a given ID */
214enum ETrackedDeviceClass
215{
216 TrackedDeviceClass_Invalid = 0, // the ID was not valid.
217 TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
218 TrackedDeviceClass_Controller = 2, // Tracked controllers
219 TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers
220 TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
221 TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
222
223 TrackedDeviceClass_Max
224};
225
226
227/** Describes what specific role associated with a tracked device */
228enum ETrackedControllerRole
229{
230 TrackedControllerRole_Invalid = 0, // Invalid value for controller type
231 TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
232 TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
233 TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection
234 TrackedControllerRole_Treadmill = 4, // Tracked device is a treadmill or other locomotion device
235 TrackedControllerRole_Stylus = 5, // Tracked device is a stylus
236 TrackedControllerRole_Max = 5
237};
238
239
240/** Returns true if the tracked controller role is allowed to be a hand */
241inline bool IsRoleAllowedAsHand( ETrackedControllerRole eRole )
242{
243 switch ( eRole )
244 {
245 case TrackedControllerRole_Invalid:
246 case TrackedControllerRole_LeftHand:
247 case TrackedControllerRole_RightHand:
248 return true;
249 default:
250 return false;
251 }
252}
253
254
255/** describes a single pose for a tracked object */
256struct TrackedDevicePose_t
257{
258 HmdMatrix34_t mDeviceToAbsoluteTracking;
259 HmdVector3_t vVelocity; // velocity in tracker space in m/s
260 HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
261 ETrackingResult eTrackingResult;
262 bool bPoseIsValid;
263
264 // This indicates that there is a device connected for this spot in the pose array.
265 // It could go from true to false if the user unplugs the device.
266 bool bDeviceIsConnected;
267};
268
269/** Identifies which style of tracking origin the application wants to use
270* for the poses it is requesting */
271enum ETrackingUniverseOrigin
272{
273 TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
274 TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
275 TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one.
276};
277
278enum EAdditionalRadioFeatures
279{
280 AdditionalRadioFeatures_None = 0x00000000,
281 AdditionalRadioFeatures_HTCLinkBox = 0x00000001,
282 AdditionalRadioFeatures_InternalDongle = 0x00000002,
283 AdditionalRadioFeatures_ExternalDongle = 0x00000004,
284};
285
286typedef uint64_t WebConsoleHandle_t;
287#define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0)
288
289// Refers to a single container of properties
290typedef uint64_t PropertyContainerHandle_t;
291typedef uint32_t PropertyTypeTag_t;
292
293static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0;
294static const PropertyTypeTag_t k_unInvalidPropertyTag = 0;
295
296typedef PropertyContainerHandle_t DriverHandle_t;
297static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0;
298
299// Use these tags to set/get common types as struct properties
300static const PropertyTypeTag_t k_unFloatPropertyTag = 1;
301static const PropertyTypeTag_t k_unInt32PropertyTag = 2;
302static const PropertyTypeTag_t k_unUint64PropertyTag = 3;
303static const PropertyTypeTag_t k_unBoolPropertyTag = 4;
304static const PropertyTypeTag_t k_unStringPropertyTag = 5;
305static const PropertyTypeTag_t k_unErrorPropertyTag = 6;
306static const PropertyTypeTag_t k_unDoublePropertyTag = 7;
307
308static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20;
309static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21;
310static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22;
311static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23;
312static const PropertyTypeTag_t k_unHmdVector2PropertyTag = 24;
313static const PropertyTypeTag_t k_unHmdQuadPropertyTag = 25;
314
315static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30;
316static const PropertyTypeTag_t k_unPathHandleInfoTag = 31;
317static const PropertyTypeTag_t k_unActionPropertyTag = 32;
318static const PropertyTypeTag_t k_unInputValuePropertyTag = 33;
319static const PropertyTypeTag_t k_unWildcardPropertyTag = 34;
320static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35;
321static const PropertyTypeTag_t k_unSkeletonPropertyTag = 36;
322
323static const PropertyTypeTag_t k_unSpatialAnchorPosePropertyTag = 40;
324static const PropertyTypeTag_t k_unJsonPropertyTag = 41;
325static const PropertyTypeTag_t k_unActiveActionSetPropertyTag = 42;
326
327static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000;
328static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000;
329
330
331/** Each entry in this enum represents a property that can be retrieved about a
332* tracked device. Many fields are only valid for one ETrackedDeviceClass. */
333enum ETrackedDeviceProperty
334{
335 Prop_Invalid = 0,
336
337 // general properties that apply to all device classes
338 Prop_TrackingSystemName_String = 1000,
339 Prop_ModelNumber_String = 1001,
340 Prop_SerialNumber_String = 1002,
341 Prop_RenderModelName_String = 1003,
342 Prop_WillDriftInYaw_Bool = 1004,
343 Prop_ManufacturerName_String = 1005,
344 Prop_TrackingFirmwareVersion_String = 1006,
345 Prop_HardwareRevision_String = 1007,
346 Prop_AllWirelessDongleDescriptions_String = 1008,
347 Prop_ConnectedWirelessDongle_String = 1009,
348 Prop_DeviceIsWireless_Bool = 1010,
349 Prop_DeviceIsCharging_Bool = 1011,
350 Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
351 Prop_StatusDisplayTransform_Matrix34 = 1013,
352 Prop_Firmware_UpdateAvailable_Bool = 1014,
353 Prop_Firmware_ManualUpdate_Bool = 1015,
354 Prop_Firmware_ManualUpdateURL_String = 1016,
355 Prop_HardwareRevision_Uint64 = 1017,
356 Prop_FirmwareVersion_Uint64 = 1018,
357 Prop_FPGAVersion_Uint64 = 1019,
358 Prop_VRCVersion_Uint64 = 1020,
359 Prop_RadioVersion_Uint64 = 1021,
360 Prop_DongleVersion_Uint64 = 1022,
361 Prop_BlockServerShutdown_Bool = 1023,
362 Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
363 Prop_ContainsProximitySensor_Bool = 1025,
364 Prop_DeviceProvidesBatteryStatus_Bool = 1026,
365 Prop_DeviceCanPowerOff_Bool = 1027,
366 Prop_Firmware_ProgrammingTarget_String = 1028,
367 Prop_DeviceClass_Int32 = 1029,
368 Prop_HasCamera_Bool = 1030,
369 Prop_DriverVersion_String = 1031,
370 Prop_Firmware_ForceUpdateRequired_Bool = 1032,
371 Prop_ViveSystemButtonFixRequired_Bool = 1033,
372 Prop_ParentDriver_Uint64 = 1034,
373 Prop_ResourceRoot_String = 1035,
374 Prop_RegisteredDeviceType_String = 1036,
375 Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided
376 Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design
377 Prop_NumCameras_Int32 = 1039,
378 Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value
379 Prop_CameraStreamFormat_Int32 = 1041, // ECameraVideoStreamFormat value
380 Prop_AdditionalDeviceSettingsPath_String = 1042, // driver-relative path to additional device and global configuration settings
381 Prop_Identifiable_Bool = 1043, // Whether device supports being identified from vrmonitor (e.g. blink LED, vibrate haptics, etc)
382 Prop_BootloaderVersion_Uint64 = 1044,
383 Prop_AdditionalSystemReportData_String = 1045, // additional string to include in system reports about a tracked device
384 Prop_CompositeFirmwareVersion_String = 1046, // additional FW components from a device that gets propagated into reports
385 Prop_Firmware_RemindUpdate_Bool = 1047,
386 Prop_PeripheralApplicationVersion_Uint64 = 1048,
387 Prop_ManufacturerSerialNumber_String = 1049,
388 Prop_ComputedSerialNumber_String = 1050,
389 Prop_EstimatedDeviceFirstUseTime_Int32 = 1051,
390
391 // Properties that are unique to TrackedDeviceClass_HMD
392 Prop_ReportsTimeSinceVSync_Bool = 2000,
393 Prop_SecondsFromVsyncToPhotons_Float = 2001,
394 Prop_DisplayFrequency_Float = 2002,
395 Prop_UserIpdMeters_Float = 2003,
396 Prop_CurrentUniverseId_Uint64 = 2004,
397 Prop_PreviousUniverseId_Uint64 = 2005,
398 Prop_DisplayFirmwareVersion_Uint64 = 2006,
399 Prop_IsOnDesktop_Bool = 2007,
400 Prop_DisplayMCType_Int32 = 2008,
401 Prop_DisplayMCOffset_Float = 2009,
402 Prop_DisplayMCScale_Float = 2010,
403 Prop_EdidVendorID_Int32 = 2011,
404 Prop_DisplayMCImageLeft_String = 2012,
405 Prop_DisplayMCImageRight_String = 2013,
406 Prop_DisplayGCBlackClamp_Float = 2014,
407 Prop_EdidProductID_Int32 = 2015,
408 Prop_CameraToHeadTransform_Matrix34 = 2016,
409 Prop_DisplayGCType_Int32 = 2017,
410 Prop_DisplayGCOffset_Float = 2018,
411 Prop_DisplayGCScale_Float = 2019,
412 Prop_DisplayGCPrescale_Float = 2020,
413 Prop_DisplayGCImage_String = 2021,
414 Prop_LensCenterLeftU_Float = 2022,
415 Prop_LensCenterLeftV_Float = 2023,
416 Prop_LensCenterRightU_Float = 2024,
417 Prop_LensCenterRightV_Float = 2025,
418 Prop_UserHeadToEyeDepthMeters_Float = 2026,
419 Prop_CameraFirmwareVersion_Uint64 = 2027,
420 Prop_CameraFirmwareDescription_String = 2028,
421 Prop_DisplayFPGAVersion_Uint64 = 2029,
422 Prop_DisplayBootloaderVersion_Uint64 = 2030,
423 Prop_DisplayHardwareVersion_Uint64 = 2031,
424 Prop_AudioFirmwareVersion_Uint64 = 2032,
425 Prop_CameraCompatibilityMode_Int32 = 2033,
426 Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
427 Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
428 Prop_DisplaySuppressed_Bool = 2036,
429 Prop_DisplayAllowNightMode_Bool = 2037,
430 Prop_DisplayMCImageWidth_Int32 = 2038,
431 Prop_DisplayMCImageHeight_Int32 = 2039,
432 Prop_DisplayMCImageNumChannels_Int32 = 2040,
433 Prop_DisplayMCImageData_Binary = 2041,
434 Prop_SecondsFromPhotonsToVblank_Float = 2042,
435 Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043,
436 Prop_DisplayDebugMode_Bool = 2044,
437 Prop_GraphicsAdapterLuid_Uint64 = 2045,
438 Prop_DriverProvidedChaperonePath_String = 2048,
439 Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for
440 Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for
441 Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded
442 Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded
443 Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded
444 Prop_DoNotApplyPrediction_Bool = 2054, // currently no effect. was used to disable HMD pose prediction on MR, which is now done by MR driver setting velocity=0
445 Prop_CameraToHeadTransforms_Matrix34_Array = 2055,
446 Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion
447 Prop_DriverIsDrawingControllers_Bool = 2057,
448 Prop_DriverRequestsApplicationPause_Bool = 2058,
449 Prop_DriverRequestsReducedRendering_Bool = 2059,
450 Prop_MinimumIpdStepMeters_Float = 2060,
451 Prop_AudioBridgeFirmwareVersion_Uint64 = 2061,
452 Prop_ImageBridgeFirmwareVersion_Uint64 = 2062,
453 Prop_ImuToHeadTransform_Matrix34 = 2063,
454 Prop_ImuFactoryGyroBias_Vector3 = 2064,
455 Prop_ImuFactoryGyroScale_Vector3 = 2065,
456 Prop_ImuFactoryAccelerometerBias_Vector3 = 2066,
457 Prop_ImuFactoryAccelerometerScale_Vector3 = 2067,
458 // reserved 2068
459 Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069,
460 Prop_AdditionalRadioFeatures_Uint64 = 2070,
461 Prop_CameraWhiteBalance_Vector4_Array = 2071, // Prop_NumCameras_Int32-sized array of float[4] RGBG white balance calibration data (max size is vr::k_unMaxCameras)
462 Prop_CameraDistortionFunction_Int32_Array = 2072, // Prop_NumCameras_Int32-sized array of vr::EVRDistortionFunctionType values (max size is vr::k_unMaxCameras)
463 Prop_CameraDistortionCoefficients_Float_Array = 2073, // Prop_NumCameras_Int32-sized array of double[vr::k_unMaxDistortionFunctionParameters] (max size is vr::k_unMaxCameras)
464 Prop_ExpectedControllerType_String = 2074,
465 Prop_HmdTrackingStyle_Int32 = 2075, // one of EHmdTrackingStyle
466 Prop_DriverProvidedChaperoneVisibility_Bool = 2076,
467 Prop_HmdColumnCorrectionSettingPrefix_String = 2077,
468 Prop_CameraSupportsCompatibilityModes_Bool = 2078,
469 Prop_SupportsRoomViewDepthProjection_Bool = 2079,
470 Prop_DisplayAvailableFrameRates_Float_Array = 2080, // populated by compositor from actual EDID list when available from GPU driver
471 Prop_DisplaySupportsMultipleFramerates_Bool = 2081, // if this is true but Prop_DisplayAvailableFrameRates_Float_Array is empty, explain to user
472 Prop_DisplayColorMultLeft_Vector3 = 2082,
473 Prop_DisplayColorMultRight_Vector3 = 2083,
474 Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084,
475 Prop_DisplaySupportsAnalogGain_Bool = 2085,
476 Prop_DisplayMinAnalogGain_Float = 2086,
477 Prop_DisplayMaxAnalogGain_Float = 2087,
478 Prop_CameraExposureTime_Float = 2088,
479 Prop_CameraGlobalGain_Float = 2089,
480 // Prop_DashboardLayoutPathName_String = 2090, // DELETED
481 Prop_DashboardScale_Float = 2091,
482 Prop_IpdUIRangeMinMeters_Float = 2100,
483 Prop_IpdUIRangeMaxMeters_Float = 2101,
484 Prop_Hmd_SupportsHDCP14LegacyCompat_Bool = 2102,
485 Prop_Hmd_SupportsMicMonitoring_Bool = 2103,
486
487 // Driver requested mura correction properties
488 Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200,
489 Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201,
490 Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202,
491 Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203,
492 Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204,
493 Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205,
494 Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206,
495 Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207,
496 Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208,
497
498 Prop_Audio_DefaultPlaybackDeviceId_String = 2300,
499 Prop_Audio_DefaultRecordingDeviceId_String = 2301,
500 Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302,
501 Prop_Audio_SupportsDualSpeakerAndJackOutput_Bool = 2303,
502
503 // Properties that are unique to TrackedDeviceClass_Controller
504 Prop_AttachedDeviceId_String = 3000,
505 Prop_SupportedButtons_Uint64 = 3001,
506 Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
507 Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
508 Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
509 Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
510 Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
511 Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole
512
513 // Properties that are unique to TrackedDeviceClass_TrackingReference
514 Prop_FieldOfViewLeftDegrees_Float = 4000,
515 Prop_FieldOfViewRightDegrees_Float = 4001,
516 Prop_FieldOfViewTopDegrees_Float = 4002,
517 Prop_FieldOfViewBottomDegrees_Float = 4003,
518 Prop_TrackingRangeMinimumMeters_Float = 4004,
519 Prop_TrackingRangeMaximumMeters_Float = 4005,
520 Prop_ModeLabel_String = 4006,
521 Prop_CanWirelessIdentify_Bool = 4007, // volatile, based on radio presence and fw discovery
522 Prop_Nonce_Int32 = 4008,
523
524 // Properties that are used for user interface like icons names
525 Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties.
526 Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
527 Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
528 Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
529 Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
530 Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
531 Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
532 Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
533 Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
534 Prop_NamedIconPathDeviceStandbyAlert_String = 5009, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
535
536 // Properties that are used by helpers, but are opaque to applications
537 Prop_DisplayHiddenArea_Binary_Start = 5100,
538 Prop_DisplayHiddenArea_Binary_End = 5150,
539 Prop_ParentContainer = 5151,
540 Prop_OverrideContainer_Uint64 = 5152,
541
542 // Properties that are unique to drivers
543 Prop_UserConfigPath_String = 6000,
544 Prop_InstallPath_String = 6001,
545 Prop_HasDisplayComponent_Bool = 6002,
546 Prop_HasControllerComponent_Bool = 6003,
547 Prop_HasCameraComponent_Bool = 6004,
548 Prop_HasDriverDirectModeComponent_Bool = 6005,
549 Prop_HasVirtualDisplayComponent_Bool = 6006,
550 Prop_HasSpatialAnchorsSupport_Bool = 6007,
551
552 // Properties that are set internally based on other information provided by drivers
553 Prop_ControllerType_String = 7000,
554 //Prop_LegacyInputProfile_String = 7001, // This is no longer used. See "legacy_binding" in the input profile instead.
555 Prop_ControllerHandSelectionPriority_Int32 = 7002, // Allows hand assignments to prefer some controllers over others. High numbers are selected over low numbers
556
557 // Vendors are free to expose private debug data in this reserved region
558 Prop_VendorSpecific_Reserved_Start = 10000,
559 Prop_VendorSpecific_Reserved_End = 10999,
560
561 Prop_TrackedDeviceProperty_Max = 1000000,
562};
563
564/** No string property will ever be longer than this length */
565static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
566
567/** Used to return errors that occur when reading properties. */
568enum ETrackedPropertyError
569{
570 TrackedProp_Success = 0,
571 TrackedProp_WrongDataType = 1,
572 TrackedProp_WrongDeviceClass = 2,
573 TrackedProp_BufferTooSmall = 3,
574 TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever).
575 TrackedProp_InvalidDevice = 5,
576 TrackedProp_CouldNotContactServer = 6,
577 TrackedProp_ValueNotProvidedByDevice = 7,
578 TrackedProp_StringExceedsMaximumLength = 8,
579 TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
580 TrackedProp_PermissionDenied = 10,
581 TrackedProp_InvalidOperation = 11,
582 TrackedProp_CannotWriteToWildcards = 12,
583 TrackedProp_IPCReadFailure = 13,
584 TrackedProp_OutOfMemory = 14,
585 TrackedProp_InvalidContainer = 15,
586};
587
588/** Used to drive certain text in the UI when talking about the tracking system for the HMD */
589enum EHmdTrackingStyle
590{
591 HmdTrackingStyle_Unknown = 0,
592
593 HmdTrackingStyle_Lighthouse = 1, // base stations and lasers
594 HmdTrackingStyle_OutsideInCameras = 2, // Cameras and LED, Rift 1 style
595 HmdTrackingStyle_InsideOutCameras = 3, // Cameras on HMD looking at the world
596};
597
598typedef uint64_t VRActionHandle_t;
599typedef uint64_t VRActionSetHandle_t;
600typedef uint64_t VRInputValueHandle_t;
601
602static const VRActionHandle_t k_ulInvalidActionHandle = 0;
603static const VRActionSetHandle_t k_ulInvalidActionSetHandle = 0;
604static const VRInputValueHandle_t k_ulInvalidInputValueHandle = 0;
605
606
607/** Allows the application to control what part of the provided texture will be used in the
608* frame buffer. */
609struct VRTextureBounds_t
610{
611 float uMin, vMin;
612 float uMax, vMax;
613};
614
615/** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */
616struct VRTextureWithPose_t : public Texture_t
617{
618 HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures.
619};
620
621struct VRTextureDepthInfo_t
622{
623 void* handle; // See ETextureType definition above
624 HmdMatrix44_t mProjection;
625 HmdVector2_t vRange; // 0..1
626};
627
628struct VRTextureWithDepth_t : public Texture_t
629{
630 VRTextureDepthInfo_t depth;
631};
632
633struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t
634{
635 VRTextureDepthInfo_t depth;
636};
637
638/** Allows the application to control how scene textures are used by the compositor when calling Submit. */
639enum EVRSubmitFlags
640{
641 // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
642 Submit_Default = 0x00,
643
644 // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
645 // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
646 // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
647 Submit_LensDistortionAlreadyApplied = 0x01,
648
649 // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
650 Submit_GlRenderBuffer = 0x02,
651
652 // Do not use
653 Submit_Reserved = 0x04,
654
655 // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t.
656 // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t.
657 Submit_TextureWithPose = 0x08,
658
659 // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t.
660 // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t.
661 Submit_TextureWithDepth = 0x10,
662
663 // Set to indicate a discontinuity between this and the last frame.
664 // This will prevent motion smoothing from attempting to extrapolate using the pair.
665 Submit_FrameDiscontinuty = 0x20,
666
667 // Set to indicate that pTexture->handle is a contains VRVulkanTextureArrayData_t
668 Submit_VulkanTextureWithArrayData = 0x40,
669
670 // If the texture pointer passed in is an OpenGL Array texture, set this flag
671 Submit_GlArrayTexture = 0x80,
672
673 // Do not use
674 Submit_Reserved2 = 0x8000,
675
676
677};
678
679/** Data required for passing Vulkan textures to IVRCompositor::Submit.
680* Be sure to call OpenVR_Shutdown before destroying these resources.
681* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */
682struct VRVulkanTextureData_t
683{
684 uint64_t m_nImage; // VkImage
685 VkDevice_T *m_pDevice;
686 VkPhysicalDevice_T *m_pPhysicalDevice;
687 VkInstance_T *m_pInstance;
688 VkQueue_T *m_pQueue;
689 uint32_t m_nQueueFamilyIndex;
690 uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount;
691};
692
693/** Data required for passing Vulkan texture arrays to IVRCompositor::Submit.
694* Be sure to call OpenVR_Shutdown before destroying these resources.
695* Please see https://github.com/ValveSoftware/openvr/wiki/Vulkan for Vulkan-specific documentation */
696struct VRVulkanTextureArrayData_t : public VRVulkanTextureData_t
697{
698 uint32_t m_unArrayIndex;
699 uint32_t m_unArraySize;
700};
701
702/** Data required for passing D3D12 textures to IVRCompositor::Submit.
703* Be sure to call OpenVR_Shutdown before destroying these resources. */
704struct D3D12TextureData_t
705{
706 ID3D12Resource *m_pResource;
707 ID3D12CommandQueue *m_pCommandQueue;
708 uint32_t m_nNodeMask;
709};
710
711/** Status of the overall system or tracked objects */
712enum EVRState
713{
714 VRState_Undefined = -1,
715 VRState_Off = 0,
716 VRState_Searching = 1,
717 VRState_Searching_Alert = 2,
718 VRState_Ready = 3,
719 VRState_Ready_Alert = 4,
720 VRState_NotReady = 5,
721 VRState_Standby = 6,
722 VRState_Ready_Alert_Low = 7,
723};
724
725/** The types of events that could be posted (and what the parameters mean for each event type) */
726enum EVREventType
727{
728 VREvent_None = 0,
729
730 VREvent_TrackedDeviceActivated = 100,
731 VREvent_TrackedDeviceDeactivated = 101,
732 VREvent_TrackedDeviceUpdated = 102,
733 VREvent_TrackedDeviceUserInteractionStarted = 103,
734 VREvent_TrackedDeviceUserInteractionEnded = 104,
735 VREvent_IpdChanged = 105,
736 VREvent_EnterStandbyMode = 106,
737 VREvent_LeaveStandbyMode = 107,
738 VREvent_TrackedDeviceRoleChanged = 108,
739 VREvent_WatchdogWakeUpRequested = 109,
740 VREvent_LensDistortionChanged = 110,
741 VREvent_PropertyChanged = 111,
742 VREvent_WirelessDisconnect = 112,
743 VREvent_WirelessReconnect = 113,
744
745 VREvent_ButtonPress = 200, // data is controller
746 VREvent_ButtonUnpress = 201, // data is controller
747 VREvent_ButtonTouch = 202, // data is controller
748 VREvent_ButtonUntouch = 203, // data is controller
749
750 // VREvent_DualAnalog_Press = 250, // No longer sent
751 // VREvent_DualAnalog_Unpress = 251, // No longer sent
752 // VREvent_DualAnalog_Touch = 252, // No longer sent
753 // VREvent_DualAnalog_Untouch = 253, // No longer sent
754 // VREvent_DualAnalog_Move = 254, // No longer sent
755 // VREvent_DualAnalog_ModeSwitch1 = 255, // No longer sent
756 // VREvent_DualAnalog_ModeSwitch2 = 256, // No longer sent
757 VREvent_Modal_Cancel = 257, // Sent to overlays with the
758
759 VREvent_MouseMove = 300, // data is mouse
760 VREvent_MouseButtonDown = 301, // data is mouse
761 VREvent_MouseButtonUp = 302, // data is mouse
762 VREvent_FocusEnter = 303, // data is overlay
763 VREvent_FocusLeave = 304, // data is overlay
764 VREvent_ScrollDiscrete = 305, // data is scroll
765 VREvent_TouchPadMove = 306, // data is mouse
766 VREvent_OverlayFocusChanged = 307, // data is overlay, global event
767 VREvent_ReloadOverlays = 308,
768 VREvent_ScrollSmooth = 309, // data is scroll
769 VREvent_LockMousePosition = 310,
770 VREvent_UnlockMousePosition = 311,
771
772 VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
773 VREvent_InputFocusReleased = 401, // data is process DEPRECATED
774 // VREvent_SceneFocusLost = 402, // data is process
775 // VREvent_SceneFocusGained = 403, // data is process
776 VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
777 VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
778 VREvent_InputFocusChanged = 406, // data is process
779 // VREvent_SceneApplicationSecondaryRenderingStarted = 407,
780 VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process
781 VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for
782
783 VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
784 VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
785
786 VREvent_SceneApplicationStateChanged = 412, // No data; but query VRApplications()->GetSceneApplicationState();
787
788 VREvent_ConsoleOpened = 420,
789 VREvent_ConsoleClosed = 421,
790
791 VREvent_OverlayShown = 500,
792 VREvent_OverlayHidden = 501,
793 VREvent_DashboardActivated = 502,
794 VREvent_DashboardDeactivated = 503,
795 //VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay - No longer sent
796 VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
797 VREvent_ResetDashboard = 506, // Send to the overlay manager
798 //VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID -- no longer sent
799 VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
800 VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
801 VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
802 VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
803 VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
804 VREvent_OverlaySharedTextureChanged = 513,
805 //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent
806 //VREvent_DashboardGuideButtonUp = 515,
807 VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
808 VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
809 VREvent_DashboardOverlayCreated = 518,
810 VREvent_SwitchGamepadFocus = 519,
811
812 // Screenshot API
813 VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
814 VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
815 VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
816 VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
817 VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted
818
819 VREvent_PrimaryDashboardDeviceChanged = 525,
820 VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled
821 VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled
822 VREvent_ShowUI = 528, // data is showUi
823 VREvent_ShowDevTools = 529, // data is showDevTools
824 VREvent_DesktopViewUpdating = 530,
825 VREvent_DesktopViewReady = 531,
826
827 VREvent_Notification_Shown = 600,
828 VREvent_Notification_Hidden = 601,
829 VREvent_Notification_BeginInteraction = 602,
830 VREvent_Notification_Destroyed = 603,
831
832 VREvent_Quit = 700, // data is process
833 VREvent_ProcessQuit = 701, // data is process
834 //VREvent_QuitAborted_UserPrompt = 702, // data is process
835 VREvent_QuitAcknowledged = 703, // data is process
836 VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
837 VREvent_RestartRequested = 705, // A driver or other component wants the user to restart SteamVR
838
839 VREvent_ChaperoneDataHasChanged = 800, // this will never happen with the new chaperone system
840 VREvent_ChaperoneUniverseHasChanged = 801,
841 VREvent_ChaperoneTempDataHasChanged = 802, // this will never happen with the new chaperone system
842 VREvent_ChaperoneSettingsHaveChanged = 803,
843 VREvent_SeatedZeroPoseReset = 804,
844 VREvent_ChaperoneFlushCache = 805, // Sent when the process needs to reload any cached data it retrieved from VRChaperone()
845 VREvent_ChaperoneRoomSetupStarting = 806, // Triggered by CVRChaperoneClient::RoomSetupStarting
846 VREvent_ChaperoneRoomSetupFinished = 807, // Triggered by CVRChaperoneClient::CommitWorkingCopy
847 VREvent_StandingZeroPoseReset = 808,
848
849 VREvent_AudioSettingsHaveChanged = 820,
850
851 VREvent_BackgroundSettingHasChanged = 850,
852 VREvent_CameraSettingsHaveChanged = 851,
853 VREvent_ReprojectionSettingHasChanged = 852,
854 VREvent_ModelSkinSettingsHaveChanged = 853,
855 VREvent_EnvironmentSettingsHaveChanged = 854,
856 VREvent_PowerSettingsHaveChanged = 855,
857 VREvent_EnableHomeAppSettingsHaveChanged = 856,
858 VREvent_SteamVRSectionSettingChanged = 857,
859 VREvent_LighthouseSectionSettingChanged = 858,
860 VREvent_NullSectionSettingChanged = 859,
861 VREvent_UserInterfaceSectionSettingChanged = 860,
862 VREvent_NotificationsSectionSettingChanged = 861,
863 VREvent_KeyboardSectionSettingChanged = 862,
864 VREvent_PerfSectionSettingChanged = 863,
865 VREvent_DashboardSectionSettingChanged = 864,
866 VREvent_WebInterfaceSectionSettingChanged = 865,
867 VREvent_TrackersSectionSettingChanged = 866,
868 VREvent_LastKnownSectionSettingChanged = 867,
869 VREvent_DismissedWarningsSectionSettingChanged = 868,
870 VREvent_GpuSpeedSectionSettingChanged = 869,
871 VREvent_WindowsMRSectionSettingChanged = 870,
872 VREvent_OtherSectionSettingChanged = 871,
873
874 VREvent_StatusUpdate = 900,
875
876 VREvent_WebInterface_InstallDriverCompleted = 950,
877
878 VREvent_MCImageUpdated = 1000,
879
880 VREvent_FirmwareUpdateStarted = 1100,
881 VREvent_FirmwareUpdateFinished = 1101,
882
883 VREvent_KeyboardClosed = 1200,
884 VREvent_KeyboardCharInput = 1201,
885 VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
886
887 //VREvent_ApplicationTransitionStarted = 1300,
888 //VREvent_ApplicationTransitionAborted = 1301,
889 //VREvent_ApplicationTransitionNewAppStarted = 1302,
890 VREvent_ApplicationListUpdated = 1303,
891 VREvent_ApplicationMimeTypeLoad = 1304,
892 // VREvent_ApplicationTransitionNewAppLaunchComplete = 1305,
893 VREvent_ProcessConnected = 1306,
894 VREvent_ProcessDisconnected = 1307,
895
896 //VREvent_Compositor_MirrorWindowShown = 1400, // DEPRECATED
897 //VREvent_Compositor_MirrorWindowHidden = 1401, // DEPRECATED
898 VREvent_Compositor_ChaperoneBoundsShown = 1410,
899 VREvent_Compositor_ChaperoneBoundsHidden = 1411,
900 VREvent_Compositor_DisplayDisconnected = 1412,
901 VREvent_Compositor_DisplayReconnected = 1413,
902 VREvent_Compositor_HDCPError = 1414, // data is hdcpError
903 VREvent_Compositor_ApplicationNotResponding = 1415,
904 VREvent_Compositor_ApplicationResumed = 1416,
905 VREvent_Compositor_OutOfVideoMemory = 1417,
906 VREvent_Compositor_DisplayModeNotSupported = 1418, // k_pch_SteamVR_PreferredRefreshRate
907 VREvent_Compositor_StageOverrideReady = 1419,
908
909 VREvent_TrackedCamera_StartVideoStream = 1500,
910 VREvent_TrackedCamera_StopVideoStream = 1501,
911 VREvent_TrackedCamera_PauseVideoStream = 1502,
912 VREvent_TrackedCamera_ResumeVideoStream = 1503,
913 VREvent_TrackedCamera_EditingSurface = 1550,
914
915 VREvent_PerformanceTest_EnableCapture = 1600,
916 VREvent_PerformanceTest_DisableCapture = 1601,
917 VREvent_PerformanceTest_FidelityLevel = 1602,
918
919 VREvent_MessageOverlay_Closed = 1650,
920 VREvent_MessageOverlayCloseRequested = 1651,
921
922 VREvent_Input_HapticVibration = 1700, // data is hapticVibration
923 VREvent_Input_BindingLoadFailed = 1701, // data is inputBinding
924 VREvent_Input_BindingLoadSuccessful = 1702, // data is inputBinding
925 VREvent_Input_ActionManifestReloaded = 1703, // no data
926 VREvent_Input_ActionManifestLoadFailed = 1704, // data is actionManifest
927 VREvent_Input_ProgressUpdate = 1705, // data is progressUpdate
928 VREvent_Input_TrackerActivated = 1706,
929 VREvent_Input_BindingsUpdated = 1707,
930 VREvent_Input_BindingSubscriptionChanged = 1708,
931
932 VREvent_SpatialAnchors_PoseUpdated = 1800, // data is spatialAnchor. broadcast
933 VREvent_SpatialAnchors_DescriptorUpdated = 1801, // data is spatialAnchor. broadcast
934 VREvent_SpatialAnchors_RequestPoseUpdate = 1802, // data is spatialAnchor. sent to specific driver
935 VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, // data is spatialAnchor. sent to specific driver
936
937 VREvent_SystemReport_Started = 1900, // user or system initiated generation of a system report. broadcast
938
939 VREvent_Monitor_ShowHeadsetView = 2000, // data is process
940 VREvent_Monitor_HideHeadsetView = 2001, // data is process
941
942 // Vendors are free to expose private events in this reserved region
943 VREvent_VendorSpecific_Reserved_Start = 10000,
944 VREvent_VendorSpecific_Reserved_End = 19999,
945};
946
947
948/** Level of Hmd activity */
949// UserInteraction_Timeout means the device is in the process of timing out.
950// InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout )
951// VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction.
952// VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle
953enum EDeviceActivityLevel
954{
955 k_EDeviceActivityLevel_Unknown = -1,
956 k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds
957 k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now
958 k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds
959 k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management)
960 k_EDeviceActivityLevel_Idle_Timeout = 4,
961};
962
963
964/** VR controller button and axis IDs */
965enum EVRButtonId
966{
967 k_EButton_System = 0,
968 k_EButton_ApplicationMenu = 1,
969 k_EButton_Grip = 2,
970 k_EButton_DPad_Left = 3,
971 k_EButton_DPad_Up = 4,
972 k_EButton_DPad_Right = 5,
973 k_EButton_DPad_Down = 6,
974 k_EButton_A = 7,
975
976 k_EButton_ProximitySensor = 31,
977
978 k_EButton_Axis0 = 32,
979 k_EButton_Axis1 = 33,
980 k_EButton_Axis2 = 34,
981 k_EButton_Axis3 = 35,
982 k_EButton_Axis4 = 36,
983
984 // aliases for well known controllers
985 k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
986 k_EButton_SteamVR_Trigger = k_EButton_Axis1,
987
988 k_EButton_Dashboard_Back = k_EButton_Grip,
989
990 k_EButton_IndexController_A = k_EButton_Grip,
991 k_EButton_IndexController_B = k_EButton_ApplicationMenu,
992 k_EButton_IndexController_JoyStick = k_EButton_Axis3,
993
994 k_EButton_Max = 64
995};
996
997inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
998
999/** used for controller button events */
1000struct VREvent_Controller_t
1001{
1002 uint32_t button; // EVRButtonId enum
1003};
1004
1005
1006/** used for simulated mouse events in overlay space */
1007enum EVRMouseButton
1008{
1009 VRMouseButton_Left = 0x0001,
1010 VRMouseButton_Right = 0x0002,
1011 VRMouseButton_Middle = 0x0004,
1012};
1013
1014
1015/** used for simulated mouse events in overlay space */
1016struct VREvent_Mouse_t
1017{
1018 float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
1019 uint32_t button; // EVRMouseButton enum
1020};
1021
1022/** used for simulated mouse wheel scroll */
1023struct VREvent_Scroll_t
1024{
1025 float xdelta, ydelta;
1026 uint32_t unused;
1027 float viewportscale; // For scrolling on an overlay with laser mouse, this is the overlay's vertical size relative to the overlay height. Range: [0,1]
1028};
1029
1030/** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
1031 is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents
1032 flag set.
1033**/
1034struct VREvent_TouchPadMove_t
1035{
1036 // true if the users finger is detected on the touch pad
1037 bool bFingerDown;
1038
1039 // How long the finger has been down in seconds
1040 float flSecondsFingerDown;
1041
1042 // These values indicate the starting finger position (so you can do some basic swipe stuff)
1043 float fValueXFirst;
1044 float fValueYFirst;
1045
1046 // This is the raw sampled coordinate without deadzoning
1047 float fValueXRaw;
1048 float fValueYRaw;
1049};
1050
1051/** notification related events. Details will still change at this point */
1052struct VREvent_Notification_t
1053{
1054 uint64_t ulUserValue;
1055 uint32_t notificationId;
1056};
1057
1058/** Used for events about processes */
1059struct VREvent_Process_t
1060{
1061 uint32_t pid;
1062 uint32_t oldPid;
1063 bool bForced;
1064 // If the associated event was triggered by a connection loss
1065 bool bConnectionLost;
1066};
1067
1068
1069/** Used for a few events about overlays */
1070struct VREvent_Overlay_t
1071{
1072 uint64_t overlayHandle;
1073 uint64_t devicePath;
1074 uint64_t memoryBlockId;
1075};
1076
1077
1078/** Used for a few events about overlays */
1079struct VREvent_Status_t
1080{
1081 uint32_t statusState; // EVRState enum
1082};
1083
1084/** Used for keyboard events **/
1085struct VREvent_Keyboard_t
1086{
1087 char cNewInput[8]; // Up to 11 bytes of new input
1088 uint64_t uUserValue; // Possible flags about the new input
1089};
1090
1091struct VREvent_Ipd_t
1092{
1093 float ipdMeters;
1094};
1095
1096struct VREvent_Chaperone_t
1097{
1098 uint64_t m_nPreviousUniverse;
1099 uint64_t m_nCurrentUniverse;
1100};
1101
1102/** Not actually used for any events */
1103struct VREvent_Reserved_t
1104{
1105 uint64_t reserved0;
1106 uint64_t reserved1;
1107 uint64_t reserved2;
1108 uint64_t reserved3;
1109 uint64_t reserved4;
1110 uint64_t reserved5;
1111};
1112
1113struct VREvent_PerformanceTest_t
1114{
1115 uint32_t m_nFidelityLevel;
1116};
1117
1118struct VREvent_SeatedZeroPoseReset_t
1119{
1120 bool bResetBySystemMenu;
1121};
1122
1123struct VREvent_Screenshot_t
1124{
1125 uint32_t handle;
1126 uint32_t type;
1127};
1128
1129struct VREvent_ScreenshotProgress_t
1130{
1131 float progress;
1132};
1133
1134struct VREvent_ApplicationLaunch_t
1135{
1136 uint32_t pid;
1137 uint32_t unArgsHandle;
1138};
1139
1140struct VREvent_EditingCameraSurface_t
1141{
1142 uint64_t overlayHandle;
1143 uint32_t nVisualMode;
1144};
1145
1146struct VREvent_MessageOverlay_t
1147{
1148 uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum
1149};
1150
1151struct VREvent_Property_t
1152{
1153 PropertyContainerHandle_t container;
1154 ETrackedDeviceProperty prop;
1155};
1156
1157struct VREvent_HapticVibration_t
1158{
1159 uint64_t containerHandle; // property container handle of the device with the haptic component
1160 uint64_t componentHandle; // Which haptic component needs to vibrate
1161 float fDurationSeconds;
1162 float fFrequency;
1163 float fAmplitude;
1164};
1165
1166struct VREvent_WebConsole_t
1167{
1168 WebConsoleHandle_t webConsoleHandle;
1169};
1170
1171struct VREvent_InputBindingLoad_t
1172{
1173 vr::PropertyContainerHandle_t ulAppContainer;
1174 uint64_t pathMessage;
1175 uint64_t pathUrl;
1176 uint64_t pathControllerType;
1177};
1178
1179struct VREvent_InputActionManifestLoad_t
1180{
1181 uint64_t pathAppKey;
1182 uint64_t pathMessage;
1183 uint64_t pathMessageParam;
1184 uint64_t pathManifestPath;
1185};
1186
1187struct VREvent_SpatialAnchor_t
1188{
1189 SpatialAnchorHandle_t unHandle;
1190};
1191
1192struct VREvent_ProgressUpdate_t
1193{
1194 uint64_t ulApplicationPropertyContainer;
1195 uint64_t pathDevice;
1196 uint64_t pathInputSource;
1197 uint64_t pathProgressAction;
1198 uint64_t pathIcon;
1199 float fProgress;
1200};
1201
1202enum EShowUIType
1203{
1204 ShowUI_ControllerBinding = 0,
1205 ShowUI_ManageTrackers = 1,
1206 // ShowUI_QuickStart = 2, // Deprecated
1207 ShowUI_Pairing = 3,
1208 ShowUI_Settings = 4,
1209 ShowUI_DebugCommands = 5,
1210 ShowUI_FullControllerBinding = 6,
1211 ShowUI_ManageDrivers = 7,
1212};
1213
1214struct VREvent_ShowUI_t
1215{
1216 EShowUIType eType;
1217};
1218
1219struct VREvent_ShowDevTools_t
1220{
1221 int32_t nBrowserIdentifier;
1222};
1223
1224enum EHDCPError
1225{
1226 HDCPError_None = 0,
1227 HDCPError_LinkLost = 1,
1228 HDCPError_Tampered = 2,
1229 HDCPError_DeviceRevoked = 3,
1230 HDCPError_Unknown = 4
1231};
1232
1233struct VREvent_HDCPError_t
1234{
1235 EHDCPError eCode;
1236};
1237
1238typedef union
1239{
1240 VREvent_Reserved_t reserved;
1241 VREvent_Controller_t controller;
1242 VREvent_Mouse_t mouse;
1243 VREvent_Scroll_t scroll;
1244 VREvent_Process_t process;
1245 VREvent_Notification_t notification;
1246 VREvent_Overlay_t overlay;
1247 VREvent_Status_t status;
1248 VREvent_Keyboard_t keyboard;
1249 VREvent_Ipd_t ipd;
1250 VREvent_Chaperone_t chaperone;
1251 VREvent_PerformanceTest_t performanceTest;
1252 VREvent_TouchPadMove_t touchPadMove;
1253 VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
1254 VREvent_Screenshot_t screenshot;
1255 VREvent_ScreenshotProgress_t screenshotProgress;
1256 VREvent_ApplicationLaunch_t applicationLaunch;
1257 VREvent_EditingCameraSurface_t cameraSurface;
1258 VREvent_MessageOverlay_t messageOverlay;
1259 VREvent_Property_t property;
1260 VREvent_HapticVibration_t hapticVibration;
1261 VREvent_WebConsole_t webConsole;
1262 VREvent_InputBindingLoad_t inputBinding;
1263 VREvent_InputActionManifestLoad_t actionManifest;
1264 VREvent_SpatialAnchor_t spatialAnchor;
1265 VREvent_ProgressUpdate_t progressUpdate;
1266 VREvent_ShowUI_t showUi;
1267 VREvent_ShowDevTools_t showDevTools;
1268 VREvent_HDCPError_t hdcpError;
1269 /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */
1270} VREvent_Data_t;
1271
1272
1273#if defined(__linux__) || defined(__APPLE__)
1274// This structure was originally defined mis-packed on Linux, preserved for
1275// compatibility.
1276#pragma pack( push, 4 )
1277#endif
1278
1279/** An event posted by the server to all running applications */
1280struct VREvent_t
1281{
1282 uint32_t eventType; // EVREventType enum
1283 TrackedDeviceIndex_t trackedDeviceIndex;
1284 float eventAgeSeconds;
1285 // event data must be the end of the struct as its size is variable
1286 VREvent_Data_t data;
1287};
1288
1289#if defined(__linux__) || defined(__APPLE__)
1290#pragma pack( pop )
1291#endif
1292
1293typedef uint32_t VRComponentProperties;
1294
1295enum EVRComponentProperty
1296{
1297 VRComponentProperty_IsStatic = (1 << 0),
1298 VRComponentProperty_IsVisible = (1 << 1),
1299 VRComponentProperty_IsTouched = (1 << 2),
1300 VRComponentProperty_IsPressed = (1 << 3),
1301 VRComponentProperty_IsScrolled = (1 << 4),
1302 VRComponentProperty_IsHighlighted = (1 << 5),
1303};
1304
1305
1306/** Describes state information about a render-model component, including transforms and other dynamic properties */
1307struct RenderModel_ComponentState_t
1308{
1309 HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model
1310 HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface )
1311 VRComponentProperties uProperties;
1312};
1313
1314
1315enum EVRInputError
1316{
1317 VRInputError_None = 0,
1318 VRInputError_NameNotFound = 1,
1319 VRInputError_WrongType = 2,
1320 VRInputError_InvalidHandle = 3,
1321 VRInputError_InvalidParam = 4,
1322 VRInputError_NoSteam = 5,
1323 VRInputError_MaxCapacityReached = 6,
1324 VRInputError_IPCError = 7,
1325 VRInputError_NoActiveActionSet = 8,
1326 VRInputError_InvalidDevice = 9,
1327 VRInputError_InvalidSkeleton = 10,
1328 VRInputError_InvalidBoneCount = 11,
1329 VRInputError_InvalidCompressedData = 12,
1330 VRInputError_NoData = 13,
1331 VRInputError_BufferTooSmall = 14,
1332 VRInputError_MismatchedActionManifest = 15,
1333 VRInputError_MissingSkeletonData = 16,
1334 VRInputError_InvalidBoneIndex = 17,
1335 VRInputError_InvalidPriority = 18,
1336 VRInputError_PermissionDenied = 19,
1337 VRInputError_InvalidRenderModel = 20,
1338};
1339
1340enum EVRSpatialAnchorError
1341{
1342 VRSpatialAnchorError_Success = 0,
1343 VRSpatialAnchorError_Internal = 1,
1344 VRSpatialAnchorError_UnknownHandle = 2,
1345 VRSpatialAnchorError_ArrayTooSmall = 3,
1346 VRSpatialAnchorError_InvalidDescriptorChar = 4,
1347 VRSpatialAnchorError_NotYetAvailable = 5,
1348 VRSpatialAnchorError_NotAvailableInThisUniverse = 6,
1349 VRSpatialAnchorError_PermanentlyUnavailable = 7,
1350 VRSpatialAnchorError_WrongDriver = 8,
1351 VRSpatialAnchorError_DescriptorTooLong = 9,
1352 VRSpatialAnchorError_Unknown = 10,
1353 VRSpatialAnchorError_NoRoomCalibration = 11,
1354 VRSpatialAnchorError_InvalidArgument = 12,
1355 VRSpatialAnchorError_UnknownDriver = 13,
1356};
1357
1358/** The mesh to draw into the stencil (or depth) buffer to perform
1359* early stencil (or depth) kills of pixels that will never appear on the HMD.
1360* This mesh draws on all the pixels that will be hidden after distortion.
1361*
1362* If the HMD does not provide a visible area mesh pVertexData will be
1363* NULL and unTriangleCount will be 0. */
1364struct HiddenAreaMesh_t
1365{
1366 const HmdVector2_t *pVertexData;
1367 uint32_t unTriangleCount;
1368};
1369
1370
1371enum EHiddenAreaMeshType
1372{
1373 k_eHiddenAreaMesh_Standard = 0,
1374 k_eHiddenAreaMesh_Inverse = 1,
1375 k_eHiddenAreaMesh_LineLoop = 2,
1376
1377 k_eHiddenAreaMesh_Max = 3,
1378};
1379
1380
1381/** Identifies what kind of axis is on the controller at index n. Read this type
1382* with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
1383*/
1384enum EVRControllerAxisType
1385{
1386 k_eControllerAxis_None = 0,
1387 k_eControllerAxis_TrackPad = 1,
1388 k_eControllerAxis_Joystick = 2,
1389 k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
1390};
1391
1392
1393/** contains information about one axis on the controller */
1394struct VRControllerAxis_t
1395{
1396 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.
1397 float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
1398};
1399
1400
1401/** the number of axes in the controller state */
1402static const uint32_t k_unControllerStateAxisCount = 5;
1403
1404
1405#if defined(__linux__) || defined(__APPLE__)
1406// This structure was originally defined mis-packed on Linux, preserved for
1407// compatibility.
1408#pragma pack( push, 4 )
1409#endif
1410
1411/** Holds all the state of a controller at one moment in time. */
1412struct VRControllerState001_t
1413{
1414 // If packet num matches that on your prior call, then the controller state hasn't been changed since
1415 // your last call and there is no need to process it
1416 uint32_t unPacketNum;
1417
1418 // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
1419 uint64_t ulButtonPressed;
1420 uint64_t ulButtonTouched;
1421
1422 // Axis data for the controller's analog inputs
1423 VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
1424};
1425#if defined(__linux__) || defined(__APPLE__)
1426#pragma pack( pop )
1427#endif
1428
1429
1430typedef VRControllerState001_t VRControllerState_t;
1431
1432
1433/** determines how to provide output to the application of various event processing functions. */
1434enum EVRControllerEventOutputType
1435{
1436 ControllerEventOutput_OSEvents = 0,
1437 ControllerEventOutput_VREvents = 1,
1438};
1439
1440
1441
1442/** Collision Bounds Style */
1443enum ECollisionBoundsStyle
1444{
1445 COLLISION_BOUNDS_STYLE_BEGINNER = 0,
1446 COLLISION_BOUNDS_STYLE_INTERMEDIATE,
1447 COLLISION_BOUNDS_STYLE_SQUARES,
1448 COLLISION_BOUNDS_STYLE_ADVANCED,
1449 COLLISION_BOUNDS_STYLE_NONE,
1450
1451 COLLISION_BOUNDS_STYLE_COUNT
1452};
1453
1454/** used to refer to a single VR overlay */
1455typedef uint64_t VROverlayHandle_t;
1456
1457static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
1458
1459/** Errors that can occur around VR overlays */
1460enum EVROverlayError
1461{
1462 VROverlayError_None = 0,
1463
1464 VROverlayError_UnknownOverlay = 10,
1465 VROverlayError_InvalidHandle = 11,
1466 VROverlayError_PermissionDenied = 12,
1467 VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
1468 VROverlayError_WrongVisibilityType = 14,
1469 VROverlayError_KeyTooLong = 15,
1470 VROverlayError_NameTooLong = 16,
1471 VROverlayError_KeyInUse = 17,
1472 VROverlayError_WrongTransformType = 18,
1473 VROverlayError_InvalidTrackedDevice = 19,
1474 VROverlayError_InvalidParameter = 20,
1475 VROverlayError_ThumbnailCantBeDestroyed = 21,
1476 VROverlayError_ArrayTooSmall = 22,
1477 VROverlayError_RequestFailed = 23,
1478 VROverlayError_InvalidTexture = 24,
1479 VROverlayError_UnableToLoadFile = 25,
1480 VROverlayError_KeyboardAlreadyInUse = 26,
1481 VROverlayError_NoNeighbor = 27,
1482 VROverlayError_TooManyMaskPrimitives = 29,
1483 VROverlayError_BadMaskPrimitive = 30,
1484 VROverlayError_TextureAlreadyLocked = 31,
1485 VROverlayError_TextureLockCapacityReached = 32,
1486 VROverlayError_TextureNotLocked = 33,
1487};
1488
1489/** enum values to pass in to VR_Init to identify whether the application will
1490* draw a 3D scene. */
1491enum EVRApplicationType
1492{
1493 VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
1494 VRApplication_Scene = 1, // Application will submit 3D frames
1495 VRApplication_Overlay = 2, // Application only interacts with overlays
1496 VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
1497 // keep it running if everything else quits.
1498 VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
1499 // interfaces (like IVRSettings and IVRApplications) but not hardware.
1500 VRApplication_VRMonitor = 5, // Reserved for vrmonitor
1501 VRApplication_SteamWatchdog = 6,// Reserved for Steam
1502 VRApplication_Bootstrapper = 7, // reserved for vrstartup
1503 VRApplication_WebHelper = 8, // reserved for vrwebhelper
1504 VRApplication_OpenXRInstance = 9, // reserved for openxr (created instance, but not session yet)
1505 VRApplication_OpenXRScene = 10, // reserved for openxr (started session)
1506 VRApplication_OpenXROverlay = 11, // reserved for openxr (started overlay session)
1507 VRApplication_Prism = 12, // reserved for the vrprismhost process
1508
1509 VRApplication_Max
1510};
1511
1512
1513/** returns true if the specified application type is one of the
1514* OpenXR types */
1515inline bool IsOpenXRAppType( EVRApplicationType eType )
1516{
1517 return eType == VRApplication_OpenXRInstance
1518 || eType == VRApplication_OpenXRScene
1519 || eType == VRApplication_OpenXROverlay;
1520}
1521
1522
1523/** error codes for firmware */
1524enum EVRFirmwareError
1525{
1526 VRFirmwareError_None = 0,
1527 VRFirmwareError_Success = 1,
1528 VRFirmwareError_Fail = 2,
1529};
1530
1531
1532/** error codes for notifications */
1533enum EVRNotificationError
1534{
1535 VRNotificationError_OK = 0,
1536 VRNotificationError_InvalidNotificationId = 100,
1537 VRNotificationError_NotificationQueueFull = 101,
1538 VRNotificationError_InvalidOverlayHandle = 102,
1539 VRNotificationError_SystemWithUserValueAlreadyExists = 103,
1540};
1541
1542
1543enum EVRSkeletalMotionRange
1544{
1545 // The range of motion of the skeleton takes into account any physical limits imposed by
1546 // the controller itself. This will tend to be the most accurate pose compared to the user's
1547 // actual hand pose, but might not allow a closed fist for example
1548 VRSkeletalMotionRange_WithController = 0,
1549
1550 // Retarget the range of motion provided by the input device to make the hand appear to move
1551 // as if it was not holding a controller. eg: map "hand grasping controller" to "closed fist"
1552 VRSkeletalMotionRange_WithoutController = 1,
1553};
1554
1555enum EVRSkeletalTrackingLevel
1556{
1557 // body part location can't be directly determined by the device. Any skeletal pose provided by
1558 // the device is estimated by assuming the position required to active buttons, triggers, joysticks,
1559 // or other input sensors.
1560 // E.g. Vive Controller, Gamepad
1561 VRSkeletalTracking_Estimated = 0,
1562
1563 // body part location can be measured directly but with fewer degrees of freedom than the actual body
1564 // part. Certain body part positions may be unmeasured by the device and estimated from other input data.
1565 // E.g. Index Controllers, gloves that only measure finger curl
1566 VRSkeletalTracking_Partial = 1,
1567
1568 // Body part location can be measured directly throughout the entire range of motion of the body part.
1569 // E.g. Mocap suit for the full body, gloves that measure rotation of each finger segment
1570 VRSkeletalTracking_Full = 2,
1571
1572 VRSkeletalTrackingLevel_Count,
1573 VRSkeletalTrackingLevel_Max = VRSkeletalTrackingLevel_Count - 1
1574};
1575
1576
1577/** Type used for referring to bones by their index */
1578typedef int32_t BoneIndex_t;
1579const BoneIndex_t k_unInvalidBoneIndex = -1;
1580
1581
1582/** error codes returned by Vr_Init */
1583
1584// Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
1585enum EVRInitError
1586{
1587 VRInitError_None = 0,
1588 VRInitError_Unknown = 1,
1589
1590 VRInitError_Init_InstallationNotFound = 100,
1591 VRInitError_Init_InstallationCorrupt = 101,
1592 VRInitError_Init_VRClientDLLNotFound = 102,
1593 VRInitError_Init_FileNotFound = 103,
1594 VRInitError_Init_FactoryNotFound = 104,
1595 VRInitError_Init_InterfaceNotFound = 105,
1596 VRInitError_Init_InvalidInterface = 106,
1597 VRInitError_Init_UserConfigDirectoryInvalid = 107,
1598 VRInitError_Init_HmdNotFound = 108,
1599 VRInitError_Init_NotInitialized = 109,
1600 VRInitError_Init_PathRegistryNotFound = 110,
1601 VRInitError_Init_NoConfigPath = 111,
1602 VRInitError_Init_NoLogPath = 112,
1603 VRInitError_Init_PathRegistryNotWritable = 113,
1604 VRInitError_Init_AppInfoInitFailed = 114,
1605 VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
1606 VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
1607 VRInitError_Init_AnotherAppLaunching = 117,
1608 VRInitError_Init_SettingsInitFailed = 118,
1609 VRInitError_Init_ShuttingDown = 119,
1610 VRInitError_Init_TooManyObjects = 120,
1611 VRInitError_Init_NoServerForBackgroundApp = 121,
1612 VRInitError_Init_NotSupportedWithCompositor = 122,
1613 VRInitError_Init_NotAvailableToUtilityApps = 123,
1614 VRInitError_Init_Internal = 124,
1615 VRInitError_Init_HmdDriverIdIsNone = 125,
1616 VRInitError_Init_HmdNotFoundPresenceFailed = 126,
1617 VRInitError_Init_VRMonitorNotFound = 127,
1618 VRInitError_Init_VRMonitorStartupFailed = 128,
1619 VRInitError_Init_LowPowerWatchdogNotSupported = 129,
1620 VRInitError_Init_InvalidApplicationType = 130,
1621 VRInitError_Init_NotAvailableToWatchdogApps = 131,
1622 VRInitError_Init_WatchdogDisabledInSettings = 132,
1623 VRInitError_Init_VRDashboardNotFound = 133,
1624 VRInitError_Init_VRDashboardStartupFailed = 134,
1625 VRInitError_Init_VRHomeNotFound = 135,
1626 VRInitError_Init_VRHomeStartupFailed = 136,
1627 VRInitError_Init_RebootingBusy = 137,
1628 VRInitError_Init_FirmwareUpdateBusy = 138,
1629 VRInitError_Init_FirmwareRecoveryBusy = 139,
1630 VRInitError_Init_USBServiceBusy = 140,
1631 VRInitError_Init_VRWebHelperStartupFailed = 141,
1632 VRInitError_Init_TrackerManagerInitFailed = 142,
1633 VRInitError_Init_AlreadyRunning = 143,
1634 VRInitError_Init_FailedForVrMonitor = 144,
1635 VRInitError_Init_PropertyManagerInitFailed = 145,
1636 VRInitError_Init_WebServerFailed = 146,
1637 VRInitError_Init_IllegalTypeTransition = 147,
1638 VRInitError_Init_MismatchedRuntimes = 148,
1639 VRInitError_Init_InvalidProcessId = 149,
1640 VRInitError_Init_VRServiceStartupFailed = 150,
1641 VRInitError_Init_PrismNeedsNewDrivers = 151,
1642 VRInitError_Init_PrismStartupTimedOut = 152,
1643 VRInitError_Init_CouldNotStartPrism = 153,
1644 VRInitError_Init_CreateDriverDirectDeviceFailed = 154,
1645 VRInitError_Init_PrismExitedUnexpectedly = 155,
1646
1647 VRInitError_Driver_Failed = 200,
1648 VRInitError_Driver_Unknown = 201,
1649 VRInitError_Driver_HmdUnknown = 202,
1650 VRInitError_Driver_NotLoaded = 203,
1651 VRInitError_Driver_RuntimeOutOfDate = 204,
1652 VRInitError_Driver_HmdInUse = 205,
1653 VRInitError_Driver_NotCalibrated = 206,
1654 VRInitError_Driver_CalibrationInvalid = 207,
1655 VRInitError_Driver_HmdDisplayNotFound = 208,
1656 VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209,
1657 // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons
1658 VRInitError_Driver_HmdDriverIdOutOfBounds = 211,
1659 VRInitError_Driver_HmdDisplayMirrored = 212,
1660 VRInitError_Driver_HmdDisplayNotFoundLaptop = 213,
1661 // Never make error 259 because we return it from main and it would conflict with STILL_ACTIVE
1662
1663 VRInitError_IPC_ServerInitFailed = 300,
1664 VRInitError_IPC_ConnectFailed = 301,
1665 VRInitError_IPC_SharedStateInitFailed = 302,
1666 VRInitError_IPC_CompositorInitFailed = 303,
1667 VRInitError_IPC_MutexInitFailed = 304,
1668 VRInitError_IPC_Failed = 305,
1669 VRInitError_IPC_CompositorConnectFailed = 306,
1670 VRInitError_IPC_CompositorInvalidConnectResponse = 307,
1671 VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308,
1672 VRInitError_IPC_ConnectFailedAfterTargetExited = 309,
1673 VRInitError_IPC_NamespaceUnavailable = 310,
1674
1675 VRInitError_Compositor_Failed = 400,
1676 VRInitError_Compositor_D3D11HardwareRequired = 401,
1677 VRInitError_Compositor_FirmwareRequiresUpdate = 402,
1678 VRInitError_Compositor_OverlayInitFailed = 403,
1679 VRInitError_Compositor_ScreenshotsInitFailed = 404,
1680 VRInitError_Compositor_UnableToCreateDevice = 405,
1681 VRInitError_Compositor_SharedStateIsNull = 406,
1682 VRInitError_Compositor_NotificationManagerIsNull = 407,
1683 VRInitError_Compositor_ResourceManagerClientIsNull = 408,
1684 VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409,
1685 VRInitError_Compositor_PropertiesInterfaceIsNull = 410,
1686 VRInitError_Compositor_CreateFullscreenWindowFailed = 411,
1687 VRInitError_Compositor_SettingsInterfaceIsNull = 412,
1688 VRInitError_Compositor_FailedToShowWindow = 413,
1689 VRInitError_Compositor_DistortInterfaceIsNull = 414,
1690 VRInitError_Compositor_DisplayFrequencyFailure = 415,
1691 VRInitError_Compositor_RendererInitializationFailed = 416,
1692 VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417,
1693 VRInitError_Compositor_DXGIFactoryCreateFailed = 418,
1694 VRInitError_Compositor_DXGIFactoryQueryFailed = 419,
1695 VRInitError_Compositor_InvalidAdapterDesktop = 420,
1696 VRInitError_Compositor_InvalidHmdAttachment = 421,
1697 VRInitError_Compositor_InvalidOutputDesktop = 422,
1698 VRInitError_Compositor_InvalidDeviceProvided = 423,
1699 VRInitError_Compositor_D3D11RendererInitializationFailed = 424,
1700 VRInitError_Compositor_FailedToFindDisplayMode = 425,
1701 VRInitError_Compositor_FailedToCreateSwapChain = 426,
1702 VRInitError_Compositor_FailedToGetBackBuffer = 427,
1703 VRInitError_Compositor_FailedToCreateRenderTarget = 428,
1704 VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429,
1705 VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430,
1706 VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431,
1707 VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432,
1708 VRInitError_Compositor_SelectDisplayMode = 433,
1709 VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434,
1710 VRInitError_Compositor_NvAPISetDisplayMode = 435,
1711 VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436,
1712 VRInitError_Compositor_InvalidHmdPropertyContainer = 437,
1713 VRInitError_Compositor_UpdateDisplayFrequency = 438,
1714 VRInitError_Compositor_CreateRasterizerState = 439,
1715 VRInitError_Compositor_CreateWireframeRasterizerState = 440,
1716 VRInitError_Compositor_CreateSamplerState = 441,
1717 VRInitError_Compositor_CreateClampToBorderSamplerState = 442,
1718 VRInitError_Compositor_CreateAnisoSamplerState = 443,
1719 VRInitError_Compositor_CreateOverlaySamplerState = 444,
1720 VRInitError_Compositor_CreatePanoramaSamplerState = 445,
1721 VRInitError_Compositor_CreateFontSamplerState = 446,
1722 VRInitError_Compositor_CreateNoBlendState = 447,
1723 VRInitError_Compositor_CreateBlendState = 448,
1724 VRInitError_Compositor_CreateAlphaBlendState = 449,
1725 VRInitError_Compositor_CreateBlendStateMaskR = 450,
1726 VRInitError_Compositor_CreateBlendStateMaskG = 451,
1727 VRInitError_Compositor_CreateBlendStateMaskB = 452,
1728 VRInitError_Compositor_CreateDepthStencilState = 453,
1729 VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454,
1730 VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455,
1731 VRInitError_Compositor_CreateFlushTexture = 456,
1732 VRInitError_Compositor_CreateDistortionSurfaces = 457,
1733 VRInitError_Compositor_CreateConstantBuffer = 458,
1734 VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459,
1735 VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460,
1736 VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461,
1737 VRInitError_Compositor_CreateOverlayConstantBuffer = 462,
1738 VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463,
1739 VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464,
1740 VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465,
1741 VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466,
1742 VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467,
1743 VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468,
1744 VRInitError_Compositor_CreateGeomConstantBuffer = 469,
1745 VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470,
1746 VRInitError_Compositor_CreatePixelSimUBO = 471,
1747 VRInitError_Compositor_CreateMSAARenderTextures = 472,
1748 VRInitError_Compositor_CreateResolveRenderTextures = 473,
1749 VRInitError_Compositor_CreateComputeResolveRenderTextures = 474,
1750 VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475,
1751 VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476,
1752 VRInitError_Compositor_CreateFallbackSyncTexture = 477,
1753 VRInitError_Compositor_ShareFallbackSyncTexture = 478,
1754 VRInitError_Compositor_CreateOverlayIndexBuffer = 479,
1755 VRInitError_Compositor_CreateOverlayVertexBuffer = 480,
1756 VRInitError_Compositor_CreateTextVertexBuffer = 481,
1757 VRInitError_Compositor_CreateTextIndexBuffer = 482,
1758 VRInitError_Compositor_CreateMirrorTextures = 483,
1759 VRInitError_Compositor_CreateLastFrameRenderTexture = 484,
1760 VRInitError_Compositor_CreateMirrorOverlay = 485,
1761 VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486,
1762 VRInitError_Compositor_DisplayModeNotSupported = 487,
1763 VRInitError_Compositor_CreateOverlayInvalidCall = 488,
1764 VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489,
1765 VRInitError_Compositor_FailedToCreateMailbox = 490,
1766 VRInitError_Compositor_WindowInterfaceIsNull = 491,
1767 VRInitError_Compositor_SystemLayerCreateInstance = 492,
1768 VRInitError_Compositor_SystemLayerCreateSession = 493,
1769
1770 VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
1771 VRInitError_VendorSpecific_WindowsNotInDevMode = 1001,
1772
1773 VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
1774 VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
1775 VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
1776 VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
1777 VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
1778 VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
1779 VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
1780 VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
1781 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
1782 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
1783 VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
1784 VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
1785 VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
1786 VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114,
1787
1788 VRInitError_Steam_SteamInstallationNotFound = 2000,
1789
1790 // Strictly a placeholder
1791 VRInitError_LastError
1792};
1793
1794enum EVRScreenshotType
1795{
1796 VRScreenshotType_None = 0,
1797 VRScreenshotType_Mono = 1, // left eye only
1798 VRScreenshotType_Stereo = 2,
1799 VRScreenshotType_Cubemap = 3,
1800 VRScreenshotType_MonoPanorama = 4,
1801 VRScreenshotType_StereoPanorama = 5
1802};
1803
1804enum EVRScreenshotPropertyFilenames
1805{
1806 VRScreenshotPropertyFilenames_Preview = 0,
1807 VRScreenshotPropertyFilenames_VR = 1,
1808};
1809
1810enum EVRTrackedCameraError
1811{
1812 VRTrackedCameraError_None = 0,
1813 VRTrackedCameraError_OperationFailed = 100,
1814 VRTrackedCameraError_InvalidHandle = 101,
1815 VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
1816 VRTrackedCameraError_OutOfHandles = 103,
1817 VRTrackedCameraError_IPCFailure = 104,
1818 VRTrackedCameraError_NotSupportedForThisDevice = 105,
1819 VRTrackedCameraError_SharedMemoryFailure = 106,
1820 VRTrackedCameraError_FrameBufferingFailure = 107,
1821 VRTrackedCameraError_StreamSetupFailure = 108,
1822 VRTrackedCameraError_InvalidGLTextureId = 109,
1823 VRTrackedCameraError_InvalidSharedTextureHandle = 110,
1824 VRTrackedCameraError_FailedToGetGLTextureId = 111,
1825 VRTrackedCameraError_SharedTextureFailure = 112,
1826 VRTrackedCameraError_NoFrameAvailable = 113,
1827 VRTrackedCameraError_InvalidArgument = 114,
1828 VRTrackedCameraError_InvalidFrameBufferSize = 115,
1829};
1830
1831enum EVRTrackedCameraFrameLayout
1832{
1833 EVRTrackedCameraFrameLayout_Mono = 0x0001,
1834 EVRTrackedCameraFrameLayout_Stereo = 0x0002,
1835 EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right)
1836 EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right
1837};
1838
1839enum EVRTrackedCameraFrameType
1840{
1841 VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
1842 VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
1843 VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
1844 MAX_CAMERA_FRAME_TYPES
1845};
1846
1847enum EVRDistortionFunctionType
1848{
1849 VRDistortionFunctionType_None,
1850 VRDistortionFunctionType_FTheta,
1851 VRDistortionFunctionType_Extended_FTheta,
1852 MAX_DISTORTION_FUNCTION_TYPES,
1853};
1854
1855static const uint32_t k_unMaxDistortionFunctionParameters = 8;
1856
1857typedef uint64_t TrackedCameraHandle_t;
1858#define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
1859
1860struct CameraVideoStreamFrameHeader_t
1861{
1862 EVRTrackedCameraFrameType eFrameType;
1863
1864 uint32_t nWidth;
1865 uint32_t nHeight;
1866 uint32_t nBytesPerPixel;
1867
1868 uint32_t nFrameSequence;
1869
1870 TrackedDevicePose_t trackedDevicePose;
1871
1872 uint64_t ulFrameExposureTime; // mid-point of the exposure of the image in host system ticks
1873};
1874
1875// Screenshot types
1876typedef uint32_t ScreenshotHandle_t;
1877
1878static const uint32_t k_unScreenshotHandleInvalid = 0;
1879
1880/** Compositor frame timing reprojection flags. */
1881const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01;
1882const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02;
1883const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicates the async reprojection mode is active,
1884 // but does not indicate if reprojection actually happened or not.
1885 // Use the ReprojectionReason flags above to check if reprojection
1886 // was actually applied (i.e. scene texture was reused).
1887 // NumFramePresents > 1 also indicates the scene texture was reused,
1888 // and also the number of times that it was presented in total.
1889
1890const uint32_t VRCompositor_ReprojectionMotion = 0x08; // This flag indicates whether or not motion smoothing was triggered for this frame
1891
1892const uint32_t VRCompositor_PredictionMask = 0xF0; // The runtime may predict more than one frame (up to four) ahead if
1893 // it detects the application is taking too long to render. These two
1894 // bits will contain the count of additional frames (normally zero).
1895 // Use the VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES macro to read from
1896 // the latest frame timing entry.
1897
1898const uint32_t VRCompositor_ThrottleMask = 0xF00; // Number of frames the compositor is throttling the application.
1899 // Use the VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES macro to read from
1900 // the latest frame timing entry.
1901
1902#define VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_PredictionMask ) >> 4 )
1903#define VR_COMPOSITOR_NUMBER_OF_THROTTLED_FRAMES( timing ) ( ( ( timing ).m_nReprojectionFlags & vr::VRCompositor_ThrottleMask ) >> 8 )
1904
1905/** Provides a single frame's timing information to the app */
1906struct Compositor_FrameTiming
1907{
1908 uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming )
1909 uint32_t m_nFrameIndex;
1910 uint32_t m_nNumFramePresents; // number of times this frame was presented
1911 uint32_t m_nNumMisPresented; // number of times this frame was presented on a vsync other than it was originally predicted to
1912 uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out
1913 uint32_t m_nReprojectionFlags;
1914
1915 /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */
1916 double m_flSystemTimeInSeconds;
1917
1918 /** These times may include work from other processes due to OS scheduling.
1919 * The fewer packets of work these are broken up into, the less likely this will happen.
1920 * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started
1921 * processing that work earlier in the frame. */
1922 float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit)
1923 float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window)
1924 float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work
1925 float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc.
1926 float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame
1927 float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time)
1928
1929 /** Miscellaneous measured intervals. */
1930 float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses
1931 float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long)
1932 float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure)
1933 float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue)
1934
1935 /** The following are all relative to this frame's SystemTimeInSeconds */
1936 float m_flWaitGetPosesCalledMs;
1937 float m_flNewPosesReadyMs;
1938 float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit
1939 float m_flCompositorUpdateStartMs;
1940 float m_flCompositorUpdateEndMs;
1941 float m_flCompositorRenderStartMs;
1942
1943 vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame
1944
1945 uint32_t m_nNumVSyncsReadyForUse;
1946 uint32_t m_nNumVSyncsToFirstView;
1947};
1948
1949/** Provides compositor benchmark results to the app */
1950struct Compositor_BenchmarkResults
1951{
1952 float m_flMegaPixelsPerSecond; // Measurement of GPU MP/s performed by compositor benchmark
1953 float m_flHmdRecommendedMegaPixelsPerSecond; // Recommended default MP/s given the HMD resolution, refresh, and panel mask.
1954};
1955
1956/** Frame timing data provided by direct mode drivers. */
1957struct DriverDirectMode_FrameTiming
1958{
1959 uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming )
1960 uint32_t m_nNumFramePresents; // number of times frame was presented
1961 uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to
1962 uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync)
1963 uint32_t m_nReprojectionFlags;
1964};
1965
1966/** These flags will be set on DriverDirectMode_FrameTiming::m_nReprojectionFlags when IVRDriverDirectModeComponent::GetFrameTiming is called for drivers to optionally respond to. */
1967const uint32_t VRCompositor_ReprojectionMotion_Enabled = 0x100; // Motion Smoothing is enabled in the UI for the currently running application
1968const uint32_t VRCompositor_ReprojectionMotion_ForcedOn = 0x200; // Motion Smoothing is forced on in the UI for the currently running application
1969const uint32_t VRCompositor_ReprojectionMotion_AppThrottled = 0x400; // Application is requesting throttling via ForceInterleavedReprojectionOn
1970
1971
1972enum EVSync
1973{
1974 VSync_None,
1975 VSync_WaitRender, // block following render work until vsync
1976 VSync_NoWaitRender, // do not block following render work (allow to get started early)
1977};
1978
1979enum EVRMuraCorrectionMode
1980{
1981 EVRMuraCorrectionMode_Default = 0,
1982 EVRMuraCorrectionMode_NoCorrection
1983};
1984
1985/** raw IMU data provided by IVRIOBuffer from paths to tracked devices with IMUs */
1986enum Imu_OffScaleFlags
1987{
1988 OffScale_AccelX = 0x01,
1989 OffScale_AccelY = 0x02,
1990 OffScale_AccelZ = 0x04,
1991 OffScale_GyroX = 0x08,
1992 OffScale_GyroY = 0x10,
1993 OffScale_GyroZ = 0x20,
1994};
1995
1996struct ImuSample_t
1997{
1998 double fSampleTime;
1999 HmdVector3d_t vAccel;
2000 HmdVector3d_t vGyro;
2001 uint32_t unOffScaleFlags;
2002};
2003
2004#pragma pack( pop )
2005
2006// figure out how to import from the VR API dll
2007#if defined(_WIN32)
2008
2009 #if !defined(OPENVR_BUILD_STATIC)
2010 #ifdef VR_API_EXPORT
2011 #define VR_INTERFACE extern "C" __declspec( dllexport )
2012 #else
2013 #define VR_INTERFACE extern "C" __declspec( dllimport )
2014 #endif
2015 #else
2016 #define VR_INTERFACE extern "C"
2017 #endif
2018
2019#elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
2020
2021#ifdef VR_API_EXPORT
2022 #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
2023#else
2024 #define VR_INTERFACE extern "C"
2025#endif
2026
2027#else
2028 #error "Unsupported Platform."
2029#endif
2030
2031
2032#if defined( _WIN32 )
2033 #define VR_CALLTYPE __cdecl
2034#else
2035 #define VR_CALLTYPE
2036#endif
2037
2038} // namespace vr
2039#endif // _INCLUDE_VRTYPES_H
2040
2041// vrannotation.h
2042
2043#ifdef API_GEN
2044# define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
2045#else
2046# define VR_CLANG_ATTR(ATTR)
2047#endif
2048
2049#define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
2050#define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
2051#define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
2052#define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
2053#define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
2054#define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
2055#define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
2056#define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
2057#define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
2058#define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
2059#define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
2060
2061// vrtrackedcameratypes.h
2062
2063#ifndef _VRTRACKEDCAMERATYPES_H
2064#define _VRTRACKEDCAMERATYPES_H
2065
2066namespace vr
2067{
2068
2069#pragma pack( push, 8 )
2070
2071enum ECameraVideoStreamFormat
2072{
2073 CVS_FORMAT_UNKNOWN = 0,
2074 CVS_FORMAT_RAW10 = 1, // 10 bits per pixel
2075 CVS_FORMAT_NV12 = 2, // 12 bits per pixel
2076 CVS_FORMAT_RGB24 = 3, // 24 bits per pixel
2077 CVS_FORMAT_NV12_2 = 4, // 12 bits per pixel, 2x height
2078 CVS_FORMAT_YUYV16 = 5, // 16 bits per pixel
2079 CVS_FORMAT_BAYER16BG = 6, // 16 bits per pixel, 10-bit BG-format Bayer, see https://docs.opencv.org/3.1.0/de/d25/imgproc_color_conversions.html
2080 CVS_FORMAT_MJPEG = 7, // variable-sized MJPEG Open DML format, see https://www.loc.gov/preservation/digital/formats/fdd/fdd000063.shtml
2081 CVS_MAX_FORMATS
2082};
2083
2084enum ECameraCompatibilityMode
2085{
2086 CAMERA_COMPAT_MODE_BULK_DEFAULT = 0,
2087 CAMERA_COMPAT_MODE_BULK_64K_DMA = 1,
2088 CAMERA_COMPAT_MODE_BULK_16K_DMA = 2,
2089 CAMERA_COMPAT_MODE_BULK_8K_DMA = 3,
2090 CAMERA_COMPAT_MODE_ISO_52FPS = 4,
2091 CAMERA_COMPAT_MODE_ISO_50FPS = 5,
2092 CAMERA_COMPAT_MODE_ISO_48FPS = 6,
2093 CAMERA_COMPAT_MODE_ISO_46FPS = 7,
2094 CAMERA_COMPAT_MODE_ISO_44FPS = 8,
2095 CAMERA_COMPAT_MODE_ISO_42FPS = 9,
2096 CAMERA_COMPAT_MODE_ISO_40FPS = 10,
2097 CAMERA_COMPAT_MODE_ISO_35FPS = 11,
2098 CAMERA_COMPAT_MODE_ISO_30FPS = 12,
2099 CAMERA_COMPAT_MODE_ISO_15FPS = 13,
2100 MAX_CAMERA_COMPAT_MODES
2101};
2102
2103enum ECameraRoomViewStyle
2104{
2105 CAMERA_ROOMVIEW_STYLE_DEFAULT = 0,
2106 CAMERA_ROOMVIEW_STYLE_EDGE_A = 1,
2107 CAMERA_ROOMVIEW_STYLE_EDGE_B = 2,
2108 CAMERA_ROOMVIEW_STYLE_VIDEO_TRANSLUSCENT = 3,
2109 CAMERA_ROOMVIEW_STYLE_VIDEO_OPAQUE = 4,
2110 CAMERA_ROOMVIEW_STYLE_COUNT = 5,
2111};
2112
2113#ifdef _MSC_VER
2114#define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) )
2115#else
2116#define VR_CAMERA_DECL_ALIGN( x ) //
2117#endif
2118
2119static const uint32_t k_unMaxCameras = 4;
2120static const uint32_t k_unMaxCameraFrameSharedHandles = 4;
2121
2122VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t
2123{
2124 ECameraVideoStreamFormat m_nStreamFormat;
2125
2126 uint32_t m_nWidth;
2127 uint32_t m_nHeight;
2128
2129 uint32_t m_nImageDataSize; // Based on stream format, width, height
2130
2131 uint32_t m_nFrameSequence; // Starts from 0 when stream starts.
2132
2133 uint32_t m_nBufferIndex; // Identifies which buffer the image data is hosted
2134 uint32_t m_nBufferCount; // Total number of configured buffers
2135
2136 uint32_t m_nExposureTime;
2137
2138 uint32_t m_nISPFrameTimeStamp; // Driver provided time stamp per driver centric time base
2139 uint32_t m_nISPReferenceTimeStamp;
2140 uint32_t m_nSyncCounter;
2141
2142 uint32_t m_nCamSyncEvents;
2143 uint32_t m_nISPSyncEvents;
2144
2145 double m_flReferenceCamSyncTime;
2146
2147 double m_flFrameElapsedTime; // Starts from 0 when stream starts. In seconds.
2148 double m_flFrameDeliveryRate;
2149
2150 double m_flFrameCaptureTime_DriverAbsolute; // In USB time, via AuxEvent
2151 double m_flFrameCaptureTime_ServerRelative; // In System time within the server
2152 uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks within the server
2153 double m_flFrameCaptureTime_ClientRelative; // At the client, relative to when the frame was exposed/captured.
2154
2155 double m_flSyncMarkerError;
2156
2157 TrackedDevicePose_t m_RawTrackedDevicePose; // Raw-and-uncalibrated pose, supplied by HMD layer when used as a tracked camera
2158
2159 uint64_t m_pImageData;
2160};
2161
2162#pragma pack( pop )
2163
2164}
2165
2166#endif // _VRTRACKEDCAMERATYPES_H
2167
2168// ivrsettings.h
2169
2170#include <string>
2171
2172namespace vr
2173{
2174 enum EVRSettingsError
2175 {
2176 VRSettingsError_None = 0,
2177 VRSettingsError_IPCFailed = 1,
2178 VRSettingsError_WriteFailed = 2,
2179 VRSettingsError_ReadFailed = 3,
2180 VRSettingsError_JsonParseFailed = 4,
2181 VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set
2182 };
2183
2184 // The maximum length of a settings key
2185 static const uint32_t k_unMaxSettingsKeyLength = 128;
2186
2187 class IVRSettings
2188 {
2189 public:
2190 virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
2191
2192 virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
2193 virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
2194 virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
2195 virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
2196
2197 // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory
2198 // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or ""
2199 virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
2200 virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
2201 virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
2202 virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0;
2203
2204 virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
2205 virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
2206 };
2207
2208 //-----------------------------------------------------------------------------
2209 static const char * const IVRSettings_Version = "IVRSettings_003";
2210
2211 class CVRSettingHelper
2212 {
2213 IVRSettings *m_pSettings;
2214 public:
2215 CVRSettingHelper( IVRSettings *pSettings )
2216 {
2217 m_pSettings = pSettings;
2218 }
2219
2220 const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError )
2221 {
2222 return m_pSettings->GetSettingsErrorNameFromEnum( eError );
2223 }
2224
2225 void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr )
2226 {
2227 m_pSettings->SetBool( pchSection, pchSettingsKey, bValue, peError );
2228 }
2229
2230 void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr )
2231 {
2232 m_pSettings->SetInt32( pchSection, pchSettingsKey, nValue, peError );
2233 }
2234 void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr )
2235 {
2236 m_pSettings->SetFloat( pchSection, pchSettingsKey, flValue, peError );
2237 }
2238 void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr )
2239 {
2240 m_pSettings->SetString( pchSection, pchSettingsKey, pchValue, peError );
2241 }
2242 void SetString( const std::string & sSection, const std::string & sSettingsKey, const std::string & sValue, EVRSettingsError *peError = nullptr )
2243 {
2244 m_pSettings->SetString( sSection.c_str(), sSettingsKey.c_str(), sValue.c_str(), peError );
2245 }
2246
2247 bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr )
2248 {
2249 return m_pSettings->GetBool( pchSection, pchSettingsKey, peError );
2250 }
2251 int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr )
2252 {
2253 return m_pSettings->GetInt32( pchSection, pchSettingsKey, peError );
2254 }
2255 float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr )
2256 {
2257 return m_pSettings->GetFloat( pchSection, pchSettingsKey, peError );
2258 }
2259 void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr )
2260 {
2261 m_pSettings->GetString( pchSection, pchSettingsKey, pchValue, unValueLen, peError );
2262 }
2263 std::string GetString( const std::string & sSection, const std::string & sSettingsKey, EVRSettingsError *peError = nullptr )
2264 {
2265 char buf[4096];
2266 vr::EVRSettingsError eError;
2267 m_pSettings->GetString( sSection.c_str(), sSettingsKey.c_str(), buf, sizeof( buf ), &eError );
2268 if ( peError )
2269 *peError = eError;
2270 if ( eError == vr::VRSettingsError_None )
2271 return buf;
2272 else
2273 return "";
2274 }
2275
2276 void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr )
2277 {
2278 m_pSettings->RemoveSection( pchSection, peError );
2279 }
2280 void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr )
2281 {
2282 m_pSettings->RemoveKeyInSection( pchSection, pchSettingsKey, peError );
2283 }
2284 };
2285
2286
2287 //-----------------------------------------------------------------------------
2288 // steamvr keys
2289 static const char * const k_pch_SteamVR_Section = "steamvr";
2290 static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
2291 static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
2292 static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
2293 static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
2294 static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
2295 static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
2296 static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
2297 static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
2298 static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
2299 static const char * const k_pch_SteamVR_IPD_Float = "ipd";
2300 static const char * const k_pch_SteamVR_Background_String = "background";
2301 static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection";
2302 static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
2303 static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
2304 static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
2305 static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
2306 static const char * const k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor";
2307 static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
2308 static const char * const k_pch_SteamVR_DrawTrackingReferences_Bool = "drawTrackingReferences";
2309 static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
2310 static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
2311 static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
2312 static const char * const k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement";
2313 static const char * const k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip";
2314 static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
2315 static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale";
2316 static const char * const k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution";
2317 static const char * const k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing";
2318 static const char * const k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride";
2319 static const char * const k_pch_SteamVR_FramesToThrottle_Int32 = "framesToThrottle";
2320 static const char * const k_pch_SteamVR_AdditionalFramesToPredict_Int32 = "additionalFramesToPredict";
2321 static const char * const k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync";
2322 static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
2323 static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView";
2324 static const char * const k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView";
2325 static const char * const k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView";
2326 static const char * const k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode";
2327 static const char * const k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye";
2328 static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry";
2329 static const char * const k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized";
2330 static const char * const k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph";
2331 static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch";
2332 static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch";
2333 static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch";
2334 static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard";
2335 static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp";
2336 static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec";
2337 static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo";
2338 static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset";
2339 static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering";
2340 static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride";
2341 static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync";
2342 static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode";
2343 static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver";
2344 static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor";
2345 static const char * const k_pch_SteamVR_DebugInputBinding = "debugInputBinding";
2346 static const char * const k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid";
2347 static const char * const k_pch_SteamVR_RenderCameraMode = "renderCameraMode";
2348 static const char * const k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling";
2349 static const char * const k_pch_SteamVR_EnableSafeMode = "enableSafeMode";
2350 static const char * const k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate";
2351 static const char * const k_pch_SteamVR_LastVersionNotice = "lastVersionNotice";
2352 static const char * const k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate";
2353 static const char * const k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR";
2354 static const char * const k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG";
2355 static const char * const k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB";
2356 static const char * const k_pch_SteamVR_CustomIconStyle_String = "customIconStyle";
2357 static const char * const k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle";
2358 static const char * const k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate";
2359 static const char * const k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority";
2360 static const char * const k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2";
2361 static const char * const k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption";
2362 static const char * const k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches";
2363 static const char * const k_pch_SteamVR_HDCPLegacyCompatibility_Bool = "hdcp14legacyCompatibility";
2364 static const char * const k_pch_SteamVR_UsePrism_Bool = "usePrism";
2365
2366 //-----------------------------------------------------------------------------
2367 // direct mode keys
2368 static const char * const k_pch_DirectMode_Section = "direct_mode";
2369 static const char * const k_pch_DirectMode_Enable_Bool = "enable";
2370 static const char * const k_pch_DirectMode_Count_Int32 = "count";
2371 static const char * const k_pch_DirectMode_EdidVid_Int32 = "edidVid";
2372 static const char * const k_pch_DirectMode_EdidPid_Int32 = "edidPid";
2373
2374 //-----------------------------------------------------------------------------
2375 // lighthouse keys
2376 static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
2377 static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
2378 static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd";
2379 static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
2380 static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
2381 static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
2382 static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
2383 static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth";
2384 static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations";
2385 static const char * const k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2";
2386 static const char * const k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations";
2387 static const char * const k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback";
2388
2389 //-----------------------------------------------------------------------------
2390 // null keys
2391 static const char * const k_pch_Null_Section = "driver_null";
2392 static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
2393 static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
2394 static const char * const k_pch_Null_WindowX_Int32 = "windowX";
2395 static const char * const k_pch_Null_WindowY_Int32 = "windowY";
2396 static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
2397 static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
2398 static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
2399 static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
2400 static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
2401 static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
2402
2403 //-----------------------------------------------------------------------------
2404 // Windows MR keys
2405 static const char * const k_pch_WindowsMR_Section = "driver_holographic";
2406
2407 //-----------------------------------------------------------------------------
2408 // user interface keys
2409 static const char * const k_pch_UserInterface_Section = "userinterface";
2410 static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
2411 static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray";
2412 static const char * const k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized";
2413 static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots";
2414 static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType";
2415
2416 //-----------------------------------------------------------------------------
2417 // notification keys
2418 static const char * const k_pch_Notifications_Section = "notifications";
2419 static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
2420
2421 //-----------------------------------------------------------------------------
2422 // keyboard keys
2423 static const char * const k_pch_Keyboard_Section = "keyboard";
2424 static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
2425 static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
2426 static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
2427 static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
2428 static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
2429 static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
2430 static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
2431
2432 //-----------------------------------------------------------------------------
2433 // perf keys
2434 static const char * const k_pch_Perf_Section = "perfcheck";
2435 static const char * const k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD";
2436 static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
2437 static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
2438 static const char * const k_pch_Perf_TestData_Float = "perfTestData";
2439 static const char * const k_pch_Perf_GPUProfiling_Bool = "GPUProfiling";
2440
2441 //-----------------------------------------------------------------------------
2442 // collision bounds keys
2443 static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
2444 static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
2445 static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
2446 static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
2447 static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
2448 static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
2449 static const char * const k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight";
2450 static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
2451 static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
2452 static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
2453 static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
2454 static const char * const k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport";
2455
2456 //-----------------------------------------------------------------------------
2457 // camera keys
2458 static const char * const k_pch_Camera_Section = "camera";
2459 static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
2460 static const char * const k_pch_Camera_ShowOnController_Bool = "showOnController";
2461 static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
2462 static const char * const k_pch_Camera_RoomView_Int32 = "roomView";
2463 static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
2464 static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
2465 static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
2466 static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
2467 static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength";
2468 static const char * const k_pch_Camera_RoomViewStyle_Int32 = "roomViewStyle";
2469
2470 //-----------------------------------------------------------------------------
2471 // audio keys
2472 static const char * const k_pch_audio_Section = "audio";
2473 static const char * const k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice";
2474 static const char * const k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride";
2475 static const char * const k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride";
2476 static const char * const k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName";
2477 static const char * const k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice";
2478 static const char * const k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride";
2479 static const char * const k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride";
2480 static const char * const k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName";
2481 static const char * const k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror";
2482 static const char * const k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice";
2483 static const char * const k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName";
2484 static const char * const k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
2485 static const char * const k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice";
2486 static const char * const k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume";
2487 static const char * const k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId";
2488 static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
2489 static const char * const k_pch_audio_DualSpeakerAndJackOutput_Bool = "dualSpeakerAndJackOutput";
2490 static const char * const k_pch_audio_MuteMicMonitor_Bool = "muteMicMonitor";
2491
2492 //-----------------------------------------------------------------------------
2493 // power management keys
2494 static const char * const k_pch_Power_Section = "power";
2495 static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit";
2496 static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout";
2497 static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout";
2498 static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout";
2499 static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress";
2500 static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby";
2501
2502 //-----------------------------------------------------------------------------
2503 // dashboard keys
2504 static const char * const k_pch_Dashboard_Section = "dashboard";
2505 static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard";
2506 static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode";
2507 static const char * const k_pch_Dashboard_Position = "position";
2508 static const char * const k_pch_Dashboard_DesktopScale = "desktopScale";
2509 static const char * const k_pch_Dashboard_DashboardScale = "dashboardScale";
2510 static const char * const k_pch_Dashboard_UseStandaloneSystemLayer = "standaloneSystemLayer";
2511
2512 //-----------------------------------------------------------------------------
2513 // model skin keys
2514 static const char * const k_pch_modelskin_Section = "modelskins";
2515
2516 //-----------------------------------------------------------------------------
2517 // driver keys - These could be checked in any driver_<name> section
2518 static const char * const k_pch_Driver_Enable_Bool = "enable";
2519 static const char * const k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode";
2520 static const char * const k_pch_Driver_LoadPriority_Int32 = "loadPriority";
2521
2522 //-----------------------------------------------------------------------------
2523 // web interface keys
2524 static const char* const k_pch_WebInterface_Section = "WebInterface";
2525
2526 //-----------------------------------------------------------------------------
2527 // vrwebhelper keys
2528 static const char* const k_pch_VRWebHelper_Section = "VRWebHelper";
2529 static const char* const k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled";
2530 static const char* const k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort";
2531
2532 //-----------------------------------------------------------------------------
2533 // tracking overrides - keys are device paths, values are the device paths their
2534 // tracking/pose information overrides
2535 static const char* const k_pch_TrackingOverride_Section = "TrackingOverrides";
2536
2537 //-----------------------------------------------------------------------------
2538 // per-app keys - the section name for these is the app key itself. Some of these are prefixed by the controller type
2539 static const char* const k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL";
2540 static const char* const k_pch_App_BindingLegacyAPISuffix_String = "_legacy";
2541 static const char* const k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput";
2542 static const char* const k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL";
2543 static const char* const k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL";
2544 static const char* const k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave";
2545 static const char* const k_pch_App_DominantHand_Int32 = "DominantHand";
2546 static const char* const k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK";
2547
2548 //-----------------------------------------------------------------------------
2549 // configuration for trackers
2550 static const char * const k_pch_Trackers_Section = "trackers";
2551
2552 //-----------------------------------------------------------------------------
2553 // configuration for desktop UI windows
2554 static const char * const k_pch_DesktopUI_Section = "DesktopUI";
2555
2556 //-----------------------------------------------------------------------------
2557 // Last known keys for righting recovery
2558 static const char * const k_pch_LastKnown_Section = "LastKnown";
2559 static const char* const k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer";
2560 static const char* const k_pch_LastKnown_HMDModel_String = "HMDModel";
2561
2562 //-----------------------------------------------------------------------------
2563 // Dismissed warnings
2564 static const char * const k_pch_DismissedWarnings_Section = "DismissedWarnings";
2565
2566 //-----------------------------------------------------------------------------
2567 // Input Settings
2568 static const char * const k_pch_Input_Section = "input";
2569 static const char* const k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation";
2570 static const char* const k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation";
2571 static const char* const k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone";
2572
2573 //-----------------------------------------------------------------------------
2574 // Log of GPU performance
2575 static const char * const k_pch_GpuSpeed_Section = "GpuSpeed";
2576
2577} // namespace vr
2578
2579// iservertrackeddevicedriver.h
2580
2581namespace vr
2582{
2583
2584
2585struct DriverPoseQuaternion_t
2586{
2587 double w, x, y, z;
2588};
2589
2590struct DriverPose_t
2591{
2592 /* Time offset of this pose, in seconds from the actual time of the pose,
2593 * relative to the time of the PoseUpdated() call made by the driver.
2594 */
2595 double poseTimeOffset;
2596
2597 /* Generally, the pose maintained by a driver
2598 * is in an inertial coordinate system different
2599 * from the world system of x+ right, y+ up, z+ back.
2600 * Also, the driver is not usually tracking the "head" position,
2601 * but instead an internal IMU or another reference point in the HMD.
2602 * The following two transforms transform positions and orientations
2603 * to app world space from driver world space,
2604 * and to HMD head space from driver local body space.
2605 *
2606 * We maintain the driver pose state in its internal coordinate system,
2607 * so we can do the pose prediction math without having to
2608 * use angular acceleration. A driver's angular acceleration is generally not measured,
2609 * and is instead calculated from successive samples of angular velocity.
2610 * This leads to a noisy angular acceleration values, which are also
2611 * lagged due to the filtering required to reduce noise to an acceptable level.
2612 */
2613 vr::HmdQuaternion_t qWorldFromDriverRotation;
2614 double vecWorldFromDriverTranslation[ 3 ];
2615
2616 vr::HmdQuaternion_t qDriverFromHeadRotation;
2617 double vecDriverFromHeadTranslation[ 3 ];
2618
2619 /* State of driver pose, in meters and radians. */
2620 /* Position of the driver tracking reference in driver world space
2621 * +[0] (x) is right
2622 * +[1] (y) is up
2623 * -[2] (z) is forward
2624 */
2625 double vecPosition[ 3 ];
2626
2627 /* Velocity of the pose in meters/second */
2628 double vecVelocity[ 3 ];
2629
2630 /* Acceleration of the pose in meters/second */
2631 double vecAcceleration[ 3 ];
2632
2633 /* Orientation of the tracker, represented as a quaternion */
2634 vr::HmdQuaternion_t qRotation;
2635
2636 /* Angular velocity of the pose in axis-angle
2637 * representation. The direction is the angle of
2638 * rotation and the magnitude is the angle around
2639 * that axis in radians/second. */
2640 double vecAngularVelocity[ 3 ];
2641
2642 /* Angular acceleration of the pose in axis-angle
2643 * representation. The direction is the angle of
2644 * rotation and the magnitude is the angle around
2645 * that axis in radians/second^2. */
2646 double vecAngularAcceleration[ 3 ];
2647
2648 ETrackingResult result;
2649
2650 bool poseIsValid;
2651 bool willDriftInYaw;
2652 bool shouldApplyHeadModel;
2653 bool deviceIsConnected;
2654};
2655
2656
2657// ----------------------------------------------------------------------------------------------
2658// Purpose: Represents a single tracked device in a driver
2659// ----------------------------------------------------------------------------------------------
2660class ITrackedDeviceServerDriver
2661{
2662public:
2663
2664 // ------------------------------------
2665 // Management Methods
2666 // ------------------------------------
2667 /** This is called before an HMD is returned to the application. It will always be
2668 * called before any display or tracking methods. Memory and processor use by the
2669 * ITrackedDeviceServerDriver object should be kept to a minimum until it is activated.
2670 * The pose listener is guaranteed to be valid until Deactivate is called, but
2671 * should not be used after that point. */
2672 virtual EVRInitError Activate( uint32_t unObjectId ) = 0;
2673
2674 /** This is called when The VR system is switching from this Hmd being the active display
2675 * to another Hmd being the active display. The driver should clean whatever memory
2676 * and thread use it can when it is deactivated */
2677 virtual void Deactivate() = 0;
2678
2679 /** Handles a request from the system to put this device into standby mode. What that means is defined per-device. */
2680 virtual void EnterStandby() = 0;
2681
2682 /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL
2683 * if the requested interface or version is not supported. */
2684 virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0;
2685
2686 /** A VR Client has made this debug request of the driver. The set of valid requests is entirely
2687 * up to the driver and the client to figure out, as is the format of the response. Responses that
2688 * exceed the length of the supplied buffer should be truncated and null terminated */
2689 virtual void DebugRequest( const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
2690
2691 // ------------------------------------
2692 // Tracking Methods
2693 // ------------------------------------
2694 virtual DriverPose_t GetPose() = 0;
2695};
2696
2697
2698
2699static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_005";
2700
2701}
2702
2703// ivrdisplaycomponent.h
2704
2705namespace vr
2706{
2707
2708
2709 // ----------------------------------------------------------------------------------------------
2710 // Purpose: The display component on a single tracked device
2711 // ----------------------------------------------------------------------------------------------
2712 class IVRDisplayComponent
2713 {
2714 public:
2715
2716 // ------------------------------------
2717 // Display Methods
2718 // ------------------------------------
2719
2720 /** Size and position that the window needs to be on the VR display. */
2721 virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
2722
2723 /** Returns true if the display is extending the desktop. */
2724 virtual bool IsDisplayOnDesktop( ) = 0;
2725
2726 /** Returns true if the display is real and not a fictional display. */
2727 virtual bool IsDisplayRealDisplay( ) = 0;
2728
2729 /** Suggested size for the intermediate render target that the distortion pulls from. */
2730 virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
2731
2732 /** Gets the viewport in the frame buffer to draw the output of the distortion into */
2733 virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
2734
2735 /** The components necessary to build your own projection matrix in case your
2736 * application is doing something fancy like infinite Z */
2737 virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
2738
2739 /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
2740 * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
2741 virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0;
2742
2743 };
2744
2745 static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_002";
2746 static const char *IVRDisplayComponent_Version3 = "IVRDisplayComponent_003";
2747
2748}
2749
2750// ivrdriverdirectmodecomponent.h
2751
2752namespace vr
2753{
2754 enum VRSwapTextureFlag
2755 {
2756 // Specify that the shared texture resource was created with the SHARED_NTHANDLE option (Windows)
2757 VRSwapTextureFlag_Shared_NTHandle = 1 << 0,
2758 };
2759
2760 // ----------------------------------------------------------------------------------------------
2761 // Purpose: This component is used for drivers that implement direct mode entirely on their own
2762 // without allowing the VR Compositor to own the window/device.
2763 // ----------------------------------------------------------------------------------------------
2764 class IVRDriverDirectModeComponent
2765 {
2766 public:
2767
2768 // -----------------------------------
2769 // Direct mode methods
2770 // -----------------------------------
2771
2772 struct SwapTextureSetDesc_t
2773 {
2774 uint32_t nWidth;
2775 uint32_t nHeight;
2776 uint32_t nFormat;
2777 uint32_t nSampleCount;
2778 };
2779
2780 struct SwapTextureSet_t
2781 {
2782 vr::SharedTextureHandle_t rSharedTextureHandles[ 3 ];
2783 uint32_t unTextureFlags;
2784 };
2785
2786 /** Called to allocate textures for applications to render into. One of these per eye will be passed back to SubmitLayer each frame. */
2787 virtual void CreateSwapTextureSet( uint32_t unPid, const SwapTextureSetDesc_t *pSwapTextureSetDesc, SwapTextureSet_t *pOutSwapTextureSet ) {}
2788
2789 /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */
2790 virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sharedTextureHandle ) {}
2791
2792 /** Used to purge all texture sets for a given process. */
2793 virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {}
2794
2795 /** After Present returns, calls this to get the next index to use for rendering. */
2796 virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {}
2797
2798 /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created
2799 * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */
2800 struct SubmitLayerPerEye_t
2801 {
2802 // Shared texture handles (depth not always provided).
2803 vr::SharedTextureHandle_t hTexture, hDepthTexture;
2804
2805 // Valid region of provided texture (and depth).
2806 vr::VRTextureBounds_t bounds;
2807
2808 // Projection matrix used to render the depth buffer.
2809 vr::HmdMatrix44_t mProjection;
2810
2811 // Hmd pose used to render this layer.
2812 vr::HmdMatrix34_t mHmdPose;
2813 };
2814 virtual void SubmitLayer( const SubmitLayerPerEye_t( &perEye )[ 2 ] ) {}
2815
2816 /** Submits queued layers for display. */
2817 virtual void Present( vr::SharedTextureHandle_t syncTexture ) {}
2818
2819 /** Called after Present to allow driver to take more time until vsync after they've successfully acquired the sync texture in Present.*/
2820 virtual void PostPresent() {}
2821
2822 /** Called to get additional frame timing stats from driver. Check m_nSize for versioning (new members will be added to end only). */
2823 virtual void GetFrameTiming( DriverDirectMode_FrameTiming *pFrameTiming ) {}
2824 };
2825
2826 static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_007";
2827
2828}
2829
2830// ivrcameracomponent.h
2831
2832namespace vr
2833{
2834 //-----------------------------------------------------------------------------
2835 //-----------------------------------------------------------------------------
2836 class ICameraVideoSinkCallback
2837 {
2838 public:
2839 virtual void OnCameraVideoSinkCallback() = 0;
2840 };
2841
2842 // ----------------------------------------------------------------------------------------------
2843 // Purpose: The camera on a single tracked device
2844 // ----------------------------------------------------------------------------------------------
2845 class IVRCameraComponent
2846 {
2847 public:
2848 // ------------------------------------
2849 // Camera Methods
2850 // ------------------------------------
2851 virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFormat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0;
2852 virtual bool GetCameraFrameBufferingRequirements( int *pDefaultFrameQueueSize, uint32_t *pFrameBufferDataSize ) = 0;
2853 virtual bool SetCameraFrameBuffering( int nFrameBufferCount, void **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0;
2854 virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamFormat nVideoStreamFormat ) = 0;
2855 virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat() = 0;
2856 virtual bool StartVideoStream() = 0;
2857 virtual void StopVideoStream() = 0;
2858 virtual bool IsVideoStreamActive( bool *pbPaused, float *pflElapsedTime ) = 0;
2859 virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame() = 0;
2860 virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStreamFrame_t *pFrameImage ) = 0;
2861 virtual bool SetAutoExposure( bool bEnable ) = 0;
2862 virtual bool PauseVideoStream() = 0;
2863 virtual bool ResumeVideoStream() = 0;
2864 virtual bool GetCameraDistortion( uint32_t nCameraIndex, float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0;
2865 virtual bool GetCameraProjection( uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
2866 virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0;
2867 virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0;
2868 virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0;
2869 virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0;
2870 virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0;
2871 virtual bool GetCameraIntrinsics( uint32_t nCameraIndex, vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter, vr::EVRDistortionFunctionType *peDistortionType, double rCoefficients[ k_unMaxDistortionFunctionParameters ] ) = 0;
2872 };
2873
2874 static const char *IVRCameraComponent_Version = "IVRCameraComponent_003";
2875}
2876
2877// itrackeddevicedriverprovider.h
2878
2879namespace vr
2880{
2881
2882class ITrackedDeviceServerDriver;
2883struct TrackedDeviceDriverInfo_t;
2884struct DriverPose_t;
2885
2886/** This interface is provided by vrserver to allow the driver to notify
2887* the system when something changes about a device. These changes must
2888* not change the serial number or class of the device because those values
2889* are permanently associated with the device's index. */
2890class IVRDriverContext
2891{
2892public:
2893 /** Returns the requested interface. If the interface was not available it will return NULL and fill
2894 * out the error. */
2895 virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError = nullptr ) = 0;
2896
2897 /** Returns the property container handle for this driver */
2898 virtual DriverHandle_t GetDriverHandle() = 0;
2899};
2900
2901
2902/** This interface must be implemented in each driver. It will be loaded in vrserver.exe */
2903class IServerTrackedDeviceProvider
2904{
2905public:
2906 /** initializes the driver. This will be called before any other methods are called.
2907 * If Init returns anything other than VRInitError_None the driver DLL will be unloaded.
2908 *
2909 * pDriverHost will never be NULL, and will always be a pointer to a IServerDriverHost interface
2910 *
2911 * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user
2912 * config files.
2913 * pchDriverInstallDir - The absolute path of the root directory for the driver.
2914 */
2915 virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
2916
2917 /** cleans up the driver right before it is unloaded */
2918 virtual void Cleanup() = 0;
2919
2920 /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */
2921 virtual const char * const *GetInterfaceVersions() = 0;
2922
2923 /** Allows the driver do to some work in the main loop of the server. */
2924 virtual void RunFrame() = 0;
2925
2926
2927 // ------------ Power State Functions ----------------------- //
2928
2929 /** Returns true if the driver wants to block Standby mode. */
2930 virtual bool ShouldBlockStandbyMode() = 0;
2931
2932 /** Called when the system is entering Standby mode. The driver should switch itself into whatever sort of low-power
2933 * state it has. */
2934 virtual void EnterStandby() = 0;
2935
2936 /** Called when the system is leaving Standby mode. The driver should switch itself back to
2937 full operation. */
2938 virtual void LeaveStandby() = 0;
2939
2940};
2941
2942
2943static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_004";
2944
2945
2946
2947
2948/** This interface must be implemented in each driver. It will be loaded in vrclient.dll */
2949class IVRWatchdogProvider
2950{
2951public:
2952 /** initializes the driver in watchdog mode. */
2953 virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
2954
2955 /** cleans up the driver right before it is unloaded */
2956 virtual void Cleanup() = 0;
2957};
2958
2959static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001";
2960
2961
2962
2963
2964/** This is an optional interface drivers may implement. It will be loaded in vrcompositor.exe */
2965class IVRCompositorPluginProvider
2966{
2967public:
2968 /** initializes the driver when used to load compositor plugins */
2969 virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
2970
2971 /** cleans up the driver right before it is unloaded */
2972 virtual void Cleanup() = 0;
2973
2974 /** Returns the versions of interfaces used by this driver */
2975 virtual const char * const *GetInterfaceVersions() = 0;
2976
2977 /** Requests a component interface of the driver for specific functionality. The driver should return NULL
2978 * if the requested interface or version is not supported. */
2979 virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0;
2980};
2981
2982static const char *IVRCompositorPluginProvider_Version = "IVRCompositorPluginProvider_001";
2983
2984}
2985
2986// ivrproperties.h
2987
2988#include <string>
2989#include <vector>
2990
2991namespace vr
2992{
2993
2994 /** This container is automatically created before a display redirect device is activated.
2995 * Any properties in this container will be returned when that property is read from the HMD's
2996 * property container. */
2997 static const PropertyContainerHandle_t k_ulDisplayRedirectContainer = 0x600000003;
2998
2999 enum EPropertyWriteType
3000 {
3001 PropertyWrite_Set = 0,
3002 PropertyWrite_Erase = 1,
3003 PropertyWrite_SetError = 2
3004 };
3005
3006 struct PropertyWrite_t
3007 {
3008 ETrackedDeviceProperty prop;
3009 EPropertyWriteType writeType;
3010 ETrackedPropertyError eSetError;
3011 void *pvBuffer;
3012 uint32_t unBufferSize;
3013 PropertyTypeTag_t unTag;
3014 ETrackedPropertyError eError;
3015 };
3016
3017 struct PropertyRead_t
3018 {
3019 ETrackedDeviceProperty prop;
3020 void *pvBuffer;
3021 uint32_t unBufferSize;
3022 PropertyTypeTag_t unTag;
3023 uint32_t unRequiredBufferSize;
3024 ETrackedPropertyError eError;
3025 };
3026
3027
3028class IVRProperties
3029{
3030public:
3031
3032 /** Reads a set of properties atomically. See the PropertyReadBatch_t struct for more information. */
3033 virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0;
3034
3035 /** Writes a set of properties atomically. See the PropertyWriteBatch_t struct for more information. */
3036 virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0;
3037
3038 /** returns a string that corresponds with the specified property error. The string will be the name
3039 * of the error enum value for all valid error codes */
3040 virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0;
3041
3042 /** Returns a container handle given a tracked device index */
3043 virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) = 0;
3044};
3045
3046static const char * const IVRProperties_Version = "IVRProperties_001";
3047
3048class CVRPropertyHelpers
3049{
3050public:
3051 CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProperties ) {}
3052
3053 /** Returns a scaler property. If the device index is not valid or the property value type does not match,
3054 * this function will return false. */
3055 bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3056 float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3057 int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3058 uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3059 HmdVector2_t GetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3060 HmdVector3_t GetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3061 HmdVector4_t GetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3062 double GetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
3063
3064 /** Returns a single typed property. If the device index is not valid or the property is not a string type this function will
3065 * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
3066 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
3067 uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L );
3068
3069
3070 /** Returns a string property. If the device index is not valid or the property is not a string type this function will
3071 * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
3072 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
3073 uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L );
3074
3075 /** 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
3076 * return an empty string. */
3077 std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr );
3078
3079 /** Reads a std::vector of data from a property. */
3080 template< typename T>
3081 ETrackedPropertyError GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults );
3082
3083 /** Sets a scaler property. The new value will be returned on any subsequent call to get this property in any process. */
3084 ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue );
3085 ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue );
3086 ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue );
3087 ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue );
3088 ETrackedPropertyError SetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector2_t & vNewValue );
3089 ETrackedPropertyError SetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector3_t & vNewValue );
3090 ETrackedPropertyError SetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector4_t & vNewValue );
3091 ETrackedPropertyError SetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, double vNewValue );
3092
3093 /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
3094 ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue );
3095
3096 /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
3097 ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag );
3098
3099 /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
3100 ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError );
3101
3102 /** Clears any value or error set for the property. */
3103 ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop );
3104
3105 /* Turns a device index into a property container handle. */
3106 PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDevice ); }
3107
3108 /** Sets a std::vector of typed data to a property. */
3109 template< typename T>
3110 ETrackedPropertyError SetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *vecProperties );
3111
3112 /** Returns true if the specified property is set on the specified container */
3113 bool IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError = nullptr );
3114private:
3115 template<typename T>
3116 T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag );
3117
3118 IVRProperties *m_pProperties;
3119};
3120
3121
3122inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError )
3123{
3124 PropertyRead_t batch;
3125 batch.prop = prop;
3126 batch.pvBuffer = pvBuffer;
3127 batch.unBufferSize = unBufferSize;
3128
3129 m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 );
3130
3131 if ( pError )
3132 {
3133 *pError = batch.eError;
3134 }
3135
3136 if ( punTag )
3137 {
3138 *punTag = batch.unTag;
3139 }
3140
3141 return batch.unRequiredBufferSize;
3142}
3143
3144
3145/** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
3146inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag )
3147{
3148 PropertyWrite_t batch;
3149 batch.writeType = PropertyWrite_Set;
3150 batch.prop = prop;
3151 batch.pvBuffer = pvNewValue;
3152 batch.unBufferSize = unNewValueSize;
3153 batch.unTag = unTag;
3154
3155 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
3156
3157 return batch.eError;
3158}
3159
3160
3161/** Returns a string property. If the device index is not valid or the property is not a string type this function will
3162* return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
3163* null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
3164inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError )
3165{
3166 PropertyTypeTag_t unTag;
3167 ETrackedPropertyError error;
3168 uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue, unBufferSize, &unTag, &error );
3169 if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success )
3170 {
3171 error = TrackedProp_WrongDataType;
3172 }
3173
3174 if ( pError )
3175 {
3176 *pError = error;
3177 }
3178
3179 if ( error != TrackedProp_Success )
3180 {
3181 if ( pchValue && unBufferSize )
3182 {
3183 *pchValue = '\0';
3184 }
3185 }
3186
3187 return unRequiredSize;
3188}
3189
3190
3191/** 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
3192* return an empty string. */
3193inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError )
3194{
3195 char buf[1024];
3196 vr::ETrackedPropertyError err;
3197 uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf, sizeof(buf), &err );
3198
3199 std::string sResult;
3200
3201 if ( err == TrackedProp_Success )
3202 {
3203 sResult = buf;
3204 }
3205 else if ( err == TrackedProp_BufferTooSmall )
3206 {
3207 char *pchBuffer = new char[unRequiredBufferLen];
3208 unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchBuffer, unRequiredBufferLen, &err );
3209 sResult = pchBuffer;
3210 delete[] pchBuffer;
3211 }
3212
3213 if ( peError )
3214 {
3215 *peError = err;
3216 }
3217
3218 return sResult;
3219}
3220
3221
3222/** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
3223inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue )
3224{
3225 if ( !pchNewValue )
3226 return TrackedProp_InvalidOperation;
3227
3228 // this is strlen without the dependency on string.h
3229 const char *pchCurr = pchNewValue;
3230 while ( *pchCurr )
3231 {
3232 pchCurr++;
3233 }
3234
3235 return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint32_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag );
3236}
3237
3238
3239template<typename T>
3240inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag )
3241{
3242 T bValue;
3243 ETrackedPropertyError eError;
3244 PropertyTypeTag_t unReadTag;
3245 GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unReadTag, &eError );
3246 if ( unReadTag != unTypeTag && eError == TrackedProp_Success )
3247 {
3248 eError = TrackedProp_WrongDataType;
3249 };
3250
3251 if ( pError )
3252 *pError = eError;
3253 if ( eError != TrackedProp_Success )
3254 {
3255 return bDefault;
3256 }
3257 else
3258 {
3259 return bValue;
3260 }
3261}
3262
3263
3264inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3265{
3266 return GetPropertyHelper<bool>( ulContainerHandle, prop, pError, false, k_unBoolPropertyTag );
3267}
3268
3269inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3270{
3271 return GetPropertyHelper<float>( ulContainerHandle, prop, pError, 0.f, k_unFloatPropertyTag );
3272}
3273
3274inline double CVRPropertyHelpers::GetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3275{
3276 return GetPropertyHelper<double>( ulContainerHandle, prop, pError, 0., k_unDoublePropertyTag );
3277}
3278
3279inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3280{
3281 return GetPropertyHelper<int32_t>( ulContainerHandle, prop, pError, 0, k_unInt32PropertyTag );
3282}
3283
3284inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3285{
3286 return GetPropertyHelper<uint64_t>( ulContainerHandle, prop, pError, 0, k_unUint64PropertyTag );
3287}
3288
3289inline HmdVector2_t CVRPropertyHelpers::GetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3290{
3291 HmdVector2_t defaultval = { 0 };
3292 return GetPropertyHelper<HmdVector2_t>( ulContainerHandle, prop, pError, defaultval, k_unHmdVector2PropertyTag );
3293}
3294
3295inline HmdVector3_t CVRPropertyHelpers::GetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3296{
3297 HmdVector3_t defaultval = { 0 };
3298 return GetPropertyHelper<HmdVector3_t>( ulContainerHandle, prop, pError, defaultval, k_unHmdVector3PropertyTag );
3299}
3300
3301inline HmdVector4_t CVRPropertyHelpers::GetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
3302{
3303 HmdVector4_t defaultval = { 0 };
3304 return GetPropertyHelper<HmdVector4_t>( ulContainerHandle, prop, pError, defaultval, k_unHmdVector4PropertyTag );
3305}
3306
3307inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue )
3308{
3309 return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewValue ), k_unBoolPropertyTag );
3310}
3311
3312inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue )
3313{
3314 return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unFloatPropertyTag );
3315}
3316
3317inline ETrackedPropertyError CVRPropertyHelpers::SetDoubleProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, double fNewValue )
3318{
3319 return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unDoublePropertyTag );
3320}
3321
3322inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue )
3323{
3324 return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewValue ), k_unInt32PropertyTag );
3325}
3326
3327inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue )
3328{
3329 return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewValue ), k_unUint64PropertyTag );
3330}
3331
3332inline ETrackedPropertyError CVRPropertyHelpers::SetVec2Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector2_t & vNewValue )
3333{
3334 return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector2_t ), k_unHmdVector2PropertyTag );
3335}
3336
3337inline ETrackedPropertyError CVRPropertyHelpers::SetVec3Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector3_t & vNewValue )
3338{
3339 return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector3_t ), k_unHmdVector3PropertyTag );
3340}
3341
3342inline ETrackedPropertyError CVRPropertyHelpers::SetVec4Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const HmdVector4_t & vNewValue )
3343{
3344 return SetProperty( ulContainerHandle, prop, ( void * ) &vNewValue, sizeof( HmdVector4_t ), k_unHmdVector4PropertyTag );
3345}
3346
3347/** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
3348inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError )
3349{
3350 PropertyWrite_t batch;
3351 batch.writeType = PropertyWrite_SetError;
3352 batch.prop = prop;
3353 batch.eSetError = eError;
3354
3355 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
3356
3357 return batch.eError;
3358}
3359
3360/** Clears any value or error set for the property. */
3361inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop )
3362{
3363 PropertyWrite_t batch;
3364 batch.writeType = PropertyWrite_Erase;
3365 batch.prop = prop;
3366
3367 m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
3368
3369 return batch.eError;
3370
3371}
3372
3373template< typename T >
3374ETrackedPropertyError CVRPropertyHelpers::SetPropertyVector(PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, PropertyTypeTag_t unTag, std::vector<T> *pvecProperties)
3375{
3376 return SetProperty( ulContainer, prop, &(*pvecProperties)[0], (uint32_t)(pvecProperties->size() * sizeof( T )), unTag );
3377}
3378
3379template< typename T >
3380ETrackedPropertyError CVRPropertyHelpers::GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults )
3381{
3382 ETrackedPropertyError err;
3383 PropertyTypeTag_t unTag;
3384 uint32_t unNeeded;
3385 if ( pvecResults->empty() )
3386 unNeeded = GetProperty( ulContainer, prop, nullptr, 0, &unTag, &err );
3387 else
3388 unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err );
3389 uint32_t unFound = unNeeded / sizeof( T );
3390 if ( err == TrackedProp_Success )
3391 {
3392 if ( unTag != unExpectedTag && unFound > 0 )
3393 {
3394 return TrackedProp_WrongDataType;
3395 }
3396
3397 pvecResults->resize( unFound );
3398 return TrackedProp_Success;
3399 }
3400 else if ( err == TrackedProp_BufferTooSmall )
3401 {
3402 pvecResults->resize( unFound );
3403 unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err );
3404 unFound = unNeeded / sizeof( T );
3405
3406 if ( err == TrackedProp_Success )
3407 {
3408 if ( unTag != unExpectedTag )
3409 {
3410 return TrackedProp_WrongDataType;
3411 }
3412
3413 pvecResults->resize( unFound );
3414 return TrackedProp_Success;
3415 }
3416 }
3417 return err;
3418}
3419
3420inline bool CVRPropertyHelpers::IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError )
3421{
3422 ETrackedPropertyError error;
3423 GetProperty( ulContainer, prop, nullptr, 0, nullptr, &error );
3424 if ( peError )
3425 *peError = error;
3426 return error == TrackedProp_Success || error == TrackedProp_BufferTooSmall;
3427}
3428
3429}
3430
3431
3432
3433// ivrdriverinput.h
3434
3435namespace vr
3436{
3437
3438 typedef uint64_t VRInputComponentHandle_t;
3439 static const VRInputComponentHandle_t k_ulInvalidInputComponentHandle = 0;
3440
3441 enum EVRScalarType
3442 {
3443 VRScalarType_Absolute = 0,
3444 VRScalarType_Relative = 1,
3445 };
3446
3447
3448 enum EVRScalarUnits
3449 {
3450 VRScalarUnits_NormalizedOneSided = 0, // Value ranges from 0 to 1
3451 VRScalarUnits_NormalizedTwoSided = 1, // Value ranges from -1 to 1
3452 };
3453
3454 class IVRDriverInput
3455 {
3456 public:
3457
3458 /** Creates a boolean input component for the device */
3459 virtual EVRInputError CreateBooleanComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0;
3460
3461 /** Updates a boolean component */
3462 virtual EVRInputError UpdateBooleanComponent( VRInputComponentHandle_t ulComponent, bool bNewValue, double fTimeOffset ) = 0;
3463
3464 /** Creates a scalar input component for the device */
3465 virtual EVRInputError CreateScalarComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle, EVRScalarType eType, EVRScalarUnits eUnits ) = 0;
3466
3467 /** Updates a boolean component */
3468 virtual EVRInputError UpdateScalarComponent( VRInputComponentHandle_t ulComponent, float fNewValue, double fTimeOffset ) = 0;
3469
3470 /** Creates a haptic component for the device */
3471 virtual EVRInputError CreateHapticComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0;
3472
3473 /** Creates a skeleton component. */
3474 virtual EVRInputError CreateSkeletonComponent( PropertyContainerHandle_t ulContainer, const char *pchName, const char *pchSkeletonPath, const char *pchBasePosePath, EVRSkeletalTrackingLevel eSkeletalTrackingLevel, const VRBoneTransform_t *pGripLimitTransforms, uint32_t unGripLimitTransformCount, VRInputComponentHandle_t *pHandle ) = 0;
3475
3476 /** Updates a skeleton component. */
3477 virtual EVRInputError UpdateSkeletonComponent( VRInputComponentHandle_t ulComponent, EVRSkeletalMotionRange eMotionRange, const VRBoneTransform_t *pTransforms, uint32_t unTransformCount ) = 0;
3478
3479 };
3480
3481 static const char * const IVRDriverInput_Version = "IVRDriverInput_003";
3482
3483} // namespace vr
3484
3485// ivrdriverlog.h
3486
3487namespace vr
3488{
3489
3490class IVRDriverLog
3491{
3492public:
3493 /** Writes a log message to the log file prefixed with the driver name */
3494 virtual void Log( const char *pchLogMessage ) = 0;
3495};
3496
3497
3498static const char *IVRDriverLog_Version = "IVRDriverLog_001";
3499
3500}
3501
3502// ivrserverdriverhost.h
3503
3504namespace vr
3505{
3506
3507class ITrackedDeviceServerDriver;
3508struct TrackedDeviceDriverInfo_t;
3509struct DriverPose_t;
3510
3511/** This interface is provided by vrserver to allow the driver to notify
3512* the system when something changes about a device. These changes must
3513* not change the serial number or class of the device because those values
3514* are permanently associated with the device's index. */
3515class IVRServerDriverHost
3516{
3517public:
3518 /** Notifies the server that a tracked device has been added. If this function returns true
3519 * the server will call Activate on the device. If it returns false some kind of error
3520 * has occurred and the device will not be activated. */
3521 virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETrackedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0;
3522
3523 /** Notifies the server that a tracked device's pose has been updated */
3524 virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose, uint32_t unPoseStructSize ) = 0;
3525
3526 /** Notifies the server that vsync has occurred on the the display attached to the device. This is
3527 * only permitted on devices of the HMD class. */
3528 virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0;
3529
3530 /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */
3531 virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0;
3532
3533 /** Returns true if SteamVR is exiting */
3534 virtual bool IsExiting() = 0;
3535
3536 /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
3537 * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
3538 virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
3539
3540 /** Provides access to device poses for drivers. Poses are in their "raw" tracking space which is uniquely
3541 * defined by each driver providing poses for its devices. It is up to clients of this function to correlate
3542 * poses across different drivers. Poses are indexed by their device id, and their associated driver and
3543 * other properties can be looked up via IVRProperties. */
3544 virtual void GetRawTrackedDevicePoses( float fPredictedSecondsFromNow, TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0;
3545
3546 /** Requests that SteamVR be restarted. The provided reason will be displayed to the user and should be in the current locale. */
3547 virtual void RequestRestart( const char *pchLocalizedReason, const char *pchExecutableToStart, const char *pchArguments, const char *pchWorkingDirectory ) = 0;
3548
3549 /** Interface for copying a range of timing data. Frames are returned in ascending order (oldest to newest) with the last being the most recent frame.
3550 * Only the first entry's m_nSize needs to be set, as the rest will be inferred from that. Returns total number of entries filled out. */
3551 virtual uint32_t GetFrameTimings( Compositor_FrameTiming *pTiming, uint32_t nFrames ) = 0;
3552
3553 /** Notifies the server that a tracked device's display component transforms have been updated.
3554 * only permitted on devices of the HMD class. */
3555 virtual void SetDisplayEyeToHead( uint32_t unWhichDevice, const HmdMatrix34_t & eyeToHeadLeft, const HmdMatrix34_t & eyeToHeadRight ) = 0;
3556
3557 /** Notifies the server that a tracked device's display projection has changed.
3558 * only permitted on devices of the HMD class. */
3559 virtual void SetDisplayProjectionRaw( uint32_t unWhichDevice, const HmdRect2_t & eyeLeft, const HmdRect2_t & eyeRight ) = 0;
3560
3561 /** Notifies the server that a tracked device's recommended render target resolution has changed.
3562 * only permitted on devices of the HMD class. */
3563 virtual void SetRecommendedRenderTargetSize( uint32_t unWhichDevice, uint32_t nWidth, uint32_t nHeight ) = 0;
3564};
3565
3566static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_006";
3567
3568}
3569
3570// ivrcompositordriverhost.h
3571
3572namespace vr
3573{
3574
3575class IVRCompositorDriverHost
3576{
3577public:
3578 /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
3579 * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
3580 virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
3581};
3582
3583static const char *IVRCompositorDriverHost_Version = "IVRCompositorDriverHost_001";
3584
3585}
3586
3587// ivrhiddenarea.h
3588
3589namespace vr
3590{
3591
3592class CVRHiddenAreaHelpers
3593{
3594public:
3595 CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pProperties ) {}
3596
3597 /** Stores a hidden area mesh in a property */
3598 ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount );
3599
3600 /** retrieves a hidden area mesh from a property. Returns the vert count read out of the property. */
3601 uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError );
3602
3603private:
3604 ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType type )
3605 {
3606 return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_Start + ((int)type * 2) + (int)eEye);
3607 }
3608
3609 IVRProperties *m_pProperties;
3610};
3611
3612
3613inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount )
3614{
3615 ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
3616 CVRPropertyHelpers propHelpers( m_pProperties );
3617 return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVertCount, k_unHiddenAreaPropertyTag );
3618}
3619
3620
3621inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError )
3622{
3623 ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
3624 CVRPropertyHelpers propHelpers( m_pProperties );
3625 ETrackedPropertyError propError;
3626 PropertyTypeTag_t unTag;
3627 uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t )*unVertCount, &unTag, &propError );
3628 if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaPropertyTag )
3629 {
3630 propError = TrackedProp_WrongDataType;
3631 unBytesNeeded = 0;
3632 }
3633
3634 if ( peError )
3635 {
3636 *peError = propError;
3637 }
3638
3639 return unBytesNeeded / sizeof( HmdVector2_t );
3640}
3641
3642}
3643
3644// ivrwatchdoghost.h
3645
3646namespace vr
3647{
3648
3649/** This interface is provided by vrclient to allow the driver to make everything wake up */
3650class IVRWatchdogHost
3651{
3652public:
3653 /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should
3654 * cause SteamVR to start */
3655 virtual void WatchdogWakeUp( vr::ETrackedDeviceClass eDeviceClass ) = 0;
3656};
3657
3658static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_002";
3659
3660}
3661
3662
3663
3664// ivrvirtualdisplay.h
3665
3666namespace vr
3667{
3668 struct PresentInfo_t
3669 {
3670 SharedTextureHandle_t backbufferTextureHandle;
3671 EVSync vsync;
3672 uint64_t nFrameId;
3673 double flVSyncTimeInSeconds;
3674 };
3675
3676 // ----------------------------------------------------------------------------------------------
3677 // Purpose: This component is used for drivers that implement a virtual display (e.g. wireless).
3678 // ----------------------------------------------------------------------------------------------
3679 class IVRVirtualDisplay
3680 {
3681 public:
3682
3683 /** Submits final backbuffer for display. */
3684 virtual void Present( const PresentInfo_t *pPresentInfo, uint32_t unPresentInfoSize ) = 0;
3685
3686 /** Block until the last presented buffer start scanning out. */
3687 virtual void WaitForPresent() = 0;
3688
3689 /** Provides timing data for synchronizing with display. */
3690 virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0;
3691 };
3692
3693 static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_002";
3694}
3695
3696
3697// ivrresources.h
3698
3699namespace vr
3700{
3701
3702class IVRResources
3703{
3704public:
3705
3706 // ------------------------------------
3707 // Shared Resource Methods
3708 // ------------------------------------
3709
3710 /** Loads the specified resource into the provided buffer if large enough.
3711 * Returns the size in bytes of the buffer required to hold the specified resource. */
3712 virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0;
3713
3714 /** Provides the full path to the specified resource. Resource names can include named directories for
3715 * drivers and other things, and this resolves all of those and returns the actual physical path.
3716 * pchResourceTypeDirectory is the subdirectory of resources to look in. */
3717 virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0;
3718};
3719
3720static const char * const IVRResources_Version = "IVRResources_001";
3721
3722
3723}
3724
3725// ivriobuffer.h
3726
3727namespace vr
3728{
3729
3730typedef uint64_t IOBufferHandle_t;
3731static const uint64_t k_ulInvalidIOBufferHandle = 0;
3732
3733 enum EIOBufferError
3734 {
3735 IOBuffer_Success = 0,
3736 IOBuffer_OperationFailed = 100,
3737 IOBuffer_InvalidHandle = 101,
3738 IOBuffer_InvalidArgument = 102,
3739 IOBuffer_PathExists = 103,
3740 IOBuffer_PathDoesNotExist = 104,
3741 IOBuffer_Permission = 105,
3742 };
3743
3744 enum EIOBufferMode
3745 {
3746 IOBufferMode_Read = 0x0001,
3747 IOBufferMode_Write = 0x0002,
3748 IOBufferMode_Create = 0x0200,
3749 };
3750
3751 // ----------------------------------------------------------------------------------------------
3752 // Purpose:
3753 // ----------------------------------------------------------------------------------------------
3754 class IVRIOBuffer
3755 {
3756 public:
3757 /** opens an existing or creates a new IOBuffer of unSize bytes */
3758 virtual vr::EIOBufferError Open( const char *pchPath, vr::EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, vr::IOBufferHandle_t *pulBuffer ) = 0;
3759
3760 /** closes a previously opened or created buffer */
3761 virtual vr::EIOBufferError Close( vr::IOBufferHandle_t ulBuffer ) = 0;
3762
3763 /** reads up to unBytes from buffer into *pDst, returning number of bytes read in *punRead */
3764 virtual vr::EIOBufferError Read( vr::IOBufferHandle_t ulBuffer, void *pDst, uint32_t unBytes, uint32_t *punRead ) = 0;
3765
3766 /** writes unBytes of data from *pSrc into a buffer. */
3767 virtual vr::EIOBufferError Write( vr::IOBufferHandle_t ulBuffer, void *pSrc, uint32_t unBytes ) = 0;
3768
3769 /** retrieves the property container of an buffer. */
3770 virtual vr::PropertyContainerHandle_t PropertyContainer( vr::IOBufferHandle_t ulBuffer ) = 0;
3771
3772 /** inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes. */
3773 virtual bool HasReaders( vr::IOBufferHandle_t ulBuffer ) = 0;
3774 };
3775
3776 static const char *IVRIOBuffer_Version = "IVRIOBuffer_002";
3777}
3778
3779// ivrdrivermanager.h
3780
3781namespace vr
3782{
3783
3784class IVRDriverManager
3785{
3786public:
3787 virtual uint32_t GetDriverCount() const = 0;
3788
3789 /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */
3790 virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0;
3791
3792 virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0;
3793
3794 virtual bool IsEnabled( vr::DriverId_t nDriver ) const = 0;
3795};
3796
3797static const char * const IVRDriverManager_Version = "IVRDriverManager_001";
3798
3799} // namespace vr
3800
3801
3802
3803// ivrdriverspatialanchors.h
3804
3805namespace vr
3806{
3807 struct SpatialAnchorDriverPose_t
3808 {
3809 /** This position is in the same "world" space (+Y up) as provided by DriverPose_t. */
3810 vr::HmdQuaternion_t qWorldRotation;
3811 vr::HmdVector3d_t vWorldTranslation;
3812
3813 /** The pose will automatically start returning VRSpatialAnchorError_NotAvailableInThisUniverse
3814 * if this is nonzero and does not match the current universe ID. */
3815 uint64_t ulRequiredUniverseId;
3816
3817 /** When this time expires, SteamVR will start generating
3818 * VREvent_SpatialAnchors_RequestPoseUpdate when the pose is read by an application
3819 * to let the driver know it is still worth updating.
3820 * You can use this facility in several ways:
3821 * 1. Set to -1 to never receive an update request for this pose. The driver
3822 * may still update poses at any time.
3823 * 2. Set to 0 to always receive an update request *after* each time the pose
3824 * is read. The rate of requests could be very high if the application gets
3825 * the pose at framerate.
3826 * 3. If the driver knows there is no reason to update the pose for some amount of
3827 * time, it can set that time here and receive the update request reminder later.
3828 * 4. If the driver plans to automatically update this pose for some amount of time
3829 * (as it gets better information about the virtual location of this anchor) it can
3830 * set that duration here to indicate that no "update requested" reminders are needed.
3831 * When that automatic update period expires, any future interest in the pose will
3832 * be indicated by a pose update request.
3833 * The driver may always update the pose, including during the valid duration. */
3834 double fValidDuration; // seconds
3835 };
3836
3837 class IVRDriverSpatialAnchors
3838 {
3839 public:
3840
3841 /* NOTE: You must declare support for spatial anchors in your driver manifest. Add
3842 * "spatialAnchorsSupport": true to your manifest. Without that setting, SteamVR
3843 * will short-circuit anchor requests from applications and provide a generic descriptor
3844 * that does not have any of the advantages of true spatial anchors. */
3845
3846 /* The driver should monitor for events VREvent_SpatialAnchors_RequestPoseUpdate (for new
3847 * descriptors from applications that need UpdateSpatialAnchorPose()) and for
3848 * VREvent_SpatialAnchors_RequestDescriptorUpdate (for new poses that need UpdateSpatialAnchorDescriptor()).
3849 * For automatic pose updates over time, the driver should keep track of the handles it
3850 * has seen and provide updates when conditions change. If the driver uses fValidDuration,
3851 * it may wait for VREvent_SpatialAnchors_RequestPoseUpdate instead of keeping track itself. */
3852
3853 /** Update a pose for a spatial anchor. Should be called when an event notifies the driver that a
3854 * new descriptor has been registered by an application. May be called for any anchor whenever the
3855 * driver has better information about the best virtual coordinate to represent the anchor. Should
3856 * be called on all active handles whenever driver state changes in a way that changes how physical
3857 * world locations map to virtual coordinates (e.g. anything that would cause a universe ID change).
3858 * This fires an event when it is called for the first time (to alert whoever submitted the descriptor). */
3859 virtual EVRSpatialAnchorError UpdateSpatialAnchorPose( SpatialAnchorHandle_t unHandle, const SpatialAnchorDriverPose_t *pPose ) = 0;
3860
3861 /** Invalidate any pose associated with the handle and cause future calls to GetSpatialAnchorPose (on
3862 * both the client and driver side) to return the specified error. eError must be one of
3863 * VRSpatialAnchorError_NotYetAvailable, VRSpatialAnchorError_NotAvailableInThisUniverse, or
3864 * VRSpatialAnchorError_PermanentlyUnavailable */
3865 virtual EVRSpatialAnchorError SetSpatialAnchorPoseError( SpatialAnchorHandle_t unHandle, EVRSpatialAnchorError eError, double fValidDuration ) = 0;
3866
3867 /** Update the descriptor for a spatial anchor. Should be called when an event notifies the driver
3868 * that a new pose has been registered by an application. May be called for any anchor whenever the
3869 * driver has better or additional information it wants to include in the anchor descriptor. Note,
3870 * however, that the application may never fetch the updated anchor descriptor and may request the
3871 * original descriptor in a future session having ignored the update.
3872 * The supplied descriptor should be only the driver's opaque internal data, not the decorated form that
3873 * is used by clients (wrapped by runtime metadata). The descriptor must not contain non-ASCII characters or
3874 * the two special characters ~ or "
3875 * This fires an event every time it is called. */
3876 virtual EVRSpatialAnchorError UpdateSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, const char *pchDescriptor ) = 0;
3877
3878 /** Get the pose for a given handle. */
3879 virtual EVRSpatialAnchorError GetSpatialAnchorPose( SpatialAnchorHandle_t unHandle, SpatialAnchorDriverPose_t *pDriverPoseOut ) = 0;
3880
3881 /** Get the descriptor for a given handle. This will be VRSpatialAnchorError_NotYetAvailable for handles
3882 * where the driver has not yet built a descriptor. It will be the application-supplied descriptor for previously
3883 * saved anchors that the application is requesting poses for. If the driver has called UpdateSpatialAnchorDescriptor()
3884 * already in this session, it will be the descriptor provided by the driver.
3885 * If bDecorated, returns the descriptor wrapped with runtime metadata suitable for a client to save. Else returns only
3886 * the driver's opaque internal data.
3887 */
3888 virtual EVRSpatialAnchorError GetSpatialAnchorDescriptor( SpatialAnchorHandle_t unHandle, VR_OUT_STRING() char *pchDescriptorOut, uint32_t *punDescriptorBufferLenInOut, bool bDecorated ) = 0;
3889
3890 };
3891
3892 static const char * const IVRDriverSpatialAnchors_Version = "IVRDriverSpatialAnchors_001";
3893
3894} // namespace vr
3895
3896
3897
3898namespace vr
3899{
3900#if !defined( OPENVR_INTERFACE_INTERNAL )
3901 static const char * const k_InterfaceVersions[] =
3902 {
3903 IVRSettings_Version,
3904 ITrackedDeviceServerDriver_Version,
3905 IVRDisplayComponent_Version,
3906 IVRDriverDirectModeComponent_Version,
3907 IVRCameraComponent_Version,
3908 IServerTrackedDeviceProvider_Version,
3909 IVRWatchdogProvider_Version,
3910 IVRVirtualDisplay_Version,
3911 IVRDriverManager_Version,
3912 IVRResources_Version,
3913 IVRCompositorPluginProvider_Version,
3914 nullptr
3915 };
3916
3917 inline IVRDriverContext *&VRDriverContext()
3918 {
3919 static IVRDriverContext *pHost;
3920 return pHost;
3921 }
3922
3923 class COpenVRDriverContext
3924 {
3925 public:
3926 COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAreaHelpers(nullptr) { Clear(); }
3927 void Clear();
3928
3929 EVRInitError InitServer();
3930 EVRInitError InitWatchdog();
3931 EVRInitError InitCompositor();
3932
3933 IVRSettings *VRSettings()
3934 {
3935 if ( m_pVRSettings == nullptr )
3936 {
3937 EVRInitError eError;
3938 m_pVRSettings = (IVRSettings *)VRDriverContext()->GetGenericInterface( IVRSettings_Version, &eError );
3939 }
3940 return m_pVRSettings;
3941 }
3942
3943 IVRProperties *VRPropertiesRaw()
3944 {
3945 if ( m_pVRProperties == nullptr )
3946 {
3947 EVRInitError eError;
3948 m_pVRProperties = (IVRProperties *)VRDriverContext()->GetGenericInterface( IVRProperties_Version, &eError );
3949 m_propertyHelpers = CVRPropertyHelpers( m_pVRProperties );
3950 m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pVRProperties );
3951 }
3952 return m_pVRProperties;
3953 }
3954
3955 CVRPropertyHelpers *VRProperties()
3956 {
3957 VRPropertiesRaw();
3958 return &m_propertyHelpers;
3959 }
3960
3961 CVRHiddenAreaHelpers *VRHiddenArea()
3962 {
3963 VRPropertiesRaw();
3964 return &m_hiddenAreaHelpers;
3965 }
3966
3967 IVRServerDriverHost *VRServerDriverHost()
3968 {
3969 if ( m_pVRServerDriverHost == nullptr )
3970 {
3971 EVRInitError eError;
3972 m_pVRServerDriverHost = (IVRServerDriverHost *)VRDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError );
3973 }
3974 return m_pVRServerDriverHost;
3975 }
3976
3977 IVRWatchdogHost *VRWatchdogHost()
3978 {
3979 if ( m_pVRWatchdogHost == nullptr )
3980 {
3981 EVRInitError eError;
3982 m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverContext()->GetGenericInterface( IVRWatchdogHost_Version, &eError );
3983 }
3984 return m_pVRWatchdogHost;
3985 }
3986
3987 IVRCompositorDriverHost *VRCompositorDriverHost()
3988 {
3989 if ( m_pVRCompositorDriverHost == nullptr )
3990 {
3991 EVRInitError eError;
3992 m_pVRCompositorDriverHost = ( IVRCompositorDriverHost * )VRDriverContext()->GetGenericInterface( IVRCompositorDriverHost_Version, &eError );
3993 }
3994 return m_pVRCompositorDriverHost;
3995 }
3996
3997 IVRDriverLog *VRDriverLog()
3998 {
3999 if ( m_pVRDriverLog == nullptr )
4000 {
4001 EVRInitError eError;
4002 m_pVRDriverLog = (IVRDriverLog *)VRDriverContext()->GetGenericInterface( IVRDriverLog_Version, &eError );
4003 }
4004 return m_pVRDriverLog;
4005 }
4006
4007 DriverHandle_t VR_CALLTYPE VRDriverHandle()
4008 {
4009 return VRDriverContext()->GetDriverHandle();
4010 }
4011
4012 IVRDriverManager *VRDriverManager()
4013 {
4014 if ( !m_pVRDriverManager )
4015 {
4016 EVRInitError eError;
4017 m_pVRDriverManager = (IVRDriverManager *)VRDriverContext()->GetGenericInterface( IVRDriverManager_Version, &eError );
4018 }
4019 return m_pVRDriverManager;
4020 }
4021
4022 IVRResources *VRResources()
4023 {
4024 if ( !m_pVRResources )
4025 {
4026 EVRInitError eError;
4027 m_pVRResources = (IVRResources *)VRDriverContext()->GetGenericInterface( IVRResources_Version, &eError );
4028 }
4029 return m_pVRResources;
4030 }
4031
4032 IVRDriverInput *VRDriverInput()
4033 {
4034 if ( !m_pVRDriverInput )
4035 {
4036 EVRInitError eError;
4037 m_pVRDriverInput = (IVRDriverInput *)VRDriverContext()->GetGenericInterface( IVRDriverInput_Version, &eError );
4038 }
4039 return m_pVRDriverInput;
4040 }
4041
4042 IVRIOBuffer *VRIOBuffer()
4043 {
4044 if ( !m_pVRIOBuffer )
4045 {
4046 EVRInitError eError;
4047 m_pVRIOBuffer = (IVRIOBuffer *)VRDriverContext()->GetGenericInterface( IVRIOBuffer_Version, &eError );
4048 }
4049 return m_pVRIOBuffer;
4050 }
4051
4052 IVRDriverSpatialAnchors *VRDriverSpatialAnchors()
4053 {
4054 if ( !m_pVRDriverSpatialAnchors )
4055 {
4056 EVRInitError eError;
4057 m_pVRDriverSpatialAnchors = (IVRDriverSpatialAnchors *)VRDriverContext()->GetGenericInterface( IVRDriverSpatialAnchors_Version, &eError );
4058 }
4059 return m_pVRDriverSpatialAnchors;
4060 }
4061
4062 private:
4063 CVRPropertyHelpers m_propertyHelpers;
4064 CVRHiddenAreaHelpers m_hiddenAreaHelpers;
4065
4066 IVRSettings *m_pVRSettings;
4067 IVRProperties *m_pVRProperties;
4068 IVRServerDriverHost *m_pVRServerDriverHost;
4069 IVRWatchdogHost *m_pVRWatchdogHost;
4070 IVRCompositorDriverHost *m_pVRCompositorDriverHost;
4071 IVRDriverLog *m_pVRDriverLog;
4072 IVRDriverManager *m_pVRDriverManager;
4073 IVRResources *m_pVRResources;
4074 IVRDriverInput *m_pVRDriverInput;
4075 IVRIOBuffer *m_pVRIOBuffer;
4076 IVRDriverSpatialAnchors *m_pVRDriverSpatialAnchors;
4077 };
4078
4079 inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext()
4080 {
4081 static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void * )];
4082 return *(COpenVRDriverContext *)ctx; // bypass zero-init constructor
4083 }
4084
4085 inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleServerDriverContext().VRSettings(); }
4086 inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInternal_ModuleServerDriverContext().VRPropertiesRaw(); }
4087 inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInternal_ModuleServerDriverContext().VRProperties(); }
4088 inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRInternal_ModuleServerDriverContext().VRHiddenArea(); }
4089 inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_ModuleServerDriverContext().VRDriverLog(); }
4090 inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRServerDriverHost(); }
4091 inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInternal_ModuleServerDriverContext().VRWatchdogHost(); }
4092 inline IVRCompositorDriverHost *VR_CALLTYPE VRCompositorDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRCompositorDriverHost(); }
4093 inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRInternal_ModuleServerDriverContext().VRDriverHandle(); }
4094 inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleServerDriverContext().VRDriverManager(); }
4095 inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleServerDriverContext().VRResources(); }
4096 inline IVRDriverInput *VR_CALLTYPE VRDriverInput() { return OpenVRInternal_ModuleServerDriverContext().VRDriverInput(); }
4097 inline IVRIOBuffer *VR_CALLTYPE VRIOBuffer() { return OpenVRInternal_ModuleServerDriverContext().VRIOBuffer(); }
4098 inline IVRDriverSpatialAnchors *VR_CALLTYPE VRDriverSpatialAnchors() { return OpenVRInternal_ModuleServerDriverContext().VRDriverSpatialAnchors(); }
4099
4100 inline void COpenVRDriverContext::Clear()
4101 {
4102 m_pVRSettings = nullptr;
4103 m_pVRProperties = nullptr;
4104 m_pVRServerDriverHost = nullptr;
4105 m_pVRWatchdogHost = nullptr;
4106 m_pVRCompositorDriverHost = nullptr;
4107 m_pVRDriverLog = nullptr;
4108 m_pVRDriverManager = nullptr;
4109 m_pVRResources = nullptr;
4110 m_pVRDriverInput = nullptr;
4111 m_pVRIOBuffer = nullptr;
4112 m_pVRDriverSpatialAnchors = nullptr;
4113 }
4114
4115 inline EVRInitError COpenVRDriverContext::InitServer()
4116 {
4117 Clear();
4118 if ( !VRServerDriverHost()
4119 || !VRSettings()
4120 || !VRProperties()
4121 || !VRDriverLog()
4122 || !VRDriverManager()
4123 || !VRResources() )
4124 return VRInitError_Init_InterfaceNotFound;
4125 return VRInitError_None;
4126 }
4127
4128 inline EVRInitError COpenVRDriverContext::InitWatchdog()
4129 {
4130 Clear();
4131 if ( !VRWatchdogHost()
4132 || !VRSettings()
4133 || !VRDriverLog() )
4134 return VRInitError_Init_InterfaceNotFound;
4135 return VRInitError_None;
4136 }
4137
4138 inline EVRInitError COpenVRDriverContext::InitCompositor()
4139 {
4140 Clear();
4141 if ( !VRCompositorDriverHost()
4142 || !VRSettings()
4143 || !VRProperties()
4144 || !VRDriverLog()
4145 || !VRDriverManager()
4146 || !VRResources() )
4147 return VRInitError_Init_InterfaceNotFound;
4148 return VRInitError_None;
4149 }
4150
4151 inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext )
4152 {
4153 VRDriverContext() = pContext;
4154 return OpenVRInternal_ModuleServerDriverContext().InitServer();
4155 }
4156
4157 inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContext )
4158 {
4159 VRDriverContext() = pContext;
4160 return OpenVRInternal_ModuleServerDriverContext().InitWatchdog();
4161 }
4162
4163 inline EVRInitError InitCompositorDriverContext( IVRDriverContext *pContext )
4164 {
4165 VRDriverContext() = pContext;
4166 return OpenVRInternal_ModuleServerDriverContext().InitCompositor();
4167 }
4168
4169 inline void CleanupDriverContext()
4170 {
4171 VRDriverContext() = nullptr;
4172 OpenVRInternal_ModuleServerDriverContext().Clear();
4173 }
4174
4175 #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \
4176 { \
4177 vr::EVRInitError eError = vr::InitServerDriverContext( pContext ); \
4178 if( eError != vr::VRInitError_None ) \
4179 return eError; \
4180 }
4181
4182 #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \
4183 vr::CleanupDriverContext();
4184
4185 #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \
4186 { \
4187 vr::EVRInitError eError = vr::InitWatchdogDriverContext( pContext ); \
4188 if( eError != vr::VRInitError_None ) \
4189 return eError; \
4190 }
4191
4192 #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \
4193 vr::CleanupDriverContext();
4194
4195#define VR_INIT_COMPOSITOR_DRIVER_CONTEXT( pContext ) \
4196 { \
4197 vr::EVRInitError eError = vr::InitCompositorDriverContext( pContext ); \
4198 if( eError != vr::VRInitError_None ) \
4199 return eError; \
4200 }
4201
4202#define VR_CLEANUP_COMPOSITOR_DRIVER_CONTEXT() \
4203 vr::CleanupDriverContext();
4204
4205
4206#endif // OPENVR_INTERFACE_INTERNAL
4207
4208}
4209// End
4210
4211#endif // _OPENVR_DRIVER_API
4212
4213