openvr_driver.h 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829
  1. #pragma once
  2. // openvr_driver.h
  3. //========= Copyright Valve Corporation ============//
  4. // Dynamically generated file. Do not modify this file directly.
  5. #ifndef _OPENVR_DRIVER_API
  6. #define _OPENVR_DRIVER_API
  7. #include <stdint.h>
  8. // vrtypes.h
  9. #ifndef _INCLUDE_VRTYPES_H
  10. #define _INCLUDE_VRTYPES_H
  11. namespace vr
  12. {
  13. #if defined(__linux__) || defined(__APPLE__)
  14. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  15. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  16. // The 64-bit version of gcc has the alignment requirement for these types set to
  17. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  18. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  19. #pragma pack( push, 4 )
  20. #else
  21. #pragma pack( push, 8 )
  22. #endif
  23. typedef void* glSharedTextureHandle_t;
  24. typedef int32_t glInt_t;
  25. typedef uint32_t glUInt_t;
  26. // right-handed system
  27. // +y is up
  28. // +x is to the right
  29. // -z is going away from you
  30. // Distance unit is meters
  31. struct HmdMatrix34_t
  32. {
  33. float m[3][4];
  34. };
  35. struct HmdMatrix44_t
  36. {
  37. float m[4][4];
  38. };
  39. struct HmdVector3_t
  40. {
  41. float v[3];
  42. };
  43. struct HmdVector4_t
  44. {
  45. float v[4];
  46. };
  47. struct HmdVector3d_t
  48. {
  49. double v[3];
  50. };
  51. struct HmdVector2_t
  52. {
  53. float v[2];
  54. };
  55. struct HmdQuaternion_t
  56. {
  57. double w, x, y, z;
  58. };
  59. struct HmdColor_t
  60. {
  61. float r, g, b, a;
  62. };
  63. struct HmdQuad_t
  64. {
  65. HmdVector3_t vCorners[ 4 ];
  66. };
  67. struct HmdRect2_t
  68. {
  69. HmdVector2_t vTopLeft;
  70. HmdVector2_t vBottomRight;
  71. };
  72. /** Used to return the post-distortion UVs for each color channel.
  73. * UVs range from 0 to 1 with 0,0 in the upper left corner of the
  74. * source render target. The 0,0 to 1,1 range covers a single eye. */
  75. struct DistortionCoordinates_t
  76. {
  77. float rfRed[2];
  78. float rfGreen[2];
  79. float rfBlue[2];
  80. };
  81. enum EVREye
  82. {
  83. Eye_Left = 0,
  84. Eye_Right = 1
  85. };
  86. enum EGraphicsAPIConvention
  87. {
  88. API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane
  89. API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane
  90. };
  91. enum EColorSpace
  92. {
  93. ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
  94. ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
  95. ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
  96. };
  97. struct Texture_t
  98. {
  99. void* handle; // Native d3d texture pointer or GL texture id.
  100. EGraphicsAPIConvention eType;
  101. EColorSpace eColorSpace;
  102. };
  103. enum ETrackingResult
  104. {
  105. TrackingResult_Uninitialized = 1,
  106. TrackingResult_Calibrating_InProgress = 100,
  107. TrackingResult_Calibrating_OutOfRange = 101,
  108. TrackingResult_Running_OK = 200,
  109. TrackingResult_Running_OutOfRange = 201,
  110. };
  111. static const uint32_t k_unTrackingStringSize = 32;
  112. static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
  113. /** Used to pass device IDs to API calls */
  114. typedef uint32_t TrackedDeviceIndex_t;
  115. static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
  116. static const uint32_t k_unMaxTrackedDeviceCount = 16;
  117. static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
  118. static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
  119. /** Describes what kind of object is being tracked at a given ID */
  120. enum ETrackedDeviceClass
  121. {
  122. TrackedDeviceClass_Invalid = 0, // the ID was not valid.
  123. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
  124. TrackedDeviceClass_Controller = 2, // Tracked controllers
  125. TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
  126. TrackedDeviceClass_Other = 1000,
  127. };
  128. /** Describes what specific role associated with a tracked device */
  129. enum ETrackedControllerRole
  130. {
  131. TrackedControllerRole_Invalid = 0, // Invalid value for controller type
  132. TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
  133. TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
  134. };
  135. /** describes a single pose for a tracked object */
  136. struct TrackedDevicePose_t
  137. {
  138. HmdMatrix34_t mDeviceToAbsoluteTracking;
  139. HmdVector3_t vVelocity; // velocity in tracker space in m/s
  140. HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
  141. ETrackingResult eTrackingResult;
  142. bool bPoseIsValid;
  143. // This indicates that there is a device connected for this spot in the pose array.
  144. // It could go from true to false if the user unplugs the device.
  145. bool bDeviceIsConnected;
  146. };
  147. /** Identifies which style of tracking origin the application wants to use
  148. * for the poses it is requesting */
  149. enum ETrackingUniverseOrigin
  150. {
  151. TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
  152. TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
  153. TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. You probably don't want this one.
  154. };
  155. /** Each entry in this enum represents a property that can be retrieved about a
  156. * tracked device. Many fields are only valid for one ETrackedDeviceClass. */
  157. enum ETrackedDeviceProperty
  158. {
  159. // general properties that apply to all device classes
  160. Prop_TrackingSystemName_String = 1000,
  161. Prop_ModelNumber_String = 1001,
  162. Prop_SerialNumber_String = 1002,
  163. Prop_RenderModelName_String = 1003,
  164. Prop_WillDriftInYaw_Bool = 1004,
  165. Prop_ManufacturerName_String = 1005,
  166. Prop_TrackingFirmwareVersion_String = 1006,
  167. Prop_HardwareRevision_String = 1007,
  168. Prop_AllWirelessDongleDescriptions_String = 1008,
  169. Prop_ConnectedWirelessDongle_String = 1009,
  170. Prop_DeviceIsWireless_Bool = 1010,
  171. Prop_DeviceIsCharging_Bool = 1011,
  172. Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
  173. Prop_StatusDisplayTransform_Matrix34 = 1013,
  174. Prop_Firmware_UpdateAvailable_Bool = 1014,
  175. Prop_Firmware_ManualUpdate_Bool = 1015,
  176. Prop_Firmware_ManualUpdateURL_String = 1016,
  177. Prop_HardwareRevision_Uint64 = 1017,
  178. Prop_FirmwareVersion_Uint64 = 1018,
  179. Prop_FPGAVersion_Uint64 = 1019,
  180. Prop_VRCVersion_Uint64 = 1020,
  181. Prop_RadioVersion_Uint64 = 1021,
  182. Prop_DongleVersion_Uint64 = 1022,
  183. Prop_BlockServerShutdown_Bool = 1023,
  184. Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
  185. Prop_ContainsProximitySensor_Bool = 1025,
  186. Prop_DeviceProvidesBatteryStatus_Bool = 1026,
  187. Prop_DeviceCanPowerOff_Bool = 1027,
  188. Prop_Firmware_ProgrammingTarget_String = 1028,
  189. Prop_DeviceClass_Int32 = 1029,
  190. Prop_HasCamera_Bool = 1030,
  191. Prop_DriverVersion_String = 1031,
  192. Prop_Firmware_ForceUpdateRequired_Bool = 1032,
  193. // Properties that are unique to TrackedDeviceClass_HMD
  194. Prop_ReportsTimeSinceVSync_Bool = 2000,
  195. Prop_SecondsFromVsyncToPhotons_Float = 2001,
  196. Prop_DisplayFrequency_Float = 2002,
  197. Prop_UserIpdMeters_Float = 2003,
  198. Prop_CurrentUniverseId_Uint64 = 2004,
  199. Prop_PreviousUniverseId_Uint64 = 2005,
  200. Prop_DisplayFirmwareVersion_Uint64 = 2006,
  201. Prop_IsOnDesktop_Bool = 2007,
  202. Prop_DisplayMCType_Int32 = 2008,
  203. Prop_DisplayMCOffset_Float = 2009,
  204. Prop_DisplayMCScale_Float = 2010,
  205. Prop_EdidVendorID_Int32 = 2011,
  206. Prop_DisplayMCImageLeft_String = 2012,
  207. Prop_DisplayMCImageRight_String = 2013,
  208. Prop_DisplayGCBlackClamp_Float = 2014,
  209. Prop_EdidProductID_Int32 = 2015,
  210. Prop_CameraToHeadTransform_Matrix34 = 2016,
  211. Prop_DisplayGCType_Int32 = 2017,
  212. Prop_DisplayGCOffset_Float = 2018,
  213. Prop_DisplayGCScale_Float = 2019,
  214. Prop_DisplayGCPrescale_Float = 2020,
  215. Prop_DisplayGCImage_String = 2021,
  216. Prop_LensCenterLeftU_Float = 2022,
  217. Prop_LensCenterLeftV_Float = 2023,
  218. Prop_LensCenterRightU_Float = 2024,
  219. Prop_LensCenterRightV_Float = 2025,
  220. Prop_UserHeadToEyeDepthMeters_Float = 2026,
  221. Prop_CameraFirmwareVersion_Uint64 = 2027,
  222. Prop_CameraFirmwareDescription_String = 2028,
  223. Prop_DisplayFPGAVersion_Uint64 = 2029,
  224. Prop_DisplayBootloaderVersion_Uint64 = 2030,
  225. Prop_DisplayHardwareVersion_Uint64 = 2031,
  226. Prop_AudioFirmwareVersion_Uint64 = 2032,
  227. Prop_CameraCompatibilityMode_Int32 = 2033,
  228. Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
  229. Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
  230. Prop_DisplaySuppressed_Bool = 2036,
  231. // Properties that are unique to TrackedDeviceClass_Controller
  232. Prop_AttachedDeviceId_String = 3000,
  233. Prop_SupportedButtons_Uint64 = 3001,
  234. Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
  235. Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
  236. Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
  237. Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
  238. Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
  239. // Properties that are unique to TrackedDeviceClass_TrackingReference
  240. Prop_FieldOfViewLeftDegrees_Float = 4000,
  241. Prop_FieldOfViewRightDegrees_Float = 4001,
  242. Prop_FieldOfViewTopDegrees_Float = 4002,
  243. Prop_FieldOfViewBottomDegrees_Float = 4003,
  244. Prop_TrackingRangeMinimumMeters_Float = 4004,
  245. Prop_TrackingRangeMaximumMeters_Float = 4005,
  246. Prop_ModeLabel_String = 4006,
  247. // Vendors are free to expose private debug data in this reserved region
  248. Prop_VendorSpecific_Reserved_Start = 10000,
  249. Prop_VendorSpecific_Reserved_End = 10999,
  250. };
  251. /** No string property will ever be longer than this length */
  252. static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
  253. /** Used to return errors that occur when reading properties. */
  254. enum ETrackedPropertyError
  255. {
  256. TrackedProp_Success = 0,
  257. TrackedProp_WrongDataType = 1,
  258. TrackedProp_WrongDeviceClass = 2,
  259. TrackedProp_BufferTooSmall = 3,
  260. TrackedProp_UnknownProperty = 4,
  261. TrackedProp_InvalidDevice = 5,
  262. TrackedProp_CouldNotContactServer = 6,
  263. TrackedProp_ValueNotProvidedByDevice = 7,
  264. TrackedProp_StringExceedsMaximumLength = 8,
  265. TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
  266. };
  267. /** Allows the application to control what part of the provided texture will be used in the
  268. * frame buffer. */
  269. struct VRTextureBounds_t
  270. {
  271. float uMin, vMin;
  272. float uMax, vMax;
  273. };
  274. /** Allows the application to control how scene textures are used by the compositor when calling Submit. */
  275. enum EVRSubmitFlags
  276. {
  277. // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
  278. Submit_Default = 0x00,
  279. // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
  280. // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
  281. // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
  282. Submit_LensDistortionAlreadyApplied = 0x01,
  283. // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
  284. Submit_GlRenderBuffer = 0x02,
  285. };
  286. /** Status of the overall system or tracked objects */
  287. enum EVRState
  288. {
  289. VRState_Undefined = -1,
  290. VRState_Off = 0,
  291. VRState_Searching = 1,
  292. VRState_Searching_Alert = 2,
  293. VRState_Ready = 3,
  294. VRState_Ready_Alert = 4,
  295. VRState_NotReady = 5,
  296. VRState_Standby = 6,
  297. };
  298. /** The types of events that could be posted (and what the parameters mean for each event type) */
  299. enum EVREventType
  300. {
  301. VREvent_None = 0,
  302. VREvent_TrackedDeviceActivated = 100,
  303. VREvent_TrackedDeviceDeactivated = 101,
  304. VREvent_TrackedDeviceUpdated = 102,
  305. VREvent_TrackedDeviceUserInteractionStarted = 103,
  306. VREvent_TrackedDeviceUserInteractionEnded = 104,
  307. VREvent_IpdChanged = 105,
  308. VREvent_EnterStandbyMode = 106,
  309. VREvent_LeaveStandbyMode = 107,
  310. VREvent_TrackedDeviceRoleChanged = 108,
  311. VREvent_ButtonPress = 200, // data is controller
  312. VREvent_ButtonUnpress = 201, // data is controller
  313. VREvent_ButtonTouch = 202, // data is controller
  314. VREvent_ButtonUntouch = 203, // data is controller
  315. VREvent_MouseMove = 300, // data is mouse
  316. VREvent_MouseButtonDown = 301, // data is mouse
  317. VREvent_MouseButtonUp = 302, // data is mouse
  318. VREvent_FocusEnter = 303, // data is overlay
  319. VREvent_FocusLeave = 304, // data is overlay
  320. VREvent_Scroll = 305, // data is mouse
  321. VREvent_TouchPadMove = 306, // data is mouse
  322. VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
  323. VREvent_InputFocusReleased = 401, // data is process DEPRECATED
  324. VREvent_SceneFocusLost = 402, // data is process
  325. VREvent_SceneFocusGained = 403, // data is process
  326. VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
  327. VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
  328. VREvent_InputFocusChanged = 406, // data is process
  329. VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process
  330. VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
  331. VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
  332. VREvent_OverlayShown = 500,
  333. VREvent_OverlayHidden = 501,
  334. VREvent_DashboardActivated = 502,
  335. VREvent_DashboardDeactivated = 503,
  336. VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
  337. VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
  338. VREvent_ResetDashboard = 506, // Send to the overlay manager
  339. VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
  340. VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
  341. VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
  342. VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
  343. VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
  344. VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
  345. VREvent_OverlaySharedTextureChanged = 513,
  346. VREvent_DashboardGuideButtonDown = 514,
  347. VREvent_DashboardGuideButtonUp = 515,
  348. VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
  349. VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
  350. // Screenshot API
  351. VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
  352. VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
  353. VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
  354. VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
  355. VREvent_Notification_Shown = 600,
  356. VREvent_Notification_Hidden = 601,
  357. VREvent_Notification_BeginInteraction = 602,
  358. VREvent_Notification_Destroyed = 603,
  359. VREvent_Quit = 700, // data is process
  360. VREvent_ProcessQuit = 701, // data is process
  361. VREvent_QuitAborted_UserPrompt = 702, // data is process
  362. VREvent_QuitAcknowledged = 703, // data is process
  363. VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
  364. VREvent_ChaperoneDataHasChanged = 800,
  365. VREvent_ChaperoneUniverseHasChanged = 801,
  366. VREvent_ChaperoneTempDataHasChanged = 802,
  367. VREvent_ChaperoneSettingsHaveChanged = 803,
  368. VREvent_SeatedZeroPoseReset = 804,
  369. VREvent_AudioSettingsHaveChanged = 820,
  370. VREvent_BackgroundSettingHasChanged = 850,
  371. VREvent_CameraSettingsHaveChanged = 851,
  372. VREvent_ReprojectionSettingHasChanged = 852,
  373. VREvent_ModelSkinSettingsHaveChanged = 853,
  374. VREvent_EnvironmentSettingsHaveChanged = 854,
  375. VREvent_StatusUpdate = 900,
  376. VREvent_MCImageUpdated = 1000,
  377. VREvent_FirmwareUpdateStarted = 1100,
  378. VREvent_FirmwareUpdateFinished = 1101,
  379. VREvent_KeyboardClosed = 1200,
  380. VREvent_KeyboardCharInput = 1201,
  381. VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
  382. VREvent_ApplicationTransitionStarted = 1300,
  383. VREvent_ApplicationTransitionAborted = 1301,
  384. VREvent_ApplicationTransitionNewAppStarted = 1302,
  385. VREvent_ApplicationListUpdated = 1303,
  386. VREvent_Compositor_MirrorWindowShown = 1400,
  387. VREvent_Compositor_MirrorWindowHidden = 1401,
  388. VREvent_Compositor_ChaperoneBoundsShown = 1410,
  389. VREvent_Compositor_ChaperoneBoundsHidden = 1411,
  390. VREvent_TrackedCamera_StartVideoStream = 1500,
  391. VREvent_TrackedCamera_StopVideoStream = 1501,
  392. VREvent_TrackedCamera_PauseVideoStream = 1502,
  393. VREvent_TrackedCamera_ResumeVideoStream = 1503,
  394. VREvent_PerformanceTest_EnableCapture = 1600,
  395. VREvent_PerformanceTest_DisableCapture = 1601,
  396. VREvent_PerformanceTest_FidelityLevel = 1602,
  397. // Vendors are free to expose private events in this reserved region
  398. VREvent_VendorSpecific_Reserved_Start = 10000,
  399. VREvent_VendorSpecific_Reserved_End = 19999,
  400. };
  401. /** Level of Hmd activity */
  402. enum EDeviceActivityLevel
  403. {
  404. k_EDeviceActivityLevel_Unknown = -1,
  405. k_EDeviceActivityLevel_Idle = 0,
  406. k_EDeviceActivityLevel_UserInteraction = 1,
  407. k_EDeviceActivityLevel_UserInteraction_Timeout = 2,
  408. k_EDeviceActivityLevel_Standby = 3,
  409. };
  410. /** VR controller button and axis IDs */
  411. enum EVRButtonId
  412. {
  413. k_EButton_System = 0,
  414. k_EButton_ApplicationMenu = 1,
  415. k_EButton_Grip = 2,
  416. k_EButton_DPad_Left = 3,
  417. k_EButton_DPad_Up = 4,
  418. k_EButton_DPad_Right = 5,
  419. k_EButton_DPad_Down = 6,
  420. k_EButton_A = 7,
  421. k_EButton_Axis0 = 32,
  422. k_EButton_Axis1 = 33,
  423. k_EButton_Axis2 = 34,
  424. k_EButton_Axis3 = 35,
  425. k_EButton_Axis4 = 36,
  426. // aliases for well known controllers
  427. k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
  428. k_EButton_SteamVR_Trigger = k_EButton_Axis1,
  429. k_EButton_Dashboard_Back = k_EButton_Grip,
  430. k_EButton_Max = 64
  431. };
  432. inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
  433. /** used for controller button events */
  434. struct VREvent_Controller_t
  435. {
  436. uint32_t button; // EVRButtonId enum
  437. };
  438. /** used for simulated mouse events in overlay space */
  439. enum EVRMouseButton
  440. {
  441. VRMouseButton_Left = 0x0001,
  442. VRMouseButton_Right = 0x0002,
  443. VRMouseButton_Middle = 0x0004,
  444. };
  445. /** used for simulated mouse events in overlay space */
  446. struct VREvent_Mouse_t
  447. {
  448. float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
  449. uint32_t button; // EVRMouseButton enum
  450. };
  451. /** used for simulated mouse wheel scroll in overlay space */
  452. struct VREvent_Scroll_t
  453. {
  454. float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
  455. uint32_t repeatCount;
  456. };
  457. /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
  458. is on the touchpad (or just released from it)
  459. **/
  460. struct VREvent_TouchPadMove_t
  461. {
  462. // true if the users finger is detected on the touch pad
  463. bool bFingerDown;
  464. // How long the finger has been down in seconds
  465. float flSecondsFingerDown;
  466. // These values indicate the starting finger position (so you can do some basic swipe stuff)
  467. float fValueXFirst;
  468. float fValueYFirst;
  469. // This is the raw sampled coordinate without deadzoning
  470. float fValueXRaw;
  471. float fValueYRaw;
  472. };
  473. /** notification related events. Details will still change at this point */
  474. struct VREvent_Notification_t
  475. {
  476. uint64_t ulUserValue;
  477. uint32_t notificationId;
  478. };
  479. /** Used for events about processes */
  480. struct VREvent_Process_t
  481. {
  482. uint32_t pid;
  483. uint32_t oldPid;
  484. bool bForced;
  485. };
  486. /** Used for a few events about overlays */
  487. struct VREvent_Overlay_t
  488. {
  489. uint64_t overlayHandle;
  490. };
  491. /** Used for a few events about overlays */
  492. struct VREvent_Status_t
  493. {
  494. uint32_t statusState; // EVRState enum
  495. };
  496. /** Used for keyboard events **/
  497. struct VREvent_Keyboard_t
  498. {
  499. char cNewInput[8]; // Up to 11 bytes of new input
  500. uint64_t uUserValue; // Possible flags about the new input
  501. };
  502. struct VREvent_Ipd_t
  503. {
  504. float ipdMeters;
  505. };
  506. struct VREvent_Chaperone_t
  507. {
  508. uint64_t m_nPreviousUniverse;
  509. uint64_t m_nCurrentUniverse;
  510. };
  511. /** Not actually used for any events */
  512. struct VREvent_Reserved_t
  513. {
  514. uint64_t reserved0;
  515. uint64_t reserved1;
  516. };
  517. struct VREvent_PerformanceTest_t
  518. {
  519. uint32_t m_nFidelityLevel;
  520. };
  521. struct VREvent_SeatedZeroPoseReset_t
  522. {
  523. bool bResetBySystemMenu;
  524. };
  525. struct VREvent_Screenshot_t
  526. {
  527. uint32_t handle;
  528. uint32_t type;
  529. };
  530. /** If you change this you must manually update openvr_interop.cs.py */
  531. typedef union
  532. {
  533. VREvent_Reserved_t reserved;
  534. VREvent_Controller_t controller;
  535. VREvent_Mouse_t mouse;
  536. VREvent_Scroll_t scroll;
  537. VREvent_Process_t process;
  538. VREvent_Notification_t notification;
  539. VREvent_Overlay_t overlay;
  540. VREvent_Status_t status;
  541. VREvent_Keyboard_t keyboard;
  542. VREvent_Ipd_t ipd;
  543. VREvent_Chaperone_t chaperone;
  544. VREvent_PerformanceTest_t performanceTest;
  545. VREvent_TouchPadMove_t touchPadMove;
  546. VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
  547. VREvent_Screenshot_t screenshot;
  548. } VREvent_Data_t;
  549. /** An event posted by the server to all running applications */
  550. struct VREvent_t
  551. {
  552. uint32_t eventType; // EVREventType enum
  553. TrackedDeviceIndex_t trackedDeviceIndex;
  554. float eventAgeSeconds;
  555. // event data must be the end of the struct as its size is variable
  556. VREvent_Data_t data;
  557. };
  558. /** The mesh to draw into the stencil (or depth) buffer to perform
  559. * early stencil (or depth) kills of pixels that will never appear on the HMD.
  560. * This mesh draws on all the pixels that will be hidden after distortion.
  561. *
  562. * If the HMD does not provide a visible area mesh pVertexData will be
  563. * NULL and unTriangleCount will be 0. */
  564. struct HiddenAreaMesh_t
  565. {
  566. const HmdVector2_t *pVertexData;
  567. uint32_t unTriangleCount;
  568. };
  569. /** Identifies what kind of axis is on the controller at index n. Read this type
  570. * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
  571. */
  572. enum EVRControllerAxisType
  573. {
  574. k_eControllerAxis_None = 0,
  575. k_eControllerAxis_TrackPad = 1,
  576. k_eControllerAxis_Joystick = 2,
  577. k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
  578. };
  579. /** contains information about one axis on the controller */
  580. struct VRControllerAxis_t
  581. {
  582. 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.
  583. float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
  584. };
  585. /** the number of axes in the controller state */
  586. static const uint32_t k_unControllerStateAxisCount = 5;
  587. /** Holds all the state of a controller at one moment in time. */
  588. struct VRControllerState001_t
  589. {
  590. // If packet num matches that on your prior call, then the controller state hasn't been changed since
  591. // your last call and there is no need to process it
  592. uint32_t unPacketNum;
  593. // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
  594. uint64_t ulButtonPressed;
  595. uint64_t ulButtonTouched;
  596. // Axis data for the controller's analog inputs
  597. VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
  598. };
  599. typedef VRControllerState001_t VRControllerState_t;
  600. /** determines how to provide output to the application of various event processing functions. */
  601. enum EVRControllerEventOutputType
  602. {
  603. ControllerEventOutput_OSEvents = 0,
  604. ControllerEventOutput_VREvents = 1,
  605. };
  606. /** Collision Bounds Style */
  607. enum ECollisionBoundsStyle
  608. {
  609. COLLISION_BOUNDS_STYLE_BEGINNER = 0,
  610. COLLISION_BOUNDS_STYLE_INTERMEDIATE,
  611. COLLISION_BOUNDS_STYLE_SQUARES,
  612. COLLISION_BOUNDS_STYLE_ADVANCED,
  613. COLLISION_BOUNDS_STYLE_NONE,
  614. COLLISION_BOUNDS_STYLE_COUNT
  615. };
  616. /** Allows the application to customize how the overlay appears in the compositor */
  617. struct Compositor_OverlaySettings
  618. {
  619. uint32_t size; // sizeof(Compositor_OverlaySettings)
  620. bool curved, antialias;
  621. float scale, distance, alpha;
  622. float uOffset, vOffset, uScale, vScale;
  623. float gridDivs, gridWidth, gridScale;
  624. HmdMatrix44_t transform;
  625. };
  626. /** used to refer to a single VR overlay */
  627. typedef uint64_t VROverlayHandle_t;
  628. static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
  629. /** Errors that can occur around VR overlays */
  630. enum EVROverlayError
  631. {
  632. VROverlayError_None = 0,
  633. VROverlayError_UnknownOverlay = 10,
  634. VROverlayError_InvalidHandle = 11,
  635. VROverlayError_PermissionDenied = 12,
  636. VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
  637. VROverlayError_WrongVisibilityType = 14,
  638. VROverlayError_KeyTooLong = 15,
  639. VROverlayError_NameTooLong = 16,
  640. VROverlayError_KeyInUse = 17,
  641. VROverlayError_WrongTransformType = 18,
  642. VROverlayError_InvalidTrackedDevice = 19,
  643. VROverlayError_InvalidParameter = 20,
  644. VROverlayError_ThumbnailCantBeDestroyed = 21,
  645. VROverlayError_ArrayTooSmall = 22,
  646. VROverlayError_RequestFailed = 23,
  647. VROverlayError_InvalidTexture = 24,
  648. VROverlayError_UnableToLoadFile = 25,
  649. VROVerlayError_KeyboardAlreadyInUse = 26,
  650. VROverlayError_NoNeighbor = 27,
  651. };
  652. /** enum values to pass in to VR_Init to identify whether the application will
  653. * draw a 3D scene. */
  654. enum EVRApplicationType
  655. {
  656. VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
  657. VRApplication_Scene = 1, // Application will submit 3D frames
  658. VRApplication_Overlay = 2, // Application only interacts with overlays
  659. VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
  660. // keep it running if everything else quits.
  661. VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
  662. // interfaces (like IVRSettings and IVRApplications) but not hardware.
  663. VRApplication_VRMonitor = 5, // Reserved for vrmonitor
  664. };
  665. /** error codes for firmware */
  666. enum EVRFirmwareError
  667. {
  668. VRFirmwareError_None = 0,
  669. VRFirmwareError_Success = 1,
  670. VRFirmwareError_Fail = 2,
  671. };
  672. /** error codes for notifications */
  673. enum EVRNotificationError
  674. {
  675. VRNotificationError_OK = 0,
  676. VRNotificationError_InvalidNotificationId = 100,
  677. VRNotificationError_NotificationQueueFull = 101,
  678. VRNotificationError_InvalidOverlayHandle = 102,
  679. VRNotificationError_SystemWithUserValueAlreadyExists = 103,
  680. };
  681. /** error codes returned by Vr_Init */
  682. // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
  683. enum EVRInitError
  684. {
  685. VRInitError_None = 0,
  686. VRInitError_Unknown = 1,
  687. VRInitError_Init_InstallationNotFound = 100,
  688. VRInitError_Init_InstallationCorrupt = 101,
  689. VRInitError_Init_VRClientDLLNotFound = 102,
  690. VRInitError_Init_FileNotFound = 103,
  691. VRInitError_Init_FactoryNotFound = 104,
  692. VRInitError_Init_InterfaceNotFound = 105,
  693. VRInitError_Init_InvalidInterface = 106,
  694. VRInitError_Init_UserConfigDirectoryInvalid = 107,
  695. VRInitError_Init_HmdNotFound = 108,
  696. VRInitError_Init_NotInitialized = 109,
  697. VRInitError_Init_PathRegistryNotFound = 110,
  698. VRInitError_Init_NoConfigPath = 111,
  699. VRInitError_Init_NoLogPath = 112,
  700. VRInitError_Init_PathRegistryNotWritable = 113,
  701. VRInitError_Init_AppInfoInitFailed = 114,
  702. VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
  703. VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
  704. VRInitError_Init_AnotherAppLaunching = 117,
  705. VRInitError_Init_SettingsInitFailed = 118,
  706. VRInitError_Init_ShuttingDown = 119,
  707. VRInitError_Init_TooManyObjects = 120,
  708. VRInitError_Init_NoServerForBackgroundApp = 121,
  709. VRInitError_Init_NotSupportedWithCompositor = 122,
  710. VRInitError_Init_NotAvailableToUtilityApps = 123,
  711. VRInitError_Init_Internal = 124,
  712. VRInitError_Driver_Failed = 200,
  713. VRInitError_Driver_Unknown = 201,
  714. VRInitError_Driver_HmdUnknown = 202,
  715. VRInitError_Driver_NotLoaded = 203,
  716. VRInitError_Driver_RuntimeOutOfDate = 204,
  717. VRInitError_Driver_HmdInUse = 205,
  718. VRInitError_Driver_NotCalibrated = 206,
  719. VRInitError_Driver_CalibrationInvalid = 207,
  720. VRInitError_Driver_HmdDisplayNotFound = 208,
  721. VRInitError_IPC_ServerInitFailed = 300,
  722. VRInitError_IPC_ConnectFailed = 301,
  723. VRInitError_IPC_SharedStateInitFailed = 302,
  724. VRInitError_IPC_CompositorInitFailed = 303,
  725. VRInitError_IPC_MutexInitFailed = 304,
  726. VRInitError_IPC_Failed = 305,
  727. VRInitError_Compositor_Failed = 400,
  728. VRInitError_Compositor_D3D11HardwareRequired = 401,
  729. VRInitError_Compositor_FirmwareRequiresUpdate = 402,
  730. VRInitError_Compositor_OverlayInitFailed = 403,
  731. VRInitError_Compositor_ScreenshotsInitFailed = 404,
  732. VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
  733. VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
  734. VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
  735. VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
  736. VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
  737. VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
  738. VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
  739. VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
  740. VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
  741. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
  742. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
  743. VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
  744. VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
  745. VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
  746. VRInitError_Steam_SteamInstallationNotFound = 2000,
  747. };
  748. enum EVRScreenshotType
  749. {
  750. VRScreenshotType_None = 0,
  751. VRScreenshotType_Mono = 1, // left eye only
  752. VRScreenshotType_Stereo = 2,
  753. VRScreenshotType_Cubemap = 3,
  754. VRScreenshotType_MonoPanorama = 4,
  755. VRScreenshotType_StereoPanorama = 5
  756. };
  757. enum EVRScreenshotPropertyFilenames
  758. {
  759. VRScreenshotPropertyFilenames_Preview = 0,
  760. VRScreenshotPropertyFilenames_VR = 1,
  761. };
  762. enum EVRTrackedCameraError
  763. {
  764. VRTrackedCameraError_None = 0,
  765. VRTrackedCameraError_OperationFailed = 100,
  766. VRTrackedCameraError_InvalidHandle = 101,
  767. VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
  768. VRTrackedCameraError_OutOfHandles = 103,
  769. VRTrackedCameraError_IPCFailure = 104,
  770. VRTrackedCameraError_NotSupportedForThisDevice = 105,
  771. VRTrackedCameraError_SharedMemoryFailure = 106,
  772. VRTrackedCameraError_FrameBufferingFailure = 107,
  773. VRTrackedCameraError_StreamSetupFailure = 108,
  774. VRTrackedCameraError_InvalidGLTextureId = 109,
  775. VRTrackedCameraError_InvalidSharedTextureHandle = 110,
  776. VRTrackedCameraError_FailedToGetGLTextureId = 111,
  777. VRTrackedCameraError_SharedTextureFailure = 112,
  778. VRTrackedCameraError_NoFrameAvailable = 113,
  779. VRTrackedCameraError_InvalidArgument = 114,
  780. VRTrackedCameraError_InvalidFrameBufferSize = 115,
  781. };
  782. enum EVRTrackedCameraFrameType
  783. {
  784. VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
  785. VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
  786. VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
  787. MAX_CAMERA_FRAME_TYPES
  788. };
  789. typedef uint64_t TrackedCameraHandle_t;
  790. #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
  791. struct CameraVideoStreamFrameHeader_t
  792. {
  793. EVRTrackedCameraFrameType eFrameType;
  794. uint32_t nWidth;
  795. uint32_t nHeight;
  796. uint32_t nBytesPerPixel;
  797. uint32_t nFrameSequence;
  798. TrackedDevicePose_t standingTrackedDevicePose;
  799. };
  800. // Screenshot types
  801. typedef uint32_t ScreenshotHandle_t;
  802. static const uint32_t k_unScreenshotHandleInvalid = 0;
  803. #pragma pack( pop )
  804. // figure out how to import from the VR API dll
  805. #if defined(_WIN32)
  806. #ifdef VR_API_EXPORT
  807. #define VR_INTERFACE extern "C" __declspec( dllexport )
  808. #else
  809. #define VR_INTERFACE extern "C" __declspec( dllimport )
  810. #endif
  811. #elif defined(GNUC) || defined(COMPILER_GCC) || defined(__APPLE__)
  812. #ifdef VR_API_EXPORT
  813. #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
  814. #else
  815. #define VR_INTERFACE extern "C"
  816. #endif
  817. #else
  818. #error "Unsupported Platform."
  819. #endif
  820. #if defined( _WIN32 )
  821. #define VR_CALLTYPE __cdecl
  822. #else
  823. #define VR_CALLTYPE
  824. #endif
  825. } // namespace vr
  826. #endif // _INCLUDE_VRTYPES_H
  827. // vrtrackedcameratypes.h
  828. #ifndef _VRTRACKEDCAMERATYPES_H
  829. #define _VRTRACKEDCAMERATYPES_H
  830. namespace vr
  831. {
  832. #if defined(__linux__) || defined(__APPLE__)
  833. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  834. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  835. // The 64-bit version of gcc has the alignment requirement for these types set to
  836. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  837. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  838. #pragma pack( push, 4 )
  839. #else
  840. #pragma pack( push, 8 )
  841. #endif
  842. enum ECameraVideoStreamFormat
  843. {
  844. CVS_FORMAT_UNKNOWN = 0,
  845. CVS_FORMAT_RAW10 = 1, // 10 bits per pixel
  846. CVS_FORMAT_NV12 = 2, // 12 bits per pixel
  847. CVS_FORMAT_RGB24 = 3, // 24 bits per pixel
  848. CVS_MAX_FORMATS
  849. };
  850. enum ECameraCompatibilityMode
  851. {
  852. CAMERA_COMPAT_MODE_BULK_DEFAULT = 0,
  853. CAMERA_COMPAT_MODE_BULK_64K_DMA,
  854. CAMERA_COMPAT_MODE_BULK_16K_DMA,
  855. CAMERA_COMPAT_MODE_BULK_8K_DMA,
  856. CAMERA_COMPAT_MODE_ISO_52FPS,
  857. CAMERA_COMPAT_MODE_ISO_50FPS,
  858. CAMERA_COMPAT_MODE_ISO_48FPS,
  859. CAMERA_COMPAT_MODE_ISO_46FPS,
  860. CAMERA_COMPAT_MODE_ISO_44FPS,
  861. CAMERA_COMPAT_MODE_ISO_42FPS,
  862. CAMERA_COMPAT_MODE_ISO_40FPS,
  863. CAMERA_COMPAT_MODE_ISO_35FPS,
  864. CAMERA_COMPAT_MODE_ISO_30FPS,
  865. MAX_CAMERA_COMPAT_MODES
  866. };
  867. #ifdef _MSC_VER
  868. #define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) )
  869. #else
  870. #define VR_CAMERA_DECL_ALIGN( x ) //
  871. #endif
  872. #define MAX_CAMERA_FRAME_SHARED_HANDLES 4
  873. VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t
  874. {
  875. ECameraVideoStreamFormat m_nStreamFormat;
  876. uint32_t m_nWidth;
  877. uint32_t m_nHeight;
  878. uint32_t m_nImageDataSize; // Based on stream format, width, height
  879. uint32_t m_nFrameSequence; // Starts from 0 when stream starts.
  880. uint32_t m_nBufferIndex; // Identifies which buffer the image data is hosted
  881. uint32_t m_nBufferCount; // Total number of configured buffers
  882. uint32_t m_nExposureTime;
  883. uint32_t m_nISPFrameTimeStamp; // Driver provided time stamp per driver centric time base
  884. uint32_t m_nISPReferenceTimeStamp;
  885. uint32_t m_nSyncCounter;
  886. uint32_t m_nCamSyncEvents;
  887. uint32_t m_nISPSyncEvents;
  888. double m_flReferenceCamSyncTime;
  889. double m_flFrameElapsedTime; // Starts from 0 when stream starts. In seconds.
  890. double m_flFrameDeliveryRate;
  891. double m_flFrameCaptureTime_DriverAbsolute; // In USB time, via AuxEvent
  892. double m_flFrameCaptureTime_ServerRelative; // In System time within the server
  893. uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks within the server
  894. double m_flFrameCaptureTime_ClientRelative; // At the client, relative to when the frame was exposed/captured.
  895. double m_flSyncMarkerError;
  896. TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by HMD layer when used as a tracked camera
  897. uint64_t m_pImageData;
  898. };
  899. #pragma pack( pop )
  900. }
  901. #endif // _VRTRACKEDCAMERATYPES_H
  902. // ivrsettings.h
  903. namespace vr
  904. {
  905. enum EVRSettingsError
  906. {
  907. VRSettingsError_None = 0,
  908. VRSettingsError_IPCFailed = 1,
  909. VRSettingsError_WriteFailed = 2,
  910. VRSettingsError_ReadFailed = 3,
  911. };
  912. // The maximum length of a settings key
  913. static const uint32_t k_unMaxSettingsKeyLength = 128;
  914. class IVRSettings
  915. {
  916. public:
  917. virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
  918. // Returns true if file sync occurred (force or settings dirty)
  919. virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0;
  920. virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, bool bDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  921. virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
  922. virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  923. virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
  924. virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, float flDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  925. virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
  926. virtual void GetString( const char *pchSection, const char *pchSettingsKey, char *pchValue, uint32_t unValueLen, const char *pchDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  927. virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
  928. virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
  929. virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  930. };
  931. //-----------------------------------------------------------------------------
  932. static const char * const IVRSettings_Version = "IVRSettings_001";
  933. //-----------------------------------------------------------------------------
  934. // steamvr keys
  935. static const char * const k_pch_SteamVR_Section = "steamvr";
  936. static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
  937. static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
  938. static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
  939. static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
  940. static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
  941. static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion";
  942. static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
  943. static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
  944. static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
  945. static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
  946. static const char * const k_pch_SteamVR_IPD_Float = "ipd";
  947. static const char * const k_pch_SteamVR_Background_String = "background";
  948. static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
  949. static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
  950. static const char * const k_pch_SteamVR_Environment_String = "environment";
  951. static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
  952. static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
  953. static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
  954. static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
  955. static const char * const k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit";
  956. static const char * const k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout";
  957. static const char * const k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout";
  958. static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode";
  959. static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
  960. static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
  961. static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
  962. static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
  963. static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
  964. static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
  965. static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier";
  966. static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection";
  967. static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection";
  968. static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
  969. static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView";
  970. static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView";
  971. //-----------------------------------------------------------------------------
  972. // lighthouse keys
  973. static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
  974. static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
  975. static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
  976. static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
  977. static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
  978. static const char * const k_pch_Lighthouse_LighthouseName_String = "lighthousename";
  979. static const char * const k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees";
  980. static const char * const k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect";
  981. static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
  982. //-----------------------------------------------------------------------------
  983. // null keys
  984. static const char * const k_pch_Null_Section = "driver_null";
  985. static const char * const k_pch_Null_EnableNullDriver_Bool = "enable";
  986. static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
  987. static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
  988. static const char * const k_pch_Null_WindowX_Int32 = "windowX";
  989. static const char * const k_pch_Null_WindowY_Int32 = "windowY";
  990. static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
  991. static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
  992. static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
  993. static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
  994. static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
  995. static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
  996. //-----------------------------------------------------------------------------
  997. // user interface keys
  998. static const char * const k_pch_UserInterface_Section = "userinterface";
  999. static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
  1000. static const char * const k_pch_UserInterface_EnableScreenshots_Bool = "EnableScreenshots";
  1001. //-----------------------------------------------------------------------------
  1002. // notification keys
  1003. static const char * const k_pch_Notifications_Section = "notifications";
  1004. static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
  1005. //-----------------------------------------------------------------------------
  1006. // keyboard keys
  1007. static const char * const k_pch_Keyboard_Section = "keyboard";
  1008. static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
  1009. static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
  1010. static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
  1011. static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
  1012. static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
  1013. static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
  1014. static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
  1015. //-----------------------------------------------------------------------------
  1016. // perf keys
  1017. static const char * const k_pch_Perf_Section = "perfcheck";
  1018. static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
  1019. static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
  1020. static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
  1021. static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
  1022. static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
  1023. static const char * const k_pch_Perf_TestData_Float = "perfTestData";
  1024. //-----------------------------------------------------------------------------
  1025. // collision bounds keys
  1026. static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
  1027. static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
  1028. static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
  1029. static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
  1030. static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
  1031. static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
  1032. static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
  1033. static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
  1034. static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
  1035. static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
  1036. //-----------------------------------------------------------------------------
  1037. // camera keys
  1038. static const char * const k_pch_Camera_Section = "camera";
  1039. static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
  1040. static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
  1041. static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
  1042. static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
  1043. static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
  1044. static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
  1045. static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
  1046. static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
  1047. //-----------------------------------------------------------------------------
  1048. // audio keys
  1049. static const char * const k_pch_audio_Section = "audio";
  1050. static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
  1051. static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
  1052. static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
  1053. static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
  1054. static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
  1055. static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
  1056. //-----------------------------------------------------------------------------
  1057. // model skin keys
  1058. static const char * const k_pch_modelskin_Section = "modelskins";
  1059. } // namespace vr
  1060. // iservertrackeddevicedriver.h
  1061. namespace vr
  1062. {
  1063. struct DriverPoseQuaternion_t
  1064. {
  1065. double w, x, y, z;
  1066. };
  1067. struct DriverPose_t
  1068. {
  1069. /* Time offset of this pose, in seconds from the actual time of the pose,
  1070. * relative to the time of the PoseUpdated() call made by the driver.
  1071. */
  1072. double poseTimeOffset;
  1073. /* Generally, the pose maintained by a driver
  1074. * is in an inertial coordinate system different
  1075. * from the world system of x+ right, y+ up, z+ back.
  1076. * Also, the driver is not usually tracking the "head" position,
  1077. * but instead an internal IMU or another reference point in the HMD.
  1078. * The following two transforms transform positions and orientations
  1079. * to app world space from driver world space,
  1080. * and to HMD head space from driver local body space.
  1081. *
  1082. * We maintain the driver pose state in its internal coordinate system,
  1083. * so we can do the pose prediction math without having to
  1084. * use angular acceleration. A driver's angular acceleration is generally not measured,
  1085. * and is instead calculated from successive samples of angular velocity.
  1086. * This leads to a noisy angular acceleration values, which are also
  1087. * lagged due to the filtering required to reduce noise to an acceptable level.
  1088. */
  1089. vr::HmdQuaternion_t qWorldFromDriverRotation;
  1090. double vecWorldFromDriverTranslation[ 3 ];
  1091. vr::HmdQuaternion_t qDriverFromHeadRotation;
  1092. double vecDriverFromHeadTranslation[ 3 ];
  1093. /* State of driver pose, in meters and radians. */
  1094. /* Position of the driver tracking reference in driver world space
  1095. * +[0] (x) is right
  1096. * +[1] (y) is up
  1097. * -[2] (z) is forward
  1098. */
  1099. double vecPosition[ 3 ];
  1100. /* Velocity of the pose in meters/second */
  1101. double vecVelocity[ 3 ];
  1102. /* Acceleration of the pose in meters/second */
  1103. double vecAcceleration[ 3 ];
  1104. /* Orientation of the tracker, represented as a quaternion */
  1105. vr::HmdQuaternion_t qRotation;
  1106. /* Angular velocity of the pose in axis-angle
  1107. * representation. The direction is the angle of
  1108. * rotation and the magnitude is the angle around
  1109. * that axis in radians/second. */
  1110. double vecAngularVelocity[ 3 ];
  1111. /* Angular acceleration of the pose in axis-angle
  1112. * representation. The direction is the angle of
  1113. * rotation and the magnitude is the angle around
  1114. * that axis in radians/second^2. */
  1115. double vecAngularAcceleration[ 3 ];
  1116. ETrackingResult result;
  1117. bool poseIsValid;
  1118. bool willDriftInYaw;
  1119. bool shouldApplyHeadModel;
  1120. bool deviceIsConnected;
  1121. };
  1122. // ----------------------------------------------------------------------------------------------
  1123. // Purpose: Represents a single tracked device in a driver
  1124. // ----------------------------------------------------------------------------------------------
  1125. class ITrackedDeviceServerDriver
  1126. {
  1127. public:
  1128. // ------------------------------------
  1129. // Management Methods
  1130. // ------------------------------------
  1131. /** This is called before an HMD is returned to the application. It will always be
  1132. * called before any display or tracking methods. Memory and processor use by the
  1133. * ITrackedDeviceServerDriver object should be kept to a minimum until it is activated.
  1134. * The pose listener is guaranteed to be valid until Deactivate is called, but
  1135. * should not be used after that point. */
  1136. virtual EVRInitError Activate( uint32_t unObjectId ) = 0;
  1137. /** This is called when The VR system is switching from this Hmd being the active display
  1138. * to another Hmd being the active display. The driver should clean whatever memory
  1139. * and thread use it can when it is deactivated */
  1140. virtual void Deactivate() = 0;
  1141. /** Handles a request from the system to power off this device */
  1142. virtual void PowerOff() = 0;
  1143. /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL
  1144. * if the requested interface or version is not supported. */
  1145. virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0;
  1146. /** A VR Client has made this debug request of the driver. The set of valid requests is entirely
  1147. * up to the driver and the client to figure out, as is the format of the response. Responses that
  1148. * exceed the length of the supplied buffer should be truncated and null terminated */
  1149. virtual void DebugRequest( const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
  1150. // ------------------------------------
  1151. // Tracking Methods
  1152. // ------------------------------------
  1153. virtual DriverPose_t GetPose() = 0;
  1154. // ------------------------------------
  1155. // Property Methods
  1156. // ------------------------------------
  1157. /** Returns a bool property. If the property is not available this function will return false. */
  1158. virtual bool GetBoolTrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0;
  1159. /** Returns a float property. If the property is not available this function will return 0. */
  1160. virtual float GetFloatTrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0;
  1161. /** Returns an int property. If the property is not available this function will return 0. */
  1162. virtual int32_t GetInt32TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0;
  1163. /** Returns a uint64 property. If the property is not available this function will return 0. */
  1164. virtual uint64_t GetUint64TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0;
  1165. /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */
  1166. virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( ETrackedDeviceProperty prop, ETrackedPropertyError *pError ) = 0;
  1167. /** Returns a string property. If the property is not available this function will return 0 and pError will be
  1168. * set to an error. Otherwise it returns the length of the number of bytes necessary to hold this string including
  1169. * the trailing null. If the buffer is too small the error will be TrackedProp_BufferTooSmall. Strings will
  1170. * generally fit in buffers of k_unTrackingStringSize characters. Drivers may not return strings longer than
  1171. * k_unMaxPropertyStringSize. */
  1172. virtual uint32_t GetStringTrackedDeviceProperty( ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError ) = 0;
  1173. };
  1174. static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_004";
  1175. }
  1176. // ivrdisplaycomponent.h
  1177. namespace vr
  1178. {
  1179. // ----------------------------------------------------------------------------------------------
  1180. // Purpose: The display component on a single tracked device
  1181. // ----------------------------------------------------------------------------------------------
  1182. class IVRDisplayComponent
  1183. {
  1184. public:
  1185. // ------------------------------------
  1186. // Display Methods
  1187. // ------------------------------------
  1188. /** Size and position that the window needs to be on the VR display. */
  1189. virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1190. /** Returns true if the display is extending the desktop. */
  1191. virtual bool IsDisplayOnDesktop( ) = 0;
  1192. /** Returns true if the display is real and not a fictional display. */
  1193. virtual bool IsDisplayRealDisplay( ) = 0;
  1194. /** Suggested size for the intermediate render target that the distortion pulls from. */
  1195. virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1196. /** Gets the viewport in the frame buffer to draw the output of the distortion into */
  1197. virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1198. /** The components necessary to build your own projection matrix in case your
  1199. * application is doing something fancy like infinite Z */
  1200. virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
  1201. /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
  1202. * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
  1203. virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0;
  1204. };
  1205. static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_002";
  1206. }
  1207. // ivrdriverdirectmodecomponent.h
  1208. namespace vr
  1209. {
  1210. // ----------------------------------------------------------------------------------------------
  1211. // Purpose: This component is used for drivers that implement direct mode entirely on their own
  1212. // without allowing the VR Compositor to own the window/device. Chances are you don't
  1213. // need to implement this component in your driver.
  1214. // ----------------------------------------------------------------------------------------------
  1215. class IVRDriverDirectModeComponent
  1216. {
  1217. public:
  1218. // -----------------------------------
  1219. // Direct mode methods
  1220. // -----------------------------------
  1221. /** Specific to Oculus compositor support, textures supplied must be created using this method. */
  1222. virtual void CreateSwapTextureSet( uint32_t unPid, uint32_t unFormat, uint32_t unWidth, uint32_t unHeight, void *(*pSharedTextureHandles)[3] ) {}
  1223. /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */
  1224. virtual void DestroySwapTextureSet( void *pSharedTextureHandle ) {}
  1225. /** Used to purge all texture sets for a given process. */
  1226. virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {}
  1227. /** After Present returns, calls this to get the next index to use for rendering. */
  1228. virtual void GetNextSwapTextureSetIndex( void *pSharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {}
  1229. /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created
  1230. * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */
  1231. virtual void SubmitLayer( void *pSharedTextureHandles[ 2 ], const vr::VRTextureBounds_t( &bounds )[ 2 ], const vr::HmdMatrix34_t *pPose ) {}
  1232. /** Submits queued layers for display. */
  1233. virtual void Present( void *hSyncTexture ) {}
  1234. };
  1235. static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_001";
  1236. }
  1237. // ivrcontrollercomponent.h
  1238. namespace vr
  1239. {
  1240. // ----------------------------------------------------------------------------------------------
  1241. // Purpose: Controller access on a single tracked device.
  1242. // ----------------------------------------------------------------------------------------------
  1243. class IVRControllerComponent
  1244. {
  1245. public:
  1246. // ------------------------------------
  1247. // Controller Methods
  1248. // ------------------------------------
  1249. /** Gets the current state of a controller. */
  1250. virtual VRControllerState_t GetControllerState( ) = 0;
  1251. /** Returns a uint64 property. If the property is not available this function will return 0. */
  1252. virtual bool TriggerHapticPulse( uint32_t unAxisId, uint16_t usPulseDurationMicroseconds ) = 0;
  1253. };
  1254. static const char *IVRControllerComponent_Version = "IVRControllerComponent_001";
  1255. }
  1256. // ivrcameracomponent.h
  1257. namespace vr
  1258. {
  1259. //-----------------------------------------------------------------------------
  1260. //-----------------------------------------------------------------------------
  1261. class ICameraVideoSinkCallback
  1262. {
  1263. public:
  1264. virtual void OnCameraVideoSinkCallback() = 0;
  1265. };
  1266. // ----------------------------------------------------------------------------------------------
  1267. // Purpose: The camera on a single tracked device
  1268. // ----------------------------------------------------------------------------------------------
  1269. class IVRCameraComponent
  1270. {
  1271. public:
  1272. // ------------------------------------
  1273. // Camera Methods
  1274. // ------------------------------------
  1275. virtual bool HasCamera() = 0;
  1276. virtual bool GetCameraFirmwareDescription( char *pBuffer, uint32_t nBufferLen ) = 0;
  1277. virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFormat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  1278. virtual bool GetCameraFrameBufferingRequirements( int *pDefaultFrameQueueSize, uint32_t *pFrameBufferDataSize ) = 0;
  1279. virtual bool SetCameraFrameBuffering( int nFrameBufferCount, void **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0;
  1280. virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamFormat nVideoStreamFormat ) = 0;
  1281. virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat() = 0;
  1282. virtual bool StartVideoStream() = 0;
  1283. virtual void StopVideoStream() = 0;
  1284. virtual bool IsVideoStreamActive() = 0;
  1285. virtual float GetVideoStreamElapsedTime() = 0;
  1286. virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame() = 0;
  1287. virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStreamFrame_t *pFrameImage ) = 0;
  1288. virtual bool SetAutoExposure( bool bEnable ) = 0;
  1289. virtual bool PauseVideoStream() = 0;
  1290. virtual bool ResumeVideoStream() = 0;
  1291. virtual bool IsVideoStreamPaused() = 0;
  1292. virtual bool GetCameraDistortion( float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0;
  1293. virtual bool GetCameraProjection( float flWidthPixels, float flHeightPixels, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
  1294. virtual bool GetRecommendedCameraUndistortion( uint32_t *pUndistortionWidthPixels, uint32_t *pUndistortionHeightPixels ) = 0;
  1295. virtual bool SetCameraUndistortion( uint32_t nUndistortionWidthPixels, uint32_t nUndistortionHeightPixels ) = 0;
  1296. virtual bool GetCameraFirmwareVersion( uint64_t *pFirmwareVersion ) = 0;
  1297. virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0;
  1298. virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0;
  1299. virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0;
  1300. virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0;
  1301. virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  1302. virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0;
  1303. };
  1304. static const char *IVRCameraComponent_Version = "IVRCameraComponent_001";
  1305. }
  1306. // itrackeddevicedriverprovider.h
  1307. namespace vr
  1308. {
  1309. class ITrackedDeviceServerDriver;
  1310. struct TrackedDeviceDriverInfo_t;
  1311. struct DriverPose_t;
  1312. class IDriverLog
  1313. {
  1314. public:
  1315. /** Writes a log message to the log file prefixed with the driver name */
  1316. virtual void Log( const char *pchLogMessage ) = 0;
  1317. };
  1318. /** This interface is provided by vrserver to allow the driver to notify
  1319. * the system when something changes about a device. These changes must
  1320. * not change the serial number or class of the device because those values
  1321. * are permanently associated with the device's index. */
  1322. class IServerDriverHost
  1323. {
  1324. public:
  1325. /** Notifies the server that a tracked device has been added. If this function returns true
  1326. * the server will call Activate on the device. If it returns false some kind of error
  1327. * has occurred and the device will not be activated. */
  1328. virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber ) = 0;
  1329. /** Notifies the server that a tracked device's pose has been updated */
  1330. virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose ) = 0;
  1331. /** Notifies the server that the property cache for the specified device should be invalidated */
  1332. virtual void TrackedDevicePropertiesChanged( uint32_t unWhichDevice ) = 0;
  1333. /** Notifies the server that vsync has occurred on the the display attached to the device. This is
  1334. * only permitted on devices of the HMD class. */
  1335. virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0;
  1336. /** notifies the server that the button was pressed */
  1337. virtual void TrackedDeviceButtonPressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1338. /** notifies the server that the button was unpressed */
  1339. virtual void TrackedDeviceButtonUnpressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1340. /** notifies the server that the button was pressed */
  1341. virtual void TrackedDeviceButtonTouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1342. /** notifies the server that the button was unpressed */
  1343. virtual void TrackedDeviceButtonUntouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1344. /** notifies the server than a controller axis changed */
  1345. virtual void TrackedDeviceAxisUpdated( uint32_t unWhichDevice, uint32_t unWhichAxis, const VRControllerAxis_t & axisState ) = 0;
  1346. /** Notifies the server that the MC image has been updated for the display attached to the device. This is
  1347. * only permitted on devices of the HMD class. */
  1348. virtual void MCImageUpdated() = 0;
  1349. /** always returns a pointer to a valid interface pointer of IVRSettings */
  1350. virtual IVRSettings *GetSettings( const char *pchInterfaceVersion ) = 0;
  1351. /** Notifies the server that the physical IPD adjustment has been moved on the HMD */
  1352. virtual void PhysicalIpdSet( uint32_t unWhichDevice, float fPhysicalIpdMeters ) = 0;
  1353. /** Notifies the server that the proximity sensor on the specified device */
  1354. virtual void ProximitySensorState( uint32_t unWhichDevice, bool bProximitySensorTriggered ) = 0;
  1355. /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */
  1356. virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0;
  1357. /** Returns true if SteamVR is exiting */
  1358. virtual bool IsExiting() = 0;
  1359. };
  1360. /** This interface must be implemented in each driver. It will be loaded in vrserver.exe */
  1361. class IServerTrackedDeviceProvider
  1362. {
  1363. public:
  1364. /** initializes the driver. This will be called before any other methods are called.
  1365. * If Init returns anything other than VRInitError_None the driver DLL will be unloaded.
  1366. *
  1367. * pDriverHost will never be NULL, and will always be a pointer to a IServerDriverHost interface
  1368. *
  1369. * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user
  1370. * config files.
  1371. * pchDriverInstallDir - The absolute path of the root directory for the driver.
  1372. */
  1373. virtual EVRInitError Init( IDriverLog *pDriverLog, vr::IServerDriverHost *pDriverHost, const char *pchUserDriverConfigDir, const char *pchDriverInstallDir ) = 0;
  1374. /** cleans up the driver right before it is unloaded */
  1375. virtual void Cleanup() = 0;
  1376. /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */
  1377. virtual const char * const *GetInterfaceVersions() = 0;
  1378. /** returns the number of HMDs that this driver manages that are physically connected. */
  1379. virtual uint32_t GetTrackedDeviceCount() = 0;
  1380. /** returns a single HMD */
  1381. virtual ITrackedDeviceServerDriver *GetTrackedDeviceDriver( uint32_t unWhich ) = 0;
  1382. /** returns a single HMD by ID */
  1383. virtual ITrackedDeviceServerDriver* FindTrackedDeviceDriver( const char *pchId ) = 0;
  1384. /** Allows the driver do to some work in the main loop of the server. */
  1385. virtual void RunFrame() = 0;
  1386. // ------------ Power State Functions ----------------------- //
  1387. /** Returns true if the driver wants to block Standby mode. */
  1388. virtual bool ShouldBlockStandbyMode() = 0;
  1389. /** Called when the system is entering Standby mode. The driver should switch itself into whatever sort of low-power
  1390. * state it has. */
  1391. virtual void EnterStandby() = 0;
  1392. /** Called when the system is leaving Standby mode. The driver should switch itself back to
  1393. full operation. */
  1394. virtual void LeaveStandby() = 0;
  1395. };
  1396. static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_003";
  1397. /** This interface is provided by vrclient to allow the driver call back and query various information */
  1398. class IClientDriverHost
  1399. {
  1400. public:
  1401. /** Returns the device class of a tracked device. If there has not been a device connected in this slot
  1402. * since the application started this function will return TrackedDevice_Invalid. For previous detected
  1403. * devices the function will return the previously observed device class.
  1404. *
  1405. * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check
  1406. * the device class. Every device with something other than TrackedDevice_Invalid is associated with an
  1407. * actual tracked device. */
  1408. virtual ETrackedDeviceClass GetTrackedDeviceClass( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1409. /** Returns true if there is a device connected in this slot. */
  1410. virtual bool IsTrackedDeviceConnected( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1411. /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */
  1412. virtual bool GetBoolTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1413. /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */
  1414. virtual float GetFloatTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1415. /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */
  1416. virtual int32_t GetInt32TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1417. /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */
  1418. virtual uint64_t GetUint64TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1419. /** Returns a string property. If the device index is not valid or the property is not a float type this function will
  1420. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  1421. * null. Strings will generally fit in buffers of k_unTrackingStringSize characters. */
  1422. virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0;
  1423. /** always returns a pointer to a valid interface pointer of IVRSettings */
  1424. virtual IVRSettings *GetSettings( const char *pchInterfaceVersion ) = 0;
  1425. };
  1426. /** This interface must be implemented in each driver. It will be loaded in vrclient.dll */
  1427. class IClientTrackedDeviceProvider
  1428. {
  1429. public:
  1430. /** initializes the driver. This will be called before any other methods are called,
  1431. * except BIsHmdPresent(). BIsHmdPresent is called outside of the Init/Cleanup pair.
  1432. * If Init returns anything other than VRInitError_None the driver DLL will be unloaded.
  1433. *
  1434. * pDriverHost will never be NULL, and will always be a pointer to a IClientDriverHost interface
  1435. *
  1436. * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user
  1437. * config files.
  1438. * pchDriverInstallDir - The absolute path of the root directory for the driver.
  1439. */
  1440. virtual EVRInitError Init( IDriverLog *pDriverLog, vr::IClientDriverHost *pDriverHost, const char *pchUserDriverConfigDir, const char *pchDriverInstallDir ) = 0;
  1441. /** cleans up the driver right before it is unloaded */
  1442. virtual void Cleanup() = 0;
  1443. /** Called when the client needs to inform an application if an HMD is attached that uses
  1444. * this driver. This method should be as lightweight as possible and should have no side effects
  1445. * such as hooking process functions or leaving resources loaded. Init will not be called before
  1446. * this method and Cleanup will not be called after it.
  1447. */
  1448. virtual bool BIsHmdPresent( const char *pchUserConfigDir ) = 0;
  1449. /** called when the client inits an HMD to let the client driver know which one is in use */
  1450. virtual EVRInitError SetDisplayId( const char *pchDisplayId ) = 0;
  1451. /** Returns the stencil mesh information for the current HMD. If this HMD does not have a stencil mesh the vertex data and count will be
  1452. * NULL and 0 respectively. This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering
  1453. * each eye's view. The pixels covered by this mesh will never be seen by the user after the lens distortion is applied and based on visibility to the panels.
  1454. * This will improve perf by letting the GPU early-reject pixels the user will never see before running the pixel shader.
  1455. * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye.
  1456. */
  1457. virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye ) = 0;
  1458. /** Get the MC image for the current HMD.
  1459. * Returns the size in bytes of the buffer required to hold the specified resource. */
  1460. virtual uint32_t GetMCImage( uint32_t *pImgWidth, uint32_t *pImgHeight, uint32_t *pChannels, void *pDataBuffer, uint32_t unBufferLen ) = 0;
  1461. };
  1462. static const char *IClientTrackedDeviceProvider_Version = "IClientTrackedDeviceProvider_003";
  1463. }
  1464. namespace vr
  1465. {
  1466. static const char * const k_InterfaceVersions[] =
  1467. {
  1468. IVRSettings_Version,
  1469. ITrackedDeviceServerDriver_Version,
  1470. IVRDisplayComponent_Version,
  1471. IVRDriverDirectModeComponent_Version,
  1472. IVRControllerComponent_Version,
  1473. IVRCameraComponent_Version,
  1474. IServerTrackedDeviceProvider_Version,
  1475. IClientTrackedDeviceProvider_Version,
  1476. nullptr
  1477. };
  1478. }
  1479. // End
  1480. #endif // _OPENVR_DRIVER_API