1 #pragma once
2
3 // openvr.h
4 //========= Copyright Valve Corporation ============//
5 // Dynamically generated file. Do not modify this file directly.
6
7 #ifndef _OPENVR_API
8 #define _OPENVR_API
9
10 #include <stdint.h>
11
12 // vrtypes.h
13 #ifndef _INCLUDE_VRTYPES_H
14 #define _INCLUDE_VRTYPES_H
15
16 // Forward declarations to avoid requiring vulkan.h
17 struct VkDevice_T;
18 struct VkPhysicalDevice_T;
19 struct VkInstance_T;
20 struct VkQueue_T;
21
22 // Forward declarations to avoid requiring d3d12.h
23 struct ID3D12Resource;
24 struct ID3D12CommandQueue;
25
26 namespace vr
27 {
28 #pragma pack(push, 8)
29
30 typedef void *glSharedTextureHandle_t;
31 typedef int32_t glInt_t;
32 typedef uint32_t glUInt_t;
33
34 // right-handed system
35 // +y is up
36 // +x is to the right
37 // -z is going away from you
38 // Distance unit is meters
39 struct HmdMatrix34_t
40 {
41 float m[3][4];
42 };
43
44 struct HmdMatrix44_t
45 {
46 float m[4][4];
47 };
48
49 struct HmdVector3_t
50 {
51 float v[3];
52 };
53
54 struct HmdVector4_t
55 {
56 float v[4];
57 };
58
59 struct HmdVector3d_t
60 {
61 double v[3];
62 };
63
64 struct HmdVector2_t
65 {
66 float v[2];
67 };
68
69 struct HmdQuaternion_t
70 {
71 double w, x, y, z;
72 };
73
74 struct HmdColor_t
75 {
76 float r, g, b, a;
77 };
78
79 struct HmdQuad_t
80 {
81 HmdVector3_t vCorners[4];
82 };
83
84 struct HmdRect2_t
85 {
86 HmdVector2_t vTopLeft;
87 HmdVector2_t vBottomRight;
88 };
89
90 /** Used to return the post-distortion UVs for each color channel.
91 * UVs range from 0 to 1 with 0,0 in the upper left corner of the
92 * source render target. The 0,0 to 1,1 range covers a single eye. */
93 struct DistortionCoordinates_t
94 {
95 float rfRed[2];
96 float rfGreen[2];
97 float rfBlue[2];
98 };
99
100 enum EVREye
101 {
102 Eye_Left = 0,
103 Eye_Right = 1
104 };
105
106 enum ETextureType
107 {
108 TextureType_DirectX = 0, // Handle is an ID3D11Texture
109 TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags
110 TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure
111 TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef
112 TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure
113 };
114
115 enum EColorSpace
116 {
117 ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
118 ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
119 ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
120 };
121
122 struct Texture_t
123 {
124 void *handle; // See ETextureType definition above
125 ETextureType eType;
126 EColorSpace eColorSpace;
127 };
128
129 // Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource).
130 typedef uint64_t SharedTextureHandle_t;
131 #define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0)
132
133 enum ETrackingResult
134 {
135 TrackingResult_Uninitialized = 1,
136
137 TrackingResult_Calibrating_InProgress = 100,
138 TrackingResult_Calibrating_OutOfRange = 101,
139
140 TrackingResult_Running_OK = 200,
141 TrackingResult_Running_OutOfRange = 201,
142 };
143
144 typedef uint32_t DriverId_t;
145 static const uint32_t k_nDriverNone = 0xFFFFFFFF;
146
147 static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
148
149 /** Used to pass device IDs to API calls */
150 typedef uint32_t TrackedDeviceIndex_t;
151 static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
152 static const uint32_t k_unMaxTrackedDeviceCount = 16;
153 static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
154 static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
155
156 /** Describes what kind of object is being tracked at a given ID */
157 enum ETrackedDeviceClass
158 {
159 TrackedDeviceClass_Invalid = 0, // the ID was not valid.
160 TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
161 TrackedDeviceClass_Controller = 2, // Tracked controllers
162 TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers
163 TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
164 TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
165 };
166
167 /** Describes what specific role associated with a tracked device */
168 enum ETrackedControllerRole
169 {
170 TrackedControllerRole_Invalid = 0, // Invalid value for controller type
171 TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
172 TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
173 };
174
175 /** describes a single pose for a tracked object */
176 struct TrackedDevicePose_t
177 {
178 HmdMatrix34_t mDeviceToAbsoluteTracking;
179 HmdVector3_t vVelocity; // velocity in tracker space in m/s
180 HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
181 ETrackingResult eTrackingResult;
182 bool bPoseIsValid;
183
184 // This indicates that there is a device connected for this spot in the pose array.
185 // It could go from true to false if the user unplugs the device.
186 bool bDeviceIsConnected;
187 };
188
189 /** Identifies which style of tracking origin the application wants to use
190 * for the poses it is requesting */
191 enum ETrackingUniverseOrigin
192 {
193 TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
194 TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
195 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.
196 };
197
198 // Refers to a single container of properties
199 typedef uint64_t PropertyContainerHandle_t;
200 typedef uint32_t PropertyTypeTag_t;
201
202 static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0;
203 static const PropertyTypeTag_t k_unInvalidPropertyTag = 0;
204
205 // Use these tags to set/get common types as struct properties
206 static const PropertyTypeTag_t k_unFloatPropertyTag = 1;
207 static const PropertyTypeTag_t k_unInt32PropertyTag = 2;
208 static const PropertyTypeTag_t k_unUint64PropertyTag = 3;
209 static const PropertyTypeTag_t k_unBoolPropertyTag = 4;
210 static const PropertyTypeTag_t k_unStringPropertyTag = 5;
211
212 static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20;
213 static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21;
214 static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22;
215 static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23;
216
217 static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30;
218
219 static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000;
220 static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000;
221
222 /** Each entry in this enum represents a property that can be retrieved about a
223 * tracked device. Many fields are only valid for one ETrackedDeviceClass. */
224 enum ETrackedDeviceProperty
225 {
226 Prop_Invalid = 0,
227
228 // general properties that apply to all device classes
229 Prop_TrackingSystemName_String = 1000,
230 Prop_ModelNumber_String = 1001,
231 Prop_SerialNumber_String = 1002,
232 Prop_RenderModelName_String = 1003,
233 Prop_WillDriftInYaw_Bool = 1004,
234 Prop_ManufacturerName_String = 1005,
235 Prop_TrackingFirmwareVersion_String = 1006,
236 Prop_HardwareRevision_String = 1007,
237 Prop_AllWirelessDongleDescriptions_String = 1008,
238 Prop_ConnectedWirelessDongle_String = 1009,
239 Prop_DeviceIsWireless_Bool = 1010,
240 Prop_DeviceIsCharging_Bool = 1011,
241 Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
242 Prop_StatusDisplayTransform_Matrix34 = 1013,
243 Prop_Firmware_UpdateAvailable_Bool = 1014,
244 Prop_Firmware_ManualUpdate_Bool = 1015,
245 Prop_Firmware_ManualUpdateURL_String = 1016,
246 Prop_HardwareRevision_Uint64 = 1017,
247 Prop_FirmwareVersion_Uint64 = 1018,
248 Prop_FPGAVersion_Uint64 = 1019,
249 Prop_VRCVersion_Uint64 = 1020,
250 Prop_RadioVersion_Uint64 = 1021,
251 Prop_DongleVersion_Uint64 = 1022,
252 Prop_BlockServerShutdown_Bool = 1023,
253 Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
254 Prop_ContainsProximitySensor_Bool = 1025,
255 Prop_DeviceProvidesBatteryStatus_Bool = 1026,
256 Prop_DeviceCanPowerOff_Bool = 1027,
257 Prop_Firmware_ProgrammingTarget_String = 1028,
258 Prop_DeviceClass_Int32 = 1029,
259 Prop_HasCamera_Bool = 1030,
260 Prop_DriverVersion_String = 1031,
261 Prop_Firmware_ForceUpdateRequired_Bool = 1032,
262 Prop_ViveSystemButtonFixRequired_Bool = 1033,
263 Prop_ParentDriver_Uint64 = 1034,
264 Prop_ResourceRoot_String = 1035,
265
266 // Properties that are unique to TrackedDeviceClass_HMD
267 Prop_ReportsTimeSinceVSync_Bool = 2000,
268 Prop_SecondsFromVsyncToPhotons_Float = 2001,
269 Prop_DisplayFrequency_Float = 2002,
270 Prop_UserIpdMeters_Float = 2003,
271 Prop_CurrentUniverseId_Uint64 = 2004,
272 Prop_PreviousUniverseId_Uint64 = 2005,
273 Prop_DisplayFirmwareVersion_Uint64 = 2006,
274 Prop_IsOnDesktop_Bool = 2007,
275 Prop_DisplayMCType_Int32 = 2008,
276 Prop_DisplayMCOffset_Float = 2009,
277 Prop_DisplayMCScale_Float = 2010,
278 Prop_EdidVendorID_Int32 = 2011,
279 Prop_DisplayMCImageLeft_String = 2012,
280 Prop_DisplayMCImageRight_String = 2013,
281 Prop_DisplayGCBlackClamp_Float = 2014,
282 Prop_EdidProductID_Int32 = 2015,
283 Prop_CameraToHeadTransform_Matrix34 = 2016,
284 Prop_DisplayGCType_Int32 = 2017,
285 Prop_DisplayGCOffset_Float = 2018,
286 Prop_DisplayGCScale_Float = 2019,
287 Prop_DisplayGCPrescale_Float = 2020,
288 Prop_DisplayGCImage_String = 2021,
289 Prop_LensCenterLeftU_Float = 2022,
290 Prop_LensCenterLeftV_Float = 2023,
291 Prop_LensCenterRightU_Float = 2024,
292 Prop_LensCenterRightV_Float = 2025,
293 Prop_UserHeadToEyeDepthMeters_Float = 2026,
294 Prop_CameraFirmwareVersion_Uint64 = 2027,
295 Prop_CameraFirmwareDescription_String = 2028,
296 Prop_DisplayFPGAVersion_Uint64 = 2029,
297 Prop_DisplayBootloaderVersion_Uint64 = 2030,
298 Prop_DisplayHardwareVersion_Uint64 = 2031,
299 Prop_AudioFirmwareVersion_Uint64 = 2032,
300 Prop_CameraCompatibilityMode_Int32 = 2033,
301 Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
302 Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
303 Prop_DisplaySuppressed_Bool = 2036,
304 Prop_DisplayAllowNightMode_Bool = 2037,
305 Prop_DisplayMCImageWidth_Int32 = 2038,
306 Prop_DisplayMCImageHeight_Int32 = 2039,
307 Prop_DisplayMCImageNumChannels_Int32 = 2040,
308 Prop_DisplayMCImageData_Binary = 2041,
309 Prop_SecondsFromPhotonsToVblank_Float = 2042,
310 Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043,
311 Prop_DisplayDebugMode_Bool = 2044,
312 Prop_GraphicsAdapterLuid_Uint64 = 2045,
313 Prop_DriverProvidedChaperonePath_String = 2048,
314
315 // Properties that are unique to TrackedDeviceClass_Controller
316 Prop_AttachedDeviceId_String = 3000,
317 Prop_SupportedButtons_Uint64 = 3001,
318 Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
319 Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
320 Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
321 Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
322 Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
323 Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole
324
325 // Properties that are unique to TrackedDeviceClass_TrackingReference
326 Prop_FieldOfViewLeftDegrees_Float = 4000,
327 Prop_FieldOfViewRightDegrees_Float = 4001,
328 Prop_FieldOfViewTopDegrees_Float = 4002,
329 Prop_FieldOfViewBottomDegrees_Float = 4003,
330 Prop_TrackingRangeMinimumMeters_Float = 4004,
331 Prop_TrackingRangeMaximumMeters_Float = 4005,
332 Prop_ModeLabel_String = 4006,
333
334 // Properties that are used for user interface like icons names
335 Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties.
336 Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
337 Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
338 Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
339 Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
340 Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
341 Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
342 Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
343 Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
344
345 // Properties that are used by helpers, but are opaque to applications
346 Prop_DisplayHiddenArea_Binary_Start = 5100,
347 Prop_DisplayHiddenArea_Binary_End = 5150,
348
349 // Properties that are unique to drivers
350 Prop_UserConfigPath_String = 6000,
351 Prop_InstallPath_String = 6001,
352 Prop_HasDisplayComponent_Bool = 6002,
353 Prop_HasControllerComponent_Bool = 6003,
354 Prop_HasCameraComponent_Bool = 6004,
355 Prop_HasDriverDirectModeComponent_Bool = 6005,
356 Prop_HasVirtualDisplayComponent_Bool = 6006,
357
358 // Vendors are free to expose private debug data in this reserved region
359 Prop_VendorSpecific_Reserved_Start = 10000,
360 Prop_VendorSpecific_Reserved_End = 10999,
361 };
362
363 /** No string property will ever be longer than this length */
364 static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
365
366 /** Used to return errors that occur when reading properties. */
367 enum ETrackedPropertyError
368 {
369 TrackedProp_Success = 0,
370 TrackedProp_WrongDataType = 1,
371 TrackedProp_WrongDeviceClass = 2,
372 TrackedProp_BufferTooSmall = 3,
373 TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever).
374 TrackedProp_InvalidDevice = 5,
375 TrackedProp_CouldNotContactServer = 6,
376 TrackedProp_ValueNotProvidedByDevice = 7,
377 TrackedProp_StringExceedsMaximumLength = 8,
378 TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
379 TrackedProp_PermissionDenied = 10,
380 TrackedProp_InvalidOperation = 11,
381 };
382
383 /** Allows the application to control what part of the provided texture will be used in the
384 * frame buffer. */
385 struct VRTextureBounds_t
386 {
387 float uMin, vMin;
388 float uMax, vMax;
389 };
390
391 /** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */
392 struct VRTextureWithPose_t : public Texture_t
393 {
394 HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures.
395 };
396
397 /** Allows the application to control how scene textures are used by the compositor when calling Submit. */
398 enum EVRSubmitFlags
399 {
400 // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
401 Submit_Default = 0x00,
402
403 // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
404 // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
405 // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
406 Submit_LensDistortionAlreadyApplied = 0x01,
407
408 // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
409 Submit_GlRenderBuffer = 0x02,
410
411 // Do not use
412 Submit_Reserved = 0x04,
413
414 // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t.
415 Submit_TextureWithPose = 0x08,
416 };
417
418 /** Data required for passing Vulkan textures to IVRCompositor::Submit.
419 * Be sure to call OpenVR_Shutdown before destroying these resources. */
420 struct VRVulkanTextureData_t
421 {
422 uint64_t m_nImage; // VkImage
423 VkDevice_T *m_pDevice;
424 VkPhysicalDevice_T *m_pPhysicalDevice;
425 VkInstance_T *m_pInstance;
426 VkQueue_T *m_pQueue;
427 uint32_t m_nQueueFamilyIndex;
428 uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount;
429 };
430
431 /** Data required for passing D3D12 textures to IVRCompositor::Submit.
432 * Be sure to call OpenVR_Shutdown before destroying these resources. */
433 struct D3D12TextureData_t
434 {
435 ID3D12Resource *m_pResource;
436 ID3D12CommandQueue *m_pCommandQueue;
437 uint32_t m_nNodeMask;
438 };
439
440 /** Status of the overall system or tracked objects */
441 enum EVRState
442 {
443 VRState_Undefined = -1,
444 VRState_Off = 0,
445 VRState_Searching = 1,
446 VRState_Searching_Alert = 2,
447 VRState_Ready = 3,
448 VRState_Ready_Alert = 4,
449 VRState_NotReady = 5,
450 VRState_Standby = 6,
451 VRState_Ready_Alert_Low = 7,
452 };
453
454 /** The types of events that could be posted (and what the parameters mean for each event type) */
455 enum EVREventType
456 {
457 VREvent_None = 0,
458
459 VREvent_TrackedDeviceActivated = 100,
460 VREvent_TrackedDeviceDeactivated = 101,
461 VREvent_TrackedDeviceUpdated = 102,
462 VREvent_TrackedDeviceUserInteractionStarted = 103,
463 VREvent_TrackedDeviceUserInteractionEnded = 104,
464 VREvent_IpdChanged = 105,
465 VREvent_EnterStandbyMode = 106,
466 VREvent_LeaveStandbyMode = 107,
467 VREvent_TrackedDeviceRoleChanged = 108,
468 VREvent_WatchdogWakeUpRequested = 109,
469 VREvent_LensDistortionChanged = 110,
470 VREvent_PropertyChanged = 111,
471 VREvent_WirelessDisconnect = 112,
472 VREvent_WirelessReconnect = 113,
473
474 VREvent_ButtonPress = 200, // data is controller
475 VREvent_ButtonUnpress = 201, // data is controller
476 VREvent_ButtonTouch = 202, // data is controller
477 VREvent_ButtonUntouch = 203, // data is controller
478
479 VREvent_MouseMove = 300, // data is mouse
480 VREvent_MouseButtonDown = 301, // data is mouse
481 VREvent_MouseButtonUp = 302, // data is mouse
482 VREvent_FocusEnter = 303, // data is overlay
483 VREvent_FocusLeave = 304, // data is overlay
484 VREvent_Scroll = 305, // data is mouse
485 VREvent_TouchPadMove = 306, // data is mouse
486 VREvent_OverlayFocusChanged = 307, // data is overlay, global event
487
488 VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
489 VREvent_InputFocusReleased = 401, // data is process DEPRECATED
490 VREvent_SceneFocusLost = 402, // data is process
491 VREvent_SceneFocusGained = 403, // data is process
492 VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
493 VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
494 VREvent_InputFocusChanged = 406, // data is process
495 VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process
496
497 VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
498 VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
499
500 VREvent_OverlayShown = 500,
501 VREvent_OverlayHidden = 501,
502 VREvent_DashboardActivated = 502,
503 VREvent_DashboardDeactivated = 503,
504 VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
505 VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
506 VREvent_ResetDashboard = 506, // Send to the overlay manager
507 VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
508 VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
509 VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
510 VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
511 VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
512 VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
513 VREvent_OverlaySharedTextureChanged = 513,
514 VREvent_DashboardGuideButtonDown = 514,
515 VREvent_DashboardGuideButtonUp = 515,
516 VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
517 VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
518 VREvent_DashboardOverlayCreated = 518,
519
520 // Screenshot API
521 VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
522 VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
523 VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
524 VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
525 VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted
526
527 VREvent_PrimaryDashboardDeviceChanged = 525,
528
529 VREvent_Notification_Shown = 600,
530 VREvent_Notification_Hidden = 601,
531 VREvent_Notification_BeginInteraction = 602,
532 VREvent_Notification_Destroyed = 603,
533
534 VREvent_Quit = 700, // data is process
535 VREvent_ProcessQuit = 701, // data is process
536 VREvent_QuitAborted_UserPrompt = 702, // data is process
537 VREvent_QuitAcknowledged = 703, // data is process
538 VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
539
540 VREvent_ChaperoneDataHasChanged = 800,
541 VREvent_ChaperoneUniverseHasChanged = 801,
542 VREvent_ChaperoneTempDataHasChanged = 802,
543 VREvent_ChaperoneSettingsHaveChanged = 803,
544 VREvent_SeatedZeroPoseReset = 804,
545
546 VREvent_AudioSettingsHaveChanged = 820,
547
548 VREvent_BackgroundSettingHasChanged = 850,
549 VREvent_CameraSettingsHaveChanged = 851,
550 VREvent_ReprojectionSettingHasChanged = 852,
551 VREvent_ModelSkinSettingsHaveChanged = 853,
552 VREvent_EnvironmentSettingsHaveChanged = 854,
553 VREvent_PowerSettingsHaveChanged = 855,
554 VREvent_EnableHomeAppSettingsHaveChanged = 856,
555
556 VREvent_StatusUpdate = 900,
557
558 VREvent_MCImageUpdated = 1000,
559
560 VREvent_FirmwareUpdateStarted = 1100,
561 VREvent_FirmwareUpdateFinished = 1101,
562
563 VREvent_KeyboardClosed = 1200,
564 VREvent_KeyboardCharInput = 1201,
565 VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
566
567 VREvent_ApplicationTransitionStarted = 1300,
568 VREvent_ApplicationTransitionAborted = 1301,
569 VREvent_ApplicationTransitionNewAppStarted = 1302,
570 VREvent_ApplicationListUpdated = 1303,
571 VREvent_ApplicationMimeTypeLoad = 1304,
572 VREvent_ApplicationTransitionNewAppLaunchComplete = 1305,
573 VREvent_ProcessConnected = 1306,
574 VREvent_ProcessDisconnected = 1307,
575
576 VREvent_Compositor_MirrorWindowShown = 1400,
577 VREvent_Compositor_MirrorWindowHidden = 1401,
578 VREvent_Compositor_ChaperoneBoundsShown = 1410,
579 VREvent_Compositor_ChaperoneBoundsHidden = 1411,
580
581 VREvent_TrackedCamera_StartVideoStream = 1500,
582 VREvent_TrackedCamera_StopVideoStream = 1501,
583 VREvent_TrackedCamera_PauseVideoStream = 1502,
584 VREvent_TrackedCamera_ResumeVideoStream = 1503,
585 VREvent_TrackedCamera_EditingSurface = 1550,
586
587 VREvent_PerformanceTest_EnableCapture = 1600,
588 VREvent_PerformanceTest_DisableCapture = 1601,
589 VREvent_PerformanceTest_FidelityLevel = 1602,
590
591 VREvent_MessageOverlay_Closed = 1650,
592 VREvent_MessageOverlayCloseRequested = 1651,
593
594 // Vendors are free to expose private events in this reserved region
595 VREvent_VendorSpecific_Reserved_Start = 10000,
596 VREvent_VendorSpecific_Reserved_End = 19999,
597 };
598
599 /** Level of Hmd activity */
600 // UserInteraction_Timeout means the device is in the process of timing out.
601 // InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout )
602 // VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction.
603 // VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle
604 enum EDeviceActivityLevel
605 {
606 k_EDeviceActivityLevel_Unknown = -1,
607 k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds
608 k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now
609 k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds
610 k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management)
611 };
612
613 /** VR controller button and axis IDs */
614 enum EVRButtonId
615 {
616 k_EButton_System = 0,
617 k_EButton_ApplicationMenu = 1,
618 k_EButton_Grip = 2,
619 k_EButton_DPad_Left = 3,
620 k_EButton_DPad_Up = 4,
621 k_EButton_DPad_Right = 5,
622 k_EButton_DPad_Down = 6,
623 k_EButton_A = 7,
624
625 k_EButton_ProximitySensor = 31,
626
627 k_EButton_Axis0 = 32,
628 k_EButton_Axis1 = 33,
629 k_EButton_Axis2 = 34,
630 k_EButton_Axis3 = 35,
631 k_EButton_Axis4 = 36,
632
633 // aliases for well known controllers
634 k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
635 k_EButton_SteamVR_Trigger = k_EButton_Axis1,
636
637 k_EButton_Dashboard_Back = k_EButton_Grip,
638
639 k_EButton_Max = 64
640 };
641
ButtonMaskFromId(EVRButtonId id)642 inline uint64_t ButtonMaskFromId(EVRButtonId id) { return 1ull << id; }
643
644 /** used for controller button events */
645 struct VREvent_Controller_t
646 {
647 uint32_t button; // EVRButtonId enum
648 };
649
650 /** used for simulated mouse events in overlay space */
651 enum EVRMouseButton
652 {
653 VRMouseButton_Left = 0x0001,
654 VRMouseButton_Right = 0x0002,
655 VRMouseButton_Middle = 0x0004,
656 };
657
658 /** used for simulated mouse events in overlay space */
659 struct VREvent_Mouse_t
660 {
661 float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
662 uint32_t button; // EVRMouseButton enum
663 };
664
665 /** used for simulated mouse wheel scroll in overlay space */
666 struct VREvent_Scroll_t
667 {
668 float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
669 uint32_t repeatCount;
670 };
671
672 /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
673 is on the touchpad (or just released from it)
674 **/
675 struct VREvent_TouchPadMove_t
676 {
677 // true if the users finger is detected on the touch pad
678 bool bFingerDown;
679
680 // How long the finger has been down in seconds
681 float flSecondsFingerDown;
682
683 // These values indicate the starting finger position (so you can do some basic swipe stuff)
684 float fValueXFirst;
685 float fValueYFirst;
686
687 // This is the raw sampled coordinate without deadzoning
688 float fValueXRaw;
689 float fValueYRaw;
690 };
691
692 /** notification related events. Details will still change at this point */
693 struct VREvent_Notification_t
694 {
695 uint64_t ulUserValue;
696 uint32_t notificationId;
697 };
698
699 /** Used for events about processes */
700 struct VREvent_Process_t
701 {
702 uint32_t pid;
703 uint32_t oldPid;
704 bool bForced;
705 };
706
707 /** Used for a few events about overlays */
708 struct VREvent_Overlay_t
709 {
710 uint64_t overlayHandle;
711 };
712
713 /** Used for a few events about overlays */
714 struct VREvent_Status_t
715 {
716 uint32_t statusState; // EVRState enum
717 };
718
719 /** Used for keyboard events **/
720 struct VREvent_Keyboard_t
721 {
722 char cNewInput[8]; // Up to 11 bytes of new input
723 uint64_t uUserValue; // Possible flags about the new input
724 };
725
726 struct VREvent_Ipd_t
727 {
728 float ipdMeters;
729 };
730
731 struct VREvent_Chaperone_t
732 {
733 uint64_t m_nPreviousUniverse;
734 uint64_t m_nCurrentUniverse;
735 };
736
737 /** Not actually used for any events */
738 struct VREvent_Reserved_t
739 {
740 uint64_t reserved0;
741 uint64_t reserved1;
742 };
743
744 struct VREvent_PerformanceTest_t
745 {
746 uint32_t m_nFidelityLevel;
747 };
748
749 struct VREvent_SeatedZeroPoseReset_t
750 {
751 bool bResetBySystemMenu;
752 };
753
754 struct VREvent_Screenshot_t
755 {
756 uint32_t handle;
757 uint32_t type;
758 };
759
760 struct VREvent_ScreenshotProgress_t
761 {
762 float progress;
763 };
764
765 struct VREvent_ApplicationLaunch_t
766 {
767 uint32_t pid;
768 uint32_t unArgsHandle;
769 };
770
771 struct VREvent_EditingCameraSurface_t
772 {
773 uint64_t overlayHandle;
774 uint32_t nVisualMode;
775 };
776
777 struct VREvent_MessageOverlay_t
778 {
779 uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum
780 };
781
782 struct VREvent_Property_t
783 {
784 PropertyContainerHandle_t container;
785 ETrackedDeviceProperty prop;
786 };
787
788 /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */
789 typedef union {
790 VREvent_Reserved_t reserved;
791 VREvent_Controller_t controller;
792 VREvent_Mouse_t mouse;
793 VREvent_Scroll_t scroll;
794 VREvent_Process_t process;
795 VREvent_Notification_t notification;
796 VREvent_Overlay_t overlay;
797 VREvent_Status_t status;
798 VREvent_Keyboard_t keyboard;
799 VREvent_Ipd_t ipd;
800 VREvent_Chaperone_t chaperone;
801 VREvent_PerformanceTest_t performanceTest;
802 VREvent_TouchPadMove_t touchPadMove;
803 VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
804 VREvent_Screenshot_t screenshot;
805 VREvent_ScreenshotProgress_t screenshotProgress;
806 VREvent_ApplicationLaunch_t applicationLaunch;
807 VREvent_EditingCameraSurface_t cameraSurface;
808 VREvent_MessageOverlay_t messageOverlay;
809 VREvent_Property_t property;
810 } VREvent_Data_t;
811
812 #if defined(__linux__) || defined(__APPLE__)
813 // This structure was originally defined mis-packed on Linux, preserved for
814 // compatibility.
815 #pragma pack(push, 4)
816 #endif
817
818 /** An event posted by the server to all running applications */
819 struct VREvent_t
820 {
821 uint32_t eventType; // EVREventType enum
822 TrackedDeviceIndex_t trackedDeviceIndex;
823 float eventAgeSeconds;
824 // event data must be the end of the struct as its size is variable
825 VREvent_Data_t data;
826 };
827
828 #if defined(__linux__) || defined(__APPLE__)
829 #pragma pack(pop)
830 #endif
831
832 /** The mesh to draw into the stencil (or depth) buffer to perform
833 * early stencil (or depth) kills of pixels that will never appear on the HMD.
834 * This mesh draws on all the pixels that will be hidden after distortion.
835 *
836 * If the HMD does not provide a visible area mesh pVertexData will be
837 * NULL and unTriangleCount will be 0. */
838 struct HiddenAreaMesh_t
839 {
840 const HmdVector2_t *pVertexData;
841 uint32_t unTriangleCount;
842 };
843
844 enum EHiddenAreaMeshType
845 {
846 k_eHiddenAreaMesh_Standard = 0,
847 k_eHiddenAreaMesh_Inverse = 1,
848 k_eHiddenAreaMesh_LineLoop = 2,
849
850 k_eHiddenAreaMesh_Max = 3,
851 };
852
853 /** Identifies what kind of axis is on the controller at index n. Read this type
854 * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
855 */
856 enum EVRControllerAxisType
857 {
858 k_eControllerAxis_None = 0,
859 k_eControllerAxis_TrackPad = 1,
860 k_eControllerAxis_Joystick = 2,
861 k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
862 };
863
864 /** contains information about one axis on the controller */
865 struct VRControllerAxis_t
866 {
867 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.
868 float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
869 };
870
871 /** the number of axes in the controller state */
872 static const uint32_t k_unControllerStateAxisCount = 5;
873
874 #if defined(__linux__) || defined(__APPLE__)
875 // This structure was originally defined mis-packed on Linux, preserved for
876 // compatibility.
877 #pragma pack(push, 4)
878 #endif
879
880 /** Holds all the state of a controller at one moment in time. */
881 struct VRControllerState001_t
882 {
883 // If packet num matches that on your prior call, then the controller state hasn't been changed since
884 // your last call and there is no need to process it
885 uint32_t unPacketNum;
886
887 // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
888 uint64_t ulButtonPressed;
889 uint64_t ulButtonTouched;
890
891 // Axis data for the controller's analog inputs
892 VRControllerAxis_t rAxis[k_unControllerStateAxisCount];
893 };
894 #if defined(__linux__) || defined(__APPLE__)
895 #pragma pack(pop)
896 #endif
897
898 typedef VRControllerState001_t VRControllerState_t;
899
900 /** determines how to provide output to the application of various event processing functions. */
901 enum EVRControllerEventOutputType
902 {
903 ControllerEventOutput_OSEvents = 0,
904 ControllerEventOutput_VREvents = 1,
905 };
906
907 /** Collision Bounds Style */
908 enum ECollisionBoundsStyle
909 {
910 COLLISION_BOUNDS_STYLE_BEGINNER = 0,
911 COLLISION_BOUNDS_STYLE_INTERMEDIATE,
912 COLLISION_BOUNDS_STYLE_SQUARES,
913 COLLISION_BOUNDS_STYLE_ADVANCED,
914 COLLISION_BOUNDS_STYLE_NONE,
915
916 COLLISION_BOUNDS_STYLE_COUNT
917 };
918
919 /** Allows the application to customize how the overlay appears in the compositor */
920 struct Compositor_OverlaySettings
921 {
922 uint32_t size; // sizeof(Compositor_OverlaySettings)
923 bool curved, antialias;
924 float scale, distance, alpha;
925 float uOffset, vOffset, uScale, vScale;
926 float gridDivs, gridWidth, gridScale;
927 HmdMatrix44_t transform;
928 };
929
930 /** used to refer to a single VR overlay */
931 typedef uint64_t VROverlayHandle_t;
932
933 static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
934
935 /** Errors that can occur around VR overlays */
936 enum EVROverlayError
937 {
938 VROverlayError_None = 0,
939
940 VROverlayError_UnknownOverlay = 10,
941 VROverlayError_InvalidHandle = 11,
942 VROverlayError_PermissionDenied = 12,
943 VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
944 VROverlayError_WrongVisibilityType = 14,
945 VROverlayError_KeyTooLong = 15,
946 VROverlayError_NameTooLong = 16,
947 VROverlayError_KeyInUse = 17,
948 VROverlayError_WrongTransformType = 18,
949 VROverlayError_InvalidTrackedDevice = 19,
950 VROverlayError_InvalidParameter = 20,
951 VROverlayError_ThumbnailCantBeDestroyed = 21,
952 VROverlayError_ArrayTooSmall = 22,
953 VROverlayError_RequestFailed = 23,
954 VROverlayError_InvalidTexture = 24,
955 VROverlayError_UnableToLoadFile = 25,
956 VROverlayError_KeyboardAlreadyInUse = 26,
957 VROverlayError_NoNeighbor = 27,
958 VROverlayError_TooManyMaskPrimitives = 29,
959 VROverlayError_BadMaskPrimitive = 30,
960 };
961
962 /** enum values to pass in to VR_Init to identify whether the application will
963 * draw a 3D scene. */
964 enum EVRApplicationType
965 {
966 VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
967 VRApplication_Scene = 1, // Application will submit 3D frames
968 VRApplication_Overlay = 2, // Application only interacts with overlays
969 VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
970 // keep it running if everything else quits.
971 VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
972 // interfaces (like IVRSettings and IVRApplications) but not hardware.
973 VRApplication_VRMonitor = 5, // Reserved for vrmonitor
974 VRApplication_SteamWatchdog = 6, // Reserved for Steam
975 VRApplication_Bootstrapper = 7, // Start up SteamVR
976
977 VRApplication_Max
978 };
979
980 /** error codes for firmware */
981 enum EVRFirmwareError
982 {
983 VRFirmwareError_None = 0,
984 VRFirmwareError_Success = 1,
985 VRFirmwareError_Fail = 2,
986 };
987
988 /** error codes for notifications */
989 enum EVRNotificationError
990 {
991 VRNotificationError_OK = 0,
992 VRNotificationError_InvalidNotificationId = 100,
993 VRNotificationError_NotificationQueueFull = 101,
994 VRNotificationError_InvalidOverlayHandle = 102,
995 VRNotificationError_SystemWithUserValueAlreadyExists = 103,
996 };
997
998 /** error codes returned by Vr_Init */
999
1000 // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
1001 enum EVRInitError
1002 {
1003 VRInitError_None = 0,
1004 VRInitError_Unknown = 1,
1005
1006 VRInitError_Init_InstallationNotFound = 100,
1007 VRInitError_Init_InstallationCorrupt = 101,
1008 VRInitError_Init_VRClientDLLNotFound = 102,
1009 VRInitError_Init_FileNotFound = 103,
1010 VRInitError_Init_FactoryNotFound = 104,
1011 VRInitError_Init_InterfaceNotFound = 105,
1012 VRInitError_Init_InvalidInterface = 106,
1013 VRInitError_Init_UserConfigDirectoryInvalid = 107,
1014 VRInitError_Init_HmdNotFound = 108,
1015 VRInitError_Init_NotInitialized = 109,
1016 VRInitError_Init_PathRegistryNotFound = 110,
1017 VRInitError_Init_NoConfigPath = 111,
1018 VRInitError_Init_NoLogPath = 112,
1019 VRInitError_Init_PathRegistryNotWritable = 113,
1020 VRInitError_Init_AppInfoInitFailed = 114,
1021 VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
1022 VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
1023 VRInitError_Init_AnotherAppLaunching = 117,
1024 VRInitError_Init_SettingsInitFailed = 118,
1025 VRInitError_Init_ShuttingDown = 119,
1026 VRInitError_Init_TooManyObjects = 120,
1027 VRInitError_Init_NoServerForBackgroundApp = 121,
1028 VRInitError_Init_NotSupportedWithCompositor = 122,
1029 VRInitError_Init_NotAvailableToUtilityApps = 123,
1030 VRInitError_Init_Internal = 124,
1031 VRInitError_Init_HmdDriverIdIsNone = 125,
1032 VRInitError_Init_HmdNotFoundPresenceFailed = 126,
1033 VRInitError_Init_VRMonitorNotFound = 127,
1034 VRInitError_Init_VRMonitorStartupFailed = 128,
1035 VRInitError_Init_LowPowerWatchdogNotSupported = 129,
1036 VRInitError_Init_InvalidApplicationType = 130,
1037 VRInitError_Init_NotAvailableToWatchdogApps = 131,
1038 VRInitError_Init_WatchdogDisabledInSettings = 132,
1039 VRInitError_Init_VRDashboardNotFound = 133,
1040 VRInitError_Init_VRDashboardStartupFailed = 134,
1041 VRInitError_Init_VRHomeNotFound = 135,
1042 VRInitError_Init_VRHomeStartupFailed = 136,
1043 VRInitError_Init_RebootingBusy = 137,
1044 VRInitError_Init_FirmwareUpdateBusy = 138,
1045 VRInitError_Init_FirmwareRecoveryBusy = 139,
1046
1047 VRInitError_Driver_Failed = 200,
1048 VRInitError_Driver_Unknown = 201,
1049 VRInitError_Driver_HmdUnknown = 202,
1050 VRInitError_Driver_NotLoaded = 203,
1051 VRInitError_Driver_RuntimeOutOfDate = 204,
1052 VRInitError_Driver_HmdInUse = 205,
1053 VRInitError_Driver_NotCalibrated = 206,
1054 VRInitError_Driver_CalibrationInvalid = 207,
1055 VRInitError_Driver_HmdDisplayNotFound = 208,
1056 VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209,
1057 // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons
1058 VRInitError_Driver_HmdDriverIdOutOfBounds = 211,
1059 VRInitError_Driver_HmdDisplayMirrored = 212,
1060
1061 VRInitError_IPC_ServerInitFailed = 300,
1062 VRInitError_IPC_ConnectFailed = 301,
1063 VRInitError_IPC_SharedStateInitFailed = 302,
1064 VRInitError_IPC_CompositorInitFailed = 303,
1065 VRInitError_IPC_MutexInitFailed = 304,
1066 VRInitError_IPC_Failed = 305,
1067 VRInitError_IPC_CompositorConnectFailed = 306,
1068 VRInitError_IPC_CompositorInvalidConnectResponse = 307,
1069 VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308,
1070
1071 VRInitError_Compositor_Failed = 400,
1072 VRInitError_Compositor_D3D11HardwareRequired = 401,
1073 VRInitError_Compositor_FirmwareRequiresUpdate = 402,
1074 VRInitError_Compositor_OverlayInitFailed = 403,
1075 VRInitError_Compositor_ScreenshotsInitFailed = 404,
1076 VRInitError_Compositor_UnableToCreateDevice = 405,
1077
1078 VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
1079
1080 VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
1081 VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
1082 VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
1083 VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
1084 VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
1085 VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
1086 VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
1087 VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
1088 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
1089 VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
1090 VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
1091 VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
1092 VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
1093
1094 VRInitError_Steam_SteamInstallationNotFound = 2000,
1095 };
1096
1097 enum EVRScreenshotType
1098 {
1099 VRScreenshotType_None = 0,
1100 VRScreenshotType_Mono = 1, // left eye only
1101 VRScreenshotType_Stereo = 2,
1102 VRScreenshotType_Cubemap = 3,
1103 VRScreenshotType_MonoPanorama = 4,
1104 VRScreenshotType_StereoPanorama = 5
1105 };
1106
1107 enum EVRScreenshotPropertyFilenames
1108 {
1109 VRScreenshotPropertyFilenames_Preview = 0,
1110 VRScreenshotPropertyFilenames_VR = 1,
1111 };
1112
1113 enum EVRTrackedCameraError
1114 {
1115 VRTrackedCameraError_None = 0,
1116 VRTrackedCameraError_OperationFailed = 100,
1117 VRTrackedCameraError_InvalidHandle = 101,
1118 VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
1119 VRTrackedCameraError_OutOfHandles = 103,
1120 VRTrackedCameraError_IPCFailure = 104,
1121 VRTrackedCameraError_NotSupportedForThisDevice = 105,
1122 VRTrackedCameraError_SharedMemoryFailure = 106,
1123 VRTrackedCameraError_FrameBufferingFailure = 107,
1124 VRTrackedCameraError_StreamSetupFailure = 108,
1125 VRTrackedCameraError_InvalidGLTextureId = 109,
1126 VRTrackedCameraError_InvalidSharedTextureHandle = 110,
1127 VRTrackedCameraError_FailedToGetGLTextureId = 111,
1128 VRTrackedCameraError_SharedTextureFailure = 112,
1129 VRTrackedCameraError_NoFrameAvailable = 113,
1130 VRTrackedCameraError_InvalidArgument = 114,
1131 VRTrackedCameraError_InvalidFrameBufferSize = 115,
1132 };
1133
1134 enum EVRTrackedCameraFrameType
1135 {
1136 VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
1137 VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
1138 VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
1139 MAX_CAMERA_FRAME_TYPES
1140 };
1141
1142 typedef uint64_t TrackedCameraHandle_t;
1143 #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
1144
1145 struct CameraVideoStreamFrameHeader_t
1146 {
1147 EVRTrackedCameraFrameType eFrameType;
1148
1149 uint32_t nWidth;
1150 uint32_t nHeight;
1151 uint32_t nBytesPerPixel;
1152
1153 uint32_t nFrameSequence;
1154
1155 TrackedDevicePose_t standingTrackedDevicePose;
1156 };
1157
1158 // Screenshot types
1159 typedef uint32_t ScreenshotHandle_t;
1160
1161 static const uint32_t k_unScreenshotHandleInvalid = 0;
1162
1163 #pragma pack(pop)
1164
1165 // figure out how to import from the VR API dll
1166 #if defined(_WIN32)
1167
1168 #ifdef VR_API_EXPORT
1169 #define VR_INTERFACE extern "C" __declspec(dllexport)
1170 #else
1171 #define VR_INTERFACE extern "C" __declspec(dllimport)
1172 #endif
1173
1174 #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
1175
1176 #ifdef VR_API_EXPORT
1177 #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
1178 #else
1179 #define VR_INTERFACE extern "C"
1180 #endif
1181
1182 #else
1183 #error "Unsupported Platform."
1184 #endif
1185
1186 #if defined(_WIN32)
1187 #define VR_CALLTYPE __cdecl
1188 #else
1189 #define VR_CALLTYPE
1190 #endif
1191
1192 } // namespace vr
1193
1194 #endif // _INCLUDE_VRTYPES_H
1195
1196 // vrannotation.h
1197 #ifdef API_GEN
1198 #define VR_CLANG_ATTR(ATTR) __attribute__((annotate(ATTR)))
1199 #else
1200 #define VR_CLANG_ATTR(ATTR)
1201 #endif
1202
1203 #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR("desc:" #DESC ";")
1204 #define VR_IGNOREATTR() VR_CLANG_ATTR("ignore")
1205 #define VR_OUT_STRUCT() VR_CLANG_ATTR("out_struct: ;")
1206 #define VR_OUT_STRING() VR_CLANG_ATTR("out_string: ;")
1207 #define VR_OUT_ARRAY_CALL(COUNTER, FUNCTION, PARAMS) VR_CLANG_ATTR("out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";")
1208 #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR("out_array_count:" #COUNTER ";")
1209 #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR("array_count:" #COUNTER ";")
1210 #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR("array_count:" #COUNTER ";desc:" #DESC)
1211 #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR("buffer_count:" #COUNTER ";")
1212 #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR("out_buffer_count:" #COUNTER ";")
1213 #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR("out_string_count:" #COUNTER ";")
1214
1215 // ivrsystem.h
1216 namespace vr
1217 {
1218 class IVRSystem
1219 {
1220 public:
1221 // ------------------------------------
1222 // Display Methods
1223 // ------------------------------------
1224
1225 /** Suggested size for the intermediate render target that the distortion pulls from. */
1226 virtual void GetRecommendedRenderTargetSize(uint32_t *pnWidth, uint32_t *pnHeight) = 0;
1227
1228 /** The projection matrix for the specified eye */
1229 virtual HmdMatrix44_t GetProjectionMatrix(EVREye eEye, float fNearZ, float fFarZ) = 0;
1230
1231 /** The components necessary to build your own projection matrix in case your
1232 * application is doing something fancy like infinite Z */
1233 virtual void GetProjectionRaw(EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom) = 0;
1234
1235 /** Gets the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
1236 * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport.
1237 * Returns true for success. Otherwise, returns false, and distortion coordinates are not suitable. */
1238 virtual bool ComputeDistortion(EVREye eEye, float fU, float fV, DistortionCoordinates_t *pDistortionCoordinates) = 0;
1239
1240 /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head
1241 * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection.
1242 * Normally View and Eye^-1 will be multiplied together and treated as View in your application.
1243 */
1244 virtual HmdMatrix34_t GetEyeToHeadTransform(EVREye eEye) = 0;
1245
1246 /** Returns the number of elapsed seconds since the last recorded vsync event. This
1247 * will come from a vsync timer event in the timer if possible or from the application-reported
1248 * time if that is not available. If no vsync times are available the function will
1249 * return zero for vsync time and frame counter and return false from the method. */
1250 virtual bool GetTimeSinceLastVsync(float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter) = 0;
1251
1252 /** [D3D9 Only]
1253 * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
1254 * a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
1255 */
1256 virtual int32_t GetD3D9AdapterIndex() = 0;
1257
1258 /** [D3D10/11 Only]
1259 * Returns the adapter index that the user should pass into EnumAdapters to create the device
1260 * and swap chain in DX10 and DX11. If an error occurs the index will be set to -1.
1261 */
1262 virtual void GetDXGIOutputInfo(int32_t *pnAdapterIndex) = 0;
1263
1264 /**
1265 * Returns platform- and texture-type specific adapter identification so that applications and the
1266 * compositor are creating textures and swap chains on the same GPU. If an error occurs the device
1267 * will be set to 0.
1268 * pInstance is an optional parameter that is required only when textureType is TextureType_Vulkan.
1269 * [D3D10/11/12 Only (D3D9 Not Supported)]
1270 * Returns the adapter LUID that identifies the GPU attached to the HMD. The user should
1271 * enumerate all adapters using IDXGIFactory::EnumAdapters and IDXGIAdapter::GetDesc to find
1272 * the adapter with the matching LUID, or use IDXGIFactory4::EnumAdapterByLuid.
1273 * The discovered IDXGIAdapter should be used to create the device and swap chain.
1274 * [Vulkan Only]
1275 * Returns the VkPhysicalDevice that should be used by the application.
1276 * pInstance must be the instance the application will use to query for the VkPhysicalDevice. The application
1277 * must create the VkInstance with extensions returned by IVRCompositor::GetVulkanInstanceExtensionsRequired enabled.
1278 * [macOS Only]
1279 * Returns an id<MTLDevice> that should be used by the application.
1280 */
1281 virtual void GetOutputDevice(uint64_t *pnDevice, ETextureType textureType, VkInstance_T *pInstance = nullptr) = 0;
1282
1283 // ------------------------------------
1284 // Display Mode methods
1285 // ------------------------------------
1286
1287 /** Use to determine if the headset display is part of the desktop (i.e. extended) or hidden (i.e. direct mode). */
1288 virtual bool IsDisplayOnDesktop() = 0;
1289
1290 /** Set the display visibility (true = extended, false = direct mode). Return value of true indicates that the change was successful. */
1291 virtual bool SetDisplayVisibility(bool bIsVisibleOnDesktop) = 0;
1292
1293 // ------------------------------------
1294 // Tracking Methods
1295 // ------------------------------------
1296
1297 /** The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
1298 * future. Pass 0 to get the state at the instant the method is called. Most of the time the application should
1299 * calculate the time until the photons will be emitted from the display and pass that time into the method.
1300 *
1301 * This is roughly analogous to the inverse of the view matrix in most applications, though
1302 * many games will need to do some additional rotation or translation on top of the rotation
1303 * and translation provided by the head pose.
1304 *
1305 * For devices where bPoseIsValid is true the application can use the pose to position the device
1306 * in question. The provided array can be any size up to k_unMaxTrackedDeviceCount.
1307 *
1308 * Seated experiences should call this method with TrackingUniverseSeated and receive poses relative
1309 * to the seated zero pose. Standing experiences should call this method with TrackingUniverseStanding
1310 * and receive poses relative to the Chaperone Play Area. TrackingUniverseRawAndUncalibrated should
1311 * probably not be used unless the application is the Chaperone calibration tool itself, but will provide
1312 * poses relative to the hardware-specific coordinate system in the driver.
1313 */
1314 virtual void GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, VR_ARRAY_COUNT(unTrackedDevicePoseArrayCount) TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount) = 0;
1315
1316 /** Sets the zero pose for the seated tracker coordinate system to the current position and yaw of the HMD. After
1317 * ResetSeatedZeroPose all GetDeviceToAbsoluteTrackingPose calls that pass TrackingUniverseSeated as the origin
1318 * will be relative to this new zero pose. The new zero coordinate system will not change the fact that the Y axis
1319 * is up in the real world, so the next pose returned from GetDeviceToAbsoluteTrackingPose after a call to
1320 * ResetSeatedZeroPose may not be exactly an identity matrix.
1321 *
1322 * NOTE: This function overrides the user's previously saved seated zero pose and should only be called as the result of a user action.
1323 * Users are also able to set their seated zero pose via the OpenVR Dashboard.
1324 **/
1325 virtual void ResetSeatedZeroPose() = 0;
1326
1327 /** Returns the transform from the seated zero pose to the standing absolute tracking system. This allows
1328 * applications to represent the seated origin to used or transform object positions from one coordinate
1329 * system to the other.
1330 *
1331 * The seated origin may or may not be inside the Play Area or Collision Bounds returned by IVRChaperone. Its position
1332 * depends on what the user has set from the Dashboard settings and previous calls to ResetSeatedZeroPose. */
1333 virtual HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() = 0;
1334
1335 /** Returns the transform from the tracking origin to the standing absolute tracking system. This allows
1336 * applications to convert from raw tracking space to the calibrated standing coordinate system. */
1337 virtual HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose() = 0;
1338
1339 /** Get a sorted array of device indices of a given class of tracked devices (e.g. controllers). Devices are sorted right to left
1340 * relative to the specified tracked device (default: hmd -- pass in -1 for absolute tracking space). Returns the number of devices
1341 * in the list, or the size of the array needed if not large enough. */
1342 virtual uint32_t GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass eTrackedDeviceClass, VR_ARRAY_COUNT(unTrackedDeviceIndexArrayCount) vr::TrackedDeviceIndex_t *punTrackedDeviceIndexArray, uint32_t unTrackedDeviceIndexArrayCount, vr::TrackedDeviceIndex_t unRelativeToTrackedDeviceIndex = k_unTrackedDeviceIndex_Hmd) = 0;
1343
1344 /** Returns the level of activity on the device. */
1345 virtual EDeviceActivityLevel GetTrackedDeviceActivityLevel(vr::TrackedDeviceIndex_t unDeviceId) = 0;
1346
1347 /** Convenience utility to apply the specified transform to the specified pose.
1348 * This properly transforms all pose components, including velocity and angular velocity
1349 */
1350 virtual void ApplyTransform(TrackedDevicePose_t *pOutputPose, const TrackedDevicePose_t *pTrackedDevicePose, const HmdMatrix34_t *pTransform) = 0;
1351
1352 /** Returns the device index associated with a specific role, for example the left hand or the right hand. */
1353 virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole(vr::ETrackedControllerRole unDeviceType) = 0;
1354
1355 /** Returns the controller type associated with a device index. */
1356 virtual vr::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex(vr::TrackedDeviceIndex_t unDeviceIndex) = 0;
1357
1358 // ------------------------------------
1359 // Property methods
1360 // ------------------------------------
1361
1362 /** Returns the device class of a tracked device. If there has not been a device connected in this slot
1363 * since the application started this function will return TrackedDevice_Invalid. For previous detected
1364 * devices the function will return the previously observed device class.
1365 *
1366 * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check
1367 * the device class. Every device with something other than TrackedDevice_Invalid is associated with an
1368 * actual tracked device. */
1369 virtual ETrackedDeviceClass GetTrackedDeviceClass(vr::TrackedDeviceIndex_t unDeviceIndex) = 0;
1370
1371 /** Returns true if there is a device connected in this slot. */
1372 virtual bool IsTrackedDeviceConnected(vr::TrackedDeviceIndex_t unDeviceIndex) = 0;
1373
1374 /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */
1375 virtual bool GetBoolTrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L) = 0;
1376
1377 /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */
1378 virtual float GetFloatTrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L) = 0;
1379
1380 /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */
1381 virtual int32_t GetInt32TrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L) = 0;
1382
1383 /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */
1384 virtual uint64_t GetUint64TrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L) = 0;
1385
1386 /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */
1387 virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L) = 0;
1388
1389 /** Returns a string property. If the device index is not valid or the property is not a string type this function will
1390 * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
1391 * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
1392 virtual uint32_t GetStringTrackedDeviceProperty(vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L) = 0;
1393
1394 /** returns a string that corresponds with the specified property error. The string will be the name
1395 * of the error enum value for all valid error codes */
1396 virtual const char *GetPropErrorNameFromEnum(ETrackedPropertyError error) = 0;
1397
1398 // ------------------------------------
1399 // Event methods
1400 // ------------------------------------
1401
1402 /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
1403 * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
1404 virtual bool PollNextEvent(VREvent_t *pEvent, uint32_t uncbVREvent) = 0;
1405
1406 /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
1407 * this method returns false. Fills in the pose of the associated tracked device in the provided pose struct.
1408 * This pose will always be older than the call to this function and should not be used to render the device.
1409 uncbVREvent should be the size in bytes of the VREvent_t struct */
1410 virtual bool PollNextEventWithPose(ETrackingUniverseOrigin eOrigin, VREvent_t *pEvent, uint32_t uncbVREvent, vr::TrackedDevicePose_t *pTrackedDevicePose) = 0;
1411
1412 /** returns the name of an EVREvent enum value */
1413 virtual const char *GetEventTypeNameFromEnum(EVREventType eType) = 0;
1414
1415 // ------------------------------------
1416 // Rendering helper methods
1417 // ------------------------------------
1418
1419 /** Returns the hidden area mesh for the current HMD. The pixels covered by this mesh will never be seen by the user after the lens distortion is
1420 * applied based on visibility to the panels. If this HMD does not have a hidden area mesh, the vertex data and count will be NULL and 0 respectively.
1421 * This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering each eye's view.
1422 * This will improve performance by letting the GPU early-reject pixels the user will never see before running the pixel shader.
1423 * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye.
1424 * Setting the bInverse argument to true will produce the visible area mesh that is commonly used in place of full-screen quads. The visible area mesh covers all of the pixels the hidden area mesh does not cover.
1425 * Setting the bLineLoop argument will return a line loop of vertices in HiddenAreaMesh_t->pVertexData with HiddenAreaMesh_t->unTriangleCount set to the number of vertices.
1426 */
1427 virtual HiddenAreaMesh_t GetHiddenAreaMesh(EVREye eEye, EHiddenAreaMeshType type = k_eHiddenAreaMesh_Standard) = 0;
1428
1429 // ------------------------------------
1430 // Controller methods
1431 // ------------------------------------
1432
1433 /** Fills the supplied struct with the current state of the controller. Returns false if the controller index
1434 * is invalid. */
1435 virtual bool GetControllerState(vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize) = 0;
1436
1437 /** fills the supplied struct with the current state of the controller and the provided pose with the pose of
1438 * the controller when the controller state was updated most recently. Use this form if you need a precise controller
1439 * pose as input to your application when the user presses or releases a button. */
1440 virtual bool GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize, TrackedDevicePose_t *pTrackedDevicePose) = 0;
1441
1442 /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller
1443 * and axis combination for 5ms. */
1444 virtual void TriggerHapticPulse(vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec) = 0;
1445
1446 /** returns the name of an EVRButtonId enum value */
1447 virtual const char *GetButtonIdNameFromEnum(EVRButtonId eButtonId) = 0;
1448
1449 /** returns the name of an EVRControllerAxisType enum value */
1450 virtual const char *GetControllerAxisTypeNameFromEnum(EVRControllerAxisType eAxisType) = 0;
1451
1452 /** Tells OpenVR that this process wants exclusive access to controller button states and button events. Other apps will be notified that
1453 * they have lost input focus with a VREvent_InputFocusCaptured event. Returns false if input focus could not be captured for
1454 * some reason. */
1455 virtual bool CaptureInputFocus() = 0;
1456
1457 /** Tells OpenVR that this process no longer wants exclusive access to button states and button events. Other apps will be notified
1458 * that input focus has been released with a VREvent_InputFocusReleased event. */
1459 virtual void ReleaseInputFocus() = 0;
1460
1461 /** Returns true if input focus is captured by another process. */
1462 virtual bool IsInputFocusCapturedByAnotherProcess() = 0;
1463
1464 // ------------------------------------
1465 // Debug Methods
1466 // ------------------------------------
1467
1468 /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k,
1469 * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated.
1470 * The size of the response including its terminating null is returned. */
1471 virtual uint32_t DriverDebugRequest(vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize) = 0;
1472
1473 // ------------------------------------
1474 // Firmware methods
1475 // ------------------------------------
1476
1477 /** Performs the actual firmware update if applicable.
1478 * The following events will be sent, if VRFirmwareError_None was returned: VREvent_FirmwareUpdateStarted, VREvent_FirmwareUpdateFinished
1479 * Use the properties Prop_Firmware_UpdateAvailable_Bool, Prop_Firmware_ManualUpdate_Bool, and Prop_Firmware_ManualUpdateURL_String
1480 * to figure our whether a firmware update is available, and to figure out whether its a manual update
1481 * Prop_Firmware_ManualUpdateURL_String should point to an URL describing the manual update process */
1482 virtual vr::EVRFirmwareError PerformFirmwareUpdate(vr::TrackedDeviceIndex_t unDeviceIndex) = 0;
1483
1484 // ------------------------------------
1485 // Application life cycle methods
1486 // ------------------------------------
1487
1488 /** Call this to acknowledge to the system that VREvent_Quit has been received and that the process is exiting.
1489 * This extends the timeout until the process is killed. */
1490 virtual void AcknowledgeQuit_Exiting() = 0;
1491
1492 /** Call this to tell the system that the user is being prompted to save data. This
1493 * halts the timeout and dismisses the dashboard (if it was up). Applications should be sure to actually
1494 * prompt the user to save and then exit afterward, otherwise the user will be left in a confusing state. */
1495 virtual void AcknowledgeQuit_UserPrompt() = 0;
1496 };
1497
1498 static const char *const IVRSystem_Version = "IVRSystem_017";
1499
1500 } // namespace vr
1501
1502 // ivrapplications.h
1503 namespace vr
1504 {
1505 /** Used for all errors reported by the IVRApplications interface */
1506 enum EVRApplicationError
1507 {
1508 VRApplicationError_None = 0,
1509
1510 VRApplicationError_AppKeyAlreadyExists = 100, // Only one application can use any given key
1511 VRApplicationError_NoManifest = 101, // the running application does not have a manifest
1512 VRApplicationError_NoApplication = 102, // No application is running
1513 VRApplicationError_InvalidIndex = 103,
1514 VRApplicationError_UnknownApplication = 104, // the application could not be found
1515 VRApplicationError_IPCFailed = 105, // An IPC failure caused the request to fail
1516 VRApplicationError_ApplicationAlreadyRunning = 106,
1517 VRApplicationError_InvalidManifest = 107,
1518 VRApplicationError_InvalidApplication = 108,
1519 VRApplicationError_LaunchFailed = 109, // the process didn't start
1520 VRApplicationError_ApplicationAlreadyStarting = 110, // the system was already starting the same application
1521 VRApplicationError_LaunchInProgress = 111, // The system was already starting a different application
1522 VRApplicationError_OldApplicationQuitting = 112,
1523 VRApplicationError_TransitionAborted = 113,
1524 VRApplicationError_IsTemplate = 114, // error when you try to call LaunchApplication() on a template type app (use LaunchTemplateApplication)
1525 VRApplicationError_SteamVRIsExiting = 115,
1526
1527 VRApplicationError_BufferTooSmall = 200, // The provided buffer was too small to fit the requested data
1528 VRApplicationError_PropertyNotSet = 201, // The requested property was not set
1529 VRApplicationError_UnknownProperty = 202,
1530 VRApplicationError_InvalidParameter = 203,
1531 };
1532
1533 /** The maximum length of an application key */
1534 static const uint32_t k_unMaxApplicationKeyLength = 128;
1535
1536 /** these are the properties available on applications. */
1537 enum EVRApplicationProperty
1538 {
1539 VRApplicationProperty_Name_String = 0,
1540
1541 VRApplicationProperty_LaunchType_String = 11,
1542 VRApplicationProperty_WorkingDirectory_String = 12,
1543 VRApplicationProperty_BinaryPath_String = 13,
1544 VRApplicationProperty_Arguments_String = 14,
1545 VRApplicationProperty_URL_String = 15,
1546
1547 VRApplicationProperty_Description_String = 50,
1548 VRApplicationProperty_NewsURL_String = 51,
1549 VRApplicationProperty_ImagePath_String = 52,
1550 VRApplicationProperty_Source_String = 53,
1551
1552 VRApplicationProperty_IsDashboardOverlay_Bool = 60,
1553 VRApplicationProperty_IsTemplate_Bool = 61,
1554 VRApplicationProperty_IsInstanced_Bool = 62,
1555 VRApplicationProperty_IsInternal_Bool = 63,
1556 VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64,
1557
1558 VRApplicationProperty_LastLaunchTime_Uint64 = 70,
1559 };
1560
1561 /** These are states the scene application startup process will go through. */
1562 enum EVRApplicationTransitionState
1563 {
1564 VRApplicationTransition_None = 0,
1565
1566 VRApplicationTransition_OldAppQuitSent = 10,
1567 VRApplicationTransition_WaitingForExternalLaunch = 11,
1568
1569 VRApplicationTransition_NewAppLaunched = 20,
1570 };
1571
1572 struct AppOverrideKeys_t
1573 {
1574 const char *pchKey;
1575 const char *pchValue;
1576 };
1577
1578 /** Currently recognized mime types */
1579 static const char *const k_pch_MimeType_HomeApp = "vr/home";
1580 static const char *const k_pch_MimeType_GameTheater = "vr/game_theater";
1581
1582 class IVRApplications
1583 {
1584 public:
1585 // --------------- Application management --------------- //
1586
1587 /** Adds an application manifest to the list to load when building the list of installed applications.
1588 * Temporary manifests are not automatically loaded */
1589 virtual EVRApplicationError AddApplicationManifest(const char *pchApplicationManifestFullPath, bool bTemporary = false) = 0;
1590
1591 /** Removes an application manifest from the list to load when building the list of installed applications. */
1592 virtual EVRApplicationError RemoveApplicationManifest(const char *pchApplicationManifestFullPath) = 0;
1593
1594 /** Returns true if an application is installed */
1595 virtual bool IsApplicationInstalled(const char *pchAppKey) = 0;
1596
1597 /** Returns the number of applications available in the list */
1598 virtual uint32_t GetApplicationCount() = 0;
1599
1600 /** Returns the key of the specified application. The index is at least 0 and is less than the return
1601 * value of GetApplicationCount(). The buffer should be at least k_unMaxApplicationKeyLength in order to
1602 * fit the key. */
1603 virtual EVRApplicationError GetApplicationKeyByIndex(uint32_t unApplicationIndex, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen) = 0;
1604
1605 /** Returns the key of the application for the specified Process Id. The buffer should be at least
1606 * k_unMaxApplicationKeyLength in order to fit the key. */
1607 virtual EVRApplicationError GetApplicationKeyByProcessId(uint32_t unProcessId, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen) = 0;
1608
1609 /** Launches the application. The existing scene application will exit and then the new application will start.
1610 * This call is not valid for dashboard overlay applications. */
1611 virtual EVRApplicationError LaunchApplication(const char *pchAppKey) = 0;
1612
1613 /** Launches an instance of an application of type template, with its app key being pchNewAppKey (which must be unique) and optionally override sections
1614 * from the manifest file via AppOverrideKeys_t
1615 */
1616 virtual EVRApplicationError LaunchTemplateApplication(const char *pchTemplateAppKey, const char *pchNewAppKey, VR_ARRAY_COUNT(unKeys) const AppOverrideKeys_t *pKeys, uint32_t unKeys) = 0;
1617
1618 /** launches the application currently associated with this mime type and passes it the option args, typically the filename or object name of the item being launched */
1619 virtual vr::EVRApplicationError LaunchApplicationFromMimeType(const char *pchMimeType, const char *pchArgs) = 0;
1620
1621 /** Launches the dashboard overlay application if it is not already running. This call is only valid for
1622 * dashboard overlay applications. */
1623 virtual EVRApplicationError LaunchDashboardOverlay(const char *pchAppKey) = 0;
1624
1625 /** Cancel a pending launch for an application */
1626 virtual bool CancelApplicationLaunch(const char *pchAppKey) = 0;
1627
1628 /** Identifies a running application. OpenVR can't always tell which process started in response
1629 * to a URL. This function allows a URL handler (or the process itself) to identify the app key
1630 * for the now running application. Passing a process ID of 0 identifies the calling process.
1631 * The application must be one that's known to the system via a call to AddApplicationManifest. */
1632 virtual EVRApplicationError IdentifyApplication(uint32_t unProcessId, const char *pchAppKey) = 0;
1633
1634 /** Returns the process ID for an application. Return 0 if the application was not found or is not running. */
1635 virtual uint32_t GetApplicationProcessId(const char *pchAppKey) = 0;
1636
1637 /** Returns a string for an applications error */
1638 virtual const char *GetApplicationsErrorNameFromEnum(EVRApplicationError error) = 0;
1639
1640 // --------------- Application properties --------------- //
1641
1642 /** Returns a value for an application property. The required buffer size to fit this value will be returned. */
1643 virtual uint32_t GetApplicationPropertyString(const char *pchAppKey, EVRApplicationProperty eProperty, VR_OUT_STRING() char *pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError *peError = nullptr) = 0;
1644
1645 /** Returns a bool value for an application property. Returns false in all error cases. */
1646 virtual bool GetApplicationPropertyBool(const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr) = 0;
1647
1648 /** Returns a uint64 value for an application property. Returns 0 in all error cases. */
1649 virtual uint64_t GetApplicationPropertyUint64(const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr) = 0;
1650
1651 /** Sets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
1652 virtual EVRApplicationError SetApplicationAutoLaunch(const char *pchAppKey, bool bAutoLaunch) = 0;
1653
1654 /** Gets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
1655 virtual bool GetApplicationAutoLaunch(const char *pchAppKey) = 0;
1656
1657 /** Adds this mime-type to the list of supported mime types for this application*/
1658 virtual EVRApplicationError SetDefaultApplicationForMimeType(const char *pchAppKey, const char *pchMimeType) = 0;
1659
1660 /** return the app key that will open this mime type */
1661 virtual bool GetDefaultApplicationForMimeType(const char *pchMimeType, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen) = 0;
1662
1663 /** Get the list of supported mime types for this application, comma-delimited */
1664 virtual bool GetApplicationSupportedMimeTypes(const char *pchAppKey, char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer) = 0;
1665
1666 /** Get the list of app-keys that support this mime type, comma-delimited, the return value is number of bytes you need to return the full string */
1667 virtual uint32_t GetApplicationsThatSupportMimeType(const char *pchMimeType, char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer) = 0;
1668
1669 /** Get the args list from an app launch that had the process already running, you call this when you get a VREvent_ApplicationMimeTypeLoad */
1670 virtual uint32_t GetApplicationLaunchArguments(uint32_t unHandle, char *pchArgs, uint32_t unArgs) = 0;
1671
1672 // --------------- Transition methods --------------- //
1673
1674 /** Returns the app key for the application that is starting up */
1675 virtual EVRApplicationError GetStartingApplication(char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen) = 0;
1676
1677 /** Returns the application transition state */
1678 virtual EVRApplicationTransitionState GetTransitionState() = 0;
1679
1680 /** Returns errors that would prevent the specified application from launching immediately. Calling this function will
1681 * cause the current scene application to quit, so only call it when you are actually about to launch something else.
1682 * What the caller should do about these failures depends on the failure:
1683 * VRApplicationError_OldApplicationQuitting - An existing application has been told to quit. Wait for a VREvent_ProcessQuit
1684 * and try again.
1685 * VRApplicationError_ApplicationAlreadyStarting - This application is already starting. This is a permanent failure.
1686 * VRApplicationError_LaunchInProgress - A different application is already starting. This is a permanent failure.
1687 * VRApplicationError_None - Go ahead and launch. Everything is clear.
1688 */
1689 virtual EVRApplicationError PerformApplicationPrelaunchCheck(const char *pchAppKey) = 0;
1690
1691 /** Returns a string for an application transition state */
1692 virtual const char *GetApplicationsTransitionStateNameFromEnum(EVRApplicationTransitionState state) = 0;
1693
1694 /** Returns true if the outgoing scene app has requested a save prompt before exiting */
1695 virtual bool IsQuitUserPromptRequested() = 0;
1696
1697 /** Starts a subprocess within the calling application. This
1698 * suppresses all application transition UI and automatically identifies the new executable
1699 * as part of the same application. On success the calling process should exit immediately.
1700 * If working directory is NULL or "" the directory portion of the binary path will be
1701 * the working directory. */
1702 virtual EVRApplicationError LaunchInternalProcess(const char *pchBinaryPath, const char *pchArguments, const char *pchWorkingDirectory) = 0;
1703
1704 /** Returns the current scene process ID according to the application system. A scene process will get scene
1705 * focus once it starts rendering, but it will appear here once it calls VR_Init with the Scene application
1706 * type. */
1707 virtual uint32_t GetCurrentSceneProcessId() = 0;
1708 };
1709
1710 static const char *const IVRApplications_Version = "IVRApplications_006";
1711
1712 } // namespace vr
1713
1714 // ivrsettings.h
1715 namespace vr
1716 {
1717 enum EVRSettingsError
1718 {
1719 VRSettingsError_None = 0,
1720 VRSettingsError_IPCFailed = 1,
1721 VRSettingsError_WriteFailed = 2,
1722 VRSettingsError_ReadFailed = 3,
1723 VRSettingsError_JsonParseFailed = 4,
1724 VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set
1725 };
1726
1727 // The maximum length of a settings key
1728 static const uint32_t k_unMaxSettingsKeyLength = 128;
1729
1730 class IVRSettings
1731 {
1732 public:
1733 virtual const char *GetSettingsErrorNameFromEnum(EVRSettingsError eError) = 0;
1734
1735 // Returns true if file sync occurred (force or settings dirty)
1736 virtual bool Sync(bool bForce = false, EVRSettingsError *peError = nullptr) = 0;
1737
1738 virtual void SetBool(const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr) = 0;
1739 virtual void SetInt32(const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr) = 0;
1740 virtual void SetFloat(const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr) = 0;
1741 virtual void SetString(const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr) = 0;
1742
1743 // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory
1744 // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or ""
1745 virtual bool GetBool(const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr) = 0;
1746 virtual int32_t GetInt32(const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr) = 0;
1747 virtual float GetFloat(const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr) = 0;
1748 virtual void GetString(const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr) = 0;
1749
1750 virtual void RemoveSection(const char *pchSection, EVRSettingsError *peError = nullptr) = 0;
1751 virtual void RemoveKeyInSection(const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr) = 0;
1752 };
1753
1754 //-----------------------------------------------------------------------------
1755 static const char *const IVRSettings_Version = "IVRSettings_002";
1756
1757 //-----------------------------------------------------------------------------
1758 // steamvr keys
1759 static const char *const k_pch_SteamVR_Section = "steamvr";
1760 static const char *const k_pch_SteamVR_RequireHmd_String = "requireHmd";
1761 static const char *const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
1762 static const char *const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
1763 static const char *const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
1764 static const char *const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
1765 static const char *const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
1766 static const char *const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
1767 static const char *const k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps";
1768 static const char *const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
1769 static const char *const k_pch_SteamVR_IPD_Float = "ipd";
1770 static const char *const k_pch_SteamVR_Background_String = "background";
1771 static const char *const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection";
1772 static const char *const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
1773 static const char *const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
1774 static const char *const k_pch_SteamVR_GridColor_String = "gridColor";
1775 static const char *const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
1776 static const char *const k_pch_SteamVR_ShowStage_Bool = "showStage";
1777 static const char *const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
1778 static const char *const k_pch_SteamVR_DirectMode_Bool = "directMode";
1779 static const char *const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
1780 static const char *const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
1781 static const char *const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
1782 static const char *const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
1783 static const char *const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
1784 static const char *const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
1785 static const char *const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale";
1786 static const char *const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection";
1787 static const char *const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection";
1788 static const char *const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection";
1789 static const char *const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
1790 static const char *const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView";
1791 static const char *const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView";
1792 static const char *const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry";
1793 static const char *const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch";
1794 static const char *const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch";
1795 static const char *const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch";
1796 static const char *const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard";
1797 static const char *const k_pch_SteamVR_EnableHomeApp = "enableHomeApp";
1798 static const char *const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec";
1799 static const char *const k_pch_SteamVR_RetailDemo_Bool = "retailDemo";
1800 static const char *const k_pch_SteamVR_IpdOffset_Float = "ipdOffset";
1801 static const char *const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering";
1802 static const char *const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync";
1803
1804 //-----------------------------------------------------------------------------
1805 // lighthouse keys
1806 static const char *const k_pch_Lighthouse_Section = "driver_lighthouse";
1807 static const char *const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
1808 static const char *const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
1809 static const char *const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
1810 static const char *const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
1811 static const char *const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
1812
1813 //-----------------------------------------------------------------------------
1814 // null keys
1815 static const char *const k_pch_Null_Section = "driver_null";
1816 static const char *const k_pch_Null_SerialNumber_String = "serialNumber";
1817 static const char *const k_pch_Null_ModelNumber_String = "modelNumber";
1818 static const char *const k_pch_Null_WindowX_Int32 = "windowX";
1819 static const char *const k_pch_Null_WindowY_Int32 = "windowY";
1820 static const char *const k_pch_Null_WindowWidth_Int32 = "windowWidth";
1821 static const char *const k_pch_Null_WindowHeight_Int32 = "windowHeight";
1822 static const char *const k_pch_Null_RenderWidth_Int32 = "renderWidth";
1823 static const char *const k_pch_Null_RenderHeight_Int32 = "renderHeight";
1824 static const char *const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
1825 static const char *const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
1826
1827 //-----------------------------------------------------------------------------
1828 // user interface keys
1829 static const char *const k_pch_UserInterface_Section = "userinterface";
1830 static const char *const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
1831 static const char *const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray";
1832 static const char *const k_pch_UserInterface_Screenshots_Bool = "screenshots";
1833 static const char *const k_pch_UserInterface_ScreenshotType_Int = "screenshotType";
1834
1835 //-----------------------------------------------------------------------------
1836 // notification keys
1837 static const char *const k_pch_Notifications_Section = "notifications";
1838 static const char *const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
1839
1840 //-----------------------------------------------------------------------------
1841 // keyboard keys
1842 static const char *const k_pch_Keyboard_Section = "keyboard";
1843 static const char *const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
1844 static const char *const k_pch_Keyboard_ScaleX = "ScaleX";
1845 static const char *const k_pch_Keyboard_ScaleY = "ScaleY";
1846 static const char *const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
1847 static const char *const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
1848 static const char *const k_pch_Keyboard_OffsetY = "OffsetY";
1849 static const char *const k_pch_Keyboard_Smoothing = "Smoothing";
1850
1851 //-----------------------------------------------------------------------------
1852 // perf keys
1853 static const char *const k_pch_Perf_Section = "perfcheck";
1854 static const char *const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
1855 static const char *const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
1856 static const char *const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
1857 static const char *const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
1858 static const char *const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
1859 static const char *const k_pch_Perf_TestData_Float = "perfTestData";
1860 static const char *const k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling";
1861
1862 //-----------------------------------------------------------------------------
1863 // collision bounds keys
1864 static const char *const k_pch_CollisionBounds_Section = "collisionBounds";
1865 static const char *const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
1866 static const char *const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
1867 static const char *const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
1868 static const char *const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
1869 static const char *const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
1870 static const char *const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
1871 static const char *const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
1872 static const char *const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
1873 static const char *const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
1874
1875 //-----------------------------------------------------------------------------
1876 // camera keys
1877 static const char *const k_pch_Camera_Section = "camera";
1878 static const char *const k_pch_Camera_EnableCamera_Bool = "enableCamera";
1879 static const char *const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
1880 static const char *const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
1881 static const char *const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
1882 static const char *const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
1883 static const char *const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
1884 static const char *const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
1885 static const char *const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
1886 static const char *const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength";
1887
1888 //-----------------------------------------------------------------------------
1889 // audio keys
1890 static const char *const k_pch_audio_Section = "audio";
1891 static const char *const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
1892 static const char *const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
1893 static const char *const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
1894 static const char *const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
1895 static const char *const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
1896 static const char *const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
1897
1898 //-----------------------------------------------------------------------------
1899 // power management keys
1900 static const char *const k_pch_Power_Section = "power";
1901 static const char *const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit";
1902 static const char *const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout";
1903 static const char *const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout";
1904 static const char *const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout";
1905 static const char *const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress";
1906 static const char *const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby";
1907
1908 //-----------------------------------------------------------------------------
1909 // dashboard keys
1910 static const char *const k_pch_Dashboard_Section = "dashboard";
1911 static const char *const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard";
1912 static const char *const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode";
1913
1914 //-----------------------------------------------------------------------------
1915 // model skin keys
1916 static const char *const k_pch_modelskin_Section = "modelskins";
1917
1918 //-----------------------------------------------------------------------------
1919 // driver keys - These could be checked in any driver_<name> section
1920 static const char *const k_pch_Driver_Enable_Bool = "enable";
1921
1922 } // namespace vr
1923
1924 // ivrchaperone.h
1925 namespace vr
1926 {
1927 #pragma pack(push, 8)
1928
1929 enum ChaperoneCalibrationState
1930 {
1931 // OK!
1932 ChaperoneCalibrationState_OK = 1, // Chaperone is fully calibrated and working correctly
1933
1934 // Warnings
1935 ChaperoneCalibrationState_Warning = 100,
1936 ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101, // A base station thinks that it might have moved
1937 ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, // There are less base stations than when calibrated
1938 ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, // Seated bounds haven't been calibrated for the current tracking center
1939
1940 // Errors
1941 ChaperoneCalibrationState_Error = 200, // The UniverseID is invalid
1942 ChaperoneCalibrationState_Error_BaseStationUninitialized = 201, // Tracking center hasn't be calibrated for at least one of the base stations
1943 ChaperoneCalibrationState_Error_BaseStationConflict = 202, // Tracking center is calibrated, but base stations disagree on the tracking space
1944 ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, // Play Area hasn't been calibrated for the current tracking center
1945 ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, // Collision Bounds haven't been calibrated for the current tracking center
1946 };
1947
1948 /** HIGH LEVEL TRACKING SPACE ASSUMPTIONS:
1949 * 0,0,0 is the preferred standing area center.
1950 * 0Y is the floor height.
1951 * -Z is the preferred forward facing direction. */
1952 class IVRChaperone
1953 {
1954 public:
1955 /** Get the current state of Chaperone calibration. This state can change at any time during a session due to physical base station changes. **/
1956 virtual ChaperoneCalibrationState GetCalibrationState() = 0;
1957
1958 /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z.
1959 * Tracking space center (0,0,0) is the center of the Play Area. **/
1960 virtual bool GetPlayAreaSize(float *pSizeX, float *pSizeZ) = 0;
1961
1962 /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds).
1963 * Corners are in counter-clockwise order.
1964 * Standing center (0,0,0) is the center of the Play Area.
1965 * It's a rectangle.
1966 * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
1967 * Height of every corner is 0Y (on the floor). **/
1968 virtual bool GetPlayAreaRect(HmdQuad_t *rect) = 0;
1969
1970 /** Reload Chaperone data from the .vrchap file on disk. */
1971 virtual void ReloadInfo(void) = 0;
1972
1973 /** Optionally give the chaperone system a hit about the color and brightness in the scene **/
1974 virtual void SetSceneColor(HmdColor_t color) = 0;
1975
1976 /** Get the current chaperone bounds draw color and brightness **/
1977 virtual void GetBoundsColor(HmdColor_t *pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, HmdColor_t *pOutputCameraColor) = 0;
1978
1979 /** Determine whether the bounds are showing right now **/
1980 virtual bool AreBoundsVisible() = 0;
1981
1982 /** Force the bounds to show, mostly for utilities **/
1983 virtual void ForceBoundsVisible(bool bForce) = 0;
1984 };
1985
1986 static const char *const IVRChaperone_Version = "IVRChaperone_003";
1987
1988 #pragma pack(pop)
1989
1990 } // namespace vr
1991
1992 // ivrchaperonesetup.h
1993 namespace vr
1994 {
1995 enum EChaperoneConfigFile
1996 {
1997 EChaperoneConfigFile_Live = 1, // The live chaperone config, used by most applications and games
1998 EChaperoneConfigFile_Temp = 2, // The temporary chaperone config, used to live-preview collision bounds in room setup
1999 };
2000
2001 enum EChaperoneImportFlags
2002 {
2003 EChaperoneImport_BoundsOnly = 0x0001,
2004 };
2005
2006 /** Manages the working copy of the chaperone info. By default this will be the same as the
2007 * live copy. Any changes made with this interface will stay in the working copy until
2008 * CommitWorkingCopy() is called, at which point the working copy and the live copy will be
2009 * the same again. */
2010 class IVRChaperoneSetup
2011 {
2012 public:
2013 /** Saves the current working copy to disk */
2014 virtual bool CommitWorkingCopy(EChaperoneConfigFile configFile) = 0;
2015
2016 /** Reverts the working copy to match the live chaperone calibration.
2017 * To modify existing data this MUST be do WHILE getting a non-error ChaperoneCalibrationStatus.
2018 * Only after this should you do gets and sets on the existing data. */
2019 virtual void RevertWorkingCopy() = 0;
2020
2021 /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z from the working copy.
2022 * Tracking space center (0,0,0) is the center of the Play Area. */
2023 virtual bool GetWorkingPlayAreaSize(float *pSizeX, float *pSizeZ) = 0;
2024
2025 /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds) from the working copy.
2026 * Corners are in clockwise order.
2027 * Tracking space center (0,0,0) is the center of the Play Area.
2028 * It's a rectangle.
2029 * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
2030 * Height of every corner is 0Y (on the floor). **/
2031 virtual bool GetWorkingPlayAreaRect(HmdQuad_t *rect) = 0;
2032
2033 /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
2034 * into the buffer up to the max specified from the working copy. */
2035 virtual bool GetWorkingCollisionBoundsInfo(VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t *punQuadsCount) = 0;
2036
2037 /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
2038 * into the buffer up to the max specified. */
2039 virtual bool GetLiveCollisionBoundsInfo(VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t *punQuadsCount) = 0;
2040
2041 /** Returns the preferred seated position from the working copy. */
2042 virtual bool GetWorkingSeatedZeroPoseToRawTrackingPose(HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose) = 0;
2043
2044 /** Returns the standing origin from the working copy. */
2045 virtual bool GetWorkingStandingZeroPoseToRawTrackingPose(HmdMatrix34_t *pmatStandingZeroPoseToRawTrackingPose) = 0;
2046
2047 /** Sets the Play Area in the working copy. */
2048 virtual void SetWorkingPlayAreaSize(float sizeX, float sizeZ) = 0;
2049
2050 /** Sets the Collision Bounds in the working copy. */
2051 virtual void SetWorkingCollisionBoundsInfo(VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount) = 0;
2052
2053 /** Sets the preferred seated position in the working copy. */
2054 virtual void SetWorkingSeatedZeroPoseToRawTrackingPose(const HmdMatrix34_t *pMatSeatedZeroPoseToRawTrackingPose) = 0;
2055
2056 /** Sets the preferred standing position in the working copy. */
2057 virtual void SetWorkingStandingZeroPoseToRawTrackingPose(const HmdMatrix34_t *pMatStandingZeroPoseToRawTrackingPose) = 0;
2058
2059 /** Tear everything down and reload it from the file on disk */
2060 virtual void ReloadFromDisk(EChaperoneConfigFile configFile) = 0;
2061
2062 /** Returns the preferred seated position. */
2063 virtual bool GetLiveSeatedZeroPoseToRawTrackingPose(HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose) = 0;
2064
2065 virtual void SetWorkingCollisionBoundsTagsInfo(VR_ARRAY_COUNT(unTagCount) uint8_t *pTagsBuffer, uint32_t unTagCount) = 0;
2066 virtual bool GetLiveCollisionBoundsTagsInfo(VR_OUT_ARRAY_COUNT(punTagCount) uint8_t *pTagsBuffer, uint32_t *punTagCount) = 0;
2067
2068 virtual bool SetWorkingPhysicalBoundsInfo(VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount) = 0;
2069 virtual bool GetLivePhysicalBoundsInfo(VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t *punQuadsCount) = 0;
2070
2071 virtual bool ExportLiveToBuffer(VR_OUT_STRING() char *pBuffer, uint32_t *pnBufferLength) = 0;
2072 virtual bool ImportFromBufferToWorking(const char *pBuffer, uint32_t nImportFlags) = 0;
2073 };
2074
2075 static const char *const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005";
2076
2077 } // namespace vr
2078
2079 // ivrcompositor.h
2080 namespace vr
2081 {
2082 #pragma pack(push, 8)
2083
2084 /** Errors that can occur with the VR compositor */
2085 enum EVRCompositorError
2086 {
2087 VRCompositorError_None = 0,
2088 VRCompositorError_RequestFailed = 1,
2089 VRCompositorError_IncompatibleVersion = 100,
2090 VRCompositorError_DoNotHaveFocus = 101,
2091 VRCompositorError_InvalidTexture = 102,
2092 VRCompositorError_IsNotSceneApplication = 103,
2093 VRCompositorError_TextureIsOnWrongDevice = 104,
2094 VRCompositorError_TextureUsesUnsupportedFormat = 105,
2095 VRCompositorError_SharedTexturesNotSupported = 106,
2096 VRCompositorError_IndexOutOfRange = 107,
2097 VRCompositorError_AlreadySubmitted = 108,
2098 VRCompositorError_InvalidBounds = 109,
2099 };
2100
2101 const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01;
2102 const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02;
2103 const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicates the async reprojection mode is active,
2104 // but does not indicate if reprojection actually happened or not.
2105 // Use the ReprojectionReason flags above to check if reprojection
2106 // was actually applied (i.e. scene texture was reused).
2107 // NumFramePresents > 1 also indicates the scene texture was reused,
2108 // and also the number of times that it was presented in total.
2109
2110 /** Provides a single frame's timing information to the app */
2111 struct Compositor_FrameTiming
2112 {
2113 uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming )
2114 uint32_t m_nFrameIndex;
2115 uint32_t m_nNumFramePresents; // number of times this frame was presented
2116 uint32_t m_nNumMisPresented; // number of times this frame was presented on a vsync other than it was originally predicted to
2117 uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out
2118 uint32_t m_nReprojectionFlags;
2119
2120 /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */
2121 double m_flSystemTimeInSeconds;
2122
2123 /** These times may include work from other processes due to OS scheduling.
2124 * The fewer packets of work these are broken up into, the less likely this will happen.
2125 * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started
2126 * processing that work earlier in the frame. */
2127 float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit)
2128 float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window)
2129 float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work
2130 float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc.
2131 float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame
2132 float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time)
2133
2134 /** Miscellaneous measured intervals. */
2135 float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses
2136 float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long)
2137 float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure)
2138 float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue)
2139
2140 /** The following are all relative to this frame's SystemTimeInSeconds */
2141 float m_flWaitGetPosesCalledMs;
2142 float m_flNewPosesReadyMs;
2143 float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit
2144 float m_flCompositorUpdateStartMs;
2145 float m_flCompositorUpdateEndMs;
2146 float m_flCompositorRenderStartMs;
2147
2148 vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame
2149 };
2150
2151 /** Cumulative stats for current application. These are not cleared until a new app connects,
2152 * but they do stop accumulating once the associated app disconnects. */
2153 struct Compositor_CumulativeStats
2154 {
2155 uint32_t m_nPid; // Process id associated with these stats (may no longer be running).
2156 uint32_t m_nNumFramePresents; // total number of times we called present (includes reprojected frames)
2157 uint32_t m_nNumDroppedFrames; // total number of times an old frame was re-scanned out (without reprojection)
2158 uint32_t m_nNumReprojectedFrames; // total number of times a frame was scanned out a second time (with reprojection)
2159
2160 /** Values recorded at startup before application has fully faded in the first time. */
2161 uint32_t m_nNumFramePresentsOnStartup;
2162 uint32_t m_nNumDroppedFramesOnStartup;
2163 uint32_t m_nNumReprojectedFramesOnStartup;
2164
2165 /** Applications may explicitly fade to the compositor. This is usually to handle level transitions, and loading often causes
2166 * system wide hitches. The following stats are collected during this period. Does not include values recorded during startup. */
2167 uint32_t m_nNumLoading;
2168 uint32_t m_nNumFramePresentsLoading;
2169 uint32_t m_nNumDroppedFramesLoading;
2170 uint32_t m_nNumReprojectedFramesLoading;
2171
2172 /** If we don't get a new frame from the app in less than 2.5 frames, then we assume the app has hung and start
2173 * fading back to the compositor. The following stats are a result of this, and are a subset of those recorded above.
2174 * Does not include values recorded during start up or loading. */
2175 uint32_t m_nNumTimedOut;
2176 uint32_t m_nNumFramePresentsTimedOut;
2177 uint32_t m_nNumDroppedFramesTimedOut;
2178 uint32_t m_nNumReprojectedFramesTimedOut;
2179 };
2180
2181 #pragma pack(pop)
2182
2183 /** Allows the application to interact with the compositor */
2184 class IVRCompositor
2185 {
2186 public:
2187 /** Sets tracking space returned by WaitGetPoses */
2188 virtual void SetTrackingSpace(ETrackingUniverseOrigin eOrigin) = 0;
2189
2190 /** Gets current tracking space returned by WaitGetPoses */
2191 virtual ETrackingUniverseOrigin GetTrackingSpace() = 0;
2192
2193 /** Scene applications should call this function to get poses to render with (and optionally poses predicted an additional frame out to use for gameplay).
2194 * This function will block until "running start" milliseconds before the start of the frame, and should be called at the last moment before needing to
2195 * start rendering.
2196 *
2197 * Return codes:
2198 * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene)
2199 * - DoNotHaveFocus (some other app has taken focus - this will throttle the call to 10hz to reduce the impact on that app)
2200 */
2201 virtual EVRCompositorError WaitGetPoses(VR_ARRAY_COUNT(unRenderPoseArrayCount) TrackedDevicePose_t *pRenderPoseArray, uint32_t unRenderPoseArrayCount,
2202 VR_ARRAY_COUNT(unGamePoseArrayCount) TrackedDevicePose_t *pGamePoseArray, uint32_t unGamePoseArrayCount) = 0;
2203
2204 /** Get the last set of poses returned by WaitGetPoses. */
2205 virtual EVRCompositorError GetLastPoses(VR_ARRAY_COUNT(unRenderPoseArrayCount) TrackedDevicePose_t *pRenderPoseArray, uint32_t unRenderPoseArrayCount,
2206 VR_ARRAY_COUNT(unGamePoseArrayCount) TrackedDevicePose_t *pGamePoseArray, uint32_t unGamePoseArrayCount) = 0;
2207
2208 /** Interface for accessing last set of poses returned by WaitGetPoses one at a time.
2209 * Returns VRCompositorError_IndexOutOfRange if unDeviceIndex not less than k_unMaxTrackedDeviceCount otherwise VRCompositorError_None.
2210 * It is okay to pass NULL for either pose if you only want one of the values. */
2211 virtual EVRCompositorError GetLastPoseForTrackedDeviceIndex(TrackedDeviceIndex_t unDeviceIndex, TrackedDevicePose_t *pOutputPose, TrackedDevicePose_t *pOutputGamePose) = 0;
2212
2213 /** Updated scene texture to display. If pBounds is NULL the entire texture will be used. If called from an OpenGL app, consider adding a glFlush after
2214 * Submitting both frames to signal the driver to start processing, otherwise it may wait until the command buffer fills up, causing the app to miss frames.
2215 *
2216 * OpenGL dirty state:
2217 * glBindTexture
2218 *
2219 * Return codes:
2220 * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene)
2221 * - DoNotHaveFocus (some other app has taken focus)
2222 * - TextureIsOnWrongDevice (application did not use proper AdapterIndex - see IVRSystem.GetDXGIOutputInfo)
2223 * - SharedTexturesNotSupported (application needs to call CreateDXGIFactory1 or later before creating DX device)
2224 * - TextureUsesUnsupportedFormat (scene textures must be compatible with DXGI sharing rules - e.g. uncompressed, no mips, etc.)
2225 * - InvalidTexture (usually means bad arguments passed in)
2226 * - AlreadySubmitted (app has submitted two left textures or two right textures in a single frame - i.e. before calling WaitGetPoses again)
2227 */
2228 virtual EVRCompositorError Submit(EVREye eEye, const Texture_t *pTexture, const VRTextureBounds_t *pBounds = 0, EVRSubmitFlags nSubmitFlags = Submit_Default) = 0;
2229
2230 /** Clears the frame that was sent with the last call to Submit. This will cause the
2231 * compositor to show the grid until Submit is called again. */
2232 virtual void ClearLastSubmittedFrame() = 0;
2233
2234 /** Call immediately after presenting your app's window (i.e. companion window) to unblock the compositor.
2235 * This is an optional call, which only needs to be used if you can't instead call WaitGetPoses immediately after Present.
2236 * For example, if your engine's render and game loop are not on separate threads, or blocking the render thread until 3ms before the next vsync would
2237 * introduce a deadlock of some sort. This function tells the compositor that you have finished all rendering after having Submitted buffers for both
2238 * eyes, and it is free to start its rendering work. This should only be called from the same thread you are rendering on. */
2239 virtual void PostPresentHandoff() = 0;
2240
2241 /** Returns true if timing data is filled it. Sets oldest timing info if nFramesAgo is larger than the stored history.
2242 * Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function. */
2243 virtual bool GetFrameTiming(Compositor_FrameTiming *pTiming, uint32_t unFramesAgo = 0) = 0;
2244
2245 /** 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.
2246 * 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. */
2247 virtual uint32_t GetFrameTimings(Compositor_FrameTiming *pTiming, uint32_t nFrames) = 0;
2248
2249 /** Returns the time in seconds left in the current (as identified by FrameTiming's frameIndex) frame.
2250 * Due to "running start", this value may roll over to the next frame before ever reaching 0.0. */
2251 virtual float GetFrameTimeRemaining() = 0;
2252
2253 /** Fills out stats accumulated for the last connected application. Pass in sizeof( Compositor_CumulativeStats ) as second parameter. */
2254 virtual void GetCumulativeStats(Compositor_CumulativeStats *pStats, uint32_t nStatsSizeInBytes) = 0;
2255
2256 /** Fades the view on the HMD to the specified color. The fade will take fSeconds, and the color values are between
2257 * 0.0 and 1.0. This color is faded on top of the scene based on the alpha parameter. Removing the fade color instantly
2258 * would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). Values are in un-premultiplied alpha space. */
2259 virtual void FadeToColor(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground = false) = 0;
2260
2261 /** Get current fade color value. */
2262 virtual HmdColor_t GetCurrentFadeColor(bool bBackground = false) = 0;
2263
2264 /** Fading the Grid in or out in fSeconds */
2265 virtual void FadeGrid(float fSeconds, bool bFadeIn) = 0;
2266
2267 /** Get current alpha value of grid. */
2268 virtual float GetCurrentGridAlpha() = 0;
2269
2270 /** Override the skybox used in the compositor (e.g. for during level loads when the app can't feed scene images fast enough)
2271 * Order is Front, Back, Left, Right, Top, Bottom. If only a single texture is passed, it is assumed in lat-long format.
2272 * If two are passed, it is assumed a lat-long stereo pair. */
2273 virtual EVRCompositorError SetSkyboxOverride(VR_ARRAY_COUNT(unTextureCount) const Texture_t *pTextures, uint32_t unTextureCount) = 0;
2274
2275 /** Resets compositor skybox back to defaults. */
2276 virtual void ClearSkyboxOverride() = 0;
2277
2278 /** Brings the compositor window to the front. This is useful for covering any other window that may be on the HMD
2279 * and is obscuring the compositor window. */
2280 virtual void CompositorBringToFront() = 0;
2281
2282 /** Pushes the compositor window to the back. This is useful for allowing other applications to draw directly to the HMD. */
2283 virtual void CompositorGoToBack() = 0;
2284
2285 /** Tells the compositor process to clean up and exit. You do not need to call this function at shutdown. Under normal
2286 * circumstances the compositor will manage its own life cycle based on what applications are running. */
2287 virtual void CompositorQuit() = 0;
2288
2289 /** Return whether the compositor is fullscreen */
2290 virtual bool IsFullscreen() = 0;
2291
2292 /** Returns the process ID of the process that is currently rendering the scene */
2293 virtual uint32_t GetCurrentSceneFocusProcess() = 0;
2294
2295 /** Returns the process ID of the process that rendered the last frame (or 0 if the compositor itself rendered the frame.)
2296 * Returns 0 when fading out from an app and the app's process Id when fading into an app. */
2297 virtual uint32_t GetLastFrameRenderer() = 0;
2298
2299 /** Returns true if the current process has the scene focus */
2300 virtual bool CanRenderScene() = 0;
2301
2302 /** Creates a window on the primary monitor to display what is being shown in the headset. */
2303 virtual void ShowMirrorWindow() = 0;
2304
2305 /** Closes the mirror window. */
2306 virtual void HideMirrorWindow() = 0;
2307
2308 /** Returns true if the mirror window is shown. */
2309 virtual bool IsMirrorWindowVisible() = 0;
2310
2311 /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */
2312 virtual void CompositorDumpImages() = 0;
2313
2314 /** Let an app know it should be rendering with low resources. */
2315 virtual bool ShouldAppRenderWithLowResources() = 0;
2316
2317 /** Override interleaved reprojection logic to force on. */
2318 virtual void ForceInterleavedReprojectionOn(bool bOverride) = 0;
2319
2320 /** Force reconnecting to the compositor process. */
2321 virtual void ForceReconnectProcess() = 0;
2322
2323 /** Temporarily suspends rendering (useful for finer control over scene transitions). */
2324 virtual void SuspendRendering(bool bSuspend) = 0;
2325
2326 /** Opens a shared D3D11 texture with the undistorted composited image for each eye. Use ReleaseMirrorTextureD3D11 when finished
2327 * instead of calling Release on the resource itself. */
2328 virtual vr::EVRCompositorError GetMirrorTextureD3D11(vr::EVREye eEye, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView) = 0;
2329 virtual void ReleaseMirrorTextureD3D11(void *pD3D11ShaderResourceView) = 0;
2330
2331 /** Access to mirror textures from OpenGL. */
2332 virtual vr::EVRCompositorError GetMirrorTextureGL(vr::EVREye eEye, vr::glUInt_t *pglTextureId, vr::glSharedTextureHandle_t *pglSharedTextureHandle) = 0;
2333 virtual bool ReleaseSharedGLTexture(vr::glUInt_t glTextureId, vr::glSharedTextureHandle_t glSharedTextureHandle) = 0;
2334 virtual void LockGLSharedTextureForAccess(vr::glSharedTextureHandle_t glSharedTextureHandle) = 0;
2335 virtual void UnlockGLSharedTextureForAccess(vr::glSharedTextureHandle_t glSharedTextureHandle) = 0;
2336
2337 /** [Vulkan Only]
2338 * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
2339 * null. The string will be a space separated list of-required instance extensions to enable in VkCreateInstance */
2340 virtual uint32_t GetVulkanInstanceExtensionsRequired(VR_OUT_STRING() char *pchValue, uint32_t unBufferSize) = 0;
2341
2342 /** [Vulkan only]
2343 * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
2344 * null. The string will be a space separated list of required device extensions to enable in VkCreateDevice */
2345 virtual uint32_t GetVulkanDeviceExtensionsRequired(VkPhysicalDevice_T *pPhysicalDevice, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize) = 0;
2346
2347 /** [ Vulkan/D3D12 Only ]
2348 * There are two purposes for SetExplicitTimingMode:
2349 * 1. To get a more accurate GPU timestamp for when the frame begins in Vulkan/D3D12 applications.
2350 * 2. (Optional) To avoid having WaitGetPoses access the Vulkan queue so that the queue can be accessed from
2351 * another thread while WaitGetPoses is executing.
2352 *
2353 * More accurate GPU timestamp for the start of the frame is achieved by the application calling
2354 * SubmitExplicitTimingData immediately before its first submission to the Vulkan/D3D12 queue.
2355 * This is more accurate because normally this GPU timestamp is recorded during WaitGetPoses. In D3D11,
2356 * WaitGetPoses queues a GPU timestamp write, but it does not actually get submitted to the GPU until the
2357 * application flushes. By using SubmitExplicitTimingData, the timestamp is recorded at the same place for
2358 * Vulkan/D3D12 as it is for D3D11, resulting in a more accurate GPU time measurement for the frame.
2359 *
2360 * Avoiding WaitGetPoses accessing the Vulkan queue can be achieved using SetExplicitTimingMode as well. If this is desired,
2361 * the application *MUST* call PostPresentHandoff itself prior to WaitGetPoses. If SetExplicitTimingMode is true and the
2362 * application calls PostPresentHandoff, then WaitGetPoses is guaranteed not to access the queue. Note that PostPresentHandoff
2363 * and SubmitExplicitTimingData will access the queue, so only WaitGetPoses becomes safe for accessing the queue from another
2364 * thread. */
2365 virtual void SetExplicitTimingMode(bool bExplicitTimingMode) = 0;
2366
2367 /** [ Vulkan/D3D12 Only ]
2368 * Submit explicit timing data. When SetExplicitTimingMode is true, this must be called immediately before
2369 * the application's first vkQueueSubmit (Vulkan) or ID3D12CommandQueue::ExecuteCommandLists (D3D12) of each frame.
2370 * This function will insert a GPU timestamp write just before the application starts its rendering. This function
2371 * will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread.
2372 * Returns VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled. */
2373 virtual EVRCompositorError SubmitExplicitTimingData() = 0;
2374 };
2375
2376 static const char *const IVRCompositor_Version = "IVRCompositor_021";
2377
2378 } // namespace vr
2379
2380 // ivrnotifications.h
2381 namespace vr
2382 {
2383 #pragma pack(push, 8)
2384
2385 // Used for passing graphic data
2386 struct NotificationBitmap_t
2387 {
NotificationBitmap_tNotificationBitmap_t2388 NotificationBitmap_t()
2389 : m_pImageData(nullptr), m_nWidth(0), m_nHeight(0), m_nBytesPerPixel(0){};
2390
2391 void *m_pImageData;
2392 int32_t m_nWidth;
2393 int32_t m_nHeight;
2394 int32_t m_nBytesPerPixel;
2395 };
2396
2397 /** Be aware that the notification type is used as 'priority' to pick the next notification */
2398 enum EVRNotificationType
2399 {
2400 /** Transient notifications are automatically hidden after a period of time set by the user.
2401 * They are used for things like information and chat messages that do not require user interaction. */
2402 EVRNotificationType_Transient = 0,
2403
2404 /** Persistent notifications are shown to the user until they are hidden by calling RemoveNotification().
2405 * They are used for things like phone calls and alarms that require user interaction. */
2406 EVRNotificationType_Persistent = 1,
2407
2408 /** System notifications are shown no matter what. It is expected, that the ulUserValue is used as ID.
2409 * If there is already a system notification in the queue with that ID it is not accepted into the queue
2410 * to prevent spamming with system notification */
2411 EVRNotificationType_Transient_SystemWithUserValue = 2,
2412 };
2413
2414 enum EVRNotificationStyle
2415 {
2416 /** Creates a notification with minimal external styling. */
2417 EVRNotificationStyle_None = 0,
2418
2419 /** Used for notifications about overlay-level status. In Steam this is used for events like downloads completing. */
2420 EVRNotificationStyle_Application = 100,
2421
2422 /** Used for notifications about contacts that are unknown or not available. In Steam this is used for friend invitations and offline friends. */
2423 EVRNotificationStyle_Contact_Disabled = 200,
2424
2425 /** Used for notifications about contacts that are available but inactive. In Steam this is used for friends that are online but not playing a game. */
2426 EVRNotificationStyle_Contact_Enabled = 201,
2427
2428 /** Used for notifications about contacts that are available and active. In Steam this is used for friends that are online and currently running a game. */
2429 EVRNotificationStyle_Contact_Active = 202,
2430 };
2431
2432 static const uint32_t k_unNotificationTextMaxSize = 256;
2433
2434 typedef uint32_t VRNotificationId;
2435
2436 #pragma pack(pop)
2437
2438 /** Allows notification sources to interact with the VR system
2439 This current interface is not yet implemented. Do not use yet. */
2440 class IVRNotifications
2441 {
2442 public:
2443 /** Create a notification and enqueue it to be shown to the user.
2444 * An overlay handle is required to create a notification, as otherwise it would be impossible for a user to act on it.
2445 * To create a two-line notification, use a line break ('\n') to split the text into two lines.
2446 * The pImage argument may be NULL, in which case the specified overlay's icon will be used instead. */
2447 virtual EVRNotificationError CreateNotification(VROverlayHandle_t ulOverlayHandle, uint64_t ulUserValue, EVRNotificationType type, const char *pchText, EVRNotificationStyle style, const NotificationBitmap_t *pImage, /* out */ VRNotificationId *pNotificationId) = 0;
2448
2449 /** Destroy a notification, hiding it first if it currently shown to the user. */
2450 virtual EVRNotificationError RemoveNotification(VRNotificationId notificationId) = 0;
2451 };
2452
2453 static const char *const IVRNotifications_Version = "IVRNotifications_002";
2454
2455 } // namespace vr
2456
2457 // ivroverlay.h
2458 namespace vr
2459 {
2460 /** The maximum length of an overlay key in bytes, counting the terminating null character. */
2461 static const uint32_t k_unVROverlayMaxKeyLength = 128;
2462
2463 /** The maximum length of an overlay name in bytes, counting the terminating null character. */
2464 static const uint32_t k_unVROverlayMaxNameLength = 128;
2465
2466 /** The maximum number of overlays that can exist in the system at one time. */
2467 static const uint32_t k_unMaxOverlayCount = 64;
2468
2469 /** The maximum number of overlay intersection mask primitives per overlay */
2470 static const uint32_t k_unMaxOverlayIntersectionMaskPrimitivesCount = 32;
2471
2472 /** Types of input supported by VR Overlays */
2473 enum VROverlayInputMethod
2474 {
2475 VROverlayInputMethod_None = 0, // No input events will be generated automatically for this overlay
2476 VROverlayInputMethod_Mouse = 1, // Tracked controllers will get mouse events automatically
2477 };
2478
2479 /** Allows the caller to figure out which overlay transform getter to call. */
2480 enum VROverlayTransformType
2481 {
2482 VROverlayTransform_Absolute = 0,
2483 VROverlayTransform_TrackedDeviceRelative = 1,
2484 VROverlayTransform_SystemOverlay = 2,
2485 VROverlayTransform_TrackedComponent = 3,
2486 };
2487
2488 /** Overlay control settings */
2489 enum VROverlayFlags
2490 {
2491 VROverlayFlags_None = 0,
2492
2493 // The following only take effect when rendered using the high quality render path (see SetHighQualityOverlay).
2494 VROverlayFlags_Curved = 1,
2495 VROverlayFlags_RGSS4X = 2,
2496
2497 // Set this flag on a dashboard overlay to prevent a tab from showing up for that overlay
2498 VROverlayFlags_NoDashboardTab = 3,
2499
2500 // Set this flag on a dashboard that is able to deal with gamepad focus events
2501 VROverlayFlags_AcceptsGamepadEvents = 4,
2502
2503 // Indicates that the overlay should dim/brighten to show gamepad focus
2504 VROverlayFlags_ShowGamepadFocus = 5,
2505
2506 // When in VROverlayInputMethod_Mouse you can optionally enable sending VRScroll_t
2507 VROverlayFlags_SendVRScrollEvents = 6,
2508 VROverlayFlags_SendVRTouchpadEvents = 7,
2509
2510 // If set this will render a vertical scroll wheel on the primary controller,
2511 // only needed if not using VROverlayFlags_SendVRScrollEvents but you still want to represent a scroll wheel
2512 VROverlayFlags_ShowTouchPadScrollWheel = 8,
2513
2514 // If this is set ownership and render access to the overlay are transferred
2515 // to the new scene process on a call to IVRApplications::LaunchInternalProcess
2516 VROverlayFlags_TransferOwnershipToInternalProcess = 9,
2517
2518 // If set, renders 50% of the texture in each eye, side by side
2519 VROverlayFlags_SideBySide_Parallel = 10, // Texture is left/right
2520 VROverlayFlags_SideBySide_Crossed = 11, // Texture is crossed and right/left
2521
2522 VROverlayFlags_Panorama = 12, // Texture is a panorama
2523 VROverlayFlags_StereoPanorama = 13, // Texture is a stereo panorama
2524
2525 // If this is set on an overlay owned by the scene application that overlay
2526 // will be sorted with the "Other" overlays on top of all other scene overlays
2527 VROverlayFlags_SortWithNonSceneOverlays = 14,
2528
2529 // If set, the overlay will be shown in the dashboard, otherwise it will be hidden.
2530 VROverlayFlags_VisibleInDashboard = 15,
2531 };
2532
2533 enum VRMessageOverlayResponse
2534 {
2535 VRMessageOverlayResponse_ButtonPress_0 = 0,
2536 VRMessageOverlayResponse_ButtonPress_1 = 1,
2537 VRMessageOverlayResponse_ButtonPress_2 = 2,
2538 VRMessageOverlayResponse_ButtonPress_3 = 3,
2539 VRMessageOverlayResponse_CouldntFindSystemOverlay = 4,
2540 VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5,
2541 VRMessageOverlayResponse_ApplicationQuit = 6
2542 };
2543
2544 struct VROverlayIntersectionParams_t
2545 {
2546 HmdVector3_t vSource;
2547 HmdVector3_t vDirection;
2548 ETrackingUniverseOrigin eOrigin;
2549 };
2550
2551 struct VROverlayIntersectionResults_t
2552 {
2553 HmdVector3_t vPoint;
2554 HmdVector3_t vNormal;
2555 HmdVector2_t vUVs;
2556 float fDistance;
2557 };
2558
2559 // Input modes for the Big Picture gamepad text entry
2560 enum EGamepadTextInputMode
2561 {
2562 k_EGamepadTextInputModeNormal = 0,
2563 k_EGamepadTextInputModePassword = 1,
2564 k_EGamepadTextInputModeSubmit = 2,
2565 };
2566
2567 // Controls number of allowed lines for the Big Picture gamepad text entry
2568 enum EGamepadTextInputLineMode
2569 {
2570 k_EGamepadTextInputLineModeSingleLine = 0,
2571 k_EGamepadTextInputLineModeMultipleLines = 1
2572 };
2573
2574 /** Directions for changing focus between overlays with the gamepad */
2575 enum EOverlayDirection
2576 {
2577 OverlayDirection_Up = 0,
2578 OverlayDirection_Down = 1,
2579 OverlayDirection_Left = 2,
2580 OverlayDirection_Right = 3,
2581
2582 OverlayDirection_Count = 4,
2583 };
2584
2585 enum EVROverlayIntersectionMaskPrimitiveType
2586 {
2587 OverlayIntersectionPrimitiveType_Rectangle,
2588 OverlayIntersectionPrimitiveType_Circle,
2589 };
2590
2591 struct IntersectionMaskRectangle_t
2592 {
2593 float m_flTopLeftX;
2594 float m_flTopLeftY;
2595 float m_flWidth;
2596 float m_flHeight;
2597 };
2598
2599 struct IntersectionMaskCircle_t
2600 {
2601 float m_flCenterX;
2602 float m_flCenterY;
2603 float m_flRadius;
2604 };
2605
2606 /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py and openvr_api_flat.h.py */
2607 typedef union {
2608 IntersectionMaskRectangle_t m_Rectangle;
2609 IntersectionMaskCircle_t m_Circle;
2610 } VROverlayIntersectionMaskPrimitive_Data_t;
2611
2612 struct VROverlayIntersectionMaskPrimitive_t
2613 {
2614 EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType;
2615 VROverlayIntersectionMaskPrimitive_Data_t m_Primitive;
2616 };
2617
2618 class IVROverlay
2619 {
2620 public:
2621 // ---------------------------------------------
2622 // Overlay management methods
2623 // ---------------------------------------------
2624
2625 /** Finds an existing overlay with the specified key. */
2626 virtual EVROverlayError FindOverlay(const char *pchOverlayKey, VROverlayHandle_t *pOverlayHandle) = 0;
2627
2628 /** Creates a new named overlay. All overlays start hidden and with default settings. */
2629 virtual EVROverlayError CreateOverlay(const char *pchOverlayKey, const char *pchOverlayName, VROverlayHandle_t *pOverlayHandle) = 0;
2630
2631 /** Destroys the specified overlay. When an application calls VR_Shutdown all overlays created by that app are
2632 * automatically destroyed. */
2633 virtual EVROverlayError DestroyOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2634
2635 /** Specify which overlay to use the high quality render path. This overlay will be composited in during the distortion pass which
2636 * results in it drawing on top of everything else, but also at a higher quality as it samples the source texture directly rather than
2637 * rasterizing into each eye's render texture first. Because if this, only one of these is supported at any given time. It is most useful
2638 * for overlays that are expected to take up most of the user's view (e.g. streaming video).
2639 * This mode does not support mouse input to your overlay. */
2640 virtual EVROverlayError SetHighQualityOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2641
2642 /** Returns the overlay handle of the current overlay being rendered using the single high quality overlay render path.
2643 * Otherwise it will return k_ulOverlayHandleInvalid. */
2644 virtual vr::VROverlayHandle_t GetHighQualityOverlay() = 0;
2645
2646 /** Fills the provided buffer with the string key of the overlay. Returns the size of buffer required to store the key, including
2647 * the terminating null character. k_unVROverlayMaxKeyLength will be enough bytes to fit the string. */
2648 virtual uint32_t GetOverlayKey(VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L) = 0;
2649
2650 /** Fills the provided buffer with the friendly name of the overlay. Returns the size of buffer required to store the key, including
2651 * the terminating null character. k_unVROverlayMaxNameLength will be enough bytes to fit the string. */
2652 virtual uint32_t GetOverlayName(VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L) = 0;
2653
2654 /** set the name to use for this overlay */
2655 virtual EVROverlayError SetOverlayName(VROverlayHandle_t ulOverlayHandle, const char *pchName) = 0;
2656
2657 /** Gets the raw image data from an overlay. Overlay image data is always returned as RGBA data, 4 bytes per pixel. If the buffer is not large enough, width and height
2658 * will be set and VROverlayError_ArrayTooSmall is returned. */
2659 virtual EVROverlayError GetOverlayImageData(VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unBufferSize, uint32_t *punWidth, uint32_t *punHeight) = 0;
2660
2661 /** returns a string that corresponds with the specified overlay error. The string will be the name
2662 * of the error enum value for all valid error codes */
2663 virtual const char *GetOverlayErrorNameFromEnum(EVROverlayError error) = 0;
2664
2665 // ---------------------------------------------
2666 // Overlay rendering methods
2667 // ---------------------------------------------
2668
2669 /** Sets the pid that is allowed to render to this overlay (the creator pid is always allow to render),
2670 * by default this is the pid of the process that made the overlay */
2671 virtual EVROverlayError SetOverlayRenderingPid(VROverlayHandle_t ulOverlayHandle, uint32_t unPID) = 0;
2672
2673 /** Gets the pid that is allowed to render to this overlay */
2674 virtual uint32_t GetOverlayRenderingPid(VROverlayHandle_t ulOverlayHandle) = 0;
2675
2676 /** Specify flag setting for a given overlay */
2677 virtual EVROverlayError SetOverlayFlag(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled) = 0;
2678
2679 /** Sets flag setting for a given overlay */
2680 virtual EVROverlayError GetOverlayFlag(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool *pbEnabled) = 0;
2681
2682 /** Sets the color tint of the overlay quad. Use 0.0 to 1.0 per channel. */
2683 virtual EVROverlayError SetOverlayColor(VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue) = 0;
2684
2685 /** Gets the color tint of the overlay quad. */
2686 virtual EVROverlayError GetOverlayColor(VROverlayHandle_t ulOverlayHandle, float *pfRed, float *pfGreen, float *pfBlue) = 0;
2687
2688 /** Sets the alpha of the overlay quad. Use 1.0 for 100 percent opacity to 0.0 for 0 percent opacity. */
2689 virtual EVROverlayError SetOverlayAlpha(VROverlayHandle_t ulOverlayHandle, float fAlpha) = 0;
2690
2691 /** Gets the alpha of the overlay quad. By default overlays are rendering at 100 percent alpha (1.0). */
2692 virtual EVROverlayError GetOverlayAlpha(VROverlayHandle_t ulOverlayHandle, float *pfAlpha) = 0;
2693
2694 /** Sets the aspect ratio of the texels in the overlay. 1.0 means the texels are square. 2.0 means the texels
2695 * are twice as wide as they are tall. Defaults to 1.0. */
2696 virtual EVROverlayError SetOverlayTexelAspect(VROverlayHandle_t ulOverlayHandle, float fTexelAspect) = 0;
2697
2698 /** Gets the aspect ratio of the texels in the overlay. Defaults to 1.0 */
2699 virtual EVROverlayError GetOverlayTexelAspect(VROverlayHandle_t ulOverlayHandle, float *pfTexelAspect) = 0;
2700
2701 /** Sets the rendering sort order for the overlay. Overlays are rendered this order:
2702 * Overlays owned by the scene application
2703 * Overlays owned by some other application
2704 *
2705 * Within a category overlays are rendered lowest sort order to highest sort order. Overlays with the same
2706 * sort order are rendered back to front base on distance from the HMD.
2707 *
2708 * Sort order defaults to 0. */
2709 virtual EVROverlayError SetOverlaySortOrder(VROverlayHandle_t ulOverlayHandle, uint32_t unSortOrder) = 0;
2710
2711 /** Gets the sort order of the overlay. See SetOverlaySortOrder for how this works. */
2712 virtual EVROverlayError GetOverlaySortOrder(VROverlayHandle_t ulOverlayHandle, uint32_t *punSortOrder) = 0;
2713
2714 /** Sets the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
2715 virtual EVROverlayError SetOverlayWidthInMeters(VROverlayHandle_t ulOverlayHandle, float fWidthInMeters) = 0;
2716
2717 /** Returns the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
2718 virtual EVROverlayError GetOverlayWidthInMeters(VROverlayHandle_t ulOverlayHandle, float *pfWidthInMeters) = 0;
2719
2720 /** For high-quality curved overlays only, sets the distance range in meters from the overlay used to automatically curve
2721 * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
2722 virtual EVROverlayError SetOverlayAutoCurveDistanceRangeInMeters(VROverlayHandle_t ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters) = 0;
2723
2724 /** For high-quality curved overlays only, gets the distance range in meters from the overlay used to automatically curve
2725 * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
2726 virtual EVROverlayError GetOverlayAutoCurveDistanceRangeInMeters(VROverlayHandle_t ulOverlayHandle, float *pfMinDistanceInMeters, float *pfMaxDistanceInMeters) = 0;
2727
2728 /** Sets the colorspace the overlay texture's data is in. Defaults to 'auto'.
2729 * If the texture needs to be resolved, you should call SetOverlayTexture with the appropriate colorspace instead. */
2730 virtual EVROverlayError SetOverlayTextureColorSpace(VROverlayHandle_t ulOverlayHandle, EColorSpace eTextureColorSpace) = 0;
2731
2732 /** Gets the overlay's current colorspace setting. */
2733 virtual EVROverlayError GetOverlayTextureColorSpace(VROverlayHandle_t ulOverlayHandle, EColorSpace *peTextureColorSpace) = 0;
2734
2735 /** Sets the part of the texture to use for the overlay. UV Min is the upper left corner and UV Max is the lower right corner. */
2736 virtual EVROverlayError SetOverlayTextureBounds(VROverlayHandle_t ulOverlayHandle, const VRTextureBounds_t *pOverlayTextureBounds) = 0;
2737
2738 /** Gets the part of the texture to use for the overlay. UV Min is the upper left corner and UV Max is the lower right corner. */
2739 virtual EVROverlayError GetOverlayTextureBounds(VROverlayHandle_t ulOverlayHandle, VRTextureBounds_t *pOverlayTextureBounds) = 0;
2740
2741 /** Gets render model to draw behind this overlay */
2742 virtual uint32_t GetOverlayRenderModel(vr::VROverlayHandle_t ulOverlayHandle, char *pchValue, uint32_t unBufferSize, HmdColor_t *pColor, vr::EVROverlayError *pError) = 0;
2743
2744 /** Sets render model to draw behind this overlay and the vertex color to use, pass null for pColor to match the overlays vertex color.
2745 The model is scaled by the same amount as the overlay, with a default of 1m. */
2746 virtual vr::EVROverlayError SetOverlayRenderModel(vr::VROverlayHandle_t ulOverlayHandle, const char *pchRenderModel, const HmdColor_t *pColor) = 0;
2747
2748 /** Returns the transform type of this overlay. */
2749 virtual EVROverlayError GetOverlayTransformType(VROverlayHandle_t ulOverlayHandle, VROverlayTransformType *peTransformType) = 0;
2750
2751 /** Sets the transform to absolute tracking origin. */
2752 virtual EVROverlayError SetOverlayTransformAbsolute(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToOverlayTransform) = 0;
2753
2754 /** Gets the transform if it is absolute. Returns an error if the transform is some other type. */
2755 virtual EVROverlayError GetOverlayTransformAbsolute(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin *peTrackingOrigin, HmdMatrix34_t *pmatTrackingOriginToOverlayTransform) = 0;
2756
2757 /** Sets the transform to relative to the transform of the specified tracked device. */
2758 virtual EVROverlayError SetOverlayTransformTrackedDeviceRelative(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unTrackedDevice, const HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform) = 0;
2759
2760 /** Gets the transform if it is relative to a tracked device. Returns an error if the transform is some other type. */
2761 virtual EVROverlayError GetOverlayTransformTrackedDeviceRelative(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punTrackedDevice, HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform) = 0;
2762
2763 /** Sets the transform to draw the overlay on a rendermodel component mesh instead of a quad. This will only draw when the system is
2764 * drawing the device. Overlays with this transform type cannot receive mouse events. */
2765 virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, const char *pchComponentName) = 0;
2766
2767 /** Gets the transform information when the overlay is rendering on a component. */
2768 virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, char *pchComponentName, uint32_t unComponentNameSize) = 0;
2769
2770 /** Gets the transform if it is relative to another overlay. Returns an error if the transform is some other type. */
2771 virtual vr::EVROverlayError GetOverlayTransformOverlayRelative(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t *ulOverlayHandleParent, HmdMatrix34_t *pmatParentOverlayToOverlayTransform) = 0;
2772
2773 /** Sets the transform to relative to the transform of the specified overlay. This overlays visibility will also track the parents visibility */
2774 virtual vr::EVROverlayError SetOverlayTransformOverlayRelative(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulOverlayHandleParent, const HmdMatrix34_t *pmatParentOverlayToOverlayTransform) = 0;
2775
2776 /** Shows the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
2777 virtual EVROverlayError ShowOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2778
2779 /** Hides the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
2780 virtual EVROverlayError HideOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2781
2782 /** Returns true if the overlay is visible. */
2783 virtual bool IsOverlayVisible(VROverlayHandle_t ulOverlayHandle) = 0;
2784
2785 /** Get the transform in 3d space associated with a specific 2d point in the overlay's coordinate space (where 0,0 is the lower left). -Z points out of the overlay */
2786 virtual EVROverlayError GetTransformForOverlayCoordinates(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, HmdVector2_t coordinatesInOverlay, HmdMatrix34_t *pmatTransform) = 0;
2787
2788 // ---------------------------------------------
2789 // Overlay input methods
2790 // ---------------------------------------------
2791
2792 /** Returns true and fills the event with the next event on the overlay's event queue, if there is one.
2793 * If there are no events this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
2794 virtual bool PollNextOverlayEvent(VROverlayHandle_t ulOverlayHandle, VREvent_t *pEvent, uint32_t uncbVREvent) = 0;
2795
2796 /** Returns the current input settings for the specified overlay. */
2797 virtual EVROverlayError GetOverlayInputMethod(VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod *peInputMethod) = 0;
2798
2799 /** Sets the input settings for the specified overlay. */
2800 virtual EVROverlayError SetOverlayInputMethod(VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod eInputMethod) = 0;
2801
2802 /** Gets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
2803 * typically the size of the underlying UI in pixels. */
2804 virtual EVROverlayError GetOverlayMouseScale(VROverlayHandle_t ulOverlayHandle, HmdVector2_t *pvecMouseScale) = 0;
2805
2806 /** Sets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
2807 * typically the size of the underlying UI in pixels (not in world space). */
2808 virtual EVROverlayError SetOverlayMouseScale(VROverlayHandle_t ulOverlayHandle, const HmdVector2_t *pvecMouseScale) = 0;
2809
2810 /** Computes the overlay-space pixel coordinates of where the ray intersects the overlay with the
2811 * specified settings. Returns false if there is no intersection. */
2812 virtual bool ComputeOverlayIntersection(VROverlayHandle_t ulOverlayHandle, const VROverlayIntersectionParams_t *pParams, VROverlayIntersectionResults_t *pResults) = 0;
2813
2814 /** Processes mouse input from the specified controller as though it were a mouse pointed at a compositor overlay with the
2815 * specified settings. The controller is treated like a laser pointer on the -z axis. The point where the laser pointer would
2816 * intersect with the overlay is the mouse position, the trigger is left mouse, and the track pad is right mouse.
2817 *
2818 * Return true if the controller is pointed at the overlay and an event was generated. */
2819 virtual bool HandleControllerOverlayInteractionAsMouse(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unControllerDeviceIndex) = 0;
2820
2821 /** Returns true if the specified overlay is the hover target. An overlay is the hover target when it is the last overlay "moused over"
2822 * by the virtual mouse pointer */
2823 virtual bool IsHoverTargetOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2824
2825 /** Returns the current Gamepad focus overlay */
2826 virtual vr::VROverlayHandle_t GetGamepadFocusOverlay() = 0;
2827
2828 /** Sets the current Gamepad focus overlay */
2829 virtual EVROverlayError SetGamepadFocusOverlay(VROverlayHandle_t ulNewFocusOverlay) = 0;
2830
2831 /** Sets an overlay's neighbor. This will also set the neighbor of the "to" overlay
2832 * to point back to the "from" overlay. If an overlay's neighbor is set to invalid both
2833 * ends will be cleared */
2834 virtual EVROverlayError SetOverlayNeighbor(EOverlayDirection eDirection, VROverlayHandle_t ulFrom, VROverlayHandle_t ulTo) = 0;
2835
2836 /** Changes the Gamepad focus from one overlay to one of its neighbors. Returns VROverlayError_NoNeighbor if there is no
2837 * neighbor in that direction */
2838 virtual EVROverlayError MoveGamepadFocusToNeighbor(EOverlayDirection eDirection, VROverlayHandle_t ulFrom) = 0;
2839
2840 // ---------------------------------------------
2841 // Overlay texture methods
2842 // ---------------------------------------------
2843
2844 /** Texture to draw for the overlay. This function can only be called by the overlay's creator or renderer process (see SetOverlayRenderingPid) .
2845 *
2846 * OpenGL dirty state:
2847 * glBindTexture
2848 */
2849 virtual EVROverlayError SetOverlayTexture(VROverlayHandle_t ulOverlayHandle, const Texture_t *pTexture) = 0;
2850
2851 /** Use this to tell the overlay system to release the texture set for this overlay. */
2852 virtual EVROverlayError ClearOverlayTexture(VROverlayHandle_t ulOverlayHandle) = 0;
2853
2854 /** Separate interface for providing the data as a stream of bytes, but there is an upper bound on data
2855 * that can be sent. This function can only be called by the overlay's renderer process. */
2856 virtual EVROverlayError SetOverlayRaw(VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unDepth) = 0;
2857
2858 /** Separate interface for providing the image through a filename: can be png or jpg, and should not be bigger than 1920x1080.
2859 * This function can only be called by the overlay's renderer process */
2860 virtual EVROverlayError SetOverlayFromFile(VROverlayHandle_t ulOverlayHandle, const char *pchFilePath) = 0;
2861
2862 /** Get the native texture handle/device for an overlay you have created.
2863 * On windows this handle will be a ID3D11ShaderResourceView with a ID3D11Texture2D bound.
2864 *
2865 * The texture will always be sized to match the backing texture you supplied in SetOverlayTexture above.
2866 *
2867 * You MUST call ReleaseNativeOverlayHandle() with pNativeTextureHandle once you are done with this texture.
2868 *
2869 * pNativeTextureHandle is an OUTPUT, it will be a pointer to a ID3D11ShaderResourceView *.
2870 * pNativeTextureRef is an INPUT and should be a ID3D11Resource *. The device used by pNativeTextureRef will be used to bind pNativeTextureHandle.
2871 */
2872 virtual EVROverlayError GetOverlayTexture(VROverlayHandle_t ulOverlayHandle, void **pNativeTextureHandle, void *pNativeTextureRef, uint32_t *pWidth, uint32_t *pHeight, uint32_t *pNativeFormat, ETextureType *pAPIType, EColorSpace *pColorSpace, VRTextureBounds_t *pTextureBounds) = 0;
2873
2874 /** Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
2875 * so only do it once you stop rendering this texture.
2876 */
2877 virtual EVROverlayError ReleaseNativeOverlayHandle(VROverlayHandle_t ulOverlayHandle, void *pNativeTextureHandle) = 0;
2878
2879 /** Get the size of the overlay texture */
2880 virtual EVROverlayError GetOverlayTextureSize(VROverlayHandle_t ulOverlayHandle, uint32_t *pWidth, uint32_t *pHeight) = 0;
2881
2882 // ----------------------------------------------
2883 // Dashboard Overlay Methods
2884 // ----------------------------------------------
2885
2886 /** Creates a dashboard overlay and returns its handle */
2887 virtual EVROverlayError CreateDashboardOverlay(const char *pchOverlayKey, const char *pchOverlayFriendlyName, VROverlayHandle_t *pMainHandle, VROverlayHandle_t *pThumbnailHandle) = 0;
2888
2889 /** Returns true if the dashboard is visible */
2890 virtual bool IsDashboardVisible() = 0;
2891
2892 /** returns true if the dashboard is visible and the specified overlay is the active system Overlay */
2893 virtual bool IsActiveDashboardOverlay(VROverlayHandle_t ulOverlayHandle) = 0;
2894
2895 /** Sets the dashboard overlay to only appear when the specified process ID has scene focus */
2896 virtual EVROverlayError SetDashboardOverlaySceneProcess(VROverlayHandle_t ulOverlayHandle, uint32_t unProcessId) = 0;
2897
2898 /** Gets the process ID that this dashboard overlay requires to have scene focus */
2899 virtual EVROverlayError GetDashboardOverlaySceneProcess(VROverlayHandle_t ulOverlayHandle, uint32_t *punProcessId) = 0;
2900
2901 /** Shows the dashboard. */
2902 virtual void ShowDashboard(const char *pchOverlayToShow) = 0;
2903
2904 /** Returns the tracked device that has the laser pointer in the dashboard */
2905 virtual vr::TrackedDeviceIndex_t GetPrimaryDashboardDevice() = 0;
2906
2907 // ---------------------------------------------
2908 // Keyboard methods
2909 // ---------------------------------------------
2910
2911 /** Show the virtual keyboard to accept input **/
2912 virtual EVROverlayError ShowKeyboard(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue) = 0;
2913
2914 virtual EVROverlayError ShowKeyboardForOverlay(VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue) = 0;
2915
2916 /** Get the text that was entered into the text input **/
2917 virtual uint32_t GetKeyboardText(VR_OUT_STRING() char *pchText, uint32_t cchText) = 0;
2918
2919 /** Hide the virtual keyboard **/
2920 virtual void HideKeyboard() = 0;
2921
2922 /** Set the position of the keyboard in world space **/
2923 virtual void SetKeyboardTransformAbsolute(ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToKeyboardTransform) = 0;
2924
2925 /** Set the position of the keyboard in overlay space by telling it to avoid a rectangle in the overlay. Rectangle coords have (0,0) in the bottom left **/
2926 virtual void SetKeyboardPositionForOverlay(VROverlayHandle_t ulOverlayHandle, HmdRect2_t avoidRect) = 0;
2927
2928 // ---------------------------------------------
2929 // Overlay input methods
2930 // ---------------------------------------------
2931
2932 /** Sets a list of primitives to be used for controller ray intersection
2933 * typically the size of the underlying UI in pixels (not in world space). */
2934 virtual EVROverlayError SetOverlayIntersectionMask(VROverlayHandle_t ulOverlayHandle, VROverlayIntersectionMaskPrimitive_t *pMaskPrimitives, uint32_t unNumMaskPrimitives, uint32_t unPrimitiveSize = sizeof(VROverlayIntersectionMaskPrimitive_t)) = 0;
2935
2936 virtual EVROverlayError GetOverlayFlags(VROverlayHandle_t ulOverlayHandle, uint32_t *pFlags) = 0;
2937
2938 // ---------------------------------------------
2939 // Message box methods
2940 // ---------------------------------------------
2941
2942 /** Show the message overlay. This will block and return you a result. **/
2943 virtual VRMessageOverlayResponse ShowMessageOverlay(const char *pchText, const char *pchCaption, const char *pchButton0Text, const char *pchButton1Text = nullptr, const char *pchButton2Text = nullptr, const char *pchButton3Text = nullptr) = 0;
2944
2945 /** If the calling process owns the overlay and it's open, this will close it. **/
2946 virtual void CloseMessageOverlay() = 0;
2947 };
2948
2949 static const char *const IVROverlay_Version = "IVROverlay_016";
2950
2951 } // namespace vr
2952
2953 // ivrrendermodels.h
2954 namespace vr
2955 {
2956 static const char *const k_pch_Controller_Component_GDC2015 = "gdc2015"; // Canonical coordinate system of the gdc 2015 wired controller, provided for backwards compatibility
2957 static const char *const k_pch_Controller_Component_Base = "base"; // For controllers with an unambiguous 'base'.
2958 static const char *const k_pch_Controller_Component_Tip = "tip"; // For controllers with an unambiguous 'tip' (used for 'laser-pointing')
2959 static const char *const k_pch_Controller_Component_HandGrip = "handgrip"; // Neutral, ambidextrous hand-pose when holding controller. On plane between neutrally posed index finger and thumb
2960 static const char *const k_pch_Controller_Component_Status = "status"; // 1:1 aspect ratio status area, with canonical [0,1] uv mapping
2961
2962 #pragma pack(push, 8)
2963
2964 /** Errors that can occur with the VR compositor */
2965 enum EVRRenderModelError
2966 {
2967 VRRenderModelError_None = 0,
2968 VRRenderModelError_Loading = 100,
2969 VRRenderModelError_NotSupported = 200,
2970 VRRenderModelError_InvalidArg = 300,
2971 VRRenderModelError_InvalidModel = 301,
2972 VRRenderModelError_NoShapes = 302,
2973 VRRenderModelError_MultipleShapes = 303,
2974 VRRenderModelError_TooManyVertices = 304,
2975 VRRenderModelError_MultipleTextures = 305,
2976 VRRenderModelError_BufferTooSmall = 306,
2977 VRRenderModelError_NotEnoughNormals = 307,
2978 VRRenderModelError_NotEnoughTexCoords = 308,
2979
2980 VRRenderModelError_InvalidTexture = 400,
2981 };
2982
2983 typedef uint32_t VRComponentProperties;
2984
2985 enum EVRComponentProperty
2986 {
2987 VRComponentProperty_IsStatic = (1 << 0),
2988 VRComponentProperty_IsVisible = (1 << 1),
2989 VRComponentProperty_IsTouched = (1 << 2),
2990 VRComponentProperty_IsPressed = (1 << 3),
2991 VRComponentProperty_IsScrolled = (1 << 4),
2992 };
2993
2994 /** Describes state information about a render-model component, including transforms and other dynamic properties */
2995 struct RenderModel_ComponentState_t
2996 {
2997 HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model
2998 HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface )
2999 VRComponentProperties uProperties;
3000 };
3001
3002 /** A single vertex in a render model */
3003 struct RenderModel_Vertex_t
3004 {
3005 HmdVector3_t vPosition; // position in meters in device space
3006 HmdVector3_t vNormal;
3007 float rfTextureCoord[2];
3008 };
3009
3010 /** A texture map for use on a render model */
3011 #if defined(__linux__) || defined(__APPLE__)
3012 // This structure was originally defined mis-packed on Linux, preserved for
3013 // compatibility.
3014 #pragma pack(push, 4)
3015 #endif
3016
3017 struct RenderModel_TextureMap_t
3018 {
3019 uint16_t unWidth, unHeight; // width and height of the texture map in pixels
3020 const uint8_t *rubTextureMapData; // Map texture data. All textures are RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub
3021 };
3022 #if defined(__linux__) || defined(__APPLE__)
3023 #pragma pack(pop)
3024 #endif
3025
3026 /** Session unique texture identifier. Rendermodels which share the same texture will have the same id.
3027 IDs <0 denote the texture is not present */
3028
3029 typedef int32_t TextureID_t;
3030
3031 const TextureID_t INVALID_TEXTURE_ID = -1;
3032
3033 #if defined(__linux__) || defined(__APPLE__)
3034 // This structure was originally defined mis-packed on Linux, preserved for
3035 // compatibility.
3036 #pragma pack(push, 4)
3037 #endif
3038
3039 struct RenderModel_t
3040 {
3041 const RenderModel_Vertex_t *rVertexData; // Vertex data for the mesh
3042 uint32_t unVertexCount; // Number of vertices in the vertex data
3043 const uint16_t *rIndexData; // Indices into the vertex data for each triangle
3044 uint32_t unTriangleCount; // Number of triangles in the mesh. Index count is 3 * TriangleCount
3045 TextureID_t diffuseTextureId; // Session unique texture identifier. Rendermodels which share the same texture will have the same id. <0 == texture not present
3046 };
3047 #if defined(__linux__) || defined(__APPLE__)
3048 #pragma pack(pop)
3049 #endif
3050
3051 struct RenderModel_ControllerMode_State_t
3052 {
3053 bool bScrollWheelVisible; // is this controller currently set to be in a scroll wheel mode
3054 };
3055
3056 #pragma pack(pop)
3057
3058 class IVRRenderModels
3059 {
3060 public:
3061 /** Loads and returns a render model for use in the application. pchRenderModelName should be a render model name
3062 * from the Prop_RenderModelName_String property or an absolute path name to a render model on disk.
3063 *
3064 * The resulting render model is valid until VR_Shutdown() is called or until FreeRenderModel() is called. When the
3065 * application is finished with the render model it should call FreeRenderModel() to free the memory associated
3066 * with the model.
3067 *
3068 * The method returns VRRenderModelError_Loading while the render model is still being loaded.
3069 * The method returns VRRenderModelError_None once loaded successfully, otherwise will return an error. */
3070 virtual EVRRenderModelError LoadRenderModel_Async(const char *pchRenderModelName, RenderModel_t **ppRenderModel) = 0;
3071
3072 /** Frees a previously returned render model
3073 * It is safe to call this on a null ptr. */
3074 virtual void FreeRenderModel(RenderModel_t *pRenderModel) = 0;
3075
3076 /** Loads and returns a texture for use in the application. */
3077 virtual EVRRenderModelError LoadTexture_Async(TextureID_t textureId, RenderModel_TextureMap_t **ppTexture) = 0;
3078
3079 /** Frees a previously returned texture
3080 * It is safe to call this on a null ptr. */
3081 virtual void FreeTexture(RenderModel_TextureMap_t *pTexture) = 0;
3082
3083 /** Creates a D3D11 texture and loads data into it. */
3084 virtual EVRRenderModelError LoadTextureD3D11_Async(TextureID_t textureId, void *pD3D11Device, void **ppD3D11Texture2D) = 0;
3085
3086 /** Helper function to copy the bits into an existing texture. */
3087 virtual EVRRenderModelError LoadIntoTextureD3D11_Async(TextureID_t textureId, void *pDstTexture) = 0;
3088
3089 /** Use this to free textures created with LoadTextureD3D11_Async instead of calling Release on them. */
3090 virtual void FreeTextureD3D11(void *pD3D11Texture2D) = 0;
3091
3092 /** Use this to get the names of available render models. Index does not correlate to a tracked device index, but
3093 * is only used for iterating over all available render models. If the index is out of range, this function will return 0.
3094 * Otherwise, it will return the size of the buffer required for the name. */
3095 virtual uint32_t GetRenderModelName(uint32_t unRenderModelIndex, VR_OUT_STRING() char *pchRenderModelName, uint32_t unRenderModelNameLen) = 0;
3096
3097 /** Returns the number of available render models. */
3098 virtual uint32_t GetRenderModelCount() = 0;
3099
3100 /** Returns the number of components of the specified render model.
3101 * Components are useful when client application wish to draw, label, or otherwise interact with components of tracked objects.
3102 * Examples controller components:
3103 * renderable things such as triggers, buttons
3104 * non-renderable things which include coordinate systems such as 'tip', 'base', a neutral controller agnostic hand-pose
3105 * If all controller components are enumerated and rendered, it will be equivalent to drawing the traditional render model
3106 * Returns 0 if components not supported, >0 otherwise */
3107 virtual uint32_t GetComponentCount(const char *pchRenderModelName) = 0;
3108
3109 /** Use this to get the names of available components. Index does not correlate to a tracked device index, but
3110 * is only used for iterating over all available components. If the index is out of range, this function will return 0.
3111 * Otherwise, it will return the size of the buffer required for the name. */
3112 virtual uint32_t GetComponentName(const char *pchRenderModelName, uint32_t unComponentIndex, VR_OUT_STRING() char *pchComponentName, uint32_t unComponentNameLen) = 0;
3113
3114 /** Get the button mask for all buttons associated with this component
3115 * If no buttons (or axes) are associated with this component, return 0
3116 * Note: multiple components may be associated with the same button. Ex: two grip buttons on a single controller.
3117 * Note: A single component may be associated with multiple buttons. Ex: A trackpad which also provides "D-pad" functionality */
3118 virtual uint64_t GetComponentButtonMask(const char *pchRenderModelName, const char *pchComponentName) = 0;
3119
3120 /** Use this to get the render model name for the specified rendermode/component combination, to be passed to LoadRenderModel.
3121 * If the component name is out of range, this function will return 0.
3122 * Otherwise, it will return the size of the buffer required for the name. */
3123 virtual uint32_t GetComponentRenderModelName(const char *pchRenderModelName, const char *pchComponentName, VR_OUT_STRING() char *pchComponentRenderModelName, uint32_t unComponentRenderModelNameLen) = 0;
3124
3125 /** Use this to query information about the component, as a function of the controller state.
3126 *
3127 * For dynamic controller components (ex: trigger) values will reflect component motions
3128 * For static components this will return a consistent value independent of the VRControllerState_t
3129 *
3130 * If the pchRenderModelName or pchComponentName is invalid, this will return false (and transforms will be set to identity).
3131 * Otherwise, return true
3132 * Note: For dynamic objects, visibility may be dynamic. (I.e., true/false will be returned based on controller state and controller mode state ) */
3133 virtual bool GetComponentState(const char *pchRenderModelName, const char *pchComponentName, const vr::VRControllerState_t *pControllerState, const RenderModel_ControllerMode_State_t *pState, RenderModel_ComponentState_t *pComponentState) = 0;
3134
3135 /** Returns true if the render model has a component with the specified name */
3136 virtual bool RenderModelHasComponent(const char *pchRenderModelName, const char *pchComponentName) = 0;
3137
3138 /** Returns the URL of the thumbnail image for this rendermodel */
3139 virtual uint32_t GetRenderModelThumbnailURL(const char *pchRenderModelName, VR_OUT_STRING() char *pchThumbnailURL, uint32_t unThumbnailURLLen, vr::EVRRenderModelError *peError) = 0;
3140
3141 /** Provides a render model path that will load the unskinned model if the model name provided has been replace by the user. If the model
3142 * hasn't been replaced the path value will still be a valid path to load the model. Pass this to LoadRenderModel_Async, etc. to load the
3143 * model. */
3144 virtual uint32_t GetRenderModelOriginalPath(const char *pchRenderModelName, VR_OUT_STRING() char *pchOriginalPath, uint32_t unOriginalPathLen, vr::EVRRenderModelError *peError) = 0;
3145
3146 /** Returns a string for a render model error */
3147 virtual const char *GetRenderModelErrorNameFromEnum(vr::EVRRenderModelError error) = 0;
3148 };
3149
3150 static const char *const IVRRenderModels_Version = "IVRRenderModels_005";
3151
3152 } // namespace vr
3153
3154 // ivrextendeddisplay.h
3155 namespace vr
3156 {
3157 /** NOTE: Use of this interface is not recommended in production applications. It will not work for displays which use
3158 * direct-to-display mode. Creating our own window is also incompatible with the VR compositor and is not available when the compositor is running. */
3159 class IVRExtendedDisplay
3160 {
3161 public:
3162 /** Size and position that the window needs to be on the VR display. */
3163 virtual void GetWindowBounds(int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight) = 0;
3164
3165 /** Gets the viewport in the frame buffer to draw the output of the distortion into */
3166 virtual void GetEyeOutputViewport(EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight) = 0;
3167
3168 /** [D3D10/11 Only]
3169 * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs
3170 * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
3171 */
3172 virtual void GetDXGIOutputInfo(int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex) = 0;
3173 };
3174
3175 static const char *const IVRExtendedDisplay_Version = "IVRExtendedDisplay_001";
3176
3177 } // namespace vr
3178
3179 // ivrtrackedcamera.h
3180 namespace vr
3181 {
3182 class IVRTrackedCamera
3183 {
3184 public:
3185 /** Returns a string for an error */
3186 virtual const char *GetCameraErrorNameFromEnum(vr::EVRTrackedCameraError eCameraError) = 0;
3187
3188 /** For convenience, same as tracked property request Prop_HasCamera_Bool */
3189 virtual vr::EVRTrackedCameraError HasCamera(vr::TrackedDeviceIndex_t nDeviceIndex, bool *pHasCamera) = 0;
3190
3191 /** Gets size of the image frame. */
3192 virtual vr::EVRTrackedCameraError GetCameraFrameSize(vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pnWidth, uint32_t *pnHeight, uint32_t *pnFrameBufferSize) = 0;
3193
3194 virtual vr::EVRTrackedCameraError GetCameraIntrinsics(vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter) = 0;
3195
3196 virtual vr::EVRTrackedCameraError GetCameraProjection(vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection) = 0;
3197
3198 /** Acquiring streaming service permits video streaming for the caller. Releasing hints the system that video services do not need to be maintained for this client.
3199 * If the camera has not already been activated, a one time spin up may incur some auto exposure as well as initial streaming frame delays.
3200 * The camera should be considered a global resource accessible for shared consumption but not exclusive to any caller.
3201 * The camera may go inactive due to lack of active consumers or headset idleness. */
3202 virtual vr::EVRTrackedCameraError AcquireVideoStreamingService(vr::TrackedDeviceIndex_t nDeviceIndex, vr::TrackedCameraHandle_t *pHandle) = 0;
3203 virtual vr::EVRTrackedCameraError ReleaseVideoStreamingService(vr::TrackedCameraHandle_t hTrackedCamera) = 0;
3204
3205 /** Copies the image frame into a caller's provided buffer. The image data is currently provided as RGBA data, 4 bytes per pixel.
3206 * A caller can provide null for the framebuffer or frameheader if not desired. Requesting the frame header first, followed by the frame buffer allows
3207 * the caller to determine if the frame as advanced per the frame header sequence.
3208 * If there is no frame available yet, due to initial camera spinup or re-activation, the error will be VRTrackedCameraError_NoFrameAvailable.
3209 * Ideally a caller should be polling at ~16ms intervals */
3210 virtual vr::EVRTrackedCameraError GetVideoStreamFrameBuffer(vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pFrameBuffer, uint32_t nFrameBufferSize, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize) = 0;
3211
3212 /** Gets size of the image frame. */
3213 virtual vr::EVRTrackedCameraError GetVideoStreamTextureSize(vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::VRTextureBounds_t *pTextureBounds, uint32_t *pnWidth, uint32_t *pnHeight) = 0;
3214
3215 /** Access a shared D3D11 texture for the specified tracked camera stream.
3216 * The camera frame type VRTrackedCameraFrameType_Undistorted is not supported directly as a shared texture. It is an interior subregion of the shared texture VRTrackedCameraFrameType_MaximumUndistorted.
3217 * Instead, use GetVideoStreamTextureSize() with VRTrackedCameraFrameType_Undistorted to determine the proper interior subregion bounds along with GetVideoStreamTextureD3D11() with
3218 * VRTrackedCameraFrameType_MaximumUndistorted to provide the texture. The VRTrackedCameraFrameType_MaximumUndistorted will yield an image where the invalid regions are decoded
3219 * by the alpha channel having a zero component. The valid regions all have a non-zero alpha component. The subregion as described by VRTrackedCameraFrameType_Undistorted
3220 * guarantees a rectangle where all pixels are valid. */
3221 virtual vr::EVRTrackedCameraError GetVideoStreamTextureD3D11(vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize) = 0;
3222
3223 /** Access a shared GL texture for the specified tracked camera stream */
3224 virtual vr::EVRTrackedCameraError GetVideoStreamTextureGL(vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, vr::glUInt_t *pglTextureId, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize) = 0;
3225 virtual vr::EVRTrackedCameraError ReleaseVideoStreamTextureGL(vr::TrackedCameraHandle_t hTrackedCamera, vr::glUInt_t glTextureId) = 0;
3226 };
3227
3228 static const char *const IVRTrackedCamera_Version = "IVRTrackedCamera_003";
3229
3230 } // namespace vr
3231
3232 // ivrscreenshots.h
3233 namespace vr
3234 {
3235 /** Errors that can occur with the VR compositor */
3236 enum EVRScreenshotError
3237 {
3238 VRScreenshotError_None = 0,
3239 VRScreenshotError_RequestFailed = 1,
3240 VRScreenshotError_IncompatibleVersion = 100,
3241 VRScreenshotError_NotFound = 101,
3242 VRScreenshotError_BufferTooSmall = 102,
3243 VRScreenshotError_ScreenshotAlreadyInProgress = 108,
3244 };
3245
3246 /** Allows the application to generate screenshots */
3247 class IVRScreenshots
3248 {
3249 public:
3250 /** Request a screenshot of the requested type.
3251 * A request of the VRScreenshotType_Stereo type will always
3252 * work. Other types will depend on the underlying application
3253 * support.
3254 * The first file name is for the preview image and should be a
3255 * regular screenshot (ideally from the left eye). The second
3256 * is the VR screenshot in the correct format. They should be
3257 * in the same aspect ratio. Formats per type:
3258 * VRScreenshotType_Mono: the VR filename is ignored (can be
3259 * nullptr), this is a normal flat single shot.
3260 * VRScreenshotType_Stereo: The VR image should be a
3261 * side-by-side with the left eye image on the left.
3262 * VRScreenshotType_Cubemap: The VR image should be six square
3263 * images composited horizontally.
3264 * VRScreenshotType_StereoPanorama: above/below with left eye
3265 * panorama being the above image. Image is typically square
3266 * with the panorama being 2x horizontal.
3267 *
3268 * Note that the VR dashboard will call this function when
3269 * the user presses the screenshot binding (currently System
3270 * Button + Trigger). If Steam is running, the destination
3271 * file names will be in %TEMP% and will be copied into
3272 * Steam's screenshot library for the running application
3273 * once SubmitScreenshot() is called.
3274 * If Steam is not running, the paths will be in the user's
3275 * documents folder under Documents\SteamVR\Screenshots.
3276 * Other VR applications can call this to initiate a
3277 * screenshot outside of user control.
3278 * The destination file names do not need an extension,
3279 * will be replaced with the correct one for the format
3280 * which is currently .png. */
3281 virtual vr::EVRScreenshotError RequestScreenshot(vr::ScreenshotHandle_t *pOutScreenshotHandle, vr::EVRScreenshotType type, const char *pchPreviewFilename, const char *pchVRFilename) = 0;
3282
3283 /** Called by the running VR application to indicate that it
3284 * wishes to be in charge of screenshots. If the
3285 * application does not call this, the Compositor will only
3286 * support VRScreenshotType_Stereo screenshots that will be
3287 * captured without notification to the running app.
3288 * Once hooked your application will receive a
3289 * VREvent_RequestScreenshot event when the user presses the
3290 * buttons to take a screenshot. */
3291 virtual vr::EVRScreenshotError HookScreenshot(VR_ARRAY_COUNT(numTypes) const vr::EVRScreenshotType *pSupportedTypes, int numTypes) = 0;
3292
3293 /** When your application receives a
3294 * VREvent_RequestScreenshot event, call these functions to get
3295 * the details of the screenshot request. */
3296 virtual vr::EVRScreenshotType GetScreenshotPropertyType(vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotError *pError) = 0;
3297
3298 /** Get the filename for the preview or vr image (see
3299 * vr::EScreenshotPropertyFilenames). The return value is
3300 * the size of the string. */
3301 virtual uint32_t GetScreenshotPropertyFilename(vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotPropertyFilenames filenameType, VR_OUT_STRING() char *pchFilename, uint32_t cchFilename, vr::EVRScreenshotError *pError) = 0;
3302
3303 /** Call this if the application is taking the screen shot
3304 * will take more than a few ms processing. This will result
3305 * in an overlay being presented that shows a completion
3306 * bar. */
3307 virtual vr::EVRScreenshotError UpdateScreenshotProgress(vr::ScreenshotHandle_t screenshotHandle, float flProgress) = 0;
3308
3309 /** Tells the compositor to take an internal screenshot of
3310 * type VRScreenshotType_Stereo. It will take the current
3311 * submitted scene textures of the running application and
3312 * write them into the preview image and a side-by-side file
3313 * for the VR image.
3314 * This is similar to request screenshot, but doesn't ever
3315 * talk to the application, just takes the shot and submits. */
3316 virtual vr::EVRScreenshotError TakeStereoScreenshot(vr::ScreenshotHandle_t *pOutScreenshotHandle, const char *pchPreviewFilename, const char *pchVRFilename) = 0;
3317
3318 /** Submit the completed screenshot. If Steam is running
3319 * this will call into the Steam client and upload the
3320 * screenshot to the screenshots section of the library for
3321 * the running application. If Steam is not running, this
3322 * function will display a notification to the user that the
3323 * screenshot was taken. The paths should be full paths with
3324 * extensions.
3325 * File paths should be absolute including extensions.
3326 * screenshotHandle can be k_unScreenshotHandleInvalid if this
3327 * was a new shot taking by the app to be saved and not
3328 * initiated by a user (achievement earned or something) */
3329 virtual vr::EVRScreenshotError SubmitScreenshot(vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotType type, const char *pchSourcePreviewFilename, const char *pchSourceVRFilename) = 0;
3330 };
3331
3332 static const char *const IVRScreenshots_Version = "IVRScreenshots_001";
3333
3334 } // namespace vr
3335
3336 // ivrresources.h
3337 namespace vr
3338 {
3339 class IVRResources
3340 {
3341 public:
3342 // ------------------------------------
3343 // Shared Resource Methods
3344 // ------------------------------------
3345
3346 /** Loads the specified resource into the provided buffer if large enough.
3347 * Returns the size in bytes of the buffer required to hold the specified resource. */
3348 virtual uint32_t LoadSharedResource(const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen) = 0;
3349
3350 /** Provides the full path to the specified resource. Resource names can include named directories for
3351 * drivers and other things, and this resolves all of those and returns the actual physical path.
3352 * pchResourceTypeDirectory is the subdirectory of resources to look in. */
3353 virtual uint32_t GetResourceFullPath(const char *pchResourceName, const char *pchResourceTypeDirectory, char *pchPathBuffer, uint32_t unBufferLen) = 0;
3354 };
3355
3356 static const char *const IVRResources_Version = "IVRResources_001";
3357
3358 } // namespace vr
3359 // ivrdrivermanager.h
3360 namespace vr
3361 {
3362 class IVRDriverManager
3363 {
3364 public:
3365 virtual uint32_t GetDriverCount() const = 0;
3366
3367 /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */
3368 virtual uint32_t GetDriverName(vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize) = 0;
3369 };
3370
3371 static const char *const IVRDriverManager_Version = "IVRDriverManager_001";
3372
3373 } // namespace vr
3374
3375 // End
3376
3377 #endif // _OPENVR_API
3378
3379 namespace vr
3380 {
3381 /** Finds the active installation of the VR API and initializes it. The provided path must be absolute
3382 * or relative to the current working directory. These are the local install versions of the equivalent
3383 * functions in steamvr.h and will work without a local Steam install.
3384 *
3385 * This path is to the "root" of the VR API install. That's the directory with
3386 * the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
3387 *
3388 * pStartupInfo is reserved for future use.
3389 */
3390 inline IVRSystem *VR_Init(EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo = nullptr);
3391
3392 /** unloads vrclient.dll. Any interface pointers from the interface are
3393 * invalid after this point */
3394 inline void VR_Shutdown();
3395
3396 /** Returns true if there is an HMD attached. This check is as lightweight as possible and
3397 * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants
3398 * to know if initializing VR is a possibility but isn't ready to take that step yet.
3399 */
3400 VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent();
3401
3402 /** Returns true if the OpenVR runtime is installed. */
3403 VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled();
3404
3405 /** Returns where the OpenVR runtime is installed. */
3406 VR_INTERFACE const char *VR_CALLTYPE VR_RuntimePath();
3407
3408 /** Returns the name of the enum value for an EVRInitError. This function may be called outside of VR_Init()/VR_Shutdown(). */
3409 VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsSymbol(EVRInitError error);
3410
3411 /** Returns an English string for an EVRInitError. Applications should call VR_GetVRInitErrorAsSymbol instead and
3412 * use that as a key to look up their own localized error message. This function may be called outside of VR_Init()/VR_Shutdown(). */
3413 VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription(EVRInitError error);
3414
3415 /** Returns the interface of the specified version. This method must be called after VR_Init. The
3416 * pointer returned is valid until VR_Shutdown is called.
3417 */
3418 VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface(const char *pchInterfaceVersion, EVRInitError *peError);
3419
3420 /** Returns whether the interface of the specified version exists.
3421 */
3422 VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid(const char *pchInterfaceVersion);
3423
3424 /** Returns a token that represents whether the VR interface handles need to be reloaded */
3425 VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken();
3426
3427 // These typedefs allow old enum names from SDK 0.9.11 to be used in applications.
3428 // They will go away in the future.
3429 typedef EVRInitError HmdError;
3430 typedef EVREye Hmd_Eye;
3431 typedef EColorSpace ColorSpace;
3432 typedef ETrackingResult HmdTrackingResult;
3433 typedef ETrackedDeviceClass TrackedDeviceClass;
3434 typedef ETrackingUniverseOrigin TrackingUniverseOrigin;
3435 typedef ETrackedDeviceProperty TrackedDeviceProperty;
3436 typedef ETrackedPropertyError TrackedPropertyError;
3437 typedef EVRSubmitFlags VRSubmitFlags_t;
3438 typedef EVRState VRState_t;
3439 typedef ECollisionBoundsStyle CollisionBoundsStyle_t;
3440 typedef EVROverlayError VROverlayError;
3441 typedef EVRFirmwareError VRFirmwareError;
3442 typedef EVRCompositorError VRCompositorError;
3443 typedef EVRScreenshotError VRScreenshotsError;
3444
VRToken()3445 inline uint32_t &VRToken()
3446 {
3447 static uint32_t token;
3448 return token;
3449 }
3450
3451 class COpenVRContext
3452 {
3453 public:
COpenVRContext()3454 COpenVRContext() { Clear(); }
3455 void Clear();
3456
CheckClear()3457 inline void CheckClear()
3458 {
3459 if (VRToken() != VR_GetInitToken())
3460 {
3461 Clear();
3462 VRToken() = VR_GetInitToken();
3463 }
3464 }
3465
VRSystem()3466 IVRSystem *VRSystem()
3467 {
3468 CheckClear();
3469 if (m_pVRSystem == nullptr)
3470 {
3471 EVRInitError eError;
3472 m_pVRSystem = (IVRSystem *)VR_GetGenericInterface(IVRSystem_Version, &eError);
3473 }
3474 return m_pVRSystem;
3475 }
VRChaperone()3476 IVRChaperone *VRChaperone()
3477 {
3478 CheckClear();
3479 if (m_pVRChaperone == nullptr)
3480 {
3481 EVRInitError eError;
3482 m_pVRChaperone = (IVRChaperone *)VR_GetGenericInterface(IVRChaperone_Version, &eError);
3483 }
3484 return m_pVRChaperone;
3485 }
3486
VRChaperoneSetup()3487 IVRChaperoneSetup *VRChaperoneSetup()
3488 {
3489 CheckClear();
3490 if (m_pVRChaperoneSetup == nullptr)
3491 {
3492 EVRInitError eError;
3493 m_pVRChaperoneSetup = (IVRChaperoneSetup *)VR_GetGenericInterface(IVRChaperoneSetup_Version, &eError);
3494 }
3495 return m_pVRChaperoneSetup;
3496 }
3497
VRCompositor()3498 IVRCompositor *VRCompositor()
3499 {
3500 CheckClear();
3501 if (m_pVRCompositor == nullptr)
3502 {
3503 EVRInitError eError;
3504 m_pVRCompositor = (IVRCompositor *)VR_GetGenericInterface(IVRCompositor_Version, &eError);
3505 }
3506 return m_pVRCompositor;
3507 }
3508
VROverlay()3509 IVROverlay *VROverlay()
3510 {
3511 CheckClear();
3512 if (m_pVROverlay == nullptr)
3513 {
3514 EVRInitError eError;
3515 m_pVROverlay = (IVROverlay *)VR_GetGenericInterface(IVROverlay_Version, &eError);
3516 }
3517 return m_pVROverlay;
3518 }
3519
VRResources()3520 IVRResources *VRResources()
3521 {
3522 CheckClear();
3523 if (m_pVRResources == nullptr)
3524 {
3525 EVRInitError eError;
3526 m_pVRResources = (IVRResources *)VR_GetGenericInterface(IVRResources_Version, &eError);
3527 }
3528 return m_pVRResources;
3529 }
3530
VRScreenshots()3531 IVRScreenshots *VRScreenshots()
3532 {
3533 CheckClear();
3534 if (m_pVRScreenshots == nullptr)
3535 {
3536 EVRInitError eError;
3537 m_pVRScreenshots = (IVRScreenshots *)VR_GetGenericInterface(IVRScreenshots_Version, &eError);
3538 }
3539 return m_pVRScreenshots;
3540 }
3541
VRRenderModels()3542 IVRRenderModels *VRRenderModels()
3543 {
3544 CheckClear();
3545 if (m_pVRRenderModels == nullptr)
3546 {
3547 EVRInitError eError;
3548 m_pVRRenderModels = (IVRRenderModels *)VR_GetGenericInterface(IVRRenderModels_Version, &eError);
3549 }
3550 return m_pVRRenderModels;
3551 }
3552
VRExtendedDisplay()3553 IVRExtendedDisplay *VRExtendedDisplay()
3554 {
3555 CheckClear();
3556 if (m_pVRExtendedDisplay == nullptr)
3557 {
3558 EVRInitError eError;
3559 m_pVRExtendedDisplay = (IVRExtendedDisplay *)VR_GetGenericInterface(IVRExtendedDisplay_Version, &eError);
3560 }
3561 return m_pVRExtendedDisplay;
3562 }
3563
VRSettings()3564 IVRSettings *VRSettings()
3565 {
3566 CheckClear();
3567 if (m_pVRSettings == nullptr)
3568 {
3569 EVRInitError eError;
3570 m_pVRSettings = (IVRSettings *)VR_GetGenericInterface(IVRSettings_Version, &eError);
3571 }
3572 return m_pVRSettings;
3573 }
3574
VRApplications()3575 IVRApplications *VRApplications()
3576 {
3577 CheckClear();
3578 if (m_pVRApplications == nullptr)
3579 {
3580 EVRInitError eError;
3581 m_pVRApplications = (IVRApplications *)VR_GetGenericInterface(IVRApplications_Version, &eError);
3582 }
3583 return m_pVRApplications;
3584 }
3585
VRTrackedCamera()3586 IVRTrackedCamera *VRTrackedCamera()
3587 {
3588 CheckClear();
3589 if (m_pVRTrackedCamera == nullptr)
3590 {
3591 EVRInitError eError;
3592 m_pVRTrackedCamera = (IVRTrackedCamera *)VR_GetGenericInterface(IVRTrackedCamera_Version, &eError);
3593 }
3594 return m_pVRTrackedCamera;
3595 }
3596
VRDriverManager()3597 IVRDriverManager *VRDriverManager()
3598 {
3599 CheckClear();
3600 if (!m_pVRDriverManager)
3601 {
3602 EVRInitError eError;
3603 m_pVRDriverManager = (IVRDriverManager *)VR_GetGenericInterface(IVRDriverManager_Version, &eError);
3604 }
3605 return m_pVRDriverManager;
3606 }
3607
3608 private:
3609 IVRSystem *m_pVRSystem;
3610 IVRChaperone *m_pVRChaperone;
3611 IVRChaperoneSetup *m_pVRChaperoneSetup;
3612 IVRCompositor *m_pVRCompositor;
3613 IVROverlay *m_pVROverlay;
3614 IVRResources *m_pVRResources;
3615 IVRRenderModels *m_pVRRenderModels;
3616 IVRExtendedDisplay *m_pVRExtendedDisplay;
3617 IVRSettings *m_pVRSettings;
3618 IVRApplications *m_pVRApplications;
3619 IVRTrackedCamera *m_pVRTrackedCamera;
3620 IVRScreenshots *m_pVRScreenshots;
3621 IVRDriverManager *m_pVRDriverManager;
3622 };
3623
OpenVRInternal_ModuleContext()3624 inline COpenVRContext &OpenVRInternal_ModuleContext()
3625 {
3626 static void *ctx[sizeof(COpenVRContext) / sizeof(void *)];
3627 return *(COpenVRContext *)ctx; // bypass zero-init constructor
3628 }
3629
VRSystem()3630 inline IVRSystem *VR_CALLTYPE VRSystem() { return OpenVRInternal_ModuleContext().VRSystem(); }
VRChaperone()3631 inline IVRChaperone *VR_CALLTYPE VRChaperone() { return OpenVRInternal_ModuleContext().VRChaperone(); }
VRChaperoneSetup()3632 inline IVRChaperoneSetup *VR_CALLTYPE VRChaperoneSetup() { return OpenVRInternal_ModuleContext().VRChaperoneSetup(); }
VRCompositor()3633 inline IVRCompositor *VR_CALLTYPE VRCompositor() { return OpenVRInternal_ModuleContext().VRCompositor(); }
VROverlay()3634 inline IVROverlay *VR_CALLTYPE VROverlay() { return OpenVRInternal_ModuleContext().VROverlay(); }
VRScreenshots()3635 inline IVRScreenshots *VR_CALLTYPE VRScreenshots() { return OpenVRInternal_ModuleContext().VRScreenshots(); }
VRRenderModels()3636 inline IVRRenderModels *VR_CALLTYPE VRRenderModels() { return OpenVRInternal_ModuleContext().VRRenderModels(); }
VRApplications()3637 inline IVRApplications *VR_CALLTYPE VRApplications() { return OpenVRInternal_ModuleContext().VRApplications(); }
VRSettings()3638 inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleContext().VRSettings(); }
VRResources()3639 inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleContext().VRResources(); }
VRExtendedDisplay()3640 inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); }
VRTrackedCamera()3641 inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); }
VRDriverManager()3642 inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleContext().VRDriverManager(); }
3643
Clear()3644 inline void COpenVRContext::Clear()
3645 {
3646 m_pVRSystem = nullptr;
3647 m_pVRChaperone = nullptr;
3648 m_pVRChaperoneSetup = nullptr;
3649 m_pVRCompositor = nullptr;
3650 m_pVROverlay = nullptr;
3651 m_pVRRenderModels = nullptr;
3652 m_pVRExtendedDisplay = nullptr;
3653 m_pVRSettings = nullptr;
3654 m_pVRApplications = nullptr;
3655 m_pVRTrackedCamera = nullptr;
3656 m_pVRResources = nullptr;
3657 m_pVRScreenshots = nullptr;
3658 m_pVRDriverManager = nullptr;
3659 }
3660
3661 VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2(EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo);
3662 VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal();
3663
3664 /** Finds the active installation of vrclient.dll and initializes it */
VR_Init(EVRInitError * peError,EVRApplicationType eApplicationType,const char * pStartupInfo)3665 inline IVRSystem *VR_Init(EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo)
3666 {
3667 IVRSystem *pVRSystem = nullptr;
3668
3669 EVRInitError eError;
3670 VRToken() = VR_InitInternal2(&eError, eApplicationType, pStartupInfo);
3671 COpenVRContext &ctx = OpenVRInternal_ModuleContext();
3672 ctx.Clear();
3673
3674 if (eError == VRInitError_None)
3675 {
3676 if (VR_IsInterfaceVersionValid(IVRSystem_Version))
3677 {
3678 pVRSystem = VRSystem();
3679 }
3680 else
3681 {
3682 VR_ShutdownInternal();
3683 eError = VRInitError_Init_InterfaceNotFound;
3684 }
3685 }
3686
3687 if (peError)
3688 *peError = eError;
3689 return pVRSystem;
3690 }
3691
3692 /** unloads vrclient.dll. Any interface pointers from the interface are
3693 * invalid after this point */
VR_Shutdown()3694 inline void VR_Shutdown()
3695 {
3696 VR_ShutdownInternal();
3697 }
3698 } // namespace vr
3699