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