openvr_driver.h 113 KB

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