1
0

openvr_driver.h 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541
  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. // Forward declarations to avoid requiring vulkan.h
  12. struct VkDevice_T;
  13. struct VkPhysicalDevice_T;
  14. struct VkInstance_T;
  15. struct VkQueue_T;
  16. // Forward declarations to avoid requiring d3d12.h
  17. struct ID3D12Resource;
  18. struct ID3D12CommandQueue;
  19. namespace vr
  20. {
  21. #if defined(__linux__) || defined(__APPLE__)
  22. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  23. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  24. // The 64-bit version of gcc has the alignment requirement for these types set to
  25. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  26. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  27. #pragma pack( push, 4 )
  28. #else
  29. #pragma pack( push, 8 )
  30. #endif
  31. typedef void* glSharedTextureHandle_t;
  32. typedef int32_t glInt_t;
  33. typedef uint32_t glUInt_t;
  34. // right-handed system
  35. // +y is up
  36. // +x is to the right
  37. // -z is going away from you
  38. // Distance unit is meters
  39. struct HmdMatrix34_t
  40. {
  41. float m[3][4];
  42. };
  43. struct HmdMatrix44_t
  44. {
  45. float m[4][4];
  46. };
  47. struct HmdVector3_t
  48. {
  49. float v[3];
  50. };
  51. struct HmdVector4_t
  52. {
  53. float v[4];
  54. };
  55. struct HmdVector3d_t
  56. {
  57. double v[3];
  58. };
  59. struct HmdVector2_t
  60. {
  61. float v[2];
  62. };
  63. struct HmdQuaternion_t
  64. {
  65. double w, x, y, z;
  66. };
  67. struct HmdColor_t
  68. {
  69. float r, g, b, a;
  70. };
  71. struct HmdQuad_t
  72. {
  73. HmdVector3_t vCorners[ 4 ];
  74. };
  75. struct HmdRect2_t
  76. {
  77. HmdVector2_t vTopLeft;
  78. HmdVector2_t vBottomRight;
  79. };
  80. /** Used to return the post-distortion UVs for each color channel.
  81. * UVs range from 0 to 1 with 0,0 in the upper left corner of the
  82. * source render target. The 0,0 to 1,1 range covers a single eye. */
  83. struct DistortionCoordinates_t
  84. {
  85. float rfRed[2];
  86. float rfGreen[2];
  87. float rfBlue[2];
  88. };
  89. enum EVREye
  90. {
  91. Eye_Left = 0,
  92. Eye_Right = 1
  93. };
  94. enum ETextureType
  95. {
  96. TextureType_DirectX = 0, // Handle is an ID3D11Texture
  97. TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags
  98. TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure
  99. TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurface
  100. TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure
  101. };
  102. enum EColorSpace
  103. {
  104. ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
  105. ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
  106. ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
  107. };
  108. struct Texture_t
  109. {
  110. void* handle; // See ETextureType definition above
  111. ETextureType eType;
  112. EColorSpace eColorSpace;
  113. };
  114. // Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource).
  115. typedef uint64_t SharedTextureHandle_t;
  116. #define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0)
  117. enum ETrackingResult
  118. {
  119. TrackingResult_Uninitialized = 1,
  120. TrackingResult_Calibrating_InProgress = 100,
  121. TrackingResult_Calibrating_OutOfRange = 101,
  122. TrackingResult_Running_OK = 200,
  123. TrackingResult_Running_OutOfRange = 201,
  124. };
  125. static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
  126. /** Used to pass device IDs to API calls */
  127. typedef uint32_t TrackedDeviceIndex_t;
  128. static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
  129. static const uint32_t k_unMaxTrackedDeviceCount = 16;
  130. static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
  131. static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
  132. /** Describes what kind of object is being tracked at a given ID */
  133. enum ETrackedDeviceClass
  134. {
  135. TrackedDeviceClass_Invalid = 0, // the ID was not valid.
  136. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
  137. TrackedDeviceClass_Controller = 2, // Tracked controllers
  138. TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers
  139. TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
  140. };
  141. /** Describes what specific role associated with a tracked device */
  142. enum ETrackedControllerRole
  143. {
  144. TrackedControllerRole_Invalid = 0, // Invalid value for controller type
  145. TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
  146. TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
  147. };
  148. /** describes a single pose for a tracked object */
  149. struct TrackedDevicePose_t
  150. {
  151. HmdMatrix34_t mDeviceToAbsoluteTracking;
  152. HmdVector3_t vVelocity; // velocity in tracker space in m/s
  153. HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
  154. ETrackingResult eTrackingResult;
  155. bool bPoseIsValid;
  156. // This indicates that there is a device connected for this spot in the pose array.
  157. // It could go from true to false if the user unplugs the device.
  158. bool bDeviceIsConnected;
  159. };
  160. /** Identifies which style of tracking origin the application wants to use
  161. * for the poses it is requesting */
  162. enum ETrackingUniverseOrigin
  163. {
  164. TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
  165. TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
  166. TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one.
  167. };
  168. // Refers to a single container of properties
  169. typedef uint64_t PropertyContainerHandle_t;
  170. typedef uint32_t PropertyTypeTag_t;
  171. static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0;
  172. static const PropertyTypeTag_t k_unInvalidPropertyTag = 0;
  173. // Use these tags to set/get common types as struct properties
  174. static const PropertyTypeTag_t k_unFloatPropertyTag = 1;
  175. static const PropertyTypeTag_t k_unInt32PropertyTag = 2;
  176. static const PropertyTypeTag_t k_unUint64PropertyTag = 3;
  177. static const PropertyTypeTag_t k_unBoolPropertyTag = 4;
  178. static const PropertyTypeTag_t k_unStringPropertyTag = 5;
  179. static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20;
  180. static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21;
  181. static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22;
  182. static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23;
  183. static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30;
  184. static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000;
  185. static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000;
  186. /** Each entry in this enum represents a property that can be retrieved about a
  187. * tracked device. Many fields are only valid for one ETrackedDeviceClass. */
  188. enum ETrackedDeviceProperty
  189. {
  190. Prop_Invalid = 0,
  191. // general properties that apply to all device classes
  192. Prop_TrackingSystemName_String = 1000,
  193. Prop_ModelNumber_String = 1001,
  194. Prop_SerialNumber_String = 1002,
  195. Prop_RenderModelName_String = 1003,
  196. Prop_WillDriftInYaw_Bool = 1004,
  197. Prop_ManufacturerName_String = 1005,
  198. Prop_TrackingFirmwareVersion_String = 1006,
  199. Prop_HardwareRevision_String = 1007,
  200. Prop_AllWirelessDongleDescriptions_String = 1008,
  201. Prop_ConnectedWirelessDongle_String = 1009,
  202. Prop_DeviceIsWireless_Bool = 1010,
  203. Prop_DeviceIsCharging_Bool = 1011,
  204. Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
  205. Prop_StatusDisplayTransform_Matrix34 = 1013,
  206. Prop_Firmware_UpdateAvailable_Bool = 1014,
  207. Prop_Firmware_ManualUpdate_Bool = 1015,
  208. Prop_Firmware_ManualUpdateURL_String = 1016,
  209. Prop_HardwareRevision_Uint64 = 1017,
  210. Prop_FirmwareVersion_Uint64 = 1018,
  211. Prop_FPGAVersion_Uint64 = 1019,
  212. Prop_VRCVersion_Uint64 = 1020,
  213. Prop_RadioVersion_Uint64 = 1021,
  214. Prop_DongleVersion_Uint64 = 1022,
  215. Prop_BlockServerShutdown_Bool = 1023,
  216. Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
  217. Prop_ContainsProximitySensor_Bool = 1025,
  218. Prop_DeviceProvidesBatteryStatus_Bool = 1026,
  219. Prop_DeviceCanPowerOff_Bool = 1027,
  220. Prop_Firmware_ProgrammingTarget_String = 1028,
  221. Prop_DeviceClass_Int32 = 1029,
  222. Prop_HasCamera_Bool = 1030,
  223. Prop_DriverVersion_String = 1031,
  224. Prop_Firmware_ForceUpdateRequired_Bool = 1032,
  225. Prop_ViveSystemButtonFixRequired_Bool = 1033,
  226. Prop_ParentDriver_Uint64 = 1034,
  227. // Properties that are unique to TrackedDeviceClass_HMD
  228. Prop_ReportsTimeSinceVSync_Bool = 2000,
  229. Prop_SecondsFromVsyncToPhotons_Float = 2001,
  230. Prop_DisplayFrequency_Float = 2002,
  231. Prop_UserIpdMeters_Float = 2003,
  232. Prop_CurrentUniverseId_Uint64 = 2004,
  233. Prop_PreviousUniverseId_Uint64 = 2005,
  234. Prop_DisplayFirmwareVersion_Uint64 = 2006,
  235. Prop_IsOnDesktop_Bool = 2007,
  236. Prop_DisplayMCType_Int32 = 2008,
  237. Prop_DisplayMCOffset_Float = 2009,
  238. Prop_DisplayMCScale_Float = 2010,
  239. Prop_EdidVendorID_Int32 = 2011,
  240. Prop_DisplayMCImageLeft_String = 2012,
  241. Prop_DisplayMCImageRight_String = 2013,
  242. Prop_DisplayGCBlackClamp_Float = 2014,
  243. Prop_EdidProductID_Int32 = 2015,
  244. Prop_CameraToHeadTransform_Matrix34 = 2016,
  245. Prop_DisplayGCType_Int32 = 2017,
  246. Prop_DisplayGCOffset_Float = 2018,
  247. Prop_DisplayGCScale_Float = 2019,
  248. Prop_DisplayGCPrescale_Float = 2020,
  249. Prop_DisplayGCImage_String = 2021,
  250. Prop_LensCenterLeftU_Float = 2022,
  251. Prop_LensCenterLeftV_Float = 2023,
  252. Prop_LensCenterRightU_Float = 2024,
  253. Prop_LensCenterRightV_Float = 2025,
  254. Prop_UserHeadToEyeDepthMeters_Float = 2026,
  255. Prop_CameraFirmwareVersion_Uint64 = 2027,
  256. Prop_CameraFirmwareDescription_String = 2028,
  257. Prop_DisplayFPGAVersion_Uint64 = 2029,
  258. Prop_DisplayBootloaderVersion_Uint64 = 2030,
  259. Prop_DisplayHardwareVersion_Uint64 = 2031,
  260. Prop_AudioFirmwareVersion_Uint64 = 2032,
  261. Prop_CameraCompatibilityMode_Int32 = 2033,
  262. Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
  263. Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
  264. Prop_DisplaySuppressed_Bool = 2036,
  265. Prop_DisplayAllowNightMode_Bool = 2037,
  266. Prop_DisplayMCImageWidth_Int32 = 2038,
  267. Prop_DisplayMCImageHeight_Int32 = 2039,
  268. Prop_DisplayMCImageNumChannels_Int32 = 2040,
  269. Prop_DisplayMCImageData_Binary = 2041,
  270. Prop_UsesDriverDirectMode_Bool = 2042,
  271. // Properties that are unique to TrackedDeviceClass_Controller
  272. Prop_AttachedDeviceId_String = 3000,
  273. Prop_SupportedButtons_Uint64 = 3001,
  274. Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
  275. Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
  276. Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
  277. Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
  278. Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
  279. Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole
  280. // Properties that are unique to TrackedDeviceClass_TrackingReference
  281. Prop_FieldOfViewLeftDegrees_Float = 4000,
  282. Prop_FieldOfViewRightDegrees_Float = 4001,
  283. Prop_FieldOfViewTopDegrees_Float = 4002,
  284. Prop_FieldOfViewBottomDegrees_Float = 4003,
  285. Prop_TrackingRangeMinimumMeters_Float = 4004,
  286. Prop_TrackingRangeMaximumMeters_Float = 4005,
  287. Prop_ModeLabel_String = 4006,
  288. // Properties that are used for user interface like icons names
  289. Prop_IconPathName_String = 5000, // usually a directory named "icons"
  290. Prop_NamedIconPathDeviceOff_String = 5001, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  291. Prop_NamedIconPathDeviceSearching_String = 5002, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  292. Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  293. Prop_NamedIconPathDeviceReady_String = 5004, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  294. Prop_NamedIconPathDeviceReadyAlert_String = 5005, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  295. Prop_NamedIconPathDeviceNotReady_String = 5006, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  296. Prop_NamedIconPathDeviceStandby_String = 5007, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  297. Prop_NamedIconPathDeviceAlertLow_String = 5008, // PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  298. // Properties that are used by helpers, but are opaque to applications
  299. Prop_DisplayHiddenArea_Binary_Start = 5100,
  300. Prop_DisplayHiddenArea_Binary_End = 5150,
  301. // Properties that are unique to drivers
  302. Prop_UserConfigPath_String = 6000,
  303. Prop_InstallPath_String = 6001,
  304. // Vendors are free to expose private debug data in this reserved region
  305. Prop_VendorSpecific_Reserved_Start = 10000,
  306. Prop_VendorSpecific_Reserved_End = 10999,
  307. };
  308. /** No string property will ever be longer than this length */
  309. static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
  310. /** Used to return errors that occur when reading properties. */
  311. enum ETrackedPropertyError
  312. {
  313. TrackedProp_Success = 0,
  314. TrackedProp_WrongDataType = 1,
  315. TrackedProp_WrongDeviceClass = 2,
  316. TrackedProp_BufferTooSmall = 3,
  317. TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever).
  318. TrackedProp_InvalidDevice = 5,
  319. TrackedProp_CouldNotContactServer = 6,
  320. TrackedProp_ValueNotProvidedByDevice = 7,
  321. TrackedProp_StringExceedsMaximumLength = 8,
  322. TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
  323. TrackedProp_PermissionDenied = 10,
  324. TrackedProp_InvalidOperation = 11,
  325. };
  326. /** Allows the application to control what part of the provided texture will be used in the
  327. * frame buffer. */
  328. struct VRTextureBounds_t
  329. {
  330. float uMin, vMin;
  331. float uMax, vMax;
  332. };
  333. /** Allows the application to control how scene textures are used by the compositor when calling Submit. */
  334. enum EVRSubmitFlags
  335. {
  336. // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
  337. Submit_Default = 0x00,
  338. // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
  339. // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
  340. // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
  341. Submit_LensDistortionAlreadyApplied = 0x01,
  342. // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
  343. Submit_GlRenderBuffer = 0x02,
  344. // Do not use
  345. Submit_Reserved = 0x04,
  346. };
  347. /** Data required for passing Vulkan textures to IVRCompositor::Submit.
  348. * Be sure to call OpenVR_Shutdown before destroying these resources. */
  349. struct VRVulkanTextureData_t
  350. {
  351. uint64_t m_nImage; // VkImage
  352. VkDevice_T *m_pDevice;
  353. VkPhysicalDevice_T *m_pPhysicalDevice;
  354. VkInstance_T *m_pInstance;
  355. VkQueue_T *m_pQueue;
  356. uint32_t m_nQueueFamilyIndex;
  357. uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount;
  358. };
  359. /** Data required for passing D3D12 textures to IVRCompositor::Submit.
  360. * Be sure to call OpenVR_Shutdown before destroying these resources. */
  361. struct D3D12TextureData_t
  362. {
  363. ID3D12Resource *m_pResource;
  364. ID3D12CommandQueue *m_pCommandQueue;
  365. uint32_t m_nNodeMask;
  366. };
  367. /** Status of the overall system or tracked objects */
  368. enum EVRState
  369. {
  370. VRState_Undefined = -1,
  371. VRState_Off = 0,
  372. VRState_Searching = 1,
  373. VRState_Searching_Alert = 2,
  374. VRState_Ready = 3,
  375. VRState_Ready_Alert = 4,
  376. VRState_NotReady = 5,
  377. VRState_Standby = 6,
  378. VRState_Ready_Alert_Low = 7,
  379. };
  380. /** The types of events that could be posted (and what the parameters mean for each event type) */
  381. enum EVREventType
  382. {
  383. VREvent_None = 0,
  384. VREvent_TrackedDeviceActivated = 100,
  385. VREvent_TrackedDeviceDeactivated = 101,
  386. VREvent_TrackedDeviceUpdated = 102,
  387. VREvent_TrackedDeviceUserInteractionStarted = 103,
  388. VREvent_TrackedDeviceUserInteractionEnded = 104,
  389. VREvent_IpdChanged = 105,
  390. VREvent_EnterStandbyMode = 106,
  391. VREvent_LeaveStandbyMode = 107,
  392. VREvent_TrackedDeviceRoleChanged = 108,
  393. VREvent_WatchdogWakeUpRequested = 109,
  394. VREvent_LensDistortionChanged = 110,
  395. VREvent_PropertyChanged = 111,
  396. VREvent_ButtonPress = 200, // data is controller
  397. VREvent_ButtonUnpress = 201, // data is controller
  398. VREvent_ButtonTouch = 202, // data is controller
  399. VREvent_ButtonUntouch = 203, // data is controller
  400. VREvent_MouseMove = 300, // data is mouse
  401. VREvent_MouseButtonDown = 301, // data is mouse
  402. VREvent_MouseButtonUp = 302, // data is mouse
  403. VREvent_FocusEnter = 303, // data is overlay
  404. VREvent_FocusLeave = 304, // data is overlay
  405. VREvent_Scroll = 305, // data is mouse
  406. VREvent_TouchPadMove = 306, // data is mouse
  407. VREvent_OverlayFocusChanged = 307, // data is overlay, global event
  408. VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
  409. VREvent_InputFocusReleased = 401, // data is process DEPRECATED
  410. VREvent_SceneFocusLost = 402, // data is process
  411. VREvent_SceneFocusGained = 403, // data is process
  412. VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
  413. VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
  414. VREvent_InputFocusChanged = 406, // data is process
  415. VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process
  416. VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
  417. VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
  418. VREvent_OverlayShown = 500,
  419. VREvent_OverlayHidden = 501,
  420. VREvent_DashboardActivated = 502,
  421. VREvent_DashboardDeactivated = 503,
  422. VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
  423. VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
  424. VREvent_ResetDashboard = 506, // Send to the overlay manager
  425. VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
  426. VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
  427. VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
  428. VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
  429. VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
  430. VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
  431. VREvent_OverlaySharedTextureChanged = 513,
  432. VREvent_DashboardGuideButtonDown = 514,
  433. VREvent_DashboardGuideButtonUp = 515,
  434. VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
  435. VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
  436. VREvent_DashboardOverlayCreated = 518,
  437. // Screenshot API
  438. VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
  439. VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
  440. VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
  441. VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
  442. VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted
  443. VREvent_PrimaryDashboardDeviceChanged = 525,
  444. VREvent_Notification_Shown = 600,
  445. VREvent_Notification_Hidden = 601,
  446. VREvent_Notification_BeginInteraction = 602,
  447. VREvent_Notification_Destroyed = 603,
  448. VREvent_Quit = 700, // data is process
  449. VREvent_ProcessQuit = 701, // data is process
  450. VREvent_QuitAborted_UserPrompt = 702, // data is process
  451. VREvent_QuitAcknowledged = 703, // data is process
  452. VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
  453. VREvent_ChaperoneDataHasChanged = 800,
  454. VREvent_ChaperoneUniverseHasChanged = 801,
  455. VREvent_ChaperoneTempDataHasChanged = 802,
  456. VREvent_ChaperoneSettingsHaveChanged = 803,
  457. VREvent_SeatedZeroPoseReset = 804,
  458. VREvent_AudioSettingsHaveChanged = 820,
  459. VREvent_BackgroundSettingHasChanged = 850,
  460. VREvent_CameraSettingsHaveChanged = 851,
  461. VREvent_ReprojectionSettingHasChanged = 852,
  462. VREvent_ModelSkinSettingsHaveChanged = 853,
  463. VREvent_EnvironmentSettingsHaveChanged = 854,
  464. VREvent_PowerSettingsHaveChanged = 855,
  465. VREvent_StatusUpdate = 900,
  466. VREvent_MCImageUpdated = 1000,
  467. VREvent_FirmwareUpdateStarted = 1100,
  468. VREvent_FirmwareUpdateFinished = 1101,
  469. VREvent_KeyboardClosed = 1200,
  470. VREvent_KeyboardCharInput = 1201,
  471. VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
  472. VREvent_ApplicationTransitionStarted = 1300,
  473. VREvent_ApplicationTransitionAborted = 1301,
  474. VREvent_ApplicationTransitionNewAppStarted = 1302,
  475. VREvent_ApplicationListUpdated = 1303,
  476. VREvent_ApplicationMimeTypeLoad = 1304,
  477. VREvent_ApplicationTransitionNewAppLaunchComplete = 1305,
  478. VREvent_Compositor_MirrorWindowShown = 1400,
  479. VREvent_Compositor_MirrorWindowHidden = 1401,
  480. VREvent_Compositor_ChaperoneBoundsShown = 1410,
  481. VREvent_Compositor_ChaperoneBoundsHidden = 1411,
  482. VREvent_TrackedCamera_StartVideoStream = 1500,
  483. VREvent_TrackedCamera_StopVideoStream = 1501,
  484. VREvent_TrackedCamera_PauseVideoStream = 1502,
  485. VREvent_TrackedCamera_ResumeVideoStream = 1503,
  486. VREvent_TrackedCamera_EditingSurface = 1550,
  487. VREvent_PerformanceTest_EnableCapture = 1600,
  488. VREvent_PerformanceTest_DisableCapture = 1601,
  489. VREvent_PerformanceTest_FidelityLevel = 1602,
  490. VREvent_MessageOverlay_Closed = 1650,
  491. // Vendors are free to expose private events in this reserved region
  492. VREvent_VendorSpecific_Reserved_Start = 10000,
  493. VREvent_VendorSpecific_Reserved_End = 19999,
  494. };
  495. /** Level of Hmd activity */
  496. enum EDeviceActivityLevel
  497. {
  498. k_EDeviceActivityLevel_Unknown = -1,
  499. k_EDeviceActivityLevel_Idle = 0,
  500. k_EDeviceActivityLevel_UserInteraction = 1,
  501. k_EDeviceActivityLevel_UserInteraction_Timeout = 2,
  502. k_EDeviceActivityLevel_Standby = 3,
  503. };
  504. /** VR controller button and axis IDs */
  505. enum EVRButtonId
  506. {
  507. k_EButton_System = 0,
  508. k_EButton_ApplicationMenu = 1,
  509. k_EButton_Grip = 2,
  510. k_EButton_DPad_Left = 3,
  511. k_EButton_DPad_Up = 4,
  512. k_EButton_DPad_Right = 5,
  513. k_EButton_DPad_Down = 6,
  514. k_EButton_A = 7,
  515. k_EButton_ProximitySensor = 31,
  516. k_EButton_Axis0 = 32,
  517. k_EButton_Axis1 = 33,
  518. k_EButton_Axis2 = 34,
  519. k_EButton_Axis3 = 35,
  520. k_EButton_Axis4 = 36,
  521. // aliases for well known controllers
  522. k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
  523. k_EButton_SteamVR_Trigger = k_EButton_Axis1,
  524. k_EButton_Dashboard_Back = k_EButton_Grip,
  525. k_EButton_Max = 64
  526. };
  527. inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
  528. /** used for controller button events */
  529. struct VREvent_Controller_t
  530. {
  531. uint32_t button; // EVRButtonId enum
  532. };
  533. /** used for simulated mouse events in overlay space */
  534. enum EVRMouseButton
  535. {
  536. VRMouseButton_Left = 0x0001,
  537. VRMouseButton_Right = 0x0002,
  538. VRMouseButton_Middle = 0x0004,
  539. };
  540. /** used for simulated mouse events in overlay space */
  541. struct VREvent_Mouse_t
  542. {
  543. float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
  544. uint32_t button; // EVRMouseButton enum
  545. };
  546. /** used for simulated mouse wheel scroll in overlay space */
  547. struct VREvent_Scroll_t
  548. {
  549. float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
  550. uint32_t repeatCount;
  551. };
  552. /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
  553. is on the touchpad (or just released from it)
  554. **/
  555. struct VREvent_TouchPadMove_t
  556. {
  557. // true if the users finger is detected on the touch pad
  558. bool bFingerDown;
  559. // How long the finger has been down in seconds
  560. float flSecondsFingerDown;
  561. // These values indicate the starting finger position (so you can do some basic swipe stuff)
  562. float fValueXFirst;
  563. float fValueYFirst;
  564. // This is the raw sampled coordinate without deadzoning
  565. float fValueXRaw;
  566. float fValueYRaw;
  567. };
  568. /** notification related events. Details will still change at this point */
  569. struct VREvent_Notification_t
  570. {
  571. uint64_t ulUserValue;
  572. uint32_t notificationId;
  573. };
  574. /** Used for events about processes */
  575. struct VREvent_Process_t
  576. {
  577. uint32_t pid;
  578. uint32_t oldPid;
  579. bool bForced;
  580. };
  581. /** Used for a few events about overlays */
  582. struct VREvent_Overlay_t
  583. {
  584. uint64_t overlayHandle;
  585. };
  586. /** Used for a few events about overlays */
  587. struct VREvent_Status_t
  588. {
  589. uint32_t statusState; // EVRState enum
  590. };
  591. /** Used for keyboard events **/
  592. struct VREvent_Keyboard_t
  593. {
  594. char cNewInput[8]; // Up to 11 bytes of new input
  595. uint64_t uUserValue; // Possible flags about the new input
  596. };
  597. struct VREvent_Ipd_t
  598. {
  599. float ipdMeters;
  600. };
  601. struct VREvent_Chaperone_t
  602. {
  603. uint64_t m_nPreviousUniverse;
  604. uint64_t m_nCurrentUniverse;
  605. };
  606. /** Not actually used for any events */
  607. struct VREvent_Reserved_t
  608. {
  609. uint64_t reserved0;
  610. uint64_t reserved1;
  611. };
  612. struct VREvent_PerformanceTest_t
  613. {
  614. uint32_t m_nFidelityLevel;
  615. };
  616. struct VREvent_SeatedZeroPoseReset_t
  617. {
  618. bool bResetBySystemMenu;
  619. };
  620. struct VREvent_Screenshot_t
  621. {
  622. uint32_t handle;
  623. uint32_t type;
  624. };
  625. struct VREvent_ScreenshotProgress_t
  626. {
  627. float progress;
  628. };
  629. struct VREvent_ApplicationLaunch_t
  630. {
  631. uint32_t pid;
  632. uint32_t unArgsHandle;
  633. };
  634. struct VREvent_EditingCameraSurface_t
  635. {
  636. uint64_t overlayHandle;
  637. uint32_t nVisualMode;
  638. };
  639. struct VREvent_MessageOverlay_t
  640. {
  641. uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum
  642. };
  643. struct VREvent_Property_t
  644. {
  645. PropertyContainerHandle_t container;
  646. ETrackedDeviceProperty prop;
  647. };
  648. /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */
  649. typedef union
  650. {
  651. VREvent_Reserved_t reserved;
  652. VREvent_Controller_t controller;
  653. VREvent_Mouse_t mouse;
  654. VREvent_Scroll_t scroll;
  655. VREvent_Process_t process;
  656. VREvent_Notification_t notification;
  657. VREvent_Overlay_t overlay;
  658. VREvent_Status_t status;
  659. VREvent_Keyboard_t keyboard;
  660. VREvent_Ipd_t ipd;
  661. VREvent_Chaperone_t chaperone;
  662. VREvent_PerformanceTest_t performanceTest;
  663. VREvent_TouchPadMove_t touchPadMove;
  664. VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
  665. VREvent_Screenshot_t screenshot;
  666. VREvent_ScreenshotProgress_t screenshotProgress;
  667. VREvent_ApplicationLaunch_t applicationLaunch;
  668. VREvent_EditingCameraSurface_t cameraSurface;
  669. VREvent_MessageOverlay_t messageOverlay;
  670. VREvent_Property_t property;
  671. } VREvent_Data_t;
  672. /** An event posted by the server to all running applications */
  673. struct VREvent_t
  674. {
  675. uint32_t eventType; // EVREventType enum
  676. TrackedDeviceIndex_t trackedDeviceIndex;
  677. float eventAgeSeconds;
  678. // event data must be the end of the struct as its size is variable
  679. VREvent_Data_t data;
  680. };
  681. /** The mesh to draw into the stencil (or depth) buffer to perform
  682. * early stencil (or depth) kills of pixels that will never appear on the HMD.
  683. * This mesh draws on all the pixels that will be hidden after distortion.
  684. *
  685. * If the HMD does not provide a visible area mesh pVertexData will be
  686. * NULL and unTriangleCount will be 0. */
  687. struct HiddenAreaMesh_t
  688. {
  689. const HmdVector2_t *pVertexData;
  690. uint32_t unTriangleCount;
  691. };
  692. enum EHiddenAreaMeshType
  693. {
  694. k_eHiddenAreaMesh_Standard = 0,
  695. k_eHiddenAreaMesh_Inverse = 1,
  696. k_eHiddenAreaMesh_LineLoop = 2,
  697. k_eHiddenAreaMesh_Max = 3,
  698. };
  699. /** Identifies what kind of axis is on the controller at index n. Read this type
  700. * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
  701. */
  702. enum EVRControllerAxisType
  703. {
  704. k_eControllerAxis_None = 0,
  705. k_eControllerAxis_TrackPad = 1,
  706. k_eControllerAxis_Joystick = 2,
  707. k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
  708. };
  709. /** contains information about one axis on the controller */
  710. struct VRControllerAxis_t
  711. {
  712. 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.
  713. float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
  714. };
  715. /** the number of axes in the controller state */
  716. static const uint32_t k_unControllerStateAxisCount = 5;
  717. /** Holds all the state of a controller at one moment in time. */
  718. struct VRControllerState001_t
  719. {
  720. // If packet num matches that on your prior call, then the controller state hasn't been changed since
  721. // your last call and there is no need to process it
  722. uint32_t unPacketNum;
  723. // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
  724. uint64_t ulButtonPressed;
  725. uint64_t ulButtonTouched;
  726. // Axis data for the controller's analog inputs
  727. VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
  728. };
  729. typedef VRControllerState001_t VRControllerState_t;
  730. /** determines how to provide output to the application of various event processing functions. */
  731. enum EVRControllerEventOutputType
  732. {
  733. ControllerEventOutput_OSEvents = 0,
  734. ControllerEventOutput_VREvents = 1,
  735. };
  736. /** Collision Bounds Style */
  737. enum ECollisionBoundsStyle
  738. {
  739. COLLISION_BOUNDS_STYLE_BEGINNER = 0,
  740. COLLISION_BOUNDS_STYLE_INTERMEDIATE,
  741. COLLISION_BOUNDS_STYLE_SQUARES,
  742. COLLISION_BOUNDS_STYLE_ADVANCED,
  743. COLLISION_BOUNDS_STYLE_NONE,
  744. COLLISION_BOUNDS_STYLE_COUNT
  745. };
  746. /** Allows the application to customize how the overlay appears in the compositor */
  747. struct Compositor_OverlaySettings
  748. {
  749. uint32_t size; // sizeof(Compositor_OverlaySettings)
  750. bool curved, antialias;
  751. float scale, distance, alpha;
  752. float uOffset, vOffset, uScale, vScale;
  753. float gridDivs, gridWidth, gridScale;
  754. HmdMatrix44_t transform;
  755. };
  756. /** used to refer to a single VR overlay */
  757. typedef uint64_t VROverlayHandle_t;
  758. static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
  759. /** Errors that can occur around VR overlays */
  760. enum EVROverlayError
  761. {
  762. VROverlayError_None = 0,
  763. VROverlayError_UnknownOverlay = 10,
  764. VROverlayError_InvalidHandle = 11,
  765. VROverlayError_PermissionDenied = 12,
  766. VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
  767. VROverlayError_WrongVisibilityType = 14,
  768. VROverlayError_KeyTooLong = 15,
  769. VROverlayError_NameTooLong = 16,
  770. VROverlayError_KeyInUse = 17,
  771. VROverlayError_WrongTransformType = 18,
  772. VROverlayError_InvalidTrackedDevice = 19,
  773. VROverlayError_InvalidParameter = 20,
  774. VROverlayError_ThumbnailCantBeDestroyed = 21,
  775. VROverlayError_ArrayTooSmall = 22,
  776. VROverlayError_RequestFailed = 23,
  777. VROverlayError_InvalidTexture = 24,
  778. VROverlayError_UnableToLoadFile = 25,
  779. VROverlayError_KeyboardAlreadyInUse = 26,
  780. VROverlayError_NoNeighbor = 27,
  781. VROverlayError_TooManyMaskPrimitives = 29,
  782. VROverlayError_BadMaskPrimitive = 30,
  783. };
  784. /** enum values to pass in to VR_Init to identify whether the application will
  785. * draw a 3D scene. */
  786. enum EVRApplicationType
  787. {
  788. VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
  789. VRApplication_Scene = 1, // Application will submit 3D frames
  790. VRApplication_Overlay = 2, // Application only interacts with overlays
  791. VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
  792. // keep it running if everything else quits.
  793. VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
  794. // interfaces (like IVRSettings and IVRApplications) but not hardware.
  795. VRApplication_VRMonitor = 5, // Reserved for vrmonitor
  796. VRApplication_SteamWatchdog = 6,// Reserved for Steam
  797. VRApplication_Max
  798. };
  799. /** error codes for firmware */
  800. enum EVRFirmwareError
  801. {
  802. VRFirmwareError_None = 0,
  803. VRFirmwareError_Success = 1,
  804. VRFirmwareError_Fail = 2,
  805. };
  806. /** error codes for notifications */
  807. enum EVRNotificationError
  808. {
  809. VRNotificationError_OK = 0,
  810. VRNotificationError_InvalidNotificationId = 100,
  811. VRNotificationError_NotificationQueueFull = 101,
  812. VRNotificationError_InvalidOverlayHandle = 102,
  813. VRNotificationError_SystemWithUserValueAlreadyExists = 103,
  814. };
  815. /** error codes returned by Vr_Init */
  816. // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
  817. enum EVRInitError
  818. {
  819. VRInitError_None = 0,
  820. VRInitError_Unknown = 1,
  821. VRInitError_Init_InstallationNotFound = 100,
  822. VRInitError_Init_InstallationCorrupt = 101,
  823. VRInitError_Init_VRClientDLLNotFound = 102,
  824. VRInitError_Init_FileNotFound = 103,
  825. VRInitError_Init_FactoryNotFound = 104,
  826. VRInitError_Init_InterfaceNotFound = 105,
  827. VRInitError_Init_InvalidInterface = 106,
  828. VRInitError_Init_UserConfigDirectoryInvalid = 107,
  829. VRInitError_Init_HmdNotFound = 108,
  830. VRInitError_Init_NotInitialized = 109,
  831. VRInitError_Init_PathRegistryNotFound = 110,
  832. VRInitError_Init_NoConfigPath = 111,
  833. VRInitError_Init_NoLogPath = 112,
  834. VRInitError_Init_PathRegistryNotWritable = 113,
  835. VRInitError_Init_AppInfoInitFailed = 114,
  836. VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
  837. VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
  838. VRInitError_Init_AnotherAppLaunching = 117,
  839. VRInitError_Init_SettingsInitFailed = 118,
  840. VRInitError_Init_ShuttingDown = 119,
  841. VRInitError_Init_TooManyObjects = 120,
  842. VRInitError_Init_NoServerForBackgroundApp = 121,
  843. VRInitError_Init_NotSupportedWithCompositor = 122,
  844. VRInitError_Init_NotAvailableToUtilityApps = 123,
  845. VRInitError_Init_Internal = 124,
  846. VRInitError_Init_HmdDriverIdIsNone = 125,
  847. VRInitError_Init_HmdNotFoundPresenceFailed = 126,
  848. VRInitError_Init_VRMonitorNotFound = 127,
  849. VRInitError_Init_VRMonitorStartupFailed = 128,
  850. VRInitError_Init_LowPowerWatchdogNotSupported = 129,
  851. VRInitError_Init_InvalidApplicationType = 130,
  852. VRInitError_Init_NotAvailableToWatchdogApps = 131,
  853. VRInitError_Init_WatchdogDisabledInSettings = 132,
  854. VRInitError_Init_VRDashboardNotFound = 133,
  855. VRInitError_Init_VRDashboardStartupFailed = 134,
  856. VRInitError_Driver_Failed = 200,
  857. VRInitError_Driver_Unknown = 201,
  858. VRInitError_Driver_HmdUnknown = 202,
  859. VRInitError_Driver_NotLoaded = 203,
  860. VRInitError_Driver_RuntimeOutOfDate = 204,
  861. VRInitError_Driver_HmdInUse = 205,
  862. VRInitError_Driver_NotCalibrated = 206,
  863. VRInitError_Driver_CalibrationInvalid = 207,
  864. VRInitError_Driver_HmdDisplayNotFound = 208,
  865. VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209,
  866. // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons
  867. VRInitError_Driver_HmdDriverIdOutOfBounds = 211,
  868. VRInitError_Driver_HmdDisplayMirrored = 212,
  869. VRInitError_IPC_ServerInitFailed = 300,
  870. VRInitError_IPC_ConnectFailed = 301,
  871. VRInitError_IPC_SharedStateInitFailed = 302,
  872. VRInitError_IPC_CompositorInitFailed = 303,
  873. VRInitError_IPC_MutexInitFailed = 304,
  874. VRInitError_IPC_Failed = 305,
  875. VRInitError_IPC_CompositorConnectFailed = 306,
  876. VRInitError_IPC_CompositorInvalidConnectResponse = 307,
  877. VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308,
  878. VRInitError_Compositor_Failed = 400,
  879. VRInitError_Compositor_D3D11HardwareRequired = 401,
  880. VRInitError_Compositor_FirmwareRequiresUpdate = 402,
  881. VRInitError_Compositor_OverlayInitFailed = 403,
  882. VRInitError_Compositor_ScreenshotsInitFailed = 404,
  883. VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
  884. VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
  885. VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
  886. VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
  887. VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
  888. VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
  889. VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
  890. VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
  891. VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
  892. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
  893. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
  894. VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
  895. VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
  896. VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
  897. VRInitError_Steam_SteamInstallationNotFound = 2000,
  898. };
  899. enum EVRScreenshotType
  900. {
  901. VRScreenshotType_None = 0,
  902. VRScreenshotType_Mono = 1, // left eye only
  903. VRScreenshotType_Stereo = 2,
  904. VRScreenshotType_Cubemap = 3,
  905. VRScreenshotType_MonoPanorama = 4,
  906. VRScreenshotType_StereoPanorama = 5
  907. };
  908. enum EVRScreenshotPropertyFilenames
  909. {
  910. VRScreenshotPropertyFilenames_Preview = 0,
  911. VRScreenshotPropertyFilenames_VR = 1,
  912. };
  913. enum EVRTrackedCameraError
  914. {
  915. VRTrackedCameraError_None = 0,
  916. VRTrackedCameraError_OperationFailed = 100,
  917. VRTrackedCameraError_InvalidHandle = 101,
  918. VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
  919. VRTrackedCameraError_OutOfHandles = 103,
  920. VRTrackedCameraError_IPCFailure = 104,
  921. VRTrackedCameraError_NotSupportedForThisDevice = 105,
  922. VRTrackedCameraError_SharedMemoryFailure = 106,
  923. VRTrackedCameraError_FrameBufferingFailure = 107,
  924. VRTrackedCameraError_StreamSetupFailure = 108,
  925. VRTrackedCameraError_InvalidGLTextureId = 109,
  926. VRTrackedCameraError_InvalidSharedTextureHandle = 110,
  927. VRTrackedCameraError_FailedToGetGLTextureId = 111,
  928. VRTrackedCameraError_SharedTextureFailure = 112,
  929. VRTrackedCameraError_NoFrameAvailable = 113,
  930. VRTrackedCameraError_InvalidArgument = 114,
  931. VRTrackedCameraError_InvalidFrameBufferSize = 115,
  932. };
  933. enum EVRTrackedCameraFrameType
  934. {
  935. VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
  936. VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
  937. VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
  938. MAX_CAMERA_FRAME_TYPES
  939. };
  940. typedef uint64_t TrackedCameraHandle_t;
  941. #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
  942. struct CameraVideoStreamFrameHeader_t
  943. {
  944. EVRTrackedCameraFrameType eFrameType;
  945. uint32_t nWidth;
  946. uint32_t nHeight;
  947. uint32_t nBytesPerPixel;
  948. uint32_t nFrameSequence;
  949. TrackedDevicePose_t standingTrackedDevicePose;
  950. };
  951. // Screenshot types
  952. typedef uint32_t ScreenshotHandle_t;
  953. static const uint32_t k_unScreenshotHandleInvalid = 0;
  954. #pragma pack( pop )
  955. // figure out how to import from the VR API dll
  956. #if defined(_WIN32)
  957. #ifdef VR_API_EXPORT
  958. #define VR_INTERFACE extern "C" __declspec( dllexport )
  959. #else
  960. #define VR_INTERFACE extern "C" __declspec( dllimport )
  961. #endif
  962. #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
  963. #ifdef VR_API_EXPORT
  964. #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
  965. #else
  966. #define VR_INTERFACE extern "C"
  967. #endif
  968. #else
  969. #error "Unsupported Platform."
  970. #endif
  971. #if defined( _WIN32 )
  972. #define VR_CALLTYPE __cdecl
  973. #else
  974. #define VR_CALLTYPE
  975. #endif
  976. } // namespace vr
  977. #endif // _INCLUDE_VRTYPES_H
  978. // vrannotation.h
  979. #ifdef API_GEN
  980. # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
  981. #else
  982. # define VR_CLANG_ATTR(ATTR)
  983. #endif
  984. #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
  985. #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
  986. #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
  987. #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
  988. #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
  989. #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
  990. #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
  991. #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
  992. #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
  993. #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
  994. #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
  995. // vrtrackedcameratypes.h
  996. #ifndef _VRTRACKEDCAMERATYPES_H
  997. #define _VRTRACKEDCAMERATYPES_H
  998. namespace vr
  999. {
  1000. #if defined(__linux__) || defined(__APPLE__)
  1001. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  1002. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  1003. // The 64-bit version of gcc has the alignment requirement for these types set to
  1004. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  1005. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  1006. #pragma pack( push, 4 )
  1007. #else
  1008. #pragma pack( push, 8 )
  1009. #endif
  1010. enum ECameraVideoStreamFormat
  1011. {
  1012. CVS_FORMAT_UNKNOWN = 0,
  1013. CVS_FORMAT_RAW10 = 1, // 10 bits per pixel
  1014. CVS_FORMAT_NV12 = 2, // 12 bits per pixel
  1015. CVS_FORMAT_RGB24 = 3, // 24 bits per pixel
  1016. CVS_MAX_FORMATS
  1017. };
  1018. enum ECameraCompatibilityMode
  1019. {
  1020. CAMERA_COMPAT_MODE_BULK_DEFAULT = 0,
  1021. CAMERA_COMPAT_MODE_BULK_64K_DMA,
  1022. CAMERA_COMPAT_MODE_BULK_16K_DMA,
  1023. CAMERA_COMPAT_MODE_BULK_8K_DMA,
  1024. CAMERA_COMPAT_MODE_ISO_52FPS,
  1025. CAMERA_COMPAT_MODE_ISO_50FPS,
  1026. CAMERA_COMPAT_MODE_ISO_48FPS,
  1027. CAMERA_COMPAT_MODE_ISO_46FPS,
  1028. CAMERA_COMPAT_MODE_ISO_44FPS,
  1029. CAMERA_COMPAT_MODE_ISO_42FPS,
  1030. CAMERA_COMPAT_MODE_ISO_40FPS,
  1031. CAMERA_COMPAT_MODE_ISO_35FPS,
  1032. CAMERA_COMPAT_MODE_ISO_30FPS,
  1033. MAX_CAMERA_COMPAT_MODES
  1034. };
  1035. #ifdef _MSC_VER
  1036. #define VR_CAMERA_DECL_ALIGN( x ) __declspec( align( x ) )
  1037. #else
  1038. #define VR_CAMERA_DECL_ALIGN( x ) //
  1039. #endif
  1040. #define MAX_CAMERA_FRAME_SHARED_HANDLES 4
  1041. VR_CAMERA_DECL_ALIGN( 8 ) struct CameraVideoStreamFrame_t
  1042. {
  1043. ECameraVideoStreamFormat m_nStreamFormat;
  1044. uint32_t m_nWidth;
  1045. uint32_t m_nHeight;
  1046. uint32_t m_nImageDataSize; // Based on stream format, width, height
  1047. uint32_t m_nFrameSequence; // Starts from 0 when stream starts.
  1048. uint32_t m_nBufferIndex; // Identifies which buffer the image data is hosted
  1049. uint32_t m_nBufferCount; // Total number of configured buffers
  1050. uint32_t m_nExposureTime;
  1051. uint32_t m_nISPFrameTimeStamp; // Driver provided time stamp per driver centric time base
  1052. uint32_t m_nISPReferenceTimeStamp;
  1053. uint32_t m_nSyncCounter;
  1054. uint32_t m_nCamSyncEvents;
  1055. uint32_t m_nISPSyncEvents;
  1056. double m_flReferenceCamSyncTime;
  1057. double m_flFrameElapsedTime; // Starts from 0 when stream starts. In seconds.
  1058. double m_flFrameDeliveryRate;
  1059. double m_flFrameCaptureTime_DriverAbsolute; // In USB time, via AuxEvent
  1060. double m_flFrameCaptureTime_ServerRelative; // In System time within the server
  1061. uint64_t m_nFrameCaptureTicks_ServerAbsolute; // In system ticks within the server
  1062. double m_flFrameCaptureTime_ClientRelative; // At the client, relative to when the frame was exposed/captured.
  1063. double m_flSyncMarkerError;
  1064. TrackedDevicePose_t m_StandingTrackedDevicePose; // Supplied by HMD layer when used as a tracked camera
  1065. uint64_t m_pImageData;
  1066. };
  1067. #pragma pack( pop )
  1068. }
  1069. #endif // _VRTRACKEDCAMERATYPES_H
  1070. // ivrsettings.h
  1071. namespace vr
  1072. {
  1073. enum EVRSettingsError
  1074. {
  1075. VRSettingsError_None = 0,
  1076. VRSettingsError_IPCFailed = 1,
  1077. VRSettingsError_WriteFailed = 2,
  1078. VRSettingsError_ReadFailed = 3,
  1079. VRSettingsError_JsonParseFailed = 4,
  1080. VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set
  1081. };
  1082. // The maximum length of a settings key
  1083. static const uint32_t k_unMaxSettingsKeyLength = 128;
  1084. class IVRSettings
  1085. {
  1086. public:
  1087. virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
  1088. // Returns true if file sync occurred (force or settings dirty)
  1089. virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0;
  1090. virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
  1091. virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
  1092. virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
  1093. virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
  1094. // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory
  1095. // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or ""
  1096. virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1097. virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1098. virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1099. virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0;
  1100. virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
  1101. virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1102. };
  1103. //-----------------------------------------------------------------------------
  1104. static const char * const IVRSettings_Version = "IVRSettings_002";
  1105. //-----------------------------------------------------------------------------
  1106. // steamvr keys
  1107. static const char * const k_pch_SteamVR_Section = "steamvr";
  1108. static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
  1109. static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
  1110. static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
  1111. static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
  1112. static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
  1113. static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion";
  1114. static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
  1115. static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
  1116. static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
  1117. static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
  1118. static const char * const k_pch_SteamVR_IPD_Float = "ipd";
  1119. static const char * const k_pch_SteamVR_Background_String = "background";
  1120. static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection";
  1121. static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
  1122. static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
  1123. static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
  1124. static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
  1125. static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
  1126. static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
  1127. static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode";
  1128. static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
  1129. static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
  1130. static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
  1131. static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
  1132. static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
  1133. static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
  1134. static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier";
  1135. static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection";
  1136. static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection";
  1137. static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection";
  1138. static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
  1139. static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView";
  1140. static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView";
  1141. static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry";
  1142. static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch";
  1143. static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch";
  1144. static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch";
  1145. static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard";
  1146. static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp";
  1147. static const char * const k_pch_SteamVR_SetInitialDefaultHomeApp = "setInitialDefaultHomeApp";
  1148. static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec";
  1149. static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo";
  1150. static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset";
  1151. //-----------------------------------------------------------------------------
  1152. // lighthouse keys
  1153. static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
  1154. static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
  1155. static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
  1156. static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
  1157. static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
  1158. static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
  1159. //-----------------------------------------------------------------------------
  1160. // null keys
  1161. static const char * const k_pch_Null_Section = "driver_null";
  1162. static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
  1163. static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
  1164. static const char * const k_pch_Null_WindowX_Int32 = "windowX";
  1165. static const char * const k_pch_Null_WindowY_Int32 = "windowY";
  1166. static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
  1167. static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
  1168. static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
  1169. static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
  1170. static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
  1171. static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
  1172. //-----------------------------------------------------------------------------
  1173. // user interface keys
  1174. static const char * const k_pch_UserInterface_Section = "userinterface";
  1175. static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
  1176. static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray";
  1177. static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots";
  1178. static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType";
  1179. //-----------------------------------------------------------------------------
  1180. // notification keys
  1181. static const char * const k_pch_Notifications_Section = "notifications";
  1182. static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
  1183. //-----------------------------------------------------------------------------
  1184. // keyboard keys
  1185. static const char * const k_pch_Keyboard_Section = "keyboard";
  1186. static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
  1187. static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
  1188. static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
  1189. static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
  1190. static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
  1191. static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
  1192. static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
  1193. //-----------------------------------------------------------------------------
  1194. // perf keys
  1195. static const char * const k_pch_Perf_Section = "perfcheck";
  1196. static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
  1197. static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
  1198. static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
  1199. static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
  1200. static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
  1201. static const char * const k_pch_Perf_TestData_Float = "perfTestData";
  1202. //-----------------------------------------------------------------------------
  1203. // collision bounds keys
  1204. static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
  1205. static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
  1206. static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
  1207. static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
  1208. static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
  1209. static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
  1210. static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
  1211. static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
  1212. static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
  1213. static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
  1214. //-----------------------------------------------------------------------------
  1215. // camera keys
  1216. static const char * const k_pch_Camera_Section = "camera";
  1217. static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
  1218. static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
  1219. static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
  1220. static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
  1221. static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
  1222. static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
  1223. static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
  1224. static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
  1225. static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength";
  1226. //-----------------------------------------------------------------------------
  1227. // audio keys
  1228. static const char * const k_pch_audio_Section = "audio";
  1229. static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
  1230. static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
  1231. static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
  1232. static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
  1233. static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
  1234. static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
  1235. //-----------------------------------------------------------------------------
  1236. // power management keys
  1237. static const char * const k_pch_Power_Section = "power";
  1238. static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit";
  1239. static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout";
  1240. static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout";
  1241. static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout";
  1242. static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress";
  1243. //-----------------------------------------------------------------------------
  1244. // dashboard keys
  1245. static const char * const k_pch_Dashboard_Section = "dashboard";
  1246. static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard";
  1247. static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode";
  1248. //-----------------------------------------------------------------------------
  1249. // model skin keys
  1250. static const char * const k_pch_modelskin_Section = "modelskins";
  1251. //-----------------------------------------------------------------------------
  1252. // driver keys - These could be checked in any driver_<name> section
  1253. static const char * const k_pch_Driver_Enable_Bool = "enable";
  1254. } // namespace vr
  1255. // iservertrackeddevicedriver.h
  1256. namespace vr
  1257. {
  1258. struct DriverPoseQuaternion_t
  1259. {
  1260. double w, x, y, z;
  1261. };
  1262. struct DriverPose_t
  1263. {
  1264. /* Time offset of this pose, in seconds from the actual time of the pose,
  1265. * relative to the time of the PoseUpdated() call made by the driver.
  1266. */
  1267. double poseTimeOffset;
  1268. /* Generally, the pose maintained by a driver
  1269. * is in an inertial coordinate system different
  1270. * from the world system of x+ right, y+ up, z+ back.
  1271. * Also, the driver is not usually tracking the "head" position,
  1272. * but instead an internal IMU or another reference point in the HMD.
  1273. * The following two transforms transform positions and orientations
  1274. * to app world space from driver world space,
  1275. * and to HMD head space from driver local body space.
  1276. *
  1277. * We maintain the driver pose state in its internal coordinate system,
  1278. * so we can do the pose prediction math without having to
  1279. * use angular acceleration. A driver's angular acceleration is generally not measured,
  1280. * and is instead calculated from successive samples of angular velocity.
  1281. * This leads to a noisy angular acceleration values, which are also
  1282. * lagged due to the filtering required to reduce noise to an acceptable level.
  1283. */
  1284. vr::HmdQuaternion_t qWorldFromDriverRotation;
  1285. double vecWorldFromDriverTranslation[ 3 ];
  1286. vr::HmdQuaternion_t qDriverFromHeadRotation;
  1287. double vecDriverFromHeadTranslation[ 3 ];
  1288. /* State of driver pose, in meters and radians. */
  1289. /* Position of the driver tracking reference in driver world space
  1290. * +[0] (x) is right
  1291. * +[1] (y) is up
  1292. * -[2] (z) is forward
  1293. */
  1294. double vecPosition[ 3 ];
  1295. /* Velocity of the pose in meters/second */
  1296. double vecVelocity[ 3 ];
  1297. /* Acceleration of the pose in meters/second */
  1298. double vecAcceleration[ 3 ];
  1299. /* Orientation of the tracker, represented as a quaternion */
  1300. vr::HmdQuaternion_t qRotation;
  1301. /* Angular velocity of the pose in axis-angle
  1302. * representation. The direction is the angle of
  1303. * rotation and the magnitude is the angle around
  1304. * that axis in radians/second. */
  1305. double vecAngularVelocity[ 3 ];
  1306. /* Angular acceleration of the pose in axis-angle
  1307. * representation. The direction is the angle of
  1308. * rotation and the magnitude is the angle around
  1309. * that axis in radians/second^2. */
  1310. double vecAngularAcceleration[ 3 ];
  1311. ETrackingResult result;
  1312. bool poseIsValid;
  1313. bool willDriftInYaw;
  1314. bool shouldApplyHeadModel;
  1315. bool deviceIsConnected;
  1316. };
  1317. // ----------------------------------------------------------------------------------------------
  1318. // Purpose: Represents a single tracked device in a driver
  1319. // ----------------------------------------------------------------------------------------------
  1320. class ITrackedDeviceServerDriver
  1321. {
  1322. public:
  1323. // ------------------------------------
  1324. // Management Methods
  1325. // ------------------------------------
  1326. /** This is called before an HMD is returned to the application. It will always be
  1327. * called before any display or tracking methods. Memory and processor use by the
  1328. * ITrackedDeviceServerDriver object should be kept to a minimum until it is activated.
  1329. * The pose listener is guaranteed to be valid until Deactivate is called, but
  1330. * should not be used after that point. */
  1331. virtual EVRInitError Activate( uint32_t unObjectId ) = 0;
  1332. /** This is called when The VR system is switching from this Hmd being the active display
  1333. * to another Hmd being the active display. The driver should clean whatever memory
  1334. * and thread use it can when it is deactivated */
  1335. virtual void Deactivate() = 0;
  1336. /** Handles a request from the system to put this device into standby mode. What that means is defined per-device. */
  1337. virtual void EnterStandby() = 0;
  1338. /** Requests a component interface of the driver for device-specific functionality. The driver should return NULL
  1339. * if the requested interface or version is not supported. */
  1340. virtual void *GetComponent( const char *pchComponentNameAndVersion ) = 0;
  1341. /** A VR Client has made this debug request of the driver. The set of valid requests is entirely
  1342. * up to the driver and the client to figure out, as is the format of the response. Responses that
  1343. * exceed the length of the supplied buffer should be truncated and null terminated */
  1344. virtual void DebugRequest( const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
  1345. // ------------------------------------
  1346. // Tracking Methods
  1347. // ------------------------------------
  1348. virtual DriverPose_t GetPose() = 0;
  1349. };
  1350. static const char *ITrackedDeviceServerDriver_Version = "ITrackedDeviceServerDriver_005";
  1351. }
  1352. // ivrdisplaycomponent.h
  1353. namespace vr
  1354. {
  1355. // ----------------------------------------------------------------------------------------------
  1356. // Purpose: The display component on a single tracked device
  1357. // ----------------------------------------------------------------------------------------------
  1358. class IVRDisplayComponent
  1359. {
  1360. public:
  1361. // ------------------------------------
  1362. // Display Methods
  1363. // ------------------------------------
  1364. /** Size and position that the window needs to be on the VR display. */
  1365. virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1366. /** Returns true if the display is extending the desktop. */
  1367. virtual bool IsDisplayOnDesktop( ) = 0;
  1368. /** Returns true if the display is real and not a fictional display. */
  1369. virtual bool IsDisplayRealDisplay( ) = 0;
  1370. /** Suggested size for the intermediate render target that the distortion pulls from. */
  1371. virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1372. /** Gets the viewport in the frame buffer to draw the output of the distortion into */
  1373. virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1374. /** The components necessary to build your own projection matrix in case your
  1375. * application is doing something fancy like infinite Z */
  1376. virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
  1377. /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
  1378. * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
  1379. virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0;
  1380. };
  1381. static const char *IVRDisplayComponent_Version = "IVRDisplayComponent_002";
  1382. }
  1383. // ivrdriverdirectmodecomponent.h
  1384. namespace vr
  1385. {
  1386. // ----------------------------------------------------------------------------------------------
  1387. // Purpose: This component is used for drivers that implement direct mode entirely on their own
  1388. // without allowing the VR Compositor to own the window/device. Chances are you don't
  1389. // need to implement this component in your driver.
  1390. // ----------------------------------------------------------------------------------------------
  1391. class IVRDriverDirectModeComponent
  1392. {
  1393. public:
  1394. // -----------------------------------
  1395. // Direct mode methods
  1396. // -----------------------------------
  1397. /** Specific to Oculus compositor support, textures supplied must be created using this method. */
  1398. virtual void CreateSwapTextureSet( uint32_t unPid, uint32_t unFormat, uint32_t unWidth, uint32_t unHeight, vr::SharedTextureHandle_t( *pSharedTextureHandles )[ 3 ] ) {}
  1399. /** Used to textures created using CreateSwapTextureSet. Only one of the set's handles needs to be used to destroy the entire set. */
  1400. virtual void DestroySwapTextureSet( vr::SharedTextureHandle_t sharedTextureHandle ) {}
  1401. /** Used to purge all texture sets for a given process. */
  1402. virtual void DestroyAllSwapTextureSets( uint32_t unPid ) {}
  1403. /** After Present returns, calls this to get the next index to use for rendering. */
  1404. virtual void GetNextSwapTextureSetIndex( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], uint32_t( *pIndices )[ 2 ] ) {}
  1405. /** Call once per layer to draw for this frame. One shared texture handle per eye. Textures must be created
  1406. * using CreateSwapTextureSet and should be alternated per frame. Call Present once all layers have been submitted. */
  1407. virtual void SubmitLayer( vr::SharedTextureHandle_t sharedTextureHandles[ 2 ], const vr::VRTextureBounds_t( &bounds )[ 2 ], const vr::HmdMatrix34_t *pPose ) {}
  1408. /** Submits queued layers for display. */
  1409. virtual void Present( vr::SharedTextureHandle_t syncTexture ) {}
  1410. };
  1411. static const char *IVRDriverDirectModeComponent_Version = "IVRDriverDirectModeComponent_002";
  1412. }
  1413. // ivrcontrollercomponent.h
  1414. namespace vr
  1415. {
  1416. // ----------------------------------------------------------------------------------------------
  1417. // Purpose: Controller access on a single tracked device.
  1418. // ----------------------------------------------------------------------------------------------
  1419. class IVRControllerComponent
  1420. {
  1421. public:
  1422. // ------------------------------------
  1423. // Controller Methods
  1424. // ------------------------------------
  1425. /** Gets the current state of a controller. */
  1426. virtual VRControllerState_t GetControllerState( ) = 0;
  1427. /** Returns a uint64 property. If the property is not available this function will return 0. */
  1428. virtual bool TriggerHapticPulse( uint32_t unAxisId, uint16_t usPulseDurationMicroseconds ) = 0;
  1429. };
  1430. static const char *IVRControllerComponent_Version = "IVRControllerComponent_001";
  1431. }
  1432. // ivrcameracomponent.h
  1433. namespace vr
  1434. {
  1435. //-----------------------------------------------------------------------------
  1436. //-----------------------------------------------------------------------------
  1437. class ICameraVideoSinkCallback
  1438. {
  1439. public:
  1440. virtual void OnCameraVideoSinkCallback() = 0;
  1441. };
  1442. // ----------------------------------------------------------------------------------------------
  1443. // Purpose: The camera on a single tracked device
  1444. // ----------------------------------------------------------------------------------------------
  1445. class IVRCameraComponent
  1446. {
  1447. public:
  1448. // ------------------------------------
  1449. // Camera Methods
  1450. // ------------------------------------
  1451. virtual bool GetCameraFrameDimensions( vr::ECameraVideoStreamFormat nVideoStreamFormat, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  1452. virtual bool GetCameraFrameBufferingRequirements( int *pDefaultFrameQueueSize, uint32_t *pFrameBufferDataSize ) = 0;
  1453. virtual bool SetCameraFrameBuffering( int nFrameBufferCount, void **ppFrameBuffers, uint32_t nFrameBufferDataSize ) = 0;
  1454. virtual bool SetCameraVideoStreamFormat( vr::ECameraVideoStreamFormat nVideoStreamFormat ) = 0;
  1455. virtual vr::ECameraVideoStreamFormat GetCameraVideoStreamFormat() = 0;
  1456. virtual bool StartVideoStream() = 0;
  1457. virtual void StopVideoStream() = 0;
  1458. virtual bool IsVideoStreamActive( bool *pbPaused, float *pflElapsedTime ) = 0;
  1459. virtual const vr::CameraVideoStreamFrame_t *GetVideoStreamFrame() = 0;
  1460. virtual void ReleaseVideoStreamFrame( const vr::CameraVideoStreamFrame_t *pFrameImage ) = 0;
  1461. virtual bool SetAutoExposure( bool bEnable ) = 0;
  1462. virtual bool PauseVideoStream() = 0;
  1463. virtual bool ResumeVideoStream() = 0;
  1464. virtual bool GetCameraDistortion( float flInputU, float flInputV, float *pflOutputU, float *pflOutputV ) = 0;
  1465. virtual bool GetCameraProjection( vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
  1466. virtual bool SetFrameRate( int nISPFrameRate, int nSensorFrameRate ) = 0;
  1467. virtual bool SetCameraVideoSinkCallback( vr::ICameraVideoSinkCallback *pCameraVideoSinkCallback ) = 0;
  1468. virtual bool GetCameraCompatibilityMode( vr::ECameraCompatibilityMode *pCameraCompatibilityMode ) = 0;
  1469. virtual bool SetCameraCompatibilityMode( vr::ECameraCompatibilityMode nCameraCompatibilityMode ) = 0;
  1470. virtual bool GetCameraFrameBounds( vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pLeft, uint32_t *pTop, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  1471. virtual bool GetCameraIntrinsics( vr::EVRTrackedCameraFrameType eFrameType, HmdVector2_t *pFocalLength, HmdVector2_t *pCenter ) = 0;
  1472. };
  1473. static const char *IVRCameraComponent_Version = "IVRCameraComponent_002";
  1474. }
  1475. // itrackeddevicedriverprovider.h
  1476. namespace vr
  1477. {
  1478. class ITrackedDeviceServerDriver;
  1479. struct TrackedDeviceDriverInfo_t;
  1480. struct DriverPose_t;
  1481. typedef PropertyContainerHandle_t DriverHandle_t;
  1482. /** This interface is provided by vrserver to allow the driver to notify
  1483. * the system when something changes about a device. These changes must
  1484. * not change the serial number or class of the device because those values
  1485. * are permanently associated with the device's index. */
  1486. class IVRDriverContext
  1487. {
  1488. public:
  1489. /** Returns the requested interface. If the interface was not available it will return NULL and fill
  1490. * out the error. */
  1491. virtual void *GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError = nullptr ) = 0;
  1492. /** Returns the property container handle for this driver */
  1493. virtual DriverHandle_t GetDriverHandle() = 0;
  1494. };
  1495. /** This interface must be implemented in each driver. It will be loaded in vrserver.exe */
  1496. class IServerTrackedDeviceProvider
  1497. {
  1498. public:
  1499. /** initializes the driver. This will be called before any other methods are called.
  1500. * If Init returns anything other than VRInitError_None the driver DLL will be unloaded.
  1501. *
  1502. * pDriverHost will never be NULL, and will always be a pointer to a IServerDriverHost interface
  1503. *
  1504. * pchUserDriverConfigDir - The absolute path of the directory where the driver should store user
  1505. * config files.
  1506. * pchDriverInstallDir - The absolute path of the root directory for the driver.
  1507. */
  1508. virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
  1509. /** cleans up the driver right before it is unloaded */
  1510. virtual void Cleanup() = 0;
  1511. /** Returns the version of the ITrackedDeviceServerDriver interface used by this driver */
  1512. virtual const char * const *GetInterfaceVersions() = 0;
  1513. /** Allows the driver do to some work in the main loop of the server. */
  1514. virtual void RunFrame() = 0;
  1515. // ------------ Power State Functions ----------------------- //
  1516. /** Returns true if the driver wants to block Standby mode. */
  1517. virtual bool ShouldBlockStandbyMode() = 0;
  1518. /** Called when the system is entering Standby mode. The driver should switch itself into whatever sort of low-power
  1519. * state it has. */
  1520. virtual void EnterStandby() = 0;
  1521. /** Called when the system is leaving Standby mode. The driver should switch itself back to
  1522. full operation. */
  1523. virtual void LeaveStandby() = 0;
  1524. };
  1525. static const char *IServerTrackedDeviceProvider_Version = "IServerTrackedDeviceProvider_004";
  1526. /** This interface must be implemented in each driver. It will be loaded in vrclient.dll */
  1527. class IVRWatchdogProvider
  1528. {
  1529. public:
  1530. /** initializes the driver in watchdog mode. */
  1531. virtual EVRInitError Init( IVRDriverContext *pDriverContext ) = 0;
  1532. /** cleans up the driver right before it is unloaded */
  1533. virtual void Cleanup() = 0;
  1534. };
  1535. static const char *IVRWatchdogProvider_Version = "IVRWatchdogProvider_001";
  1536. }
  1537. // ivrproperties.h
  1538. #include <string>
  1539. namespace vr
  1540. {
  1541. enum EPropertyWriteType
  1542. {
  1543. PropertyWrite_Set = 0,
  1544. PropertyWrite_Erase = 1,
  1545. PropertyWrite_SetError = 2
  1546. };
  1547. struct PropertyWrite_t
  1548. {
  1549. ETrackedDeviceProperty prop;
  1550. EPropertyWriteType writeType;
  1551. ETrackedPropertyError eSetError;
  1552. void *pvBuffer;
  1553. uint32_t unBufferSize;
  1554. PropertyTypeTag_t unTag;
  1555. ETrackedPropertyError eError;
  1556. };
  1557. struct PropertyRead_t
  1558. {
  1559. ETrackedDeviceProperty prop;
  1560. void *pvBuffer;
  1561. uint32_t unBufferSize;
  1562. PropertyTypeTag_t unTag;
  1563. uint32_t unRequiredBufferSize;
  1564. ETrackedPropertyError eError;
  1565. };
  1566. class IVRProperties
  1567. {
  1568. public:
  1569. /** Reads a set of properties atomically. See the PropertyReadBatch_t struct for more information. */
  1570. virtual ETrackedPropertyError ReadPropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyRead_t *pBatch, uint32_t unBatchEntryCount ) = 0;
  1571. /** Writes a set of properties atomically. See the PropertyWriteBatch_t struct for more information. */
  1572. virtual ETrackedPropertyError WritePropertyBatch( PropertyContainerHandle_t ulContainerHandle, PropertyWrite_t *pBatch, uint32_t unBatchEntryCount ) = 0;
  1573. /** returns a string that corresponds with the specified property error. The string will be the name
  1574. * of the error enum value for all valid error codes */
  1575. virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0;
  1576. /** Returns a container handle given a tracked device index */
  1577. virtual PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) = 0;
  1578. };
  1579. static const char * const IVRProperties_Version = "IVRProperties_001";
  1580. class CVRPropertyHelpers
  1581. {
  1582. public:
  1583. CVRPropertyHelpers( IVRProperties * pProperties ) : m_pProperties( pProperties ) {}
  1584. /** Returns a scaler property. If the device index is not valid or the property value type does not match,
  1585. * this function will return false. */
  1586. bool GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
  1587. float GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
  1588. int32_t GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
  1589. uint64_t GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L );
  1590. /** Returns a single typed property. If the device index is not valid or the property is not a string type this function will
  1591. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  1592. * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
  1593. uint32_t GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError = 0L );
  1594. /** Returns a string property. If the device index is not valid or the property is not a string type this function will
  1595. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  1596. * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
  1597. uint32_t GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L );
  1598. /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will
  1599. * return an empty string. */
  1600. std::string GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError = nullptr );
  1601. /** Sets a scaler property. The new value will be returned on any subsequent call to get this property in any process. */
  1602. ETrackedPropertyError SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue );
  1603. ETrackedPropertyError SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue );
  1604. ETrackedPropertyError SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue );
  1605. ETrackedPropertyError SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue );
  1606. /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
  1607. ETrackedPropertyError SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue );
  1608. /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
  1609. ETrackedPropertyError SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag );
  1610. /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
  1611. ETrackedPropertyError SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError );
  1612. /** Clears any value or error set for the property. */
  1613. ETrackedPropertyError EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop );
  1614. /* Turns a device index into a property container handle. */
  1615. PropertyContainerHandle_t TrackedDeviceToPropertyContainer( TrackedDeviceIndex_t nDevice ) { return m_pProperties->TrackedDeviceToPropertyContainer( nDevice ); }
  1616. private:
  1617. template<typename T>
  1618. T GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag );
  1619. IVRProperties *m_pProperties;
  1620. };
  1621. inline uint32_t CVRPropertyHelpers::GetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() void *pvBuffer, uint32_t unBufferSize, PropertyTypeTag_t *punTag, ETrackedPropertyError *pError )
  1622. {
  1623. PropertyRead_t batch;
  1624. batch.prop = prop;
  1625. batch.pvBuffer = pvBuffer;
  1626. batch.unBufferSize = unBufferSize;
  1627. m_pProperties->ReadPropertyBatch( ulContainerHandle, &batch, 1 );
  1628. if ( pError )
  1629. {
  1630. *pError = batch.eError;
  1631. }
  1632. if ( punTag )
  1633. {
  1634. *punTag = batch.unTag;
  1635. }
  1636. return batch.unRequiredBufferSize;
  1637. }
  1638. /** Sets a single typed property. The new value will be returned on any subsequent call to get this property in any process. */
  1639. inline ETrackedPropertyError CVRPropertyHelpers::SetProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, void *pvNewValue, uint32_t unNewValueSize, PropertyTypeTag_t unTag )
  1640. {
  1641. PropertyWrite_t batch;
  1642. batch.writeType = PropertyWrite_Set;
  1643. batch.prop = prop;
  1644. batch.pvBuffer = pvNewValue;
  1645. batch.unBufferSize = unNewValueSize;
  1646. batch.unTag = unTag;
  1647. m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
  1648. return batch.eError;
  1649. }
  1650. /** Returns a string property. If the device index is not valid or the property is not a string type this function will
  1651. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  1652. * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
  1653. inline uint32_t CVRPropertyHelpers::GetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError )
  1654. {
  1655. PropertyTypeTag_t unTag;
  1656. ETrackedPropertyError error;
  1657. uint32_t unRequiredSize = GetProperty( ulContainerHandle, prop, pchValue, unBufferSize, &unTag, &error );
  1658. if ( unTag != k_unStringPropertyTag && error == TrackedProp_Success )
  1659. {
  1660. error = TrackedProp_WrongDataType;
  1661. }
  1662. if ( pError )
  1663. {
  1664. *pError = error;
  1665. }
  1666. if ( error != TrackedProp_Success )
  1667. {
  1668. if ( pchValue && unBufferSize )
  1669. {
  1670. *pchValue = '\0';
  1671. }
  1672. }
  1673. return unRequiredSize;
  1674. }
  1675. /** Returns a string property as a std::string. If the device index is not valid or the property is not a string type this function will
  1676. * return an empty string. */
  1677. inline std::string CVRPropertyHelpers::GetStringProperty( vr::PropertyContainerHandle_t ulContainer, vr::ETrackedDeviceProperty prop, vr::ETrackedPropertyError *peError )
  1678. {
  1679. char buf[1024];
  1680. vr::ETrackedPropertyError err;
  1681. uint32_t unRequiredBufferLen = GetStringProperty( ulContainer, prop, buf, sizeof(buf), &err );
  1682. std::string sResult;
  1683. if ( err == TrackedProp_Success )
  1684. {
  1685. sResult = buf;
  1686. }
  1687. else if ( err == TrackedProp_BufferTooSmall )
  1688. {
  1689. char *pchBuffer = new char[unRequiredBufferLen];
  1690. unRequiredBufferLen = GetStringProperty( ulContainer, prop, pchBuffer, unRequiredBufferLen, &err );
  1691. sResult = pchBuffer;
  1692. delete[] pchBuffer;
  1693. }
  1694. if ( peError )
  1695. {
  1696. *peError = err;
  1697. }
  1698. return sResult;
  1699. }
  1700. /** Sets a string property. The new value will be returned on any subsequent call to get this property in any process. */
  1701. inline ETrackedPropertyError CVRPropertyHelpers::SetStringProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, const char *pchNewValue )
  1702. {
  1703. if ( !pchNewValue )
  1704. return TrackedProp_InvalidOperation;
  1705. // this is strlen without the dependency on string.h
  1706. const char *pchCurr = pchNewValue;
  1707. while ( *pchCurr )
  1708. {
  1709. pchCurr++;
  1710. }
  1711. return SetProperty( ulContainerHandle, prop, (void *)pchNewValue, (uint32_t)(pchCurr - pchNewValue) + 1, k_unStringPropertyTag );
  1712. }
  1713. template<typename T>
  1714. inline T CVRPropertyHelpers::GetPropertyHelper( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError, T bDefault, PropertyTypeTag_t unTypeTag )
  1715. {
  1716. T bValue;
  1717. ETrackedPropertyError eError;
  1718. PropertyTypeTag_t unReadTag;
  1719. GetProperty( ulContainerHandle, prop, &bValue, sizeof( bValue ), &unReadTag, &eError );
  1720. if ( unReadTag != unTypeTag && eError == TrackedProp_Success )
  1721. {
  1722. eError = TrackedProp_WrongDataType;
  1723. };
  1724. if ( pError )
  1725. *pError = eError;
  1726. if ( eError != TrackedProp_Success )
  1727. {
  1728. return bDefault;
  1729. }
  1730. else
  1731. {
  1732. return bValue;
  1733. }
  1734. }
  1735. inline bool CVRPropertyHelpers::GetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
  1736. {
  1737. return GetPropertyHelper<bool>( ulContainerHandle, prop, pError, false, k_unBoolPropertyTag );
  1738. }
  1739. inline float CVRPropertyHelpers::GetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
  1740. {
  1741. return GetPropertyHelper<float>( ulContainerHandle, prop, pError, 0.f, k_unFloatPropertyTag );
  1742. }
  1743. inline int32_t CVRPropertyHelpers::GetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
  1744. {
  1745. return GetPropertyHelper<int32_t>( ulContainerHandle, prop, pError, 0, k_unInt32PropertyTag );
  1746. }
  1747. inline uint64_t CVRPropertyHelpers::GetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError *pError )
  1748. {
  1749. return GetPropertyHelper<uint64_t>( ulContainerHandle, prop, pError, 0, k_unUint64PropertyTag );
  1750. }
  1751. inline ETrackedPropertyError CVRPropertyHelpers::SetBoolProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, bool bNewValue )
  1752. {
  1753. return SetProperty( ulContainerHandle, prop, &bNewValue, sizeof( bNewValue ), k_unBoolPropertyTag );
  1754. }
  1755. inline ETrackedPropertyError CVRPropertyHelpers::SetFloatProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, float fNewValue )
  1756. {
  1757. return SetProperty( ulContainerHandle, prop, &fNewValue, sizeof( fNewValue ), k_unFloatPropertyTag );
  1758. }
  1759. inline ETrackedPropertyError CVRPropertyHelpers::SetInt32Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, int32_t nNewValue )
  1760. {
  1761. return SetProperty( ulContainerHandle, prop, &nNewValue, sizeof( nNewValue ), k_unInt32PropertyTag );
  1762. }
  1763. inline ETrackedPropertyError CVRPropertyHelpers::SetUint64Property( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, uint64_t ulNewValue )
  1764. {
  1765. return SetProperty( ulContainerHandle, prop, &ulNewValue, sizeof( ulNewValue ), k_unUint64PropertyTag );
  1766. }
  1767. /** Sets the error return value for a property. This value will be returned on all subsequent requests to get the property */
  1768. inline ETrackedPropertyError CVRPropertyHelpers::SetPropertyError( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop, ETrackedPropertyError eError )
  1769. {
  1770. PropertyWrite_t batch;
  1771. batch.writeType = PropertyWrite_SetError;
  1772. batch.prop = prop;
  1773. batch.eSetError = eError;
  1774. m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
  1775. return batch.eError;
  1776. }
  1777. /** Clears any value or error set for the property. */
  1778. inline ETrackedPropertyError CVRPropertyHelpers::EraseProperty( PropertyContainerHandle_t ulContainerHandle, ETrackedDeviceProperty prop )
  1779. {
  1780. PropertyWrite_t batch;
  1781. batch.writeType = PropertyWrite_Erase;
  1782. batch.prop = prop;
  1783. m_pProperties->WritePropertyBatch( ulContainerHandle, &batch, 1 );
  1784. return batch.eError;
  1785. }
  1786. }
  1787. // ivrdriverlog.h
  1788. namespace vr
  1789. {
  1790. class IVRDriverLog
  1791. {
  1792. public:
  1793. /** Writes a log message to the log file prefixed with the driver name */
  1794. virtual void Log( const char *pchLogMessage ) = 0;
  1795. };
  1796. static const char *IVRDriverLog_Version = "IVRDriverLog_001";
  1797. }
  1798. // ivrserverdriverhost.h
  1799. namespace vr
  1800. {
  1801. class ITrackedDeviceServerDriver;
  1802. struct TrackedDeviceDriverInfo_t;
  1803. struct DriverPose_t;
  1804. /** This interface is provided by vrserver to allow the driver to notify
  1805. * the system when something changes about a device. These changes must
  1806. * not change the serial number or class of the device because those values
  1807. * are permanently associated with the device's index. */
  1808. class IVRServerDriverHost
  1809. {
  1810. public:
  1811. /** Notifies the server that a tracked device has been added. If this function returns true
  1812. * the server will call Activate on the device. If it returns false some kind of error
  1813. * has occurred and the device will not be activated. */
  1814. virtual bool TrackedDeviceAdded( const char *pchDeviceSerialNumber, ETrackedDeviceClass eDeviceClass, ITrackedDeviceServerDriver *pDriver ) = 0;
  1815. /** Notifies the server that a tracked device's pose has been updated */
  1816. virtual void TrackedDevicePoseUpdated( uint32_t unWhichDevice, const DriverPose_t & newPose, uint32_t unPoseStructSize ) = 0;
  1817. /** Notifies the server that vsync has occurred on the the display attached to the device. This is
  1818. * only permitted on devices of the HMD class. */
  1819. virtual void VsyncEvent( double vsyncTimeOffsetSeconds ) = 0;
  1820. /** notifies the server that the button was pressed */
  1821. virtual void TrackedDeviceButtonPressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1822. /** notifies the server that the button was unpressed */
  1823. virtual void TrackedDeviceButtonUnpressed( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1824. /** notifies the server that the button was pressed */
  1825. virtual void TrackedDeviceButtonTouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1826. /** notifies the server that the button was unpressed */
  1827. virtual void TrackedDeviceButtonUntouched( uint32_t unWhichDevice, EVRButtonId eButtonId, double eventTimeOffset ) = 0;
  1828. /** notifies the server than a controller axis changed */
  1829. virtual void TrackedDeviceAxisUpdated( uint32_t unWhichDevice, uint32_t unWhichAxis, const VRControllerAxis_t & axisState ) = 0;
  1830. /** Notifies the server that the proximity sensor on the specified device */
  1831. virtual void ProximitySensorState( uint32_t unWhichDevice, bool bProximitySensorTriggered ) = 0;
  1832. /** Sends a vendor specific event (VREvent_VendorSpecific_Reserved_Start..VREvent_VendorSpecific_Reserved_End */
  1833. virtual void VendorSpecificEvent( uint32_t unWhichDevice, vr::EVREventType eventType, const VREvent_Data_t & eventData, double eventTimeOffset ) = 0;
  1834. /** Returns true if SteamVR is exiting */
  1835. virtual bool IsExiting() = 0;
  1836. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  1837. * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
  1838. virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
  1839. };
  1840. static const char *IVRServerDriverHost_Version = "IVRServerDriverHost_004";
  1841. }
  1842. // ivrhiddenarea.h
  1843. namespace vr
  1844. {
  1845. class CVRHiddenAreaHelpers
  1846. {
  1847. public:
  1848. CVRHiddenAreaHelpers( IVRProperties *pProperties ) : m_pProperties( pProperties ) {}
  1849. /** Stores a hidden area mesh in a property */
  1850. ETrackedPropertyError SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount );
  1851. /** retrieves a hidden area mesh from a property. Returns the vert count read out of the property. */
  1852. uint32_t GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError );
  1853. private:
  1854. ETrackedDeviceProperty GetPropertyEnum( EVREye eEye, EHiddenAreaMeshType type )
  1855. {
  1856. return (ETrackedDeviceProperty)(Prop_DisplayHiddenArea_Binary_Start + ((int)type * 2) + (int)eEye);
  1857. }
  1858. IVRProperties *m_pProperties;
  1859. };
  1860. inline ETrackedPropertyError CVRHiddenAreaHelpers::SetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount )
  1861. {
  1862. ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
  1863. CVRPropertyHelpers propHelpers( m_pProperties );
  1864. return propHelpers.SetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t ) * unVertCount, k_unHiddenAreaPropertyTag );
  1865. }
  1866. inline uint32_t CVRHiddenAreaHelpers::GetHiddenArea( EVREye eEye, EHiddenAreaMeshType type, HmdVector2_t *pVerts, uint32_t unVertCount, ETrackedPropertyError *peError )
  1867. {
  1868. ETrackedDeviceProperty prop = GetPropertyEnum( eEye, type );
  1869. CVRPropertyHelpers propHelpers( m_pProperties );
  1870. ETrackedPropertyError propError;
  1871. PropertyTypeTag_t unTag;
  1872. uint32_t unBytesNeeded = propHelpers.GetProperty( propHelpers.TrackedDeviceToPropertyContainer( k_unTrackedDeviceIndex_Hmd ), prop, pVerts, sizeof( HmdVector2_t )*unVertCount, &unTag, &propError );
  1873. if ( propError == TrackedProp_Success && unTag != k_unHiddenAreaPropertyTag )
  1874. {
  1875. propError = TrackedProp_WrongDataType;
  1876. unBytesNeeded = 0;
  1877. }
  1878. if ( peError )
  1879. {
  1880. *peError = propError;
  1881. }
  1882. return unBytesNeeded / sizeof( HmdVector2_t );
  1883. }
  1884. }
  1885. // ivrwatchdoghost.h
  1886. namespace vr
  1887. {
  1888. /** This interface is provided by vrclient to allow the driver to make everything wake up */
  1889. class IVRWatchdogHost
  1890. {
  1891. public:
  1892. /** Client drivers in watchdog mode should call this when they have received a signal from hardware that should
  1893. * cause SteamVR to start */
  1894. virtual void WatchdogWakeUp() = 0;
  1895. };
  1896. static const char *IVRWatchdogHost_Version = "IVRWatchdogHost_001";
  1897. };
  1898. namespace vr
  1899. {
  1900. static const char * const k_InterfaceVersions[] =
  1901. {
  1902. IVRSettings_Version,
  1903. ITrackedDeviceServerDriver_Version,
  1904. IVRDisplayComponent_Version,
  1905. IVRDriverDirectModeComponent_Version,
  1906. IVRControllerComponent_Version,
  1907. IVRCameraComponent_Version,
  1908. IServerTrackedDeviceProvider_Version,
  1909. IVRWatchdogProvider_Version,
  1910. nullptr
  1911. };
  1912. inline IVRDriverContext *&VRDriverContext()
  1913. {
  1914. static IVRDriverContext *pHost;
  1915. return pHost;
  1916. }
  1917. class COpenVRDriverContext
  1918. {
  1919. public:
  1920. COpenVRDriverContext() : m_propertyHelpers(nullptr), m_hiddenAreaHelpers(nullptr) { Clear(); }
  1921. void Clear();
  1922. EVRInitError InitServer();
  1923. EVRInitError InitWatchdog();
  1924. IVRSettings *VRSettings()
  1925. {
  1926. if ( m_pVRSettings == nullptr )
  1927. {
  1928. EVRInitError eError;
  1929. m_pVRSettings = (IVRSettings *)VRDriverContext()->GetGenericInterface( IVRSettings_Version, &eError );
  1930. }
  1931. return m_pVRSettings;
  1932. }
  1933. IVRProperties *VRPropertiesRaw()
  1934. {
  1935. if ( m_pVRProperties == nullptr )
  1936. {
  1937. EVRInitError eError;
  1938. m_pVRProperties = (IVRProperties *)VRDriverContext()->GetGenericInterface( IVRProperties_Version, &eError );
  1939. m_propertyHelpers = CVRPropertyHelpers( m_pVRProperties );
  1940. m_hiddenAreaHelpers = CVRHiddenAreaHelpers( m_pVRProperties );
  1941. }
  1942. return m_pVRProperties;
  1943. }
  1944. CVRPropertyHelpers *VRProperties()
  1945. {
  1946. VRPropertiesRaw();
  1947. return &m_propertyHelpers;
  1948. }
  1949. CVRHiddenAreaHelpers *VRHiddenArea()
  1950. {
  1951. VRPropertiesRaw();
  1952. return &m_hiddenAreaHelpers;
  1953. }
  1954. IVRServerDriverHost *VRServerDriverHost()
  1955. {
  1956. if ( m_pVRServerDriverHost == nullptr )
  1957. {
  1958. EVRInitError eError;
  1959. m_pVRServerDriverHost = (IVRServerDriverHost *)VRDriverContext()->GetGenericInterface( IVRServerDriverHost_Version, &eError );
  1960. }
  1961. return m_pVRServerDriverHost;
  1962. }
  1963. IVRWatchdogHost *VRWatchdogHost()
  1964. {
  1965. if ( m_pVRWatchdogHost == nullptr )
  1966. {
  1967. EVRInitError eError;
  1968. m_pVRWatchdogHost = (IVRWatchdogHost *)VRDriverContext()->GetGenericInterface( IVRWatchdogHost_Version, &eError );
  1969. }
  1970. return m_pVRWatchdogHost;
  1971. }
  1972. IVRDriverLog *VRDriverLog()
  1973. {
  1974. if ( m_pVRDriverLog == nullptr )
  1975. {
  1976. EVRInitError eError;
  1977. m_pVRDriverLog = (IVRDriverLog *)VRDriverContext()->GetGenericInterface( IVRDriverLog_Version, &eError );
  1978. }
  1979. return m_pVRDriverLog;
  1980. }
  1981. DriverHandle_t VR_CALLTYPE VRDriverHandle()
  1982. {
  1983. return VRDriverContext()->GetDriverHandle();
  1984. }
  1985. private:
  1986. IVRSettings *m_pVRSettings;
  1987. IVRProperties *m_pVRProperties;
  1988. CVRPropertyHelpers m_propertyHelpers;
  1989. CVRHiddenAreaHelpers m_hiddenAreaHelpers;
  1990. IVRServerDriverHost *m_pVRServerDriverHost;
  1991. IVRWatchdogHost *m_pVRWatchdogHost;
  1992. IVRDriverLog *m_pVRDriverLog;
  1993. };
  1994. inline COpenVRDriverContext &OpenVRInternal_ModuleServerDriverContext()
  1995. {
  1996. static void *ctx[sizeof( COpenVRDriverContext ) / sizeof( void * )];
  1997. return *(COpenVRDriverContext *)ctx; // bypass zero-init constructor
  1998. }
  1999. inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleServerDriverContext().VRSettings(); }
  2000. inline IVRProperties *VR_CALLTYPE VRPropertiesRaw() { return OpenVRInternal_ModuleServerDriverContext().VRPropertiesRaw(); }
  2001. inline CVRPropertyHelpers *VR_CALLTYPE VRProperties() { return OpenVRInternal_ModuleServerDriverContext().VRProperties(); }
  2002. inline CVRHiddenAreaHelpers *VR_CALLTYPE VRHiddenArea() { return OpenVRInternal_ModuleServerDriverContext().VRHiddenArea(); }
  2003. inline IVRDriverLog *VR_CALLTYPE VRDriverLog() { return OpenVRInternal_ModuleServerDriverContext().VRDriverLog(); }
  2004. inline IVRServerDriverHost *VR_CALLTYPE VRServerDriverHost() { return OpenVRInternal_ModuleServerDriverContext().VRServerDriverHost(); }
  2005. inline IVRWatchdogHost *VR_CALLTYPE VRWatchdogHost() { return OpenVRInternal_ModuleServerDriverContext().VRWatchdogHost(); }
  2006. inline DriverHandle_t VR_CALLTYPE VRDriverHandle() { return OpenVRInternal_ModuleServerDriverContext().VRDriverHandle(); }
  2007. inline void COpenVRDriverContext::Clear()
  2008. {
  2009. m_pVRSettings = nullptr;
  2010. m_pVRProperties = nullptr;
  2011. m_pVRServerDriverHost = nullptr;
  2012. m_pVRDriverLog = nullptr;
  2013. m_pVRWatchdogHost = nullptr;
  2014. }
  2015. inline EVRInitError COpenVRDriverContext::InitServer()
  2016. {
  2017. Clear();
  2018. if ( !VRServerDriverHost()
  2019. || !VRSettings()
  2020. || !VRProperties()
  2021. || !VRDriverLog() )
  2022. return VRInitError_Init_InterfaceNotFound;
  2023. return VRInitError_None;
  2024. }
  2025. inline EVRInitError COpenVRDriverContext::InitWatchdog()
  2026. {
  2027. Clear();
  2028. if ( !VRWatchdogHost()
  2029. || !VRSettings()
  2030. || !VRDriverLog() )
  2031. return VRInitError_Init_InterfaceNotFound;
  2032. return VRInitError_None;
  2033. }
  2034. inline EVRInitError InitServerDriverContext( IVRDriverContext *pContext )
  2035. {
  2036. VRDriverContext() = pContext;
  2037. return OpenVRInternal_ModuleServerDriverContext().InitServer();
  2038. }
  2039. inline EVRInitError InitWatchdogDriverContext( IVRDriverContext *pContext )
  2040. {
  2041. VRDriverContext() = pContext;
  2042. return OpenVRInternal_ModuleServerDriverContext().InitWatchdog();
  2043. }
  2044. inline void CleanupDriverContext()
  2045. {
  2046. VRDriverContext() = nullptr;
  2047. OpenVRInternal_ModuleServerDriverContext().Clear();
  2048. }
  2049. #define VR_INIT_SERVER_DRIVER_CONTEXT( pContext ) \
  2050. { \
  2051. vr::EVRInitError eError = vr::InitServerDriverContext( pContext ); \
  2052. if( eError != vr::VRInitError_None ) \
  2053. return eError; \
  2054. }
  2055. #define VR_CLEANUP_SERVER_DRIVER_CONTEXT() \
  2056. vr::CleanupDriverContext();
  2057. #define VR_INIT_WATCHDOG_DRIVER_CONTEXT( pContext ) \
  2058. { \
  2059. vr::EVRInitError eError = vr::InitWatchdogDriverContext( pContext ); \
  2060. if( eError != vr::VRInitError_None ) \
  2061. return eError; \
  2062. }
  2063. #define VR_CLEANUP_WATCHDOG_DRIVER_CONTEXT() \
  2064. vr::CleanupDriverContext();
  2065. }
  2066. // End
  2067. #endif // _OPENVR_DRIVER_API