Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(931)

Side by Side Diff: third_party/openvr/src/headers/openvr.h

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

Powered by Google App Engine
This is Rietveld 408576698