openvr_driver.h 70 KB

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