···11+# Current version
22+33+* Synced on 2020-06-10 `OpenVR SDK 1.12.5`
+27
src/external/openvr_includes/LICENSE
···11+Copyright (c) 2015, Valve Corporation
22+All rights reserved.
33+44+Redistribution and use in source and binary forms, with or without modification,
55+are permitted provided that the following conditions are met:
66+77+1. Redistributions of source code must retain the above copyright notice, this
88+list of conditions and the following disclaimer.
99+1010+2. Redistributions in binary form must reproduce the above copyright notice,
1111+this list of conditions and the following disclaimer in the documentation and/or
1212+other materials provided with the distribution.
1313+1414+3. Neither the name of the copyright holder nor the names of its contributors
1515+may be used to endorse or promote products derived from this software without
1616+specific prior written permission.
1717+1818+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2121+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
2222+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2323+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2424+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
2525+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2626+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2727+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+3005
src/external/openvr_includes/openvr_driver.h
···11+#pragma once
22+33+// openvr_driver.h
44+//========= Copyright Valve Corporation ============//
55+// Dynamically generated file. Do not modify this file directly.
66+77+#ifndef _OPENVR_DRIVER_API
88+#define _OPENVR_DRIVER_API
99+1010+#include <stdint.h>
1111+1212+1313+1414+// vrtypes.h
1515+#ifndef _INCLUDE_VRTYPES_H
1616+#define _INCLUDE_VRTYPES_H
1717+1818+// Forward declarations to avoid requiring vulkan.h
1919+struct VkDevice_T;
2020+struct VkPhysicalDevice_T;
2121+struct VkInstance_T;
2222+struct VkQueue_T;
2323+2424+// Forward declarations to avoid requiring d3d12.h
2525+struct ID3D12Resource;
2626+struct ID3D12CommandQueue;
2727+2828+namespace vr
2929+{
3030+#pragma pack( push, 8 )
3131+3232+typedef void* glSharedTextureHandle_t;
3333+typedef int32_t glInt_t;
3434+typedef uint32_t glUInt_t;
3535+3636+// right-handed system
3737+// +y is up
3838+// +x is to the right
3939+// -z is forward
4040+// Distance unit is meters
4141+struct HmdMatrix34_t
4242+{
4343+ float m[3][4];
4444+};
4545+4646+struct HmdMatrix44_t
4747+{
4848+ float m[4][4];
4949+};
5050+5151+struct HmdVector3_t
5252+{
5353+ float v[3];
5454+};
5555+5656+struct HmdVector4_t
5757+{
5858+ float v[4];
5959+};
6060+6161+struct HmdVector3d_t
6262+{
6363+ double v[3];
6464+};
6565+6666+struct HmdVector2_t
6767+{
6868+ float v[2];
6969+};
7070+7171+struct HmdQuaternion_t
7272+{
7373+ double w, x, y, z;
7474+};
7575+7676+struct HmdColor_t
7777+{
7878+ float r, g, b, a;
7979+};
8080+8181+struct HmdQuad_t
8282+{
8383+ HmdVector3_t vCorners[ 4 ];
8484+};
8585+8686+struct HmdRect2_t
8787+{
8888+ HmdVector2_t vTopLeft;
8989+ HmdVector2_t vBottomRight;
9090+};
9191+9292+/** Used to return the post-distortion UVs for each color channel.
9393+* UVs range from 0 to 1 with 0,0 in the upper left corner of the
9494+* source render target. The 0,0 to 1,1 range covers a single eye. */
9595+struct DistortionCoordinates_t
9696+{
9797+ float rfRed[2];
9898+ float rfGreen[2];
9999+ float rfBlue[2];
100100+};
101101+102102+enum EVREye
103103+{
104104+ Eye_Left = 0,
105105+ Eye_Right = 1
106106+};
107107+108108+enum ETextureType
109109+{
110110+ TextureType_DirectX = 0, // Handle is an ID3D11Texture
111111+ TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags
112112+ TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure
113113+ TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef
114114+ TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure
115115+ TextureType_DXGISharedHandle = 5, // Handle is a HANDLE DXGI share handle, only supported for Overlay render targets.
116116+ // this texture is used directly by our renderer, so only perform atomic (copyresource or resolve) on it
117117+};
118118+119119+enum EColorSpace
120120+{
121121+ ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
122122+ ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
123123+ ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
124124+};
125125+126126+struct Texture_t
127127+{
128128+ void* handle; // See ETextureType definition above
129129+ ETextureType eType;
130130+ EColorSpace eColorSpace;
131131+};
132132+133133+// Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource).
134134+typedef uint64_t SharedTextureHandle_t;
135135+#define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0)
136136+137137+enum ETrackingResult
138138+{
139139+ TrackingResult_Uninitialized = 1,
140140+141141+ TrackingResult_Calibrating_InProgress = 100,
142142+ TrackingResult_Calibrating_OutOfRange = 101,
143143+144144+ TrackingResult_Running_OK = 200,
145145+ TrackingResult_Running_OutOfRange = 201,
146146+};
147147+148148+typedef uint32_t DriverId_t;
149149+static const uint32_t k_nDriverNone = 0xFFFFFFFF;
150150+151151+static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
152152+153153+/** Used to pass device IDs to API calls */
154154+typedef uint32_t TrackedDeviceIndex_t;
155155+static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
156156+static const uint32_t k_unMaxTrackedDeviceCount = 64;
157157+static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
158158+static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
159159+160160+/** Describes what kind of object is being tracked at a given ID */
161161+enum ETrackedDeviceClass
162162+{
163163+ TrackedDeviceClass_Invalid = 0, // the ID was not valid.
164164+ TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
165165+ TrackedDeviceClass_Controller = 2, // Tracked controllers
166166+ TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers
167167+ TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
168168+ TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
169169+};
170170+171171+172172+/** Describes what specific role associated with a tracked device */
173173+enum ETrackedControllerRole
174174+{
175175+ TrackedControllerRole_Invalid = 0, // Invalid value for controller type
176176+ TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
177177+ TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
178178+ TrackedControllerRole_OptOut = 3, // Tracked device is opting out of left/right hand selection
179179+ TrackedControllerRole_Max = 4
180180+};
181181+182182+183183+/** describes a single pose for a tracked object */
184184+struct TrackedDevicePose_t
185185+{
186186+ HmdMatrix34_t mDeviceToAbsoluteTracking;
187187+ HmdVector3_t vVelocity; // velocity in tracker space in m/s
188188+ HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
189189+ ETrackingResult eTrackingResult;
190190+ bool bPoseIsValid;
191191+192192+ // This indicates that there is a device connected for this spot in the pose array.
193193+ // It could go from true to false if the user unplugs the device.
194194+ bool bDeviceIsConnected;
195195+};
196196+197197+/** Identifies which style of tracking origin the application wants to use
198198+* for the poses it is requesting */
199199+enum ETrackingUniverseOrigin
200200+{
201201+ TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
202202+ TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
203203+ 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.
204204+};
205205+206206+typedef uint64_t WebConsoleHandle_t;
207207+#define INVALID_WEB_CONSOLE_HANDLE ((vr::WebConsoleHandle_t)0)
208208+209209+// Refers to a single container of properties
210210+typedef uint64_t PropertyContainerHandle_t;
211211+typedef uint32_t PropertyTypeTag_t;
212212+213213+static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0;
214214+static const PropertyTypeTag_t k_unInvalidPropertyTag = 0;
215215+216216+typedef PropertyContainerHandle_t DriverHandle_t;
217217+static const PropertyContainerHandle_t k_ulInvalidDriverHandle = 0;
218218+219219+// Use these tags to set/get common types as struct properties
220220+static const PropertyTypeTag_t k_unFloatPropertyTag = 1;
221221+static const PropertyTypeTag_t k_unInt32PropertyTag = 2;
222222+static const PropertyTypeTag_t k_unUint64PropertyTag = 3;
223223+static const PropertyTypeTag_t k_unBoolPropertyTag = 4;
224224+static const PropertyTypeTag_t k_unStringPropertyTag = 5;
225225+226226+static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20;
227227+static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21;
228228+static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22;
229229+static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23;
230230+231231+static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30;
232232+static const PropertyTypeTag_t k_unPathHandleInfoTag = 31;
233233+static const PropertyTypeTag_t k_unActionPropertyTag = 32;
234234+static const PropertyTypeTag_t k_unInputValuePropertyTag = 33;
235235+static const PropertyTypeTag_t k_unWildcardPropertyTag = 34;
236236+static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35;
237237+238238+static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000;
239239+static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000;
240240+241241+242242+/** Each entry in this enum represents a property that can be retrieved about a
243243+* tracked device. Many fields are only valid for one ETrackedDeviceClass. */
244244+enum ETrackedDeviceProperty
245245+{
246246+ Prop_Invalid = 0,
247247+248248+ // general properties that apply to all device classes
249249+ Prop_TrackingSystemName_String = 1000,
250250+ Prop_ModelNumber_String = 1001,
251251+ Prop_SerialNumber_String = 1002,
252252+ Prop_RenderModelName_String = 1003,
253253+ Prop_WillDriftInYaw_Bool = 1004,
254254+ Prop_ManufacturerName_String = 1005,
255255+ Prop_TrackingFirmwareVersion_String = 1006,
256256+ Prop_HardwareRevision_String = 1007,
257257+ Prop_AllWirelessDongleDescriptions_String = 1008,
258258+ Prop_ConnectedWirelessDongle_String = 1009,
259259+ Prop_DeviceIsWireless_Bool = 1010,
260260+ Prop_DeviceIsCharging_Bool = 1011,
261261+ Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
262262+ Prop_StatusDisplayTransform_Matrix34 = 1013,
263263+ Prop_Firmware_UpdateAvailable_Bool = 1014,
264264+ Prop_Firmware_ManualUpdate_Bool = 1015,
265265+ Prop_Firmware_ManualUpdateURL_String = 1016,
266266+ Prop_HardwareRevision_Uint64 = 1017,
267267+ Prop_FirmwareVersion_Uint64 = 1018,
268268+ Prop_FPGAVersion_Uint64 = 1019,
269269+ Prop_VRCVersion_Uint64 = 1020,
270270+ Prop_RadioVersion_Uint64 = 1021,
271271+ Prop_DongleVersion_Uint64 = 1022,
272272+ Prop_BlockServerShutdown_Bool = 1023,
273273+ Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
274274+ Prop_ContainsProximitySensor_Bool = 1025,
275275+ Prop_DeviceProvidesBatteryStatus_Bool = 1026,
276276+ Prop_DeviceCanPowerOff_Bool = 1027,
277277+ Prop_Firmware_ProgrammingTarget_String = 1028,
278278+ Prop_DeviceClass_Int32 = 1029,
279279+ Prop_HasCamera_Bool = 1030,
280280+ Prop_DriverVersion_String = 1031,
281281+ Prop_Firmware_ForceUpdateRequired_Bool = 1032,
282282+ Prop_ViveSystemButtonFixRequired_Bool = 1033,
283283+ Prop_ParentDriver_Uint64 = 1034,
284284+ Prop_ResourceRoot_String = 1035,
285285+ Prop_RegisteredDeviceType_String = 1036,
286286+ Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided
287287+ Prop_NeverTracked_Bool = 1038, // Used for devices that will never have a valid pose by design
288288+ Prop_NumCameras_Int32 = 1039,
289289+ Prop_CameraFrameLayout_Int32 = 1040, // EVRTrackedCameraFrameLayout value
290290+291291+ // Properties that are unique to TrackedDeviceClass_HMD
292292+ Prop_ReportsTimeSinceVSync_Bool = 2000,
293293+ Prop_SecondsFromVsyncToPhotons_Float = 2001,
294294+ Prop_DisplayFrequency_Float = 2002,
295295+ Prop_UserIpdMeters_Float = 2003,
296296+ Prop_CurrentUniverseId_Uint64 = 2004,
297297+ Prop_PreviousUniverseId_Uint64 = 2005,
298298+ Prop_DisplayFirmwareVersion_Uint64 = 2006,
299299+ Prop_IsOnDesktop_Bool = 2007,
300300+ Prop_DisplayMCType_Int32 = 2008,
301301+ Prop_DisplayMCOffset_Float = 2009,
302302+ Prop_DisplayMCScale_Float = 2010,
303303+ Prop_EdidVendorID_Int32 = 2011,
304304+ Prop_DisplayMCImageLeft_String = 2012,
305305+ Prop_DisplayMCImageRight_String = 2013,
306306+ Prop_DisplayGCBlackClamp_Float = 2014,
307307+ Prop_EdidProductID_Int32 = 2015,
308308+ Prop_CameraToHeadTransform_Matrix34 = 2016,
309309+ Prop_DisplayGCType_Int32 = 2017,
310310+ Prop_DisplayGCOffset_Float = 2018,
311311+ Prop_DisplayGCScale_Float = 2019,
312312+ Prop_DisplayGCPrescale_Float = 2020,
313313+ Prop_DisplayGCImage_String = 2021,
314314+ Prop_LensCenterLeftU_Float = 2022,
315315+ Prop_LensCenterLeftV_Float = 2023,
316316+ Prop_LensCenterRightU_Float = 2024,
317317+ Prop_LensCenterRightV_Float = 2025,
318318+ Prop_UserHeadToEyeDepthMeters_Float = 2026,
319319+ Prop_CameraFirmwareVersion_Uint64 = 2027,
320320+ Prop_CameraFirmwareDescription_String = 2028,
321321+ Prop_DisplayFPGAVersion_Uint64 = 2029,
322322+ Prop_DisplayBootloaderVersion_Uint64 = 2030,
323323+ Prop_DisplayHardwareVersion_Uint64 = 2031,
324324+ Prop_AudioFirmwareVersion_Uint64 = 2032,
325325+ Prop_CameraCompatibilityMode_Int32 = 2033,
326326+ Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
327327+ Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
328328+ Prop_DisplaySuppressed_Bool = 2036,
329329+ Prop_DisplayAllowNightMode_Bool = 2037,
330330+ Prop_DisplayMCImageWidth_Int32 = 2038,
331331+ Prop_DisplayMCImageHeight_Int32 = 2039,
332332+ Prop_DisplayMCImageNumChannels_Int32 = 2040,
333333+ Prop_DisplayMCImageData_Binary = 2041,
334334+ Prop_SecondsFromPhotonsToVblank_Float = 2042,
335335+ Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043,
336336+ Prop_DisplayDebugMode_Bool = 2044,
337337+ Prop_GraphicsAdapterLuid_Uint64 = 2045,
338338+ Prop_DriverProvidedChaperonePath_String = 2048,
339339+ Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for
340340+ Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for
341341+ Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded
342342+ Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded
343343+ Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded
344344+ Prop_DoNotApplyPrediction_Bool = 2054,
345345+ Prop_CameraToHeadTransforms_Matrix34_Array = 2055,
346346+ Prop_DistortionMeshResolution_Int32 = 2056, // custom resolution of compositor calls to IVRSystem::ComputeDistortion
347347+ Prop_DriverIsDrawingControllers_Bool = 2057,
348348+ Prop_DriverRequestsApplicationPause_Bool = 2058,
349349+ Prop_DriverRequestsReducedRendering_Bool = 2059,
350350+ Prop_MinimumIpdStepMeters_Float = 2060,
351351+ Prop_AudioBridgeFirmwareVersion_Uint64 = 2061,
352352+ Prop_ImageBridgeFirmwareVersion_Uint64 = 2062,
353353+354354+ // Properties that are unique to TrackedDeviceClass_Controller
355355+ Prop_AttachedDeviceId_String = 3000,
356356+ Prop_SupportedButtons_Uint64 = 3001,
357357+ Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
358358+ Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
359359+ Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
360360+ Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
361361+ Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
362362+ Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole
363363+364364+ // Properties that are unique to TrackedDeviceClass_TrackingReference
365365+ Prop_FieldOfViewLeftDegrees_Float = 4000,
366366+ Prop_FieldOfViewRightDegrees_Float = 4001,
367367+ Prop_FieldOfViewTopDegrees_Float = 4002,
368368+ Prop_FieldOfViewBottomDegrees_Float = 4003,
369369+ Prop_TrackingRangeMinimumMeters_Float = 4004,
370370+ Prop_TrackingRangeMaximumMeters_Float = 4005,
371371+ Prop_ModeLabel_String = 4006,
372372+373373+ // Properties that are used for user interface like icons names
374374+ Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties.
375375+ Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
376376+ Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
377377+ Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
378378+ Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
379379+ Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
380380+ Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
381381+ Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
382382+ Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
383383+384384+ // Properties that are used by helpers, but are opaque to applications
385385+ Prop_DisplayHiddenArea_Binary_Start = 5100,
386386+ Prop_DisplayHiddenArea_Binary_End = 5150,
387387+ Prop_ParentContainer = 5151,
388388+389389+ // Properties that are unique to drivers
390390+ Prop_UserConfigPath_String = 6000,
391391+ Prop_InstallPath_String = 6001,
392392+ Prop_HasDisplayComponent_Bool = 6002,
393393+ Prop_HasControllerComponent_Bool = 6003,
394394+ Prop_HasCameraComponent_Bool = 6004,
395395+ Prop_HasDriverDirectModeComponent_Bool = 6005,
396396+ Prop_HasVirtualDisplayComponent_Bool = 6006,
397397+398398+ // Properties that are set internally based on other information provided by drivers
399399+ Prop_ControllerType_String = 7000,
400400+ Prop_LegacyInputProfile_String = 7001,
401401+402402+ // Vendors are free to expose private debug data in this reserved region
403403+ Prop_VendorSpecific_Reserved_Start = 10000,
404404+ Prop_VendorSpecific_Reserved_End = 10999,
405405+406406+ Prop_TrackedDeviceProperty_Max = 1000000,
407407+};
408408+409409+/** No string property will ever be longer than this length */
410410+static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
411411+412412+/** Used to return errors that occur when reading properties. */
413413+enum ETrackedPropertyError
414414+{
415415+ TrackedProp_Success = 0,
416416+ TrackedProp_WrongDataType = 1,
417417+ TrackedProp_WrongDeviceClass = 2,
418418+ TrackedProp_BufferTooSmall = 3,
419419+ TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever).
420420+ TrackedProp_InvalidDevice = 5,
421421+ TrackedProp_CouldNotContactServer = 6,
422422+ TrackedProp_ValueNotProvidedByDevice = 7,
423423+ TrackedProp_StringExceedsMaximumLength = 8,
424424+ TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
425425+ TrackedProp_PermissionDenied = 10,
426426+ TrackedProp_InvalidOperation = 11,
427427+ TrackedProp_CannotWriteToWildcards = 12,
428428+};
429429+430430+/** Allows the application to control what part of the provided texture will be used in the
431431+* frame buffer. */
432432+struct VRTextureBounds_t
433433+{
434434+ float uMin, vMin;
435435+ float uMax, vMax;
436436+};
437437+438438+/** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */
439439+struct VRTextureWithPose_t : public Texture_t
440440+{
441441+ HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures.
442442+};
443443+444444+struct VRTextureDepthInfo_t
445445+{
446446+ void* handle; // See ETextureType definition above
447447+ HmdMatrix44_t mProjection;
448448+ HmdVector2_t vRange; // 0..1
449449+};
450450+451451+struct VRTextureWithDepth_t : public Texture_t
452452+{
453453+ VRTextureDepthInfo_t depth;
454454+};
455455+456456+struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t
457457+{
458458+ VRTextureDepthInfo_t depth;
459459+};
460460+461461+/** Allows the application to control how scene textures are used by the compositor when calling Submit. */
462462+enum EVRSubmitFlags
463463+{
464464+ // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
465465+ Submit_Default = 0x00,
466466+467467+ // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
468468+ // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
469469+ // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
470470+ Submit_LensDistortionAlreadyApplied = 0x01,
471471+472472+ // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
473473+ Submit_GlRenderBuffer = 0x02,
474474+475475+ // Do not use
476476+ Submit_Reserved = 0x04,
477477+478478+ // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t.
479479+ // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t.
480480+ Submit_TextureWithPose = 0x08,
481481+482482+ // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t.
483483+ // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t.
484484+ Submit_TextureWithDepth = 0x10,
485485+};
486486+487487+/** Data required for passing Vulkan textures to IVRCompositor::Submit.
488488+* Be sure to call OpenVR_Shutdown before destroying these resources. */
489489+struct VRVulkanTextureData_t
490490+{
491491+ uint64_t m_nImage; // VkImage
492492+ VkDevice_T *m_pDevice;
493493+ VkPhysicalDevice_T *m_pPhysicalDevice;
494494+ VkInstance_T *m_pInstance;
495495+ VkQueue_T *m_pQueue;
496496+ uint32_t m_nQueueFamilyIndex;
497497+ uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount;
498498+};
499499+500500+/** Data required for passing D3D12 textures to IVRCompositor::Submit.
501501+* Be sure to call OpenVR_Shutdown before destroying these resources. */
502502+struct D3D12TextureData_t
503503+{
504504+ ID3D12Resource *m_pResource;
505505+ ID3D12CommandQueue *m_pCommandQueue;
506506+ uint32_t m_nNodeMask;
507507+};
508508+509509+/** Status of the overall system or tracked objects */
510510+enum EVRState
511511+{
512512+ VRState_Undefined = -1,
513513+ VRState_Off = 0,
514514+ VRState_Searching = 1,
515515+ VRState_Searching_Alert = 2,
516516+ VRState_Ready = 3,
517517+ VRState_Ready_Alert = 4,
518518+ VRState_NotReady = 5,
519519+ VRState_Standby = 6,
520520+ VRState_Ready_Alert_Low = 7,
521521+};
522522+523523+/** The types of events that could be posted (and what the parameters mean for each event type) */
524524+enum EVREventType
525525+{
526526+ VREvent_None = 0,
527527+528528+ VREvent_TrackedDeviceActivated = 100,
529529+ VREvent_TrackedDeviceDeactivated = 101,
530530+ VREvent_TrackedDeviceUpdated = 102,
531531+ VREvent_TrackedDeviceUserInteractionStarted = 103,
532532+ VREvent_TrackedDeviceUserInteractionEnded = 104,
533533+ VREvent_IpdChanged = 105,
534534+ VREvent_EnterStandbyMode = 106,
535535+ VREvent_LeaveStandbyMode = 107,
536536+ VREvent_TrackedDeviceRoleChanged = 108,
537537+ VREvent_WatchdogWakeUpRequested = 109,
538538+ VREvent_LensDistortionChanged = 110,
539539+ VREvent_PropertyChanged = 111,
540540+ VREvent_WirelessDisconnect = 112,
541541+ VREvent_WirelessReconnect = 113,
542542+543543+ VREvent_ButtonPress = 200, // data is controller
544544+ VREvent_ButtonUnpress = 201, // data is controller
545545+ VREvent_ButtonTouch = 202, // data is controller
546546+ VREvent_ButtonUntouch = 203, // data is controller
547547+548548+ VREvent_DualAnalog_Press = 250, // data is dualAnalog
549549+ VREvent_DualAnalog_Unpress = 251, // data is dualAnalog
550550+ VREvent_DualAnalog_Touch = 252, // data is dualAnalog
551551+ VREvent_DualAnalog_Untouch = 253, // data is dualAnalog
552552+ VREvent_DualAnalog_Move = 254, // data is dualAnalog
553553+ VREvent_DualAnalog_ModeSwitch1 = 255, // data is dualAnalog
554554+ VREvent_DualAnalog_ModeSwitch2 = 256, // data is dualAnalog
555555+ VREvent_DualAnalog_Cancel = 257, // data is dualAnalog
556556+557557+ VREvent_MouseMove = 300, // data is mouse
558558+ VREvent_MouseButtonDown = 301, // data is mouse
559559+ VREvent_MouseButtonUp = 302, // data is mouse
560560+ VREvent_FocusEnter = 303, // data is overlay
561561+ VREvent_FocusLeave = 304, // data is overlay
562562+ VREvent_Scroll = 305, // data is mouse
563563+ VREvent_TouchPadMove = 306, // data is mouse
564564+ VREvent_OverlayFocusChanged = 307, // data is overlay, global event
565565+566566+ VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
567567+ VREvent_InputFocusReleased = 401, // data is process DEPRECATED
568568+ VREvent_SceneFocusLost = 402, // data is process
569569+ VREvent_SceneFocusGained = 403, // data is process
570570+ VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
571571+ VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
572572+ VREvent_InputFocusChanged = 406, // data is process
573573+ VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process
574574+ VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, // data is process
575575+ VREvent_ActionBindingReloaded = 409, // data is process - The App that action binds reloaded for
576576+577577+ VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
578578+ VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
579579+580580+ VREvent_ConsoleOpened = 420,
581581+ VREvent_ConsoleClosed = 421,
582582+583583+ VREvent_OverlayShown = 500,
584584+ VREvent_OverlayHidden = 501,
585585+ VREvent_DashboardActivated = 502,
586586+ VREvent_DashboardDeactivated = 503,
587587+ VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
588588+ VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
589589+ VREvent_ResetDashboard = 506, // Send to the overlay manager
590590+ VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
591591+ VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
592592+ VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
593593+ VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
594594+ VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
595595+ VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
596596+ VREvent_OverlaySharedTextureChanged = 513,
597597+ //VREvent_DashboardGuideButtonDown = 514, // These are no longer sent
598598+ //VREvent_DashboardGuideButtonUp = 515,
599599+ VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
600600+ VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
601601+ VREvent_DashboardOverlayCreated = 518,
602602+ VREvent_SwitchGamepadFocus = 519,
603603+604604+ // Screenshot API
605605+ VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
606606+ VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
607607+ VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
608608+ VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
609609+ VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted
610610+611611+ VREvent_PrimaryDashboardDeviceChanged = 525,
612612+ VREvent_RoomViewShown = 526, // Sent by compositor whenever room-view is enabled
613613+ VREvent_RoomViewHidden = 527, // Sent by compositor whenever room-view is disabled
614614+615615+ VREvent_Notification_Shown = 600,
616616+ VREvent_Notification_Hidden = 601,
617617+ VREvent_Notification_BeginInteraction = 602,
618618+ VREvent_Notification_Destroyed = 603,
619619+620620+ VREvent_Quit = 700, // data is process
621621+ VREvent_ProcessQuit = 701, // data is process
622622+ VREvent_QuitAborted_UserPrompt = 702, // data is process
623623+ VREvent_QuitAcknowledged = 703, // data is process
624624+ VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
625625+626626+ VREvent_ChaperoneDataHasChanged = 800,
627627+ VREvent_ChaperoneUniverseHasChanged = 801,
628628+ VREvent_ChaperoneTempDataHasChanged = 802,
629629+ VREvent_ChaperoneSettingsHaveChanged = 803,
630630+ VREvent_SeatedZeroPoseReset = 804,
631631+632632+ VREvent_AudioSettingsHaveChanged = 820,
633633+634634+ VREvent_BackgroundSettingHasChanged = 850,
635635+ VREvent_CameraSettingsHaveChanged = 851,
636636+ VREvent_ReprojectionSettingHasChanged = 852,
637637+ VREvent_ModelSkinSettingsHaveChanged = 853,
638638+ VREvent_EnvironmentSettingsHaveChanged = 854,
639639+ VREvent_PowerSettingsHaveChanged = 855,
640640+ VREvent_EnableHomeAppSettingsHaveChanged = 856,
641641+ VREvent_SteamVRSectionSettingChanged = 857,
642642+ VREvent_LighthouseSectionSettingChanged = 858,
643643+ VREvent_NullSectionSettingChanged = 859,
644644+ VREvent_UserInterfaceSectionSettingChanged = 860,
645645+ VREvent_NotificationsSectionSettingChanged = 861,
646646+ VREvent_KeyboardSectionSettingChanged = 862,
647647+ VREvent_PerfSectionSettingChanged = 863,
648648+ VREvent_DashboardSectionSettingChanged = 864,
649649+ VREvent_WebInterfaceSectionSettingChanged = 865,
650650+651651+ VREvent_StatusUpdate = 900,
652652+653653+ VREvent_WebInterface_InstallDriverCompleted = 950,
654654+655655+ VREvent_MCImageUpdated = 1000,
656656+657657+ VREvent_FirmwareUpdateStarted = 1100,
658658+ VREvent_FirmwareUpdateFinished = 1101,
659659+660660+ VREvent_KeyboardClosed = 1200,
661661+ VREvent_KeyboardCharInput = 1201,
662662+ VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
663663+664664+ VREvent_ApplicationTransitionStarted = 1300,
665665+ VREvent_ApplicationTransitionAborted = 1301,
666666+ VREvent_ApplicationTransitionNewAppStarted = 1302,
667667+ VREvent_ApplicationListUpdated = 1303,
668668+ VREvent_ApplicationMimeTypeLoad = 1304,
669669+ VREvent_ApplicationTransitionNewAppLaunchComplete = 1305,
670670+ VREvent_ProcessConnected = 1306,
671671+ VREvent_ProcessDisconnected = 1307,
672672+673673+ VREvent_Compositor_MirrorWindowShown = 1400,
674674+ VREvent_Compositor_MirrorWindowHidden = 1401,
675675+ VREvent_Compositor_ChaperoneBoundsShown = 1410,
676676+ VREvent_Compositor_ChaperoneBoundsHidden = 1411,
677677+678678+ VREvent_TrackedCamera_StartVideoStream = 1500,
679679+ VREvent_TrackedCamera_StopVideoStream = 1501,
680680+ VREvent_TrackedCamera_PauseVideoStream = 1502,
681681+ VREvent_TrackedCamera_ResumeVideoStream = 1503,
682682+ VREvent_TrackedCamera_EditingSurface = 1550,
683683+684684+ VREvent_PerformanceTest_EnableCapture = 1600,
685685+ VREvent_PerformanceTest_DisableCapture = 1601,
686686+ VREvent_PerformanceTest_FidelityLevel = 1602,
687687+688688+ VREvent_MessageOverlay_Closed = 1650,
689689+ VREvent_MessageOverlayCloseRequested = 1651,
690690+691691+ VREvent_Input_HapticVibration = 1700, // data is hapticVibration
692692+693693+ // Vendors are free to expose private events in this reserved region
694694+ VREvent_VendorSpecific_Reserved_Start = 10000,
695695+ VREvent_VendorSpecific_Reserved_End = 19999,
696696+};
697697+698698+699699+/** Level of Hmd activity */
700700+// UserInteraction_Timeout means the device is in the process of timing out.
701701+// InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout )
702702+// VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction.
703703+// VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle
704704+enum EDeviceActivityLevel
705705+{
706706+ k_EDeviceActivityLevel_Unknown = -1,
707707+ k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds
708708+ k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now
709709+ k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds
710710+ k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management)
711711+};
712712+713713+714714+/** VR controller button and axis IDs */
715715+enum EVRButtonId
716716+{
717717+ k_EButton_System = 0,
718718+ k_EButton_ApplicationMenu = 1,
719719+ k_EButton_Grip = 2,
720720+ k_EButton_DPad_Left = 3,
721721+ k_EButton_DPad_Up = 4,
722722+ k_EButton_DPad_Right = 5,
723723+ k_EButton_DPad_Down = 6,
724724+ k_EButton_A = 7,
725725+726726+ k_EButton_ProximitySensor = 31,
727727+728728+ k_EButton_Axis0 = 32,
729729+ k_EButton_Axis1 = 33,
730730+ k_EButton_Axis2 = 34,
731731+ k_EButton_Axis3 = 35,
732732+ k_EButton_Axis4 = 36,
733733+734734+ // aliases for well known controllers
735735+ k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
736736+ k_EButton_SteamVR_Trigger = k_EButton_Axis1,
737737+738738+ k_EButton_Dashboard_Back = k_EButton_Grip,
739739+740740+ k_EButton_Max = 64
741741+};
742742+743743+inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
744744+745745+/** used for controller button events */
746746+struct VREvent_Controller_t
747747+{
748748+ uint32_t button; // EVRButtonId enum
749749+};
750750+751751+752752+/** used for simulated mouse events in overlay space */
753753+enum EVRMouseButton
754754+{
755755+ VRMouseButton_Left = 0x0001,
756756+ VRMouseButton_Right = 0x0002,
757757+ VRMouseButton_Middle = 0x0004,
758758+};
759759+760760+761761+/** used for simulated mouse events in overlay space */
762762+struct VREvent_Mouse_t
763763+{
764764+ float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
765765+ uint32_t button; // EVRMouseButton enum
766766+};
767767+768768+/** used for simulated mouse wheel scroll in overlay space */
769769+struct VREvent_Scroll_t
770770+{
771771+ float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
772772+ uint32_t repeatCount;
773773+};
774774+775775+/** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
776776+ is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents
777777+ flag set.
778778+**/
779779+struct VREvent_TouchPadMove_t
780780+{
781781+ // true if the users finger is detected on the touch pad
782782+ bool bFingerDown;
783783+784784+ // How long the finger has been down in seconds
785785+ float flSecondsFingerDown;
786786+787787+ // These values indicate the starting finger position (so you can do some basic swipe stuff)
788788+ float fValueXFirst;
789789+ float fValueYFirst;
790790+791791+ // This is the raw sampled coordinate without deadzoning
792792+ float fValueXRaw;
793793+ float fValueYRaw;
794794+};
795795+796796+/** notification related events. Details will still change at this point */
797797+struct VREvent_Notification_t
798798+{
799799+ uint64_t ulUserValue;
800800+ uint32_t notificationId;
801801+};
802802+803803+/** Used for events about processes */
804804+struct VREvent_Process_t
805805+{
806806+ uint32_t pid;
807807+ uint32_t oldPid;
808808+ bool bForced;
809809+};
810810+811811+812812+/** Used for a few events about overlays */
813813+struct VREvent_Overlay_t
814814+{
815815+ uint64_t overlayHandle;
816816+ uint64_t devicePath;
817817+};
818818+819819+820820+/** Used for a few events about overlays */
821821+struct VREvent_Status_t
822822+{
823823+ uint32_t statusState; // EVRState enum
824824+};
825825+826826+/** Used for keyboard events **/
827827+struct VREvent_Keyboard_t
828828+{
829829+ char cNewInput[8]; // Up to 11 bytes of new input
830830+ uint64_t uUserValue; // Possible flags about the new input
831831+};
832832+833833+struct VREvent_Ipd_t
834834+{
835835+ float ipdMeters;
836836+};
837837+838838+struct VREvent_Chaperone_t
839839+{
840840+ uint64_t m_nPreviousUniverse;
841841+ uint64_t m_nCurrentUniverse;
842842+};
843843+844844+/** Not actually used for any events */
845845+struct VREvent_Reserved_t
846846+{
847847+ uint64_t reserved0;
848848+ uint64_t reserved1;
849849+ uint64_t reserved2;
850850+ uint64_t reserved3;
851851+};
852852+853853+struct VREvent_PerformanceTest_t
854854+{
855855+ uint32_t m_nFidelityLevel;
856856+};
857857+858858+struct VREvent_SeatedZeroPoseReset_t
859859+{
860860+ bool bResetBySystemMenu;
861861+};
862862+863863+struct VREvent_Screenshot_t
864864+{
865865+ uint32_t handle;
866866+ uint32_t type;
867867+};
868868+869869+struct VREvent_ScreenshotProgress_t
870870+{
871871+ float progress;
872872+};
873873+874874+struct VREvent_ApplicationLaunch_t
875875+{
876876+ uint32_t pid;
877877+ uint32_t unArgsHandle;
878878+};
879879+880880+struct VREvent_EditingCameraSurface_t
881881+{
882882+ uint64_t overlayHandle;
883883+ uint32_t nVisualMode;
884884+};
885885+886886+struct VREvent_MessageOverlay_t
887887+{
888888+ uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum
889889+};
890890+891891+struct VREvent_Property_t
892892+{
893893+ PropertyContainerHandle_t container;
894894+ ETrackedDeviceProperty prop;
895895+};
896896+897897+enum EDualAnalogWhich
898898+{
899899+ k_EDualAnalog_Left = 0,
900900+ k_EDualAnalog_Right = 1,
901901+};
902902+903903+struct VREvent_DualAnalog_t
904904+{
905905+ float x, y; // coordinates are -1..1 analog values
906906+ float transformedX, transformedY; // transformed by the center and radius numbers provided by the overlay
907907+ EDualAnalogWhich which;
908908+};
909909+910910+struct VREvent_HapticVibration_t
911911+{
912912+ uint64_t containerHandle; // property container handle of the device with the haptic component
913913+ uint64_t componentHandle; // Which haptic component needs to vibrate
914914+ float fDurationSeconds;
915915+ float fFrequency;
916916+ float fAmplitude;
917917+};
918918+919919+struct VREvent_WebConsole_t
920920+{
921921+ WebConsoleHandle_t webConsoleHandle;
922922+};
923923+924924+/** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */
925925+typedef union
926926+{
927927+ VREvent_Reserved_t reserved;
928928+ VREvent_Controller_t controller;
929929+ VREvent_Mouse_t mouse;
930930+ VREvent_Scroll_t scroll;
931931+ VREvent_Process_t process;
932932+ VREvent_Notification_t notification;
933933+ VREvent_Overlay_t overlay;
934934+ VREvent_Status_t status;
935935+ VREvent_Keyboard_t keyboard;
936936+ VREvent_Ipd_t ipd;
937937+ VREvent_Chaperone_t chaperone;
938938+ VREvent_PerformanceTest_t performanceTest;
939939+ VREvent_TouchPadMove_t touchPadMove;
940940+ VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
941941+ VREvent_Screenshot_t screenshot;
942942+ VREvent_ScreenshotProgress_t screenshotProgress;
943943+ VREvent_ApplicationLaunch_t applicationLaunch;
944944+ VREvent_EditingCameraSurface_t cameraSurface;
945945+ VREvent_MessageOverlay_t messageOverlay;
946946+ VREvent_Property_t property;
947947+ VREvent_DualAnalog_t dualAnalog;
948948+ VREvent_HapticVibration_t hapticVibration;
949949+ VREvent_WebConsole_t webConsole;
950950+} VREvent_Data_t;
951951+952952+953953+#if defined(__linux__) || defined(__APPLE__)
954954+// This structure was originally defined mis-packed on Linux, preserved for
955955+// compatibility.
956956+#pragma pack( push, 4 )
957957+#endif
958958+959959+/** An event posted by the server to all running applications */
960960+struct VREvent_t
961961+{
962962+ uint32_t eventType; // EVREventType enum
963963+ TrackedDeviceIndex_t trackedDeviceIndex;
964964+ float eventAgeSeconds;
965965+ // event data must be the end of the struct as its size is variable
966966+ VREvent_Data_t data;
967967+};
968968+969969+#if defined(__linux__) || defined(__APPLE__)
970970+#pragma pack( pop )
971971+#endif
972972+973973+enum EVRInputError
974974+{
975975+ VRInputError_None = 0,
976976+ VRInputError_NameNotFound = 1,
977977+ VRInputError_WrongType = 2,
978978+ VRInputError_InvalidHandle = 3,
979979+ VRInputError_InvalidParam = 4,
980980+ VRInputError_NoSteam = 5,
981981+ VRInputError_MaxCapacityReached = 6,
982982+ VRInputError_IPCError = 7,
983983+ VRInputError_NoActiveActionSet = 8,
984984+ VRInputError_InvalidDevice = 9,
985985+};
986986+987987+988988+/** The mesh to draw into the stencil (or depth) buffer to perform
989989+* early stencil (or depth) kills of pixels that will never appear on the HMD.
990990+* This mesh draws on all the pixels that will be hidden after distortion.
991991+*
992992+* If the HMD does not provide a visible area mesh pVertexData will be
993993+* NULL and unTriangleCount will be 0. */
994994+struct HiddenAreaMesh_t
995995+{
996996+ const HmdVector2_t *pVertexData;
997997+ uint32_t unTriangleCount;
998998+};
999999+10001000+10011001+enum EHiddenAreaMeshType
10021002+{
10031003+ k_eHiddenAreaMesh_Standard = 0,
10041004+ k_eHiddenAreaMesh_Inverse = 1,
10051005+ k_eHiddenAreaMesh_LineLoop = 2,
10061006+10071007+ k_eHiddenAreaMesh_Max = 3,
10081008+};
10091009+10101010+10111011+/** Identifies what kind of axis is on the controller at index n. Read this type
10121012+* with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
10131013+*/
10141014+enum EVRControllerAxisType
10151015+{
10161016+ k_eControllerAxis_None = 0,
10171017+ k_eControllerAxis_TrackPad = 1,
10181018+ k_eControllerAxis_Joystick = 2,
10191019+ k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
10201020+};
10211021+10221022+10231023+/** contains information about one axis on the controller */
10241024+struct VRControllerAxis_t
10251025+{
10261026+ 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.
10271027+ float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
10281028+};
10291029+10301030+10311031+/** the number of axes in the controller state */
10321032+static const uint32_t k_unControllerStateAxisCount = 5;
10331033+10341034+10351035+#if defined(__linux__) || defined(__APPLE__)
10361036+// This structure was originally defined mis-packed on Linux, preserved for
10371037+// compatibility.
10381038+#pragma pack( push, 4 )
10391039+#endif
10401040+10411041+/** Holds all the state of a controller at one moment in time. */
10421042+struct VRControllerState001_t
10431043+{
10441044+ // If packet num matches that on your prior call, then the controller state hasn't been changed since
10451045+ // your last call and there is no need to process it
10461046+ uint32_t unPacketNum;
10471047+10481048+ // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
10491049+ uint64_t ulButtonPressed;
10501050+ uint64_t ulButtonTouched;
10511051+10521052+ // Axis data for the controller's analog inputs
10531053+ VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
10541054+};
10551055+#if defined(__linux__) || defined(__APPLE__)
10561056+#pragma pack( pop )
10571057+#endif
10581058+10591059+10601060+typedef VRControllerState001_t VRControllerState_t;
10611061+10621062+10631063+/** determines how to provide output to the application of various event processing functions. */
10641064+enum EVRControllerEventOutputType
10651065+{
10661066+ ControllerEventOutput_OSEvents = 0,
10671067+ ControllerEventOutput_VREvents = 1,
10681068+};
10691069+10701070+10711071+10721072+/** Collision Bounds Style */
10731073+enum ECollisionBoundsStyle
10741074+{
10751075+ COLLISION_BOUNDS_STYLE_BEGINNER = 0,
10761076+ COLLISION_BOUNDS_STYLE_INTERMEDIATE,
10771077+ COLLISION_BOUNDS_STYLE_SQUARES,
10781078+ COLLISION_BOUNDS_STYLE_ADVANCED,
10791079+ COLLISION_BOUNDS_STYLE_NONE,
10801080+10811081+ COLLISION_BOUNDS_STYLE_COUNT
10821082+};
10831083+10841084+/** Allows the application to customize how the overlay appears in the compositor */
10851085+struct Compositor_OverlaySettings
10861086+{
10871087+ uint32_t size; // sizeof(Compositor_OverlaySettings)
10881088+ bool curved, antialias;
10891089+ float scale, distance, alpha;
10901090+ float uOffset, vOffset, uScale, vScale;
10911091+ float gridDivs, gridWidth, gridScale;
10921092+ HmdMatrix44_t transform;
10931093+};
10941094+10951095+/** used to refer to a single VR overlay */
10961096+typedef uint64_t VROverlayHandle_t;
10971097+10981098+static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
10991099+11001100+/** Errors that can occur around VR overlays */
11011101+enum EVROverlayError
11021102+{
11031103+ VROverlayError_None = 0,
11041104+11051105+ VROverlayError_UnknownOverlay = 10,
11061106+ VROverlayError_InvalidHandle = 11,
11071107+ VROverlayError_PermissionDenied = 12,
11081108+ VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
11091109+ VROverlayError_WrongVisibilityType = 14,
11101110+ VROverlayError_KeyTooLong = 15,
11111111+ VROverlayError_NameTooLong = 16,
11121112+ VROverlayError_KeyInUse = 17,
11131113+ VROverlayError_WrongTransformType = 18,
11141114+ VROverlayError_InvalidTrackedDevice = 19,
11151115+ VROverlayError_InvalidParameter = 20,
11161116+ VROverlayError_ThumbnailCantBeDestroyed = 21,
11171117+ VROverlayError_ArrayTooSmall = 22,
11181118+ VROverlayError_RequestFailed = 23,
11191119+ VROverlayError_InvalidTexture = 24,
11201120+ VROverlayError_UnableToLoadFile = 25,
11211121+ VROverlayError_KeyboardAlreadyInUse = 26,
11221122+ VROverlayError_NoNeighbor = 27,
11231123+ VROverlayError_TooManyMaskPrimitives = 29,
11241124+ VROverlayError_BadMaskPrimitive = 30,
11251125+ VROverlayError_TextureAlreadyLocked = 31,
11261126+ VROverlayError_TextureLockCapacityReached = 32,
11271127+ VROverlayError_TextureNotLocked = 33,
11281128+};
11291129+11301130+/** enum values to pass in to VR_Init to identify whether the application will
11311131+* draw a 3D scene. */
11321132+enum EVRApplicationType
11331133+{
11341134+ VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
11351135+ VRApplication_Scene = 1, // Application will submit 3D frames
11361136+ VRApplication_Overlay = 2, // Application only interacts with overlays
11371137+ VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
11381138+ // keep it running if everything else quits.
11391139+ VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
11401140+ // interfaces (like IVRSettings and IVRApplications) but not hardware.
11411141+ VRApplication_VRMonitor = 5, // Reserved for vrmonitor
11421142+ VRApplication_SteamWatchdog = 6,// Reserved for Steam
11431143+ VRApplication_Bootstrapper = 7, // Start up SteamVR
11441144+11451145+ VRApplication_Max
11461146+};
11471147+11481148+11491149+/** error codes for firmware */
11501150+enum EVRFirmwareError
11511151+{
11521152+ VRFirmwareError_None = 0,
11531153+ VRFirmwareError_Success = 1,
11541154+ VRFirmwareError_Fail = 2,
11551155+};
11561156+11571157+11581158+/** error codes for notifications */
11591159+enum EVRNotificationError
11601160+{
11611161+ VRNotificationError_OK = 0,
11621162+ VRNotificationError_InvalidNotificationId = 100,
11631163+ VRNotificationError_NotificationQueueFull = 101,
11641164+ VRNotificationError_InvalidOverlayHandle = 102,
11651165+ VRNotificationError_SystemWithUserValueAlreadyExists = 103,
11661166+};
11671167+11681168+11691169+/** error codes returned by Vr_Init */
11701170+11711171+// Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
11721172+enum EVRInitError
11731173+{
11741174+ VRInitError_None = 0,
11751175+ VRInitError_Unknown = 1,
11761176+11771177+ VRInitError_Init_InstallationNotFound = 100,
11781178+ VRInitError_Init_InstallationCorrupt = 101,
11791179+ VRInitError_Init_VRClientDLLNotFound = 102,
11801180+ VRInitError_Init_FileNotFound = 103,
11811181+ VRInitError_Init_FactoryNotFound = 104,
11821182+ VRInitError_Init_InterfaceNotFound = 105,
11831183+ VRInitError_Init_InvalidInterface = 106,
11841184+ VRInitError_Init_UserConfigDirectoryInvalid = 107,
11851185+ VRInitError_Init_HmdNotFound = 108,
11861186+ VRInitError_Init_NotInitialized = 109,
11871187+ VRInitError_Init_PathRegistryNotFound = 110,
11881188+ VRInitError_Init_NoConfigPath = 111,
11891189+ VRInitError_Init_NoLogPath = 112,
11901190+ VRInitError_Init_PathRegistryNotWritable = 113,
11911191+ VRInitError_Init_AppInfoInitFailed = 114,
11921192+ VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
11931193+ VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
11941194+ VRInitError_Init_AnotherAppLaunching = 117,
11951195+ VRInitError_Init_SettingsInitFailed = 118,
11961196+ VRInitError_Init_ShuttingDown = 119,
11971197+ VRInitError_Init_TooManyObjects = 120,
11981198+ VRInitError_Init_NoServerForBackgroundApp = 121,
11991199+ VRInitError_Init_NotSupportedWithCompositor = 122,
12001200+ VRInitError_Init_NotAvailableToUtilityApps = 123,
12011201+ VRInitError_Init_Internal = 124,
12021202+ VRInitError_Init_HmdDriverIdIsNone = 125,
12031203+ VRInitError_Init_HmdNotFoundPresenceFailed = 126,
12041204+ VRInitError_Init_VRMonitorNotFound = 127,
12051205+ VRInitError_Init_VRMonitorStartupFailed = 128,
12061206+ VRInitError_Init_LowPowerWatchdogNotSupported = 129,
12071207+ VRInitError_Init_InvalidApplicationType = 130,
12081208+ VRInitError_Init_NotAvailableToWatchdogApps = 131,
12091209+ VRInitError_Init_WatchdogDisabledInSettings = 132,
12101210+ VRInitError_Init_VRDashboardNotFound = 133,
12111211+ VRInitError_Init_VRDashboardStartupFailed = 134,
12121212+ VRInitError_Init_VRHomeNotFound = 135,
12131213+ VRInitError_Init_VRHomeStartupFailed = 136,
12141214+ VRInitError_Init_RebootingBusy = 137,
12151215+ VRInitError_Init_FirmwareUpdateBusy = 138,
12161216+ VRInitError_Init_FirmwareRecoveryBusy = 139,
12171217+ VRInitError_Init_USBServiceBusy = 140,
12181218+ VRInitError_Init_VRWebHelperStartupFailed = 141,
12191219+12201220+ VRInitError_Driver_Failed = 200,
12211221+ VRInitError_Driver_Unknown = 201,
12221222+ VRInitError_Driver_HmdUnknown = 202,
12231223+ VRInitError_Driver_NotLoaded = 203,
12241224+ VRInitError_Driver_RuntimeOutOfDate = 204,
12251225+ VRInitError_Driver_HmdInUse = 205,
12261226+ VRInitError_Driver_NotCalibrated = 206,
12271227+ VRInitError_Driver_CalibrationInvalid = 207,
12281228+ VRInitError_Driver_HmdDisplayNotFound = 208,
12291229+ VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209,
12301230+ // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons
12311231+ VRInitError_Driver_HmdDriverIdOutOfBounds = 211,
12321232+ VRInitError_Driver_HmdDisplayMirrored = 212,
12331233+12341234+ VRInitError_IPC_ServerInitFailed = 300,
12351235+ VRInitError_IPC_ConnectFailed = 301,
12361236+ VRInitError_IPC_SharedStateInitFailed = 302,
12371237+ VRInitError_IPC_CompositorInitFailed = 303,
12381238+ VRInitError_IPC_MutexInitFailed = 304,
12391239+ VRInitError_IPC_Failed = 305,
12401240+ VRInitError_IPC_CompositorConnectFailed = 306,
12411241+ VRInitError_IPC_CompositorInvalidConnectResponse = 307,
12421242+ VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308,
12431243+12441244+ VRInitError_Compositor_Failed = 400,
12451245+ VRInitError_Compositor_D3D11HardwareRequired = 401,
12461246+ VRInitError_Compositor_FirmwareRequiresUpdate = 402,
12471247+ VRInitError_Compositor_OverlayInitFailed = 403,
12481248+ VRInitError_Compositor_ScreenshotsInitFailed = 404,
12491249+ VRInitError_Compositor_UnableToCreateDevice = 405,
12501250+12511251+ VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
12521252+ VRInitError_VendorSpecific_WindowsNotInDevMode = 1001,
12531253+12541254+ VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
12551255+ VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
12561256+ VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
12571257+ VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
12581258+ VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
12591259+ VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
12601260+ VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
12611261+ VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
12621262+ VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
12631263+ VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
12641264+ VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
12651265+ VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
12661266+ VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
12671267+12681268+ VRInitError_Steam_SteamInstallationNotFound = 2000,
12691269+};
12701270+12711271+enum EVRScreenshotType
12721272+{
12731273+ VRScreenshotType_None = 0,
12741274+ VRScreenshotType_Mono = 1, // left eye only
12751275+ VRScreenshotType_Stereo = 2,
12761276+ VRScreenshotType_Cubemap = 3,
12771277+ VRScreenshotType_MonoPanorama = 4,
12781278+ VRScreenshotType_StereoPanorama = 5
12791279+};
12801280+12811281+enum EVRScreenshotPropertyFilenames
12821282+{
12831283+ VRScreenshotPropertyFilenames_Preview = 0,
12841284+ VRScreenshotPropertyFilenames_VR = 1,
12851285+};
12861286+12871287+enum EVRTrackedCameraError
12881288+{
12891289+ VRTrackedCameraError_None = 0,
12901290+ VRTrackedCameraError_OperationFailed = 100,
12911291+ VRTrackedCameraError_InvalidHandle = 101,
12921292+ VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
12931293+ VRTrackedCameraError_OutOfHandles = 103,
12941294+ VRTrackedCameraError_IPCFailure = 104,
12951295+ VRTrackedCameraError_NotSupportedForThisDevice = 105,
12961296+ VRTrackedCameraError_SharedMemoryFailure = 106,
12971297+ VRTrackedCameraError_FrameBufferingFailure = 107,
12981298+ VRTrackedCameraError_StreamSetupFailure = 108,
12991299+ VRTrackedCameraError_InvalidGLTextureId = 109,
13001300+ VRTrackedCameraError_InvalidSharedTextureHandle = 110,
13011301+ VRTrackedCameraError_FailedToGetGLTextureId = 111,
13021302+ VRTrackedCameraError_SharedTextureFailure = 112,
13031303+ VRTrackedCameraError_NoFrameAvailable = 113,
13041304+ VRTrackedCameraError_InvalidArgument = 114,
13051305+ VRTrackedCameraError_InvalidFrameBufferSize = 115,
13061306+};
13071307+13081308+enum EVRTrackedCameraFrameLayout
13091309+{
13101310+ EVRTrackedCameraFrameLayout_Mono = 0x0001,
13111311+ EVRTrackedCameraFrameLayout_Stereo = 0x0002,
13121312+ EVRTrackedCameraFrameLayout_VerticalLayout = 0x0010, // Stereo frames are Top/Bottom (left/right)
13131313+ EVRTrackedCameraFrameLayout_HorizontalLayout = 0x0020, // Stereo frames are Left/Right
13141314+};
13151315+13161316+enum EVRTrackedCameraFrameType
13171317+{
13181318+ VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
13191319+ VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
13201320+ VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
13211321+ MAX_CAMERA_FRAME_TYPES
13221322+};
13231323+13241324+typedef uint64_t TrackedCameraHandle_t;
13251325+#define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
13261326+13271327+struct CameraVideoStreamFrameHeader_t
13281328+{
13291329+ EVRTrackedCameraFrameType eFrameType;
13301330+13311331+ uint32_t nWidth;
13321332+ uint32_t nHeight;
13331333+ uint32_t nBytesPerPixel;
13341334+13351335+ uint32_t nFrameSequence;
13361336+13371337+ TrackedDevicePose_t standingTrackedDevicePose;
13381338+};
13391339+13401340+// Screenshot types
13411341+typedef uint32_t ScreenshotHandle_t;
13421342+13431343+static const uint32_t k_unScreenshotHandleInvalid = 0;
13441344+13451345+/** Frame timing data provided by direct mode drivers. */
13461346+struct DriverDirectMode_FrameTiming
13471347+{
13481348+ uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming )
13491349+ uint32_t m_nNumFramePresents; // number of times frame was presented
13501350+ uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to
13511351+ uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync)
13521352+ uint32_t m_nReprojectionFlags;
13531353+};
13541354+13551355+enum EVSync
13561356+{
13571357+ VSync_None,
13581358+ VSync_WaitRender, // block following render work until vsync
13591359+ VSync_NoWaitRender, // do not block following render work (allow to get started early)
13601360+};
13611361+13621362+#pragma pack( pop )
13631363+13641364+// figure out how to import from the VR API dll
13651365+#if defined(_WIN32)
13661366+13671367+#ifdef VR_API_EXPORT
13681368+#define VR_INTERFACE extern "C" __declspec( dllexport )
13691369+#else
13701370+#define VR_INTERFACE extern "C" __declspec( dllimport )
13711371+#endif
13721372+13731373+#elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
13741374+13751375+#ifdef VR_API_EXPORT
13761376+#define VR_INTERFACE extern "C" __attribute__((visibility("default")))
13771377+#else
13781378+#define VR_INTERFACE extern "C"
13791379+#endif
13801380+13811381+#else
13821382+#error "Unsupported Platform."
13831383+#endif
13841384+13851385+13861386+#if defined( _WIN32 )
13871387+#define VR_CALLTYPE __cdecl
13881388+#else
13891389+#define VR_CALLTYPE
13901390+#endif
13911391+13921392+} // namespace vr
13931393+13941394+#endif // _INCLUDE_VRTYPES_H
13951395+13961396+13971397+// vrannotation.h
13981398+#ifdef API_GEN
13991399+# define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
14001400+#else
14011401+# define VR_CLANG_ATTR(ATTR)
14021402+#endif
14031403+14041404+#define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
14051405+#define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
14061406+#define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
14071407+#define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
14081408+#define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
14091409+#define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
14101410+#define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
14111411+#define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
14121412+#define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
14131413+#define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
14141414+#define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
14151415+14161416+// vrtrackedcameratypes.h
14171417+#ifndef _VRTRACKEDCAMERATYPES_H
14181418+#define _VRTRACKEDCAMERATYPES_H
14191419+14201420+namespace vr
14211421+{
14221422+14231423+#pragma pack( push, 8 )
14241424+14251425+enum ECameraVideoStreamFormat
14261426+{
14271427+ CVS_FORMAT_UNKNOWN = 0,
14281428+ CVS_FORMAT_RAW10 = 1, // 10 bits per pixel
14291429+ CVS_FORMAT_NV12 = 2, // 12 bits per pixel
14301430+ CVS_FORMAT_RGB24 = 3, // 24 bits per pixel
14311431+ CVS_FORMAT_NV12_2 = 4, // 12 bits per pixel, 2x height
14321432+ CVS_MAX_FORMATS
14331433+};
14341434+14351435+enum ECameraCompatibilityMode
14361436+{
14371437+ CAMERA_COMPAT_MODE_BULK_DEFAULT = 0,
14381438+ CAMERA_COMPAT_MODE_BULK_64K_DMA,
14391439+ CAMERA_COMPAT_MODE_BULK_16K_DMA,
14401440+ CAMERA_COMPAT_MODE_BULK_8K_DMA,
14411441+ CAMERA_COMPAT_MODE_ISO_52FPS,
14421442+ CAMERA_COMPAT_MODE_ISO_50FPS,
14431443+ CAMERA_COMPAT_MODE_ISO_48FPS,
14441444+ CAMERA_COMPAT_MODE_ISO_46FPS,
14451445+ CAMERA_COMPAT_MODE_ISO_44FPS,
14461446+ CAMERA_COMPAT_MODE_ISO_42FPS,
14471447+ CAMERA_COMPAT_MODE_ISO_40FPS,
14481448+ CAMERA_COMPAT_MODE_ISO_35FPS,
14491449+ CAMERA_COMPAT_MODE_ISO_30FPS,
14501450+ MAX_CAMERA_COMPAT_MODES
14511451+};
14521452+14531453+enum ETrackedCameraRoomViewMode
14541454+{
14551455+ TRACKED_CAMERA_ROOMVIEW_MODE_DEFAULT = 0,
14561456+ TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_A,
14571457+ TRACKED_CAMERA_ROOMVIEW_MODE_EDGE_B,
14581458+ TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_TRANSLUSCENT,
14591459+ TRACKED_CAMERA_ROOMVIEW_MODE_VIDEO_OPAQUE,
14601460+ TRACKED_CAMERA_ROOMVIEW_MODE_COUNT,
14611461+};
14621462+14631463+#ifdef _MSC_VER
14641464+#define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) )
14651465+#else
14661466+#define VR_CAMERA_DECL_ALIGN( x ) //
14671467+#endif
14681468+14691469+#define MAX_CAMERA_FRAME_SHARED_HANDLES 4
14701470+14711471+VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t
14721472+{
14731473+ ECameraVideoStreamFormat m_nStreamFormat;
14741474+14751475+ uint32_t m_nWidth;
14761476+ uint32_t m_nHeight;
14771477+14781478+ uint32_t m_nImageDataSize; // Based on stream format, width, height
14791479+14801480+ uint32_t m_nFrameSequence; // Starts from 0 when stream starts.
14811481+14821482+ uint32_t m_nBufferIndex; // Identifies which buffer the image data is hosted
14831483+ uint32_t m_nBufferCount; // Total number of configured buffers
14841484+14851485+ uint32_t m_nExposureTime;
14861486+14871487+ uint32_t m_nISPFrameTimeStamp; // Driver provided time stamp per driver centric time base
14881488+ uint32_t m_nISPReferenceTimeStamp;
14891489+ uint32_t m_nSyncCounter;
14901490+14911491+ uint32_t m_nCamSyncEvents;
14921492+ uint32_t m_nISPSyncEvents;
14931493+14941494+ double m_flReferenceCamSyncTime;
14951495+14961496+ double m_flFrameElapsedTime; // Starts from 0 when stream starts. In seconds.
14971497+ double m_flFrameDeliveryRate;
14981498+14991499+ double m_flFrameCaptureTime_DriverAbsolute; // In USB time, via AuxEvent
15001500+ double m_flFrameCaptureTime_ServerRelative; // In System time within the server
15011501+ uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks within the server
15021502+ double m_flFrameCaptureTime_ClientRelative; // At the client, relative to when the frame was exposed/captured.
15031503+15041504+ double m_flSyncMarkerError;
15051505+15061506+ TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by HMD layer when used as a tracked camera
15071507+15081508+ uint64_t m_pImageData;
15091509+};
15101510+15111511+#pragma pack( pop )
15121512+15131513+}
15141514+15151515+#endif // _VRTRACKEDCAMERATYPES_H
15161516+// ivrsettings.h
15171517+namespace vr
15181518+{
15191519+ enum EVRSettingsError
15201520+ {
15211521+ VRSettingsError_None = 0,
15221522+ VRSettingsError_IPCFailed = 1,
15231523+ VRSettingsError_WriteFailed = 2,
15241524+ VRSettingsError_ReadFailed = 3,
15251525+ VRSettingsError_JsonParseFailed = 4,
15261526+ VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set
15271527+ };
15281528+15291529+ // The maximum length of a settings key
15301530+ static const uint32_t k_unMaxSettingsKeyLength = 128;
15311531+15321532+ class IVRSettings
15331533+ {
15341534+ public:
15351535+ virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
15361536+15371537+ // Returns true if file sync occurred (force or settings dirty)
15381538+ virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0;
15391539+15401540+ virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
15411541+ virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
15421542+ virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
15431543+ virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
15441544+15451545+ // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory
15461546+ // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or ""
15471547+ virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
15481548+ virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
15491549+ virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
15501550+ virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0;
15511551+15521552+ virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
15531553+ virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
15541554+ };
15551555+15561556+ //-----------------------------------------------------------------------------
15571557+ static const char * const IVRSettings_Version = "IVRSettings_002";
15581558+15591559+ //-----------------------------------------------------------------------------
15601560+ // steamvr keys
15611561+ static const char * const k_pch_SteamVR_Section = "steamvr";
15621562+ static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
15631563+ static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
15641564+ static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
15651565+ static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
15661566+ static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
15671567+ static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
15681568+ static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
15691569+ static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
15701570+ static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
15711571+ static const char * const k_pch_SteamVR_IPD_Float = "ipd";
15721572+ static const char * const k_pch_SteamVR_Background_String = "background";
15731573+ static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection";
15741574+ static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
15751575+ static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
15761576+ static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
15771577+ static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
15781578+ static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
15791579+ static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
15801580+ static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode";
15811581+ static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
15821582+ static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
15831583+ static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
15841584+ static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
15851585+ static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
15861586+ static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
15871587+ static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale";
15881588+ static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection";
15891589+ static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection";
15901590+ static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection";
15911591+ static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
15921592+ static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView";
15931593+ static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView";
15941594+ static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry";
15951595+ static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch";
15961596+ static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch";
15971597+ static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch";
15981598+ static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard";
15991599+ static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp";
16001600+ static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec";
16011601+ static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo";
16021602+ static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset";
16031603+ static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering";
16041604+ static const char * const k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride";
16051605+ static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync";
16061606+ static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode";
16071607+ static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver";
16081608+ static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor";
16091609+ static const char * const k_pch_SteamVR_DebugInput = "debugInput";
16101610+ static const char * const k_pch_SteamVR_LegacyInputRebinding = "legacyInputRebinding";
16111611+16121612+ //-----------------------------------------------------------------------------
16131613+ // lighthouse keys
16141614+ static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
16151615+ static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
16161616+ static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd";
16171617+ static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
16181618+ static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
16191619+ static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
16201620+ static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
16211621+ static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth";
16221622+ static const char * const k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations";
16231623+16241624+ //-----------------------------------------------------------------------------
16251625+ // null keys
16261626+ static const char * const k_pch_Null_Section = "driver_null";
16271627+ static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
16281628+ static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
16291629+ static const char * const k_pch_Null_WindowX_Int32 = "windowX";
16301630+ static const char * const k_pch_Null_WindowY_Int32 = "windowY";
16311631+ static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
16321632+ static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
16331633+ static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
16341634+ static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
16351635+ static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
16361636+ static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
16371637+16381638+ //-----------------------------------------------------------------------------
16391639+ // user interface keys
16401640+ static const char * const k_pch_UserInterface_Section = "userinterface";
16411641+ static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
16421642+ static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray";
16431643+ static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots";
16441644+ static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType";
16451645+16461646+ //-----------------------------------------------------------------------------
16471647+ // notification keys
16481648+ static const char * const k_pch_Notifications_Section = "notifications";
16491649+ static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
16501650+16511651+ //-----------------------------------------------------------------------------
16521652+ // keyboard keys
16531653+ static const char * const k_pch_Keyboard_Section = "keyboard";
16541654+ static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
16551655+ static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
16561656+ static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
16571657+ static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
16581658+ static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
16591659+ static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
16601660+ static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
16611661+16621662+ //-----------------------------------------------------------------------------
16631663+ // perf keys
16641664+ static const char * const k_pch_Perf_Section = "perfcheck";
16651665+ static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
16661666+ static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
16671667+ static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
16681668+ static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
16691669+ static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
16701670+ static const char * const k_pch_Perf_TestData_Float = "perfTestData";
16711671+ static const char * const k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling";
16721672+16731673+ //-----------------------------------------------------------------------------
16741674+ // collision bounds keys
16751675+ static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
16761676+ static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
16771677+ static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
16781678+ static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
16791679+ static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
16801680+ static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
16811681+ static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
16821682+ static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
16831683+ static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
16841684+ static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
16851685+16861686+ //-----------------------------------------------------------------------------
16871687+ // camera keys
16881688+ static const char * const k_pch_Camera_Section = "camera";
16891689+ static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
16901690+ static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
16911691+ static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
16921692+ static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
16931693+ static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
16941694+ static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
16951695+ static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
16961696+ static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
16971697+ static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength";
16981698+ static const char * const k_pch_Camera_RoomViewMode_Int32 = "cameraRoomViewMode";
16991699+17001700+ //-----------------------------------------------------------------------------
17011701+ // audio keys
17021702+ static const char * const k_pch_audio_Section = "audio";
17031703+ static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
17041704+ static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
17051705+ static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
17061706+ static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
17071707+ static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
17081708+ static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
17091709+17101710+ //-----------------------------------------------------------------------------
17111711+ // power management keys
17121712+ static const char * const k_pch_Power_Section = "power";
17131713+ static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit";
17141714+ static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout";
17151715+ static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout";
17161716+ static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout";
17171717+ static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress";
17181718+ static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby";
17191719+17201720+ //-----------------------------------------------------------------------------
17211721+ // dashboard keys
17221722+ static const char * const k_pch_Dashboard_Section = "dashboard";
17231723+ static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard";
17241724+ static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode";
17251725+ static const char * const k_pch_Dashboard_EnableWebUI = "webUI";
17261726+ static const char * const k_pch_Dashboard_EnableWebUIDevTools = "webUIDevTools";
17271727+17281728+ //-----------------------------------------------------------------------------
17291729+ // model skin keys
17301730+ static const char * const k_pch_modelskin_Section = "modelskins";
17311731+17321732+ //-----------------------------------------------------------------------------
17331733+ // driver keys - These could be checked in any driver_<name> section
17341734+ static const char * const k_pch_Driver_Enable_Bool = "enable";
17351735+17361736+ //-----------------------------------------------------------------------------
17371737+ // web interface keys
17381738+ static const char* const k_pch_WebInterface_Section = "WebInterface";
17391739+ static const char* const k_pch_WebInterface_WebPort_String = "WebPort";
17401740+17411741+} // namespace vr
17421742+17431743+// iservertrackeddevicedriver.h
17441744+namespace vr
17451745+{
17461746+17471747+17481748+struct DriverPoseQuaternion_t
17491749+{
17501750+ double w, x, y, z;
17511751+};
17521752+17531753+struct DriverPose_t
17541754+{
17551755+ /* Time offset of this pose, in seconds from the actual time of the pose,
17561756+ * relative to the time of the PoseUpdated() call made by the driver.
17571757+ */
17581758+ double poseTimeOffset;
17591759+17601760+ /* Generally, the pose maintained by a driver
17611761+ * is in an inertial coordinate system different
17621762+ * from the world system of x+ right, y+ up, z+ back.
17631763+ * Also, the driver is not usually tracking the "head" position,
17641764+ * but instead an internal IMU or another reference point in the HMD.
17651765+ * The following two transforms transform positions and orientations
17661766+ * to app world space from driver world space,
17671767+ * and to HMD head space from driver local body space.
17681768+ *
17691769+ * We maintain the driver pose state in its internal coordinate system,
17701770+ * so we can do the pose prediction math without having to
17711771+ * use angular acceleration. A driver's angular acceleration is generally not measured,
17721772+ * and is instead calculated from successive samples of angular velocity.
17731773+ * This leads to a noisy angular acceleration values, which are also
17741774+ * lagged due to the filtering required to reduce noise to an acceptable level.
17751775+ */
17761776+ vr::HmdQuaternion_t qWorldFromDriverRotation;
17771777+ double vecWorldFromDriverTranslation[ 3 ];
17781778+17791779+ vr::HmdQuaternion_t qDriverFromHeadRotation;
17801780+ double vecDriverFromHeadTranslation[ 3 ];
17811781+17821782+ /* State of driver pose, in meters and radians. */
17831783+ /* Position of the driver tracking reference in driver world space
17841784+ * +[0] (x) is right
17851785+ * +[1] (y) is up
17861786+ * -[2] (z) is forward
17871787+ */
17881788+ double vecPosition[ 3 ];
17891789+17901790+ /* Velocity of the pose in meters/second */
17911791+ double vecVelocity[ 3 ];
17921792+17931793+ /* Acceleration of the pose in meters/second */
17941794+ double vecAcceleration[ 3 ];
17951795+17961796+ /* Orientation of the tracker, represented as a quaternion */
17971797+ vr::HmdQuaternion_t qRotation;
17981798+17991799+ /* Angular velocity of the pose in axis-angle
18001800+ * representation. The direction is the angle of
18011801+ * rotation and the magnitude is the angle around
18021802+ * that axis in radians/second. */
18031803+ double vecAngularVelocity[ 3 ];
18041804+18051805+ /* Angular acceleration of the pose in axis-angle
18061806+ * representation. The direction is the angle of
18071807+ * rotation and the magnitude is the angle around
18081808+ * that axis in radians/second^2. */
18091809+ double vecAngularAcceleration[ 3 ];
18101810+18111811+ ETrackingResult result;
18121812+18131813+ bool poseIsValid;
18141814+ bool willDriftInYaw;
18151815+ bool shouldApplyHeadModel;
18161816+ bool deviceIsConnected;
18171817+};
18181818+18191819+18201820+// ----------------------------------------------------------------------------------------------
18211821+// Purpose: Represents a single tracked device in a driver
18221822+// ----------------------------------------------------------------------------------------------
18231823+class ITrackedDeviceServerDriver
18241824+{
18251825+public:
18261826+18271827+ // ------------------------------------
18281828+ // Management Methods
18291829+ // ------------------------------------
18301830+ /** This is called before an HMD is returned to the application. It will always be
18311831+ * called before any display or tracking methods. Memory and processor use by the
18321832+ * ITrackedDeviceServerDriver object should be kept to a minimum until it is activated.
18331833+ * The pose listener is guaranteed to be valid until Deactivate is called, but
18341834+ * should not be used after that point. */
18351835+ virtual EVRInitError Activate( uint32_t unObjectId ) = 0;
18361836+18371837+ /** This is called when The VR system is switching from this Hmd being the active display
18381838+ * to another Hmd being the active display. The driver should clean whatever memory
18391839+ * and thread use it can when it is deactivated */
18401840+ virtual void Deactivate() = 0;
18411841+18421842+ /** Handles a request from the system to put this device into standby mode. What that means is defined per-device. */
18431843+ virtual void EnterStandby() = 0;
18441844+18451845+ /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL
18461846+ * if the requested interface or version is not supported. */
18471847+ virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0;
18481848+18491849+ /** A VR Client has made this debug request of the driver. The set of valid requests is entirely
18501850+ * up to the driver and the client to figure out, as is the format of the response. Responses that
18511851+ * exceed the length of the supplied buffer should be truncated and null terminated */
18521852+ virtual void DebugRequest( const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
18531853+18541854+ // ------------------------------------
18551855+ // Tracking Methods
18561856+ // ------------------------------------
18571857+ virtual DriverPose_t GetPose() = 0;
18581858+};
18591859+18601860+18611861+18621862+static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_005";
18631863+18641864+}
18651865+// ivrdisplaycomponent.h
18661866+namespace vr
18671867+{
18681868+18691869+18701870+ // ----------------------------------------------------------------------------------------------
18711871+ // Purpose: The display component on a single tracked device
18721872+ // ----------------------------------------------------------------------------------------------
18731873+ class IVRDisplayComponent
18741874+ {
18751875+ public:
18761876+18771877+ // ------------------------------------
18781878+ // Display Methods
18791879+ // ------------------------------------
18801880+18811881+ /** Size and position that the window needs to be on the VR display. */
18821882+ virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
18831883+18841884+ /** Returns true if the display is extending the desktop. */
18851885+ virtual bool IsDisplayOnDesktop( ) = 0;
18861886+18871887+ /** Returns true if the display is real and not a fictional display. */
18881888+ virtual bool IsDisplayRealDisplay( ) = 0;
18891889+18901890+ /** Suggested size for the intermediate render target that the distortion pulls from. */
18911891+ virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
18921892+18931893+ /** Gets the viewport in the frame buffer to draw the output of the distortion into */
18941894+ virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
18951895+18961896+ /** The components necessary to build your own projection matrix in case your
18971897+ * application is doing something fancy like infinite Z */
18981898+ virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
18991899+19001900+ /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
19011901+ * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
19021902+ virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0;
19031903+19041904+ };
19051905+19061906+ static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_002";
19071907+19081908+}
19091909+19101910+// ivrdriverdirectmodecomponent.h
19111911+namespace vr
19121912+{
19131913+19141914+19151915+ // ----------------------------------------------------------------------------------------------
19161916+ // Purpose: This component is used for drivers that implement direct mode entirely on their own
19171917+ // without allowing the VR Compositor to own the window/device. Chances are you don't
19181918+ // need to implement this component in your driver.
19191919+ // ----------------------------------------------------------------------------------------------
19201920+ class IVRDriverDirectModeComponent
19211921+ {
19221922+ public:
19231923+19241924+ // -----------------------------------
19251925+ // Direct mode methods
19261926+ // -----------------------------------
19271927+19281928+ /** Specific to Oculus compositor support, textures supplied must be created using this method. */
19291929+ struct SwapTextureSetDesc_t
19301930+ {
19311931+ uint32_t nWidth;
19321932+ uint32_t nHeight;
19331933+ uint32_t nFormat;
19341934+ uint32_t nSampleCount;
19351935+ };
19361936+ virtual void CreateSwapTextureSet( uint32_t unPid, const SwapTextureSetDesc_t *pSwapTextureSetDesc, vr::SharedTextureHandle_t( *pSharedTextureHandles )[ 3 ] ) {}
19371937+19381938+ /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */
19391939+ virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sharedTextureHandle ) {}
19401940+19411941+ /** Used to purge all texture sets for a given process. */
19421942+ virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {}
19431943+19441944+ /** After Present returns, calls this to get the next index to use for rendering. */
19451945+ virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {}
19461946+19471947+ /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created
19481948+ * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */
19491949+ struct SubmitLayerPerEye_t
19501950+ {
19511951+ // Shared texture handles (depth not always provided).
19521952+ vr::SharedTextureHandle_t hTexture, hDepthTexture;
19531953+19541954+ // Valid region of provided texture (and depth).
19551955+ vr::VRTextureBounds_t bounds;
19561956+19571957+ // Projection matrix used to render the depth buffer.
19581958+ vr::HmdMatrix44_t mProjection;
19591959+ };
19601960+ virtual void SubmitLayer( const SubmitLayerPerEye_t( &perEye )[ 2 ], const vr::HmdMatrix34_t *pPose ) {}
19611961+19621962+ /** Submits queued layers for display. */
19631963+ virtual void Present( vr::SharedTextureHandle_t syncTexture ) {}
19641964+19651965+ /** Called after Present to allow driver to take more time until vsync after they've successfully acquired the sync texture in Present.*/
19661966+ virtual void PostPresent() {}
19671967+19681968+ /** Called to get additional frame timing stats from driver. Check m_nSize for versioning (new members will be added to end only). */
19691969+ virtual void GetFrameTiming( DriverDirectMode_FrameTiming *pFrameTiming ) {}
19701970+ };
19711971+19721972+ static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_005";
19731973+19741974+}
19751975+19761976+// ivrcameracomponent.h
19771977+namespace vr
19781978+{
19791979+ //-----------------------------------------------------------------------------
19801980+ //-----------------------------------------------------------------------------
19811981+ class ICameraVideoSinkCallback
19821982+ {
19831983+ public:
19841984+ virtual void OnCameraVideoSinkCallback() = 0;
19851985+ };
19861986+19871987+ // ----------------------------------------------------------------------------------------------
19881988+ // Purpose: The camera on a single tracked device
19891989+ // ----------------------------------------------------------------------------------------------
19901990+ class IVRCameraComponent
19911991+ {
19921992+ public:
19931993+ // ------------------------------------
19941994+ // Camera Methods
19951995+ // ------------------------------------
19961996+ virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFormat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0;
19971997+ virtual bool GetCameraFrameBufferingRequirements( int *pDefaultFrameQueueSize, uint32_t *pFrameBufferDataSize ) = 0;
19981998+ virtual bool SetCameraFrameBuffering( int nFrameBufferCount, void **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0;
19991999+ virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamFormat nVideoStreamFormat ) = 0;
20002000+ virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat() = 0;
20012001+ virtual bool StartVideoStream() = 0;
20022002+ virtual void StopVideoStream() = 0;
20032003+ virtual bool IsVideoStreamActive( bool *pbPaused, float *pflElapsedTime ) = 0;
20042004+ virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame() = 0;
20052005+ virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStreamFrame_t *pFrameImage ) = 0;
20062006+ virtual bool SetAutoExposure( bool bEnable ) = 0;
20072007+ virtual bool PauseVideoStream() = 0;
20082008+ virtual bool ResumeVideoStream() = 0;
20092009+ virtual bool GetCameraDistortion( float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0;
20102010+ virtual bool GetCameraProjection( vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
20112011+ virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0;
20122012+ virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0;
20132013+ virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0;
20142014+ virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0;
20152015+ virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0;
20162016+ virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0;
20172017+ };
20182018+20192019+ static const char *IVRCameraComponent_Version = "IVRCameraComponent_002";
20202020+}
20212021+// itrackeddevicedriverprovider.h
20222022+namespace vr
20232023+{
20242024+20252025+class ITrackedDeviceServerDriver;
20262026+struct TrackedDeviceDriverInfo_t;
20272027+struct DriverPose_t;
20282028+20292029+/** This interface is provided by vrserver to allow the driver to notify
20302030+* the system when something changes about a device. These changes must
20312031+* not change the serial number or class of the device because those values
20322032+* are permanently associated with the device's index. */
20332033+class IVRDriverContext
20342034+{
20352035+public:
20362036+ /** Returns the requested interface. If the interface was not available it will return NULL and fill
20372037+ * out the error. */
20382038+ virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError = nullptr ) = 0;
20392039+20402040+ /** Returns the property container handle for this driver */
20412041+ virtual DriverHandle_t GetDriverHandle() = 0;
20422042+};
20432043+20442044+20452045+/** This interface must be implemented in each driver. It will be loaded in vrserver.exe */
20462046+class IServerTrackedDeviceProvider
20472047+{
20482048+public:
20492049+ /** initializes the driver. This will be called before any other methods are called.
20502050+ * If Init returns anything other than VRInitError_None the driver DLL will be unloaded.
20512051+ *
20522052+ * pDriverHost will never be NULL, and will always be a pointer to a IServerDriverHost interface
20532053+ *
20542054+ * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user
20552055+ * config files.
20562056+ * pchDriverInstallDir - The absolute path of the root directory for the driver.
20572057+ */
20582058+ virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
20592059+20602060+ /** cleans up the driver right before it is unloaded */
20612061+ virtual void Cleanup() = 0;
20622062+20632063+ /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */
20642064+ virtual const char * const *GetInterfaceVersions() = 0;
20652065+20662066+ /** Allows the driver do to some work in the main loop of the server. */
20672067+ virtual void RunFrame() = 0;
20682068+20692069+20702070+ // ------------ Power State Functions ----------------------- //
20712071+20722072+ /** Returns true if the driver wants to block Standby mode. */
20732073+ virtual bool ShouldBlockStandbyMode() = 0;
20742074+20752075+ /** Called when the system is entering Standby mode. The driver should switch itself into whatever sort of low-power
20762076+ * state it has. */
20772077+ virtual void EnterStandby() = 0;
20782078+20792079+ /** Called when the system is leaving Standby mode. The driver should switch itself back to
20802080+ full operation. */
20812081+ virtual void LeaveStandby() = 0;
20822082+20832083+};
20842084+20852085+20862086+static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_004";
20872087+20882088+20892089+20902090+20912091+/** This interface must be implemented in each driver. It will be loaded in vrclient.dll */
20922092+class IVRWatchdogProvider
20932093+{
20942094+public:
20952095+ /** initializes the driver in watchdog mode. */
20962096+ virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
20972097+20982098+ /** cleans up the driver right before it is unloaded */
20992099+ virtual void Cleanup() = 0;
21002100+};
21012101+21022102+static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001";
21032103+21042104+}
21052105+// ivrproperties.h
21062106+#include <string>
21072107+#include <vector>
21082108+21092109+namespace vr
21102110+{
21112111+21122112+ enum EPropertyWriteType
21132113+ {
21142114+ PropertyWrite_Set = 0,
21152115+ PropertyWrite_Erase = 1,
21162116+ PropertyWrite_SetError = 2
21172117+ };
21182118+21192119+ struct PropertyWrite_t
21202120+ {
21212121+ ETrackedDeviceProperty prop;
21222122+ EPropertyWriteType writeType;
21232123+ ETrackedPropertyError eSetError;
21242124+ void *pvBuffer;
21252125+ uint32_t unBufferSize;
21262126+ PropertyTypeTag_t unTag;
21272127+ ETrackedPropertyError eError;
21282128+ };
21292129+21302130+ struct PropertyRead_t
21312131+ {
21322132+ ETrackedDeviceProperty prop;
21332133+ void *pvBuffer;
21342134+ uint32_t unBufferSize;
21352135+ PropertyTypeTag_t unTag;
21362136+ uint32_t unRequiredBufferSize;
21372137+ ETrackedPropertyError eError;
21382138+ };
21392139+21402140+21412141+class IVRProperties
21422142+{
21432143+public:
21442144+21452145+ /** Reads a set of properties atomically. See the PropertyReadBatch_t struct for more information. */
21462146+ virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0;
21472147+21482148+ /** Writes a set of properties atomically. See the PropertyWriteBatch_t struct for more information. */
21492149+ virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0;
21502150+21512151+ /** returns a string that corresponds with the specified property error. The string will be the name
21522152+ * of the error enum value for all valid error codes */
21532153+ virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0;
21542154+21552155+ /** Returns a container handle given a tracked device index */
21562156+ virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) = 0;
21572157+21582158+};
21592159+21602160+static const char * const IVRProperties_Version = "IVRProperties_001";
21612161+21622162+class CVRPropertyHelpers
21632163+{
21642164+public:
21652165+ CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProperties ) {}
21662166+21672167+ /** Returns a scaler property. If the device index is not valid or the property value type does not match,
21682168+ * this function will return false. */
21692169+ bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
21702170+ float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
21712171+ int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
21722172+ uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
21732173+21742174+ /** Returns a single typed property. If the device index is not valid or the property is not a string type this function will
21752175+ * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
21762176+ * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
21772177+ uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L );
21782178+21792179+21802180+ /** Returns a string property. If the device index is not valid or the property is not a string type this function will
21812181+ * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
21822182+ * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
21832183+ uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L );
21842184+21852185+ /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will
21862186+ * return an empty string. */
21872187+ std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr );
21882188+21892189+ /** Reads a std::vector of data from a property. */
21902190+ template< typename T>
21912191+ ETrackedPropertyError GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults );
21922192+21932193+ /** Sets a scaler property. The new value will be returned on any subsequent call to get this property in any process. */
21942194+ ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue );
21952195+ ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue );
21962196+ ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue );
21972197+ ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue );
21982198+21992199+ /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
22002200+ ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue );
22012201+22022202+ /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
22032203+ ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag );
22042204+22052205+ /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
22062206+ ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError );
22072207+22082208+ /** Clears any value or error set for the property. */
22092209+ ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop );
22102210+22112211+ /* Turns a device index into a property container handle. */
22122212+ PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDevice ); }
22132213+22142214+ /** Sets a std::vector of typed data to a property. */
22152215+ template< typename T>
22162216+ ETrackedPropertyError SetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *vecProperties );
22172217+22182218+ /** Returns true if the specified property is set on the specified container */
22192219+ bool IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError = nullptr );
22202220+private:
22212221+ template<typename T>
22222222+ T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag );
22232223+22242224+ IVRProperties *m_pProperties;
22252225+};
22262226+22272227+22282228+inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError )
22292229+{
22302230+ PropertyRead_t batch;
22312231+ batch.prop = prop;
22322232+ batch.pvBuffer = pvBuffer;
22332233+ batch.unBufferSize = unBufferSize;
22342234+22352235+ m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 );
22362236+22372237+ if ( pError )
22382238+ {
22392239+ *pError = batch.eError;
22402240+ }
22412241+22422242+ if ( punTag )
22432243+ {
22442244+ *punTag = batch.unTag;
22452245+ }
22462246+22472247+ return batch.unRequiredBufferSize;
22482248+}
22492249+22502250+22512251+/** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
22522252+inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag )
22532253+{
22542254+ PropertyWrite_t batch;
22552255+ batch.writeType = PropertyWrite_Set;
22562256+ batch.prop = prop;
22572257+ batch.pvBuffer = pvNewValue;
22582258+ batch.unBufferSize = unNewValueSize;
22592259+ batch.unTag = unTag;
22602260+22612261+ m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
22622262+22632263+ return batch.eError;
22642264+}
22652265+22662266+22672267+/** Returns a string property. If the device index is not valid or the property is not a string type this function will
22682268+* return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
22692269+* null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
22702270+inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError )
22712271+{
22722272+ PropertyTypeTag_t unTag;
22732273+ ETrackedPropertyError error;
22742274+ uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue, unBufferSize, &unTag, &error );
22752275+ if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success )
22762276+ {
22772277+ error = TrackedProp_WrongDataType;
22782278+ }
22792279+22802280+ if ( pError )
22812281+ {
22822282+ *pError = error;
22832283+ }
22842284+22852285+ if ( error != TrackedProp_Success )
22862286+ {
22872287+ if ( pchValue && unBufferSize )
22882288+ {
22892289+ *pchValue = '\0';
22902290+ }
22912291+ }
22922292+22932293+ return unRequiredSize;
22942294+}
22952295+22962296+22972297+/** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will
22982298+* return an empty string. */
22992299+inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError )
23002300+{
23012301+ char buf[1024];
23022302+ vr::ETrackedPropertyError err;
23032303+ uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf, sizeof(buf), &err );
23042304+23052305+ std::string sResult;
23062306+23072307+ if ( err == TrackedProp_Success )
23082308+ {
23092309+ sResult = buf;
23102310+ }
23112311+ else if ( err == TrackedProp_BufferTooSmall )
23122312+ {
23132313+ char *pchBuffer = new char[unRequiredBufferLen];
23142314+ unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchBuffer, unRequiredBufferLen, &err );
23152315+ sResult = pchBuffer;
23162316+ delete[] pchBuffer;
23172317+ }
23182318+23192319+ if ( peError )
23202320+ {
23212321+ *peError = err;
23222322+ }
23232323+23242324+ return sResult;
23252325+}
23262326+23272327+23282328+/** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
23292329+inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue )
23302330+{
23312331+ if ( !pchNewValue )
23322332+ return TrackedProp_InvalidOperation;
23332333+23342334+ // this is strlen without the dependency on string.h
23352335+ const char *pchCurr = pchNewValue;
23362336+ while ( *pchCurr )
23372337+ {
23382338+ pchCurr++;
23392339+ }
23402340+23412341+ return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint32_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag );
23422342+}
23432343+23442344+23452345+template<typename T>
23462346+inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag )
23472347+{
23482348+ T bValue;
23492349+ ETrackedPropertyError eError;
23502350+ PropertyTypeTag_t unReadTag;
23512351+ GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unReadTag, &eError );
23522352+ if ( unReadTag != unTypeTag && eError == TrackedProp_Success )
23532353+ {
23542354+ eError = TrackedProp_WrongDataType;
23552355+ };
23562356+23572357+ if ( pError )
23582358+ *pError = eError;
23592359+ if ( eError != TrackedProp_Success )
23602360+ {
23612361+ return bDefault;
23622362+ }
23632363+ else
23642364+ {
23652365+ return bValue;
23662366+ }
23672367+}
23682368+23692369+23702370+inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
23712371+{
23722372+ return GetPropertyHelper<bool>( ulContainerHandle, prop, pError, false, k_unBoolPropertyTag );
23732373+}
23742374+23752375+23762376+inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
23772377+{
23782378+ return GetPropertyHelper<float>( ulContainerHandle, prop, pError, 0.f, k_unFloatPropertyTag );
23792379+}
23802380+23812381+inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
23822382+{
23832383+ return GetPropertyHelper<int32_t>( ulContainerHandle, prop, pError, 0, k_unInt32PropertyTag );
23842384+}
23852385+23862386+inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
23872387+{
23882388+ return GetPropertyHelper<uint64_t>( ulContainerHandle, prop, pError, 0, k_unUint64PropertyTag );
23892389+}
23902390+23912391+inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue )
23922392+{
23932393+ return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewValue ), k_unBoolPropertyTag );
23942394+}
23952395+23962396+inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue )
23972397+{
23982398+ return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unFloatPropertyTag );
23992399+}
24002400+24012401+inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue )
24022402+{
24032403+ return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewValue ), k_unInt32PropertyTag );
24042404+}
24052405+24062406+inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue )
24072407+{
24082408+ return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewValue ), k_unUint64PropertyTag );
24092409+}
24102410+24112411+/** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
24122412+inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError )
24132413+{
24142414+ PropertyWrite_t batch;
24152415+ batch.writeType = PropertyWrite_SetError;
24162416+ batch.prop = prop;
24172417+ batch.eSetError = eError;
24182418+24192419+ m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
24202420+24212421+ return batch.eError;
24222422+}
24232423+24242424+/** Clears any value or error set for the property. */
24252425+inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop )
24262426+{
24272427+ PropertyWrite_t batch;
24282428+ batch.writeType = PropertyWrite_Erase;
24292429+ batch.prop = prop;
24302430+24312431+ m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
24322432+24332433+ return batch.eError;
24342434+24352435+}
24362436+24372437+template< typename T >
24382438+ETrackedPropertyError CVRPropertyHelpers::SetPropertyVector(PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, PropertyTypeTag_t unTag, std::vector<T> *pvecProperties)
24392439+{
24402440+ return SetProperty( ulContainer, prop, &(*pvecProperties)[0], (uint32_t)(pvecProperties->size() * sizeof( T )), unTag );
24412441+}
24422442+24432443+template< typename T >
24442444+ETrackedPropertyError CVRPropertyHelpers::GetPropertyVector( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, PropertyTypeTag_t unExpectedTag, std::vector<T> *pvecResults )
24452445+{
24462446+ ETrackedPropertyError err;
24472447+ PropertyTypeTag_t unTag;
24482448+ uint32_t unNeeded;
24492449+ if ( pvecResults->empty() )
24502450+ unNeeded = GetProperty( ulContainer, prop, nullptr, 0, &unTag, &err );
24512451+ else
24522452+ unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err );
24532453+ uint32_t unFound = unNeeded / sizeof( T );
24542454+ if ( err == TrackedProp_Success )
24552455+ {
24562456+ if ( unTag != unExpectedTag && unFound > 0 )
24572457+ {
24582458+ return TrackedProp_WrongDataType;
24592459+ }
24602460+24612461+ pvecResults->resize( unFound );
24622462+ return TrackedProp_Success;
24632463+ }
24642464+ else if ( err == TrackedProp_BufferTooSmall )
24652465+ {
24662466+ pvecResults->resize( unFound );
24672467+ unNeeded = GetProperty( ulContainer, prop, &(*pvecResults)[0], (uint32_t)(pvecResults->size() * sizeof( T )), &unTag, &err );
24682468+ unFound = unNeeded / sizeof( T );
24692469+24702470+ if ( err == TrackedProp_Success )
24712471+ {
24722472+ if ( unTag != unExpectedTag )
24732473+ {
24742474+ return TrackedProp_WrongDataType;
24752475+ }
24762476+24772477+ pvecResults->resize( unFound );
24782478+ return TrackedProp_Success;
24792479+ }
24802480+ }
24812481+ return err;
24822482+}
24832483+24842484+inline bool CVRPropertyHelpers::IsPropertySet( PropertyContainerHandle_t ulContainer, ETrackedDeviceProperty prop, ETrackedPropertyError *peError )
24852485+{
24862486+ ETrackedPropertyError error;
24872487+ GetProperty( ulContainer, prop, nullptr, 0, nullptr, &error );
24882488+ if ( peError )
24892489+ *peError = error;
24902490+ return error == TrackedProp_Success || error == TrackedProp_BufferTooSmall;
24912491+}
24922492+24932493+}
24942494+24952495+24962496+24972497+// ivrdriverinput.h
24982498+namespace vr
24992499+{
25002500+25012501+ typedef uint64_t VRInputComponentHandle_t;
25022502+ static const VRInputComponentHandle_t k_ulInvalidInputComponentHandle = 0;
25032503+25042504+ enum EVRScalarType
25052505+ {
25062506+ VRScalarType_Absolute = 0,
25072507+ VRScalarType_Relative = 1,
25082508+ };
25092509+25102510+25112511+ enum EVRScalarUnits
25122512+ {
25132513+ VRScalarUnits_NormalizedOneSided = 0, // Value ranges from 0 to 1
25142514+ VRScalarUnits_NormalizedTwoSided = 1, // Value ranges from -1 to 1
25152515+ };
25162516+25172517+ class IVRDriverInput
25182518+ {
25192519+ public:
25202520+25212521+ /** Creates a boolean input component for the device */
25222522+ virtual EVRInputError CreateBooleanComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0;
25232523+25242524+ /** Updates a boolean component */
25252525+ virtual EVRInputError UpdateBooleanComponent( VRInputComponentHandle_t ulComponent, bool bNewValue, double fTimeOffset ) = 0;
25262526+25272527+ /** Creates a scalar input component for the device */
25282528+ virtual EVRInputError CreateScalarComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle, EVRScalarType eType, EVRScalarUnits eUnits ) = 0;
25292529+25302530+ /** Updates a boolean component */
25312531+ virtual EVRInputError UpdateScalarComponent( VRInputComponentHandle_t ulComponent, float fNewValue, double fTimeOffset ) = 0;
25322532+25332533+ /** Creates a haptic component for the device */
25342534+ virtual EVRInputError CreateHapticComponent( PropertyContainerHandle_t ulContainer, const char *pchName, VRInputComponentHandle_t *pHandle ) = 0;
25352535+25362536+ };
25372537+25382538+ static const char * const IVRDriverInput_Version = "IVRDriverInput_001";
25392539+25402540+} // namespace vr
25412541+25422542+// ivrdriverlog.h
25432543+namespace vr
25442544+{
25452545+25462546+class IVRDriverLog
25472547+{
25482548+public:
25492549+ /** Writes a log message to the log file prefixed with the driver name */
25502550+ virtual void Log( const char *pchLogMessage ) = 0;
25512551+};
25522552+25532553+25542554+static const char *IVRDriverLog_Version = "IVRDriverLog_001";
25552555+25562556+}
25572557+// ivrserverdriverhost.h
25582558+namespace vr
25592559+{
25602560+25612561+class ITrackedDeviceServerDriver;
25622562+struct TrackedDeviceDriverInfo_t;
25632563+struct DriverPose_t;
25642564+25652565+/** This interface is provided by vrserver to allow the driver to notify
25662566+* the system when something changes about a device. These changes must
25672567+* not change the serial number or class of the device because those values
25682568+* are permanently associated with the device's index. */
25692569+class IVRServerDriverHost
25702570+{
25712571+public:
25722572+ /** Notifies the server that a tracked device has been added. If this function returns true
25732573+ * the server will call Activate on the device. If it returns false some kind of error
25742574+ * has occurred and the device will not be activated. */
25752575+ virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETrackedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0;
25762576+25772577+ /** Notifies the server that a tracked device's pose has been updated */
25782578+ virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose, uint32_t unPoseStructSize ) = 0;
25792579+25802580+ /** Notifies the server that vsync has occurred on the the display attached to the device. This is
25812581+ * only permitted on devices of the HMD class. */
25822582+ virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0;
25832583+25842584+ /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */
25852585+ virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0;
25862586+25872587+ /** Returns true if SteamVR is exiting */
25882588+ virtual bool IsExiting() = 0;
25892589+25902590+ /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
25912591+ * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
25922592+ virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
25932593+25942594+ /** Provides access to device poses for drivers. Poses are in their "raw" tracking space which is uniquely
25952595+ * defined by each driver providing poses for its devices. It is up to clients of this function to correlate
25962596+ * poses across different drivers. Poses are indexed by their device id, and their associated driver and
25972597+ * other properties can be looked up via IVRProperties. */
25982598+ virtual void GetRawTrackedDevicePoses( float fPredictedSecondsFromNow, TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0;
25992599+26002600+ /** Notifies the server that a tracked device's display component transforms have been updated. */
26012601+ virtual void TrackedDeviceDisplayTransformUpdated( uint32_t unWhichDevice, HmdMatrix34_t eyeToHeadLeft, HmdMatrix34_t eyeToHeadRight ) = 0;
26022602+};
26032603+26042604+static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_005";
26052605+26062606+}
26072607+26082608+// ivrhiddenarea.h
26092609+namespace vr
26102610+{
26112611+26122612+class CVRHiddenAreaHelpers
26132613+{
26142614+public:
26152615+ CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pProperties ) {}
26162616+26172617+ /** Stores a hidden area mesh in a property */
26182618+ ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount );
26192619+26202620+ /** retrieves a hidden area mesh from a property. Returns the vert count read out of the property. */
26212621+ uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError );
26222622+26232623+private:
26242624+ ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType type )
26252625+ {
26262626+ return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_Start + ((int)type * 2) + (int)eEye);
26272627+ }
26282628+26292629+ IVRProperties *m_pProperties;
26302630+};
26312631+26322632+26332633+inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount )
26342634+{
26352635+ ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
26362636+ CVRPropertyHelpers propHelpers( m_pProperties );
26372637+ return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVertCount, k_unHiddenAreaPropertyTag );
26382638+}
26392639+26402640+26412641+inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError )
26422642+{
26432643+ ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
26442644+ CVRPropertyHelpers propHelpers( m_pProperties );
26452645+ ETrackedPropertyError propError;
26462646+ PropertyTypeTag_t unTag;
26472647+ uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t )*unVertCount, &unTag, &propError );
26482648+ if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaPropertyTag )
26492649+ {
26502650+ propError = TrackedProp_WrongDataType;
26512651+ unBytesNeeded = 0;
26522652+ }
26532653+26542654+ if ( peError )
26552655+ {
26562656+ *peError = propError;
26572657+ }
26582658+26592659+ return unBytesNeeded / sizeof( HmdVector2_t );
26602660+}
26612661+26622662+}
26632663+// ivrwatchdoghost.h
26642664+namespace vr
26652665+{
26662666+26672667+/** This interface is provided by vrclient to allow the driver to make everything wake up */
26682668+class IVRWatchdogHost
26692669+{
26702670+public:
26712671+ /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should
26722672+ * cause SteamVR to start */
26732673+ virtual void WatchdogWakeUp() = 0;
26742674+};
26752675+26762676+static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001";
26772677+26782678+}
26792679+26802680+26812681+26822682+// ivrvirtualdisplay.h
26832683+namespace vr
26842684+{
26852685+ struct PresentInfo_t
26862686+ {
26872687+ SharedTextureHandle_t backbufferTextureHandle;
26882688+ EVSync vsync;
26892689+ uint64_t nFrameId;
26902690+ double flVSyncTimeInSeconds;
26912691+ };
26922692+26932693+ // ----------------------------------------------------------------------------------------------
26942694+ // Purpose: This component is used for drivers that implement a virtual display (e.g. wireless).
26952695+ // ----------------------------------------------------------------------------------------------
26962696+ class IVRVirtualDisplay
26972697+ {
26982698+ public:
26992699+27002700+ /** Submits final backbuffer for display. */
27012701+ virtual void Present( const PresentInfo_t *pPresentInfo, uint32_t unPresentInfoSize ) = 0;
27022702+27032703+ /** Block until the last presented buffer start scanning out. */
27042704+ virtual void WaitForPresent() = 0;
27052705+27062706+ /** Provides timing data for synchronizing with display. */
27072707+ virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0;
27082708+ };
27092709+27102710+ static const char *IVRVirtualDisplay_Version = "IVRVirtualDisplay_002";
27112711+27122712+ /** Returns the current IVRVirtualDisplay pointer or NULL the interface could not be found. */
27132713+ VR_INTERFACE vr::IVRVirtualDisplay *VR_CALLTYPE VRVirtualDisplay();
27142714+}
27152715+27162716+27172717+// ivrresources.h
27182718+namespace vr
27192719+{
27202720+27212721+class IVRResources
27222722+{
27232723+public:
27242724+27252725+ // ------------------------------------
27262726+ // Shared Resource Methods
27272727+ // ------------------------------------
27282728+27292729+ /** Loads the specified resource into the provided buffer if large enough.
27302730+ * Returns the size in bytes of the buffer required to hold the specified resource. */
27312731+ virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0;
27322732+27332733+ /** Provides the full path to the specified resource. Resource names can include named directories for
27342734+ * drivers and other things, and this resolves all of those and returns the actual physical path.
27352735+ * pchResourceTypeDirectory is the subdirectory of resources to look in. */
27362736+ virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0;
27372737+};
27382738+27392739+static const char * const IVRResources_Version = "IVRResources_001";
27402740+27412741+27422742+}
27432743+// ivrdrivermanager.h
27442744+namespace vr
27452745+{
27462746+27472747+class IVRDriverManager
27482748+{
27492749+public:
27502750+ virtual uint32_t GetDriverCount() const = 0;
27512751+27522752+ /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */
27532753+ virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0;
27542754+27552755+ virtual DriverHandle_t GetDriverHandle( const char *pchDriverName ) = 0;
27562756+};
27572757+27582758+static const char * const IVRDriverManager_Version = "IVRDriverManager_001";
27592759+27602760+} // namespace vr
27612761+27622762+27632763+27642764+27652765+27662766+namespace vr
27672767+{
27682768+ static const char * const k_InterfaceVersions[] =
27692769+ {
27702770+ IVRSettings_Version,
27712771+ ITrackedDeviceServerDriver_Version,
27722772+ IVRDisplayComponent_Version,
27732773+ IVRDriverDirectModeComponent_Version,
27742774+ IVRCameraComponent_Version,
27752775+ IServerTrackedDeviceProvider_Version,
27762776+ IVRWatchdogProvider_Version,
27772777+ IVRVirtualDisplay_Version,
27782778+ IVRDriverManager_Version,
27792779+ IVRResources_Version,
27802780+ nullptr
27812781+ };
27822782+27832783+ inline IVRDriverContext *&VRDriverContext()
27842784+ {
27852785+ static IVRDriverContext *pHost;
27862786+ return pHost;
27872787+ }
27882788+27892789+ class COpenVRDriverContext
27902790+ {
27912791+ public:
27922792+ COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAreaHelpers(nullptr) { Clear(); }
27932793+ void Clear();
27942794+27952795+ EVRInitError InitServer();
27962796+ EVRInitError InitWatchdog();
27972797+27982798+ IVRSettings *VRSettings()
27992799+ {
28002800+ if ( m_pVRSettings == nullptr )
28012801+ {
28022802+ EVRInitError eError;
28032803+ m_pVRSettings = (IVRSettings *)VRDriverContext()->GetGenericInterface( IVRSettings_Version, &eError );
28042804+ }
28052805+ return m_pVRSettings;
28062806+ }
28072807+28082808+ IVRProperties *VRPropertiesRaw()
28092809+ {
28102810+ if ( m_pVRProperties == nullptr )
28112811+ {
28122812+ EVRInitError eError;
28132813+ m_pVRProperties = (IVRProperties *)VRDriverContext()->GetGenericInterface( IVRProperties_Version, &eError );
28142814+ m_propertyHelpers = CVRPropertyHelpers( m_pVRProperties );
28152815+ m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pVRProperties );
28162816+ }
28172817+ return m_pVRProperties;
28182818+ }
28192819+28202820+ CVRPropertyHelpers *VRProperties()
28212821+ {
28222822+ VRPropertiesRaw();
28232823+ return &m_propertyHelpers;
28242824+ }
28252825+28262826+ CVRHiddenAreaHelpers *VRHiddenArea()
28272827+ {
28282828+ VRPropertiesRaw();
28292829+ return &m_hiddenAreaHelpers;
28302830+ }
28312831+28322832+ IVRServerDriverHost *VRServerDriverHost()
28332833+ {
28342834+ if ( m_pVRServerDriverHost == nullptr )
28352835+ {
28362836+ EVRInitError eError;
28372837+ m_pVRServerDriverHost = (IVRServerDriverHost *)VRDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError );
28382838+ }
28392839+ return m_pVRServerDriverHost;
28402840+ }
28412841+28422842+ IVRWatchdogHost *VRWatchdogHost()
28432843+ {
28442844+ if ( m_pVRWatchdogHost == nullptr )
28452845+ {
28462846+ EVRInitError eError;
28472847+ m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverContext()->GetGenericInterface( IVRWatchdogHost_Version, &eError );
28482848+ }
28492849+ return m_pVRWatchdogHost;
28502850+ }
28512851+28522852+ IVRDriverLog *VRDriverLog()
28532853+ {
28542854+ if ( m_pVRDriverLog == nullptr )
28552855+ {
28562856+ EVRInitError eError;
28572857+ m_pVRDriverLog = (IVRDriverLog *)VRDriverContext()->GetGenericInterface( IVRDriverLog_Version, &eError );
28582858+ }
28592859+ return m_pVRDriverLog;
28602860+ }
28612861+28622862+ DriverHandle_t VR_CALLTYPE VRDriverHandle()
28632863+ {
28642864+ return VRDriverContext()->GetDriverHandle();
28652865+ }
28662866+28672867+ IVRDriverManager *VRDriverManager()
28682868+ {
28692869+ if ( !m_pVRDriverManager )
28702870+ {
28712871+ EVRInitError eError;
28722872+ m_pVRDriverManager = (IVRDriverManager *)VRDriverContext()->GetGenericInterface( IVRDriverManager_Version, &eError );
28732873+ }
28742874+ return m_pVRDriverManager;
28752875+ }
28762876+28772877+ IVRResources *VRResources()
28782878+ {
28792879+ if ( !m_pVRResources )
28802880+ {
28812881+ EVRInitError eError;
28822882+ m_pVRResources = (IVRResources *)VRDriverContext()->GetGenericInterface( IVRResources_Version, &eError );
28832883+ }
28842884+ return m_pVRResources;
28852885+ }
28862886+28872887+ IVRDriverInput *VRDriverInput()
28882888+ {
28892889+ if ( !m_pVRDriverInput )
28902890+ {
28912891+ EVRInitError eError;
28922892+ m_pVRDriverInput = (IVRDriverInput *)VRDriverContext()->GetGenericInterface( IVRDriverInput_Version, &eError );
28932893+ }
28942894+ return m_pVRDriverInput;
28952895+ }
28962896+28972897+ private:
28982898+ CVRPropertyHelpers m_propertyHelpers;
28992899+ CVRHiddenAreaHelpers m_hiddenAreaHelpers;
29002900+29012901+ IVRSettings *m_pVRSettings;
29022902+ IVRProperties *m_pVRProperties;
29032903+ IVRServerDriverHost *m_pVRServerDriverHost;
29042904+ IVRWatchdogHost *m_pVRWatchdogHost;
29052905+ IVRDriverLog *m_pVRDriverLog;
29062906+ IVRDriverManager *m_pVRDriverManager;
29072907+ IVRResources *m_pVRResources;
29082908+ IVRDriverInput *m_pVRDriverInput;
29092909+ };
29102910+29112911+ inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext()
29122912+ {
29132913+ static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void * )];
29142914+ return *(COpenVRDriverContext *)ctx; // bypass zero-init constructor
29152915+ }
29162916+29172917+ inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleServerDriverContext().VRSettings(); }
29182918+ inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInternal_ModuleServerDriverContext().VRPropertiesRaw(); }
29192919+ inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInternal_ModuleServerDriverContext().VRProperties(); }
29202920+ inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRInternal_ModuleServerDriverContext().VRHiddenArea(); }
29212921+ inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_ModuleServerDriverContext().VRDriverLog(); }
29222922+ inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRServerDriverHost(); }
29232923+ inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInternal_ModuleServerDriverContext().VRWatchdogHost(); }
29242924+ inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRInternal_ModuleServerDriverContext().VRDriverHandle(); }
29252925+ inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleServerDriverContext().VRDriverManager(); }
29262926+ inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleServerDriverContext().VRResources(); }
29272927+ inline IVRDriverInput *VR_CALLTYPE VRDriverInput() { return OpenVRInternal_ModuleServerDriverContext().VRDriverInput(); }
29282928+29292929+ inline void COpenVRDriverContext::Clear()
29302930+ {
29312931+ m_pVRSettings = nullptr;
29322932+ m_pVRProperties = nullptr;
29332933+ m_pVRServerDriverHost = nullptr;
29342934+ m_pVRDriverLog = nullptr;
29352935+ m_pVRWatchdogHost = nullptr;
29362936+ m_pVRDriverManager = nullptr;
29372937+ m_pVRResources = nullptr;
29382938+ m_pVRDriverInput = nullptr;
29392939+ }
29402940+29412941+ inline EVRInitError COpenVRDriverContext::InitServer()
29422942+ {
29432943+ Clear();
29442944+ if ( !VRServerDriverHost()
29452945+ || !VRSettings()
29462946+ || !VRProperties()
29472947+ || !VRDriverLog()
29482948+ || !VRDriverManager()
29492949+ || !VRResources() )
29502950+ return VRInitError_Init_InterfaceNotFound;
29512951+ return VRInitError_None;
29522952+ }
29532953+29542954+ inline EVRInitError COpenVRDriverContext::InitWatchdog()
29552955+ {
29562956+ Clear();
29572957+ if ( !VRWatchdogHost()
29582958+ || !VRSettings()
29592959+ || !VRDriverLog() )
29602960+ return VRInitError_Init_InterfaceNotFound;
29612961+ return VRInitError_None;
29622962+ }
29632963+29642964+ inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext )
29652965+ {
29662966+ VRDriverContext() = pContext;
29672967+ return OpenVRInternal_ModuleServerDriverContext().InitServer();
29682968+ }
29692969+29702970+ inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContext )
29712971+ {
29722972+ VRDriverContext() = pContext;
29732973+ return OpenVRInternal_ModuleServerDriverContext().InitWatchdog();
29742974+ }
29752975+29762976+ inline void CleanupDriverContext()
29772977+ {
29782978+ VRDriverContext() = nullptr;
29792979+ OpenVRInternal_ModuleServerDriverContext().Clear();
29802980+ }
29812981+29822982+ #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \
29832983+ { \
29842984+ vr::EVRInitError eError = vr::InitServerDriverContext( pContext ); \
29852985+ if( eError != vr::VRInitError_None ) \
29862986+ return eError; \
29872987+ }
29882988+29892989+ #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \
29902990+ vr::CleanupDriverContext();
29912991+29922992+ #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \
29932993+ { \
29942994+ vr::EVRInitError eError = vr::InitWatchdogDriverContext( pContext ); \
29952995+ if( eError != vr::VRInitError_None ) \
29962996+ return eError; \
29972997+ }
29982998+29992999+ #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \
30003000+ vr::CleanupDriverContext();
30013001+}
30023002+// End
30033003+30043004+#endif // _OPENVR_DRIVER_API
30053005+