openvr.h 141 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089
  1. #pragma once
  2. // openvr.h
  3. //========= Copyright Valve Corporation ============//
  4. // Dynamically generated file. Do not modify this file directly.
  5. #ifndef _OPENVR_API
  6. #define _OPENVR_API
  7. #include <stdint.h>
  8. // vrtypes.h
  9. #ifndef _INCLUDE_VRTYPES_H
  10. #define _INCLUDE_VRTYPES_H
  11. namespace vr
  12. {
  13. #if defined(__linux__) || defined(__APPLE__)
  14. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  15. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  16. // The 64-bit version of gcc has the alignment requirement for these types set to
  17. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  18. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  19. #pragma pack( push, 4 )
  20. #else
  21. #pragma pack( push, 8 )
  22. #endif
  23. typedef void* glSharedTextureHandle_t;
  24. typedef int32_t glInt_t;
  25. typedef uint32_t glUInt_t;
  26. // right-handed system
  27. // +y is up
  28. // +x is to the right
  29. // -z is going away from you
  30. // Distance unit is meters
  31. struct HmdMatrix34_t
  32. {
  33. float m[3][4];
  34. };
  35. struct HmdMatrix44_t
  36. {
  37. float m[4][4];
  38. };
  39. struct HmdVector3_t
  40. {
  41. float v[3];
  42. };
  43. struct HmdVector4_t
  44. {
  45. float v[4];
  46. };
  47. struct HmdVector3d_t
  48. {
  49. double v[3];
  50. };
  51. struct HmdVector2_t
  52. {
  53. float v[2];
  54. };
  55. struct HmdQuaternion_t
  56. {
  57. double w, x, y, z;
  58. };
  59. struct HmdColor_t
  60. {
  61. float r, g, b, a;
  62. };
  63. struct HmdQuad_t
  64. {
  65. HmdVector3_t vCorners[ 4 ];
  66. };
  67. struct HmdRect2_t
  68. {
  69. HmdVector2_t vTopLeft;
  70. HmdVector2_t vBottomRight;
  71. };
  72. /** Used to return the post-distortion UVs for each color channel.
  73. * UVs range from 0 to 1 with 0,0 in the upper left corner of the
  74. * source render target. The 0,0 to 1,1 range covers a single eye. */
  75. struct DistortionCoordinates_t
  76. {
  77. float rfRed[2];
  78. float rfGreen[2];
  79. float rfBlue[2];
  80. };
  81. enum EVREye
  82. {
  83. Eye_Left = 0,
  84. Eye_Right = 1
  85. };
  86. enum EGraphicsAPIConvention
  87. {
  88. API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane
  89. API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane
  90. };
  91. enum EColorSpace
  92. {
  93. ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
  94. ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
  95. ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
  96. };
  97. struct Texture_t
  98. {
  99. void* handle; // Native d3d texture pointer or GL texture id.
  100. EGraphicsAPIConvention eType;
  101. EColorSpace eColorSpace;
  102. };
  103. enum ETrackingResult
  104. {
  105. TrackingResult_Uninitialized = 1,
  106. TrackingResult_Calibrating_InProgress = 100,
  107. TrackingResult_Calibrating_OutOfRange = 101,
  108. TrackingResult_Running_OK = 200,
  109. TrackingResult_Running_OutOfRange = 201,
  110. };
  111. static const uint32_t k_unTrackingStringSize = 32;
  112. static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
  113. /** Used to pass device IDs to API calls */
  114. typedef uint32_t TrackedDeviceIndex_t;
  115. static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
  116. static const uint32_t k_unMaxTrackedDeviceCount = 16;
  117. static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
  118. static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
  119. /** Describes what kind of object is being tracked at a given ID */
  120. enum ETrackedDeviceClass
  121. {
  122. TrackedDeviceClass_Invalid = 0, // the ID was not valid.
  123. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
  124. TrackedDeviceClass_Controller = 2, // Tracked controllers
  125. TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
  126. TrackedDeviceClass_Other = 1000,
  127. };
  128. /** Describes what specific role associated with a tracked device */
  129. enum ETrackedControllerRole
  130. {
  131. TrackedControllerRole_Invalid = 0, // Invalid value for controller type
  132. TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
  133. TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
  134. };
  135. /** describes a single pose for a tracked object */
  136. struct TrackedDevicePose_t
  137. {
  138. HmdMatrix34_t mDeviceToAbsoluteTracking;
  139. HmdVector3_t vVelocity; // velocity in tracker space in m/s
  140. HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
  141. ETrackingResult eTrackingResult;
  142. bool bPoseIsValid;
  143. // This indicates that there is a device connected for this spot in the pose array.
  144. // It could go from true to false if the user unplugs the device.
  145. bool bDeviceIsConnected;
  146. };
  147. /** Identifies which style of tracking origin the application wants to use
  148. * for the poses it is requesting */
  149. enum ETrackingUniverseOrigin
  150. {
  151. TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
  152. TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
  153. TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. You probably don't want this one.
  154. };
  155. /** Each entry in this enum represents a property that can be retrieved about a
  156. * tracked device. Many fields are only valid for one ETrackedDeviceClass. */
  157. enum ETrackedDeviceProperty
  158. {
  159. // general properties that apply to all device classes
  160. Prop_TrackingSystemName_String = 1000,
  161. Prop_ModelNumber_String = 1001,
  162. Prop_SerialNumber_String = 1002,
  163. Prop_RenderModelName_String = 1003,
  164. Prop_WillDriftInYaw_Bool = 1004,
  165. Prop_ManufacturerName_String = 1005,
  166. Prop_TrackingFirmwareVersion_String = 1006,
  167. Prop_HardwareRevision_String = 1007,
  168. Prop_AllWirelessDongleDescriptions_String = 1008,
  169. Prop_ConnectedWirelessDongle_String = 1009,
  170. Prop_DeviceIsWireless_Bool = 1010,
  171. Prop_DeviceIsCharging_Bool = 1011,
  172. Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
  173. Prop_StatusDisplayTransform_Matrix34 = 1013,
  174. Prop_Firmware_UpdateAvailable_Bool = 1014,
  175. Prop_Firmware_ManualUpdate_Bool = 1015,
  176. Prop_Firmware_ManualUpdateURL_String = 1016,
  177. Prop_HardwareRevision_Uint64 = 1017,
  178. Prop_FirmwareVersion_Uint64 = 1018,
  179. Prop_FPGAVersion_Uint64 = 1019,
  180. Prop_VRCVersion_Uint64 = 1020,
  181. Prop_RadioVersion_Uint64 = 1021,
  182. Prop_DongleVersion_Uint64 = 1022,
  183. Prop_BlockServerShutdown_Bool = 1023,
  184. Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
  185. Prop_ContainsProximitySensor_Bool = 1025,
  186. Prop_DeviceProvidesBatteryStatus_Bool = 1026,
  187. Prop_DeviceCanPowerOff_Bool = 1027,
  188. Prop_Firmware_ProgrammingTarget_String = 1028,
  189. Prop_DeviceClass_Int32 = 1029,
  190. Prop_HasCamera_Bool = 1030,
  191. Prop_DriverVersion_String = 1031,
  192. Prop_Firmware_ForceUpdateRequired_Bool = 1032,
  193. // Properties that are unique to TrackedDeviceClass_HMD
  194. Prop_ReportsTimeSinceVSync_Bool = 2000,
  195. Prop_SecondsFromVsyncToPhotons_Float = 2001,
  196. Prop_DisplayFrequency_Float = 2002,
  197. Prop_UserIpdMeters_Float = 2003,
  198. Prop_CurrentUniverseId_Uint64 = 2004,
  199. Prop_PreviousUniverseId_Uint64 = 2005,
  200. Prop_DisplayFirmwareVersion_Uint64 = 2006,
  201. Prop_IsOnDesktop_Bool = 2007,
  202. Prop_DisplayMCType_Int32 = 2008,
  203. Prop_DisplayMCOffset_Float = 2009,
  204. Prop_DisplayMCScale_Float = 2010,
  205. Prop_EdidVendorID_Int32 = 2011,
  206. Prop_DisplayMCImageLeft_String = 2012,
  207. Prop_DisplayMCImageRight_String = 2013,
  208. Prop_DisplayGCBlackClamp_Float = 2014,
  209. Prop_EdidProductID_Int32 = 2015,
  210. Prop_CameraToHeadTransform_Matrix34 = 2016,
  211. Prop_DisplayGCType_Int32 = 2017,
  212. Prop_DisplayGCOffset_Float = 2018,
  213. Prop_DisplayGCScale_Float = 2019,
  214. Prop_DisplayGCPrescale_Float = 2020,
  215. Prop_DisplayGCImage_String = 2021,
  216. Prop_LensCenterLeftU_Float = 2022,
  217. Prop_LensCenterLeftV_Float = 2023,
  218. Prop_LensCenterRightU_Float = 2024,
  219. Prop_LensCenterRightV_Float = 2025,
  220. Prop_UserHeadToEyeDepthMeters_Float = 2026,
  221. Prop_CameraFirmwareVersion_Uint64 = 2027,
  222. Prop_CameraFirmwareDescription_String = 2028,
  223. Prop_DisplayFPGAVersion_Uint64 = 2029,
  224. Prop_DisplayBootloaderVersion_Uint64 = 2030,
  225. Prop_DisplayHardwareVersion_Uint64 = 2031,
  226. Prop_AudioFirmwareVersion_Uint64 = 2032,
  227. Prop_CameraCompatibilityMode_Int32 = 2033,
  228. Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
  229. Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
  230. // Properties that are unique to TrackedDeviceClass_Controller
  231. Prop_AttachedDeviceId_String = 3000,
  232. Prop_SupportedButtons_Uint64 = 3001,
  233. Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
  234. Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
  235. Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
  236. Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
  237. Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
  238. // Properties that are unique to TrackedDeviceClass_TrackingReference
  239. Prop_FieldOfViewLeftDegrees_Float = 4000,
  240. Prop_FieldOfViewRightDegrees_Float = 4001,
  241. Prop_FieldOfViewTopDegrees_Float = 4002,
  242. Prop_FieldOfViewBottomDegrees_Float = 4003,
  243. Prop_TrackingRangeMinimumMeters_Float = 4004,
  244. Prop_TrackingRangeMaximumMeters_Float = 4005,
  245. Prop_ModeLabel_String = 4006,
  246. // Vendors are free to expose private debug data in this reserved region
  247. Prop_VendorSpecific_Reserved_Start = 10000,
  248. Prop_VendorSpecific_Reserved_End = 10999,
  249. };
  250. /** No string property will ever be longer than this length */
  251. static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
  252. /** Used to return errors that occur when reading properties. */
  253. enum ETrackedPropertyError
  254. {
  255. TrackedProp_Success = 0,
  256. TrackedProp_WrongDataType = 1,
  257. TrackedProp_WrongDeviceClass = 2,
  258. TrackedProp_BufferTooSmall = 3,
  259. TrackedProp_UnknownProperty = 4,
  260. TrackedProp_InvalidDevice = 5,
  261. TrackedProp_CouldNotContactServer = 6,
  262. TrackedProp_ValueNotProvidedByDevice = 7,
  263. TrackedProp_StringExceedsMaximumLength = 8,
  264. TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
  265. };
  266. /** Allows the application to control what part of the provided texture will be used in the
  267. * frame buffer. */
  268. struct VRTextureBounds_t
  269. {
  270. float uMin, vMin;
  271. float uMax, vMax;
  272. };
  273. /** Allows the applicaiton to control how scene textures are used by the compositor when calling Submit. */
  274. enum EVRSubmitFlags
  275. {
  276. // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
  277. Submit_Default = 0x00,
  278. // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
  279. // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
  280. // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
  281. Submit_LensDistortionAlreadyApplied = 0x01,
  282. // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
  283. Submit_GlRenderBuffer = 0x02,
  284. // If you application receives a screenshot request, submit with this flag to let the compositor this submission
  285. // is in the response to the screenshot
  286. Submit_Screenshot = 0x04
  287. };
  288. /** Status of the overall system or tracked objects */
  289. enum EVRState
  290. {
  291. VRState_Undefined = -1,
  292. VRState_Off = 0,
  293. VRState_Searching = 1,
  294. VRState_Searching_Alert = 2,
  295. VRState_Ready = 3,
  296. VRState_Ready_Alert = 4,
  297. VRState_NotReady = 5,
  298. VRState_Standby = 6,
  299. };
  300. /** The types of events that could be posted (and what the parameters mean for each event type) */
  301. enum EVREventType
  302. {
  303. VREvent_None = 0,
  304. VREvent_TrackedDeviceActivated = 100,
  305. VREvent_TrackedDeviceDeactivated = 101,
  306. VREvent_TrackedDeviceUpdated = 102,
  307. VREvent_TrackedDeviceUserInteractionStarted = 103,
  308. VREvent_TrackedDeviceUserInteractionEnded = 104,
  309. VREvent_IpdChanged = 105,
  310. VREvent_EnterStandbyMode = 106,
  311. VREvent_LeaveStandbyMode = 107,
  312. VREvent_TrackedDeviceRoleChanged = 108,
  313. VREvent_ButtonPress = 200, // data is controller
  314. VREvent_ButtonUnpress = 201, // data is controller
  315. VREvent_ButtonTouch = 202, // data is controller
  316. VREvent_ButtonUntouch = 203, // data is controller
  317. VREvent_MouseMove = 300, // data is mouse
  318. VREvent_MouseButtonDown = 301, // data is mouse
  319. VREvent_MouseButtonUp = 302, // data is mouse
  320. VREvent_FocusEnter = 303, // data is overlay
  321. VREvent_FocusLeave = 304, // data is overlay
  322. VREvent_Scroll = 305, // data is mouse
  323. VREvent_TouchPadMove = 306, // data is mouse
  324. VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
  325. VREvent_InputFocusReleased = 401, // data is process DEPRECATED
  326. VREvent_SceneFocusLost = 402, // data is process
  327. VREvent_SceneFocusGained = 403, // data is process
  328. VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
  329. VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
  330. VREvent_InputFocusChanged = 406, // data is process
  331. VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
  332. VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
  333. VREvent_OverlayShown = 500,
  334. VREvent_OverlayHidden = 501,
  335. VREvent_DashboardActivated = 502,
  336. VREvent_DashboardDeactivated = 503,
  337. VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
  338. VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
  339. VREvent_ResetDashboard = 506, // Send to the overlay manager
  340. VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
  341. VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
  342. VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
  343. VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
  344. VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
  345. VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
  346. VREvent_OverlaySharedTextureChanged = 513,
  347. VREvent_DashboardGuideButtonDown = 514,
  348. VREvent_DashboardGuideButtonUp = 515,
  349. VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
  350. // Screenshot API
  351. VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
  352. VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
  353. VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
  354. VREvent_Notification_Shown = 600,
  355. VREvent_Notification_Hidden = 601,
  356. VREvent_Notification_BeginInteraction = 602,
  357. VREvent_Notification_Destroyed = 603,
  358. VREvent_Quit = 700, // data is process
  359. VREvent_ProcessQuit = 701, // data is process
  360. VREvent_QuitAborted_UserPrompt = 702, // data is process
  361. VREvent_QuitAcknowledged = 703, // data is process
  362. VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
  363. VREvent_ChaperoneDataHasChanged = 800,
  364. VREvent_ChaperoneUniverseHasChanged = 801,
  365. VREvent_ChaperoneTempDataHasChanged = 802,
  366. VREvent_ChaperoneSettingsHaveChanged = 803,
  367. VREvent_SeatedZeroPoseReset = 804,
  368. VREvent_AudioSettingsHaveChanged = 820,
  369. VREvent_BackgroundSettingHasChanged = 850,
  370. VREvent_CameraSettingsHaveChanged = 851,
  371. VREvent_ReprojectionSettingHasChanged = 852,
  372. VREvent_ModelSkinSettingsHaveChanged = 853,
  373. VREvent_EnvironmentSettingsHaveChanged = 854,
  374. VREvent_StatusUpdate = 900,
  375. VREvent_MCImageUpdated = 1000,
  376. VREvent_FirmwareUpdateStarted = 1100,
  377. VREvent_FirmwareUpdateFinished = 1101,
  378. VREvent_KeyboardClosed = 1200,
  379. VREvent_KeyboardCharInput = 1201,
  380. VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
  381. VREvent_ApplicationTransitionStarted = 1300,
  382. VREvent_ApplicationTransitionAborted = 1301,
  383. VREvent_ApplicationTransitionNewAppStarted = 1302,
  384. VREvent_ApplicationListUpdated = 1303,
  385. VREvent_Compositor_MirrorWindowShown = 1400,
  386. VREvent_Compositor_MirrorWindowHidden = 1401,
  387. VREvent_Compositor_ChaperoneBoundsShown = 1410,
  388. VREvent_Compositor_ChaperoneBoundsHidden = 1411,
  389. VREvent_TrackedCamera_StartVideoStream = 1500,
  390. VREvent_TrackedCamera_StopVideoStream = 1501,
  391. VREvent_TrackedCamera_PauseVideoStream = 1502,
  392. VREvent_TrackedCamera_ResumeVideoStream = 1503,
  393. VREvent_PerformanceTest_EnableCapture = 1600,
  394. VREvent_PerformanceTest_DisableCapture = 1601,
  395. VREvent_PerformanceTest_FidelityLevel = 1602,
  396. // Vendors are free to expose private events in this reserved region
  397. VREvent_VendorSpecific_Reserved_Start = 10000,
  398. VREvent_VendorSpecific_Reserved_End = 19999,
  399. };
  400. /** Level of Hmd activity */
  401. enum EDeviceActivityLevel
  402. {
  403. k_EDeviceActivityLevel_Unknown = -1,
  404. k_EDeviceActivityLevel_Idle = 0,
  405. k_EDeviceActivityLevel_UserInteraction = 1,
  406. k_EDeviceActivityLevel_UserInteraction_Timeout = 2,
  407. k_EDeviceActivityLevel_Standby = 3,
  408. };
  409. /** VR controller button and axis IDs */
  410. enum EVRButtonId
  411. {
  412. k_EButton_System = 0,
  413. k_EButton_ApplicationMenu = 1,
  414. k_EButton_Grip = 2,
  415. k_EButton_DPad_Left = 3,
  416. k_EButton_DPad_Up = 4,
  417. k_EButton_DPad_Right = 5,
  418. k_EButton_DPad_Down = 6,
  419. k_EButton_A = 7,
  420. k_EButton_Axis0 = 32,
  421. k_EButton_Axis1 = 33,
  422. k_EButton_Axis2 = 34,
  423. k_EButton_Axis3 = 35,
  424. k_EButton_Axis4 = 36,
  425. // aliases for well known controllers
  426. k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
  427. k_EButton_SteamVR_Trigger = k_EButton_Axis1,
  428. k_EButton_Dashboard_Back = k_EButton_Grip,
  429. k_EButton_Max = 64
  430. };
  431. inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
  432. /** used for controller button events */
  433. struct VREvent_Controller_t
  434. {
  435. uint32_t button; // EVRButtonId enum
  436. };
  437. /** used for simulated mouse events in overlay space */
  438. enum EVRMouseButton
  439. {
  440. VRMouseButton_Left = 0x0001,
  441. VRMouseButton_Right = 0x0002,
  442. VRMouseButton_Middle = 0x0004,
  443. };
  444. /** used for simulated mouse events in overlay space */
  445. struct VREvent_Mouse_t
  446. {
  447. float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
  448. uint32_t button; // EVRMouseButton enum
  449. };
  450. /** used for simulated mouse wheel scroll in overlay space */
  451. struct VREvent_Scroll_t
  452. {
  453. float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
  454. uint32_t repeatCount;
  455. };
  456. /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
  457. is on the touchpad (or just released from it)
  458. **/
  459. struct VREvent_TouchPadMove_t
  460. {
  461. // true if the users finger is detected on the touch pad
  462. bool bFingerDown;
  463. // How long the finger has been down in seconds
  464. float flSecondsFingerDown;
  465. // These values indicate the starting finger position (so you can do some basic swipe stuff)
  466. float fValueXFirst;
  467. float fValueYFirst;
  468. // This is the raw sampled coordinate without deadzoning
  469. float fValueXRaw;
  470. float fValueYRaw;
  471. };
  472. /** notification related events. Details will still change at this point */
  473. struct VREvent_Notification_t
  474. {
  475. uint64_t ulUserValue;
  476. uint32_t notificationId;
  477. };
  478. /** Used for events about processes */
  479. struct VREvent_Process_t
  480. {
  481. uint32_t pid;
  482. uint32_t oldPid;
  483. bool bForced;
  484. };
  485. /** Used for a few events about overlays */
  486. struct VREvent_Overlay_t
  487. {
  488. uint64_t overlayHandle;
  489. };
  490. /** Used for a few events about overlays */
  491. struct VREvent_Status_t
  492. {
  493. uint32_t statusState; // EVRState enum
  494. };
  495. /** Used for keyboard events **/
  496. struct VREvent_Keyboard_t
  497. {
  498. char cNewInput[8]; // Up to 11 bytes of new input
  499. uint64_t uUserValue; // Possible flags about the new input
  500. };
  501. struct VREvent_Ipd_t
  502. {
  503. float ipdMeters;
  504. };
  505. struct VREvent_Chaperone_t
  506. {
  507. uint64_t m_nPreviousUniverse;
  508. uint64_t m_nCurrentUniverse;
  509. };
  510. /** Not actually used for any events */
  511. struct VREvent_Reserved_t
  512. {
  513. uint64_t reserved0;
  514. uint64_t reserved1;
  515. };
  516. struct VREvent_PerformanceTest_t
  517. {
  518. uint32_t m_nFidelityLevel;
  519. };
  520. struct VREvent_SeatedZeroPoseReset_t
  521. {
  522. bool bResetBySystemMenu;
  523. };
  524. /** If you change this you must manually update openvr_interop.cs.py */
  525. typedef union
  526. {
  527. VREvent_Reserved_t reserved;
  528. VREvent_Controller_t controller;
  529. VREvent_Mouse_t mouse;
  530. VREvent_Scroll_t scroll;
  531. VREvent_Process_t process;
  532. VREvent_Notification_t notification;
  533. VREvent_Overlay_t overlay;
  534. VREvent_Status_t status;
  535. VREvent_Keyboard_t keyboard;
  536. VREvent_Ipd_t ipd;
  537. VREvent_Chaperone_t chaperone;
  538. VREvent_PerformanceTest_t performanceTest;
  539. VREvent_TouchPadMove_t touchPadMove;
  540. VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
  541. } VREvent_Data_t;
  542. /** An event posted by the server to all running applications */
  543. struct VREvent_t
  544. {
  545. uint32_t eventType; // EVREventType enum
  546. TrackedDeviceIndex_t trackedDeviceIndex;
  547. float eventAgeSeconds;
  548. // event data must be the end of the struct as its size is variable
  549. VREvent_Data_t data;
  550. };
  551. /** The mesh to draw into the stencil (or depth) buffer to perform
  552. * early stencil (or depth) kills of pixels that will never appear on the HMD.
  553. * This mesh draws on all the pixels that will be hidden after distortion.
  554. *
  555. * If the HMD does not provide a visible area mesh pVertexData will be
  556. * NULL and unTriangleCount will be 0. */
  557. struct HiddenAreaMesh_t
  558. {
  559. const HmdVector2_t *pVertexData;
  560. uint32_t unTriangleCount;
  561. };
  562. /** Identifies what kind of axis is on the controller at index n. Read this type
  563. * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
  564. */
  565. enum EVRControllerAxisType
  566. {
  567. k_eControllerAxis_None = 0,
  568. k_eControllerAxis_TrackPad = 1,
  569. k_eControllerAxis_Joystick = 2,
  570. k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
  571. };
  572. /** contains information about one axis on the controller */
  573. struct VRControllerAxis_t
  574. {
  575. float x; // Ranges from -1.0 to 1.0 for joysticks and track pads. Ranges from 0.0 to 1.0 for triggers were 0 is fully released.
  576. float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
  577. };
  578. /** the number of axes in the controller state */
  579. static const uint32_t k_unControllerStateAxisCount = 5;
  580. /** Holds all the state of a controller at one moment in time. */
  581. struct VRControllerState001_t
  582. {
  583. // If packet num matches that on your prior call, then the controller state hasn't been changed since
  584. // your last call and there is no need to process it
  585. uint32_t unPacketNum;
  586. // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
  587. uint64_t ulButtonPressed;
  588. uint64_t ulButtonTouched;
  589. // Axis data for the controller's analog inputs
  590. VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
  591. };
  592. typedef VRControllerState001_t VRControllerState_t;
  593. /** determines how to provide output to the application of various event processing functions. */
  594. enum EVRControllerEventOutputType
  595. {
  596. ControllerEventOutput_OSEvents = 0,
  597. ControllerEventOutput_VREvents = 1,
  598. };
  599. /** Collision Bounds Style */
  600. enum ECollisionBoundsStyle
  601. {
  602. COLLISION_BOUNDS_STYLE_BEGINNER = 0,
  603. COLLISION_BOUNDS_STYLE_INTERMEDIATE,
  604. COLLISION_BOUNDS_STYLE_SQUARES,
  605. COLLISION_BOUNDS_STYLE_ADVANCED,
  606. COLLISION_BOUNDS_STYLE_NONE,
  607. COLLISION_BOUNDS_STYLE_COUNT
  608. };
  609. /** Allows the application to customize how the overlay appears in the compositor */
  610. struct Compositor_OverlaySettings
  611. {
  612. uint32_t size; // sizeof(Compositor_OverlaySettings)
  613. bool curved, antialias;
  614. float scale, distance, alpha;
  615. float uOffset, vOffset, uScale, vScale;
  616. float gridDivs, gridWidth, gridScale;
  617. HmdMatrix44_t transform;
  618. };
  619. /** used to refer to a single VR overlay */
  620. typedef uint64_t VROverlayHandle_t;
  621. static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
  622. /** Errors that can occur around VR overlays */
  623. enum EVROverlayError
  624. {
  625. VROverlayError_None = 0,
  626. VROverlayError_UnknownOverlay = 10,
  627. VROverlayError_InvalidHandle = 11,
  628. VROverlayError_PermissionDenied = 12,
  629. VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
  630. VROverlayError_WrongVisibilityType = 14,
  631. VROverlayError_KeyTooLong = 15,
  632. VROverlayError_NameTooLong = 16,
  633. VROverlayError_KeyInUse = 17,
  634. VROverlayError_WrongTransformType = 18,
  635. VROverlayError_InvalidTrackedDevice = 19,
  636. VROverlayError_InvalidParameter = 20,
  637. VROverlayError_ThumbnailCantBeDestroyed = 21,
  638. VROverlayError_ArrayTooSmall = 22,
  639. VROverlayError_RequestFailed = 23,
  640. VROverlayError_InvalidTexture = 24,
  641. VROverlayError_UnableToLoadFile = 25,
  642. VROVerlayError_KeyboardAlreadyInUse = 26,
  643. VROverlayError_NoNeighbor = 27,
  644. };
  645. /** enum values to pass in to VR_Init to identify whether the application will
  646. * draw a 3D scene. */
  647. enum EVRApplicationType
  648. {
  649. VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
  650. VRApplication_Scene = 1, // Application will submit 3D frames
  651. VRApplication_Overlay = 2, // Application only interacts with overlays
  652. VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
  653. // keep it running if everything else quits.
  654. VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
  655. // interfaces (like IVRSettings and IVRApplications) but not hardware.
  656. VRApplication_VRMonitor = 5, // Reserved for vrmonitor
  657. };
  658. /** error codes for firmware */
  659. enum EVRFirmwareError
  660. {
  661. VRFirmwareError_None = 0,
  662. VRFirmwareError_Success = 1,
  663. VRFirmwareError_Fail = 2,
  664. };
  665. /** error codes for notifications */
  666. enum EVRNotificationError
  667. {
  668. VRNotificationError_OK = 0,
  669. VRNotificationError_InvalidNotificationId = 100,
  670. VRNotificationError_NotificationQueueFull = 101,
  671. VRNotificationError_InvalidOverlayHandle = 102,
  672. VRNotificationError_SystemWithUserValueAlreadyExists = 103,
  673. };
  674. /** error codes returned by Vr_Init */
  675. // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
  676. enum EVRInitError
  677. {
  678. VRInitError_None = 0,
  679. VRInitError_Unknown = 1,
  680. VRInitError_Init_InstallationNotFound = 100,
  681. VRInitError_Init_InstallationCorrupt = 101,
  682. VRInitError_Init_VRClientDLLNotFound = 102,
  683. VRInitError_Init_FileNotFound = 103,
  684. VRInitError_Init_FactoryNotFound = 104,
  685. VRInitError_Init_InterfaceNotFound = 105,
  686. VRInitError_Init_InvalidInterface = 106,
  687. VRInitError_Init_UserConfigDirectoryInvalid = 107,
  688. VRInitError_Init_HmdNotFound = 108,
  689. VRInitError_Init_NotInitialized = 109,
  690. VRInitError_Init_PathRegistryNotFound = 110,
  691. VRInitError_Init_NoConfigPath = 111,
  692. VRInitError_Init_NoLogPath = 112,
  693. VRInitError_Init_PathRegistryNotWritable = 113,
  694. VRInitError_Init_AppInfoInitFailed = 114,
  695. VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
  696. VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
  697. VRInitError_Init_AnotherAppLaunching = 117,
  698. VRInitError_Init_SettingsInitFailed = 118,
  699. VRInitError_Init_ShuttingDown = 119,
  700. VRInitError_Init_TooManyObjects = 120,
  701. VRInitError_Init_NoServerForBackgroundApp = 121,
  702. VRInitError_Init_NotSupportedWithCompositor = 122,
  703. VRInitError_Init_NotAvailableToUtilityApps = 123,
  704. VRInitError_Init_Internal = 124,
  705. VRInitError_Driver_Failed = 200,
  706. VRInitError_Driver_Unknown = 201,
  707. VRInitError_Driver_HmdUnknown = 202,
  708. VRInitError_Driver_NotLoaded = 203,
  709. VRInitError_Driver_RuntimeOutOfDate = 204,
  710. VRInitError_Driver_HmdInUse = 205,
  711. VRInitError_Driver_NotCalibrated = 206,
  712. VRInitError_Driver_CalibrationInvalid = 207,
  713. VRInitError_Driver_HmdDisplayNotFound = 208,
  714. VRInitError_IPC_ServerInitFailed = 300,
  715. VRInitError_IPC_ConnectFailed = 301,
  716. VRInitError_IPC_SharedStateInitFailed = 302,
  717. VRInitError_IPC_CompositorInitFailed = 303,
  718. VRInitError_IPC_MutexInitFailed = 304,
  719. VRInitError_IPC_Failed = 305,
  720. VRInitError_Compositor_Failed = 400,
  721. VRInitError_Compositor_D3D11HardwareRequired = 401,
  722. VRInitError_Compositor_FirmwareRequiresUpdate = 402,
  723. VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
  724. VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
  725. VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
  726. VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
  727. VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
  728. VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
  729. VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
  730. VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
  731. VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
  732. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
  733. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
  734. VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
  735. VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
  736. VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
  737. VRInitError_Steam_SteamInstallationNotFound = 2000,
  738. };
  739. enum EVRScreenshotType
  740. {
  741. VRScreenshotType_None = 0,
  742. VRScreenshotType_Mono = 1, // left eye only
  743. VRScreenshotType_Stereo = 2,
  744. VRScreenshotType_Cubemap = 3,
  745. VRScreenshotType_StereoPanorama = 4
  746. };
  747. enum EVRTrackedCameraError
  748. {
  749. VRTrackedCameraError_None = 0,
  750. VRTrackedCameraError_OperationFailed = 100,
  751. VRTrackedCameraError_InvalidHandle = 101,
  752. VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
  753. VRTrackedCameraError_OutOfHandles = 103,
  754. VRTrackedCameraError_IPCFailure = 104,
  755. VRTrackedCameraError_NotSupportedForThisDevice = 105,
  756. VRTrackedCameraError_SharedMemoryFailure = 106,
  757. VRTrackedCameraError_FrameBufferingFailure = 107,
  758. VRTrackedCameraError_StreamSetupFailure = 108,
  759. VRTrackedCameraError_InvalidGLTextureId = 109,
  760. VRTrackedCameraError_InvalidSharedTextureHandle = 110,
  761. VRTrackedCameraError_FailedToGetGLTextureId = 111,
  762. VRTrackedCameraError_SharedTextureFailure = 112,
  763. VRTrackedCameraError_NoFrameAvailable = 113,
  764. VRTrackedCameraError_InvalidArgument = 114,
  765. VRTrackedCameraError_InvalidFrameBufferSize = 115,
  766. };
  767. enum EVRTrackedCameraFrameType
  768. {
  769. VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
  770. VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
  771. VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
  772. MAX_CAMERA_FRAME_TYPES
  773. };
  774. typedef void* TrackedCameraHandle_t;
  775. #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
  776. struct CameraVideoStreamFrameHeader_t
  777. {
  778. EVRTrackedCameraFrameType eFrameType;
  779. uint32_t nWidth;
  780. uint32_t nHeight;
  781. uint32_t nBytesPerPixel;
  782. uint32_t nFrameSequence;
  783. TrackedDevicePose_t standingTrackedDevicePose;
  784. };
  785. #pragma pack( pop )
  786. // figure out how to import from the VR API dll
  787. #if defined(_WIN32)
  788. #ifdef VR_API_EXPORT
  789. #define VR_INTERFACE extern "C" __declspec( dllexport )
  790. #else
  791. #define VR_INTERFACE extern "C" __declspec( dllimport )
  792. #endif
  793. #elif defined(GNUC) || defined(COMPILER_GCC) || defined(__APPLE__)
  794. #ifdef VR_API_EXPORT
  795. #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
  796. #else
  797. #define VR_INTERFACE extern "C"
  798. #endif
  799. #else
  800. #error "Unsupported Platform."
  801. #endif
  802. #if defined( _WIN32 )
  803. #define VR_CALLTYPE __cdecl
  804. #else
  805. #define VR_CALLTYPE
  806. #endif
  807. } // namespace vr
  808. #endif // _INCLUDE_VRTYPES_H
  809. // vrannotation.h
  810. #ifdef API_GEN
  811. # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
  812. #else
  813. # define VR_CLANG_ATTR(ATTR)
  814. #endif
  815. #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
  816. #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
  817. #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
  818. #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
  819. #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
  820. #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
  821. #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
  822. #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
  823. #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
  824. #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
  825. #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
  826. // ivrsystem.h
  827. namespace vr
  828. {
  829. class IVRSystem
  830. {
  831. public:
  832. // ------------------------------------
  833. // Display Methods
  834. // ------------------------------------
  835. /** Suggested size for the intermediate render target that the distortion pulls from. */
  836. virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  837. /** The projection matrix for the specified eye */
  838. virtual HmdMatrix44_t GetProjectionMatrix( EVREye eEye, float fNearZ, float fFarZ, EGraphicsAPIConvention eProjType ) = 0;
  839. /** The components necessary to build your own projection matrix in case your
  840. * application is doing something fancy like infinite Z */
  841. virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
  842. /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
  843. * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
  844. virtual DistortionCoordinates_t ComputeDistortion( EVREye eEye, float fU, float fV ) = 0;
  845. /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head
  846. * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection.
  847. * Normally View and Eye^-1 will be multiplied together and treated as View in your application.
  848. */
  849. virtual HmdMatrix34_t GetEyeToHeadTransform( EVREye eEye ) = 0;
  850. /** Returns the number of elapsed seconds since the last recorded vsync event. This
  851. * will come from a vsync timer event in the timer if possible or from the application-reported
  852. * time if that is not available. If no vsync times are available the function will
  853. * return zero for vsync time and frame counter and return false from the method. */
  854. virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0;
  855. /** [D3D9 Only]
  856. * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
  857. * a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
  858. */
  859. virtual int32_t GetD3D9AdapterIndex() = 0;
  860. /** [D3D10/11 Only]
  861. * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs
  862. * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
  863. */
  864. virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex ) = 0;
  865. // ------------------------------------
  866. // Display Mode methods
  867. // ------------------------------------
  868. /** Use to determine if the headset display is part of the desktop (i.e. extended) or hidden (i.e. direct mode). */
  869. virtual bool IsDisplayOnDesktop() = 0;
  870. /** Set the display visibility (true = extended, false = direct mode). Return value of true indicates that the change was successful. */
  871. virtual bool SetDisplayVisibility( bool bIsVisibleOnDesktop ) = 0;
  872. // ------------------------------------
  873. // Tracking Methods
  874. // ------------------------------------
  875. /** The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
  876. * future. Pass 0 to get the state at the instant the method is called. Most of the time the application should
  877. * calculate the time until the photons will be emitted from the display and pass that time into the method.
  878. *
  879. * This is roughly analogous to the inverse of the view matrix in most applications, though
  880. * many games will need to do some additional rotation or translation on top of the rotation
  881. * and translation provided by the head pose.
  882. *
  883. * For devices where bPoseIsValid is true the application can use the pose to position the device
  884. * in question. The provided array can be any size up to k_unMaxTrackedDeviceCount.
  885. *
  886. * Seated experiences should call this method with TrackingUniverseSeated and receive poses relative
  887. * to the seated zero pose. Standing experiences should call this method with TrackingUniverseStanding
  888. * and receive poses relative to the Chaperone Play Area. TrackingUniverseRawAndUncalibrated should
  889. * probably not be used unless the application is the Chaperone calibration tool itself, but will provide
  890. * poses relative to the hardware-specific coordinate system in the driver.
  891. */
  892. virtual void GetDeviceToAbsoluteTrackingPose( ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, VR_ARRAY_COUNT(unTrackedDevicePoseArrayCount) TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0;
  893. /** Sets the zero pose for the seated tracker coordinate system to the current position and yaw of the HMD. After
  894. * ResetSeatedZeroPose all GetDeviceToAbsoluteTrackingPose calls that pass TrackingUniverseSeated as the origin
  895. * will be relative to this new zero pose. The new zero coordinate system will not change the fact that the Y axis
  896. * is up in the real world, so the next pose returned from GetDeviceToAbsoluteTrackingPose after a call to
  897. * ResetSeatedZeroPose may not be exactly an identity matrix.
  898. *
  899. * NOTE: This function overrides the user's previously saved seated zero pose and should only be called as the result of a user action.
  900. * Users are also able to set their seated zero pose via the OpenVR Dashboard.
  901. **/
  902. virtual void ResetSeatedZeroPose() = 0;
  903. /** Returns the transform from the seated zero pose to the standing absolute tracking system. This allows
  904. * applications to represent the seated origin to used or transform object positions from one coordinate
  905. * system to the other.
  906. *
  907. * The seated origin may or may not be inside the Play Area or Collision Bounds returned by IVRChaperone. Its position
  908. * depends on what the user has set from the Dashboard settings and previous calls to ResetSeatedZeroPose. */
  909. virtual HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() = 0;
  910. /** Returns the transform from the tracking origin to the standing absolute tracking system. This allows
  911. * applications to convert from raw tracking space to the calibrated standing coordinate system. */
  912. virtual HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose() = 0;
  913. /** Get a sorted array of device indices of a given class of tracked devices (e.g. controllers). Devices are sorted right to left
  914. * relative to the specified tracked device (default: hmd -- pass in -1 for absolute tracking space). Returns the number of devices
  915. * in the list, or the size of the array needed if not large enough. */
  916. virtual uint32_t GetSortedTrackedDeviceIndicesOfClass( ETrackedDeviceClass eTrackedDeviceClass, VR_ARRAY_COUNT(unTrackedDeviceIndexArrayCount) vr::TrackedDeviceIndex_t *punTrackedDeviceIndexArray, uint32_t unTrackedDeviceIndexArrayCount, vr::TrackedDeviceIndex_t unRelativeToTrackedDeviceIndex = k_unTrackedDeviceIndex_Hmd ) = 0;
  917. /** Returns the level of activity on the device. */
  918. virtual EDeviceActivityLevel GetTrackedDeviceActivityLevel( vr::TrackedDeviceIndex_t unDeviceId ) = 0;
  919. /** Convenience utility to apply the specified transform to the specified pose.
  920. * This properly transforms all pose components, including velocity and angular velocity
  921. */
  922. virtual void ApplyTransform( TrackedDevicePose_t *pOutputPose, const TrackedDevicePose_t *pTrackedDevicePose, const HmdMatrix34_t *pTransform ) = 0;
  923. /** Returns the device index associated with a specific role, for example the left hand or the right hand. */
  924. virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole( vr::ETrackedControllerRole unDeviceType ) = 0;
  925. /** Returns the controller type associated with a device index. */
  926. virtual vr::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  927. // ------------------------------------
  928. // Property methods
  929. // ------------------------------------
  930. /** Returns the device class of a tracked device. If there has not been a device connected in this slot
  931. * since the application started this function will return TrackedDevice_Invalid. For previous detected
  932. * devices the function will return the previously observed device class.
  933. *
  934. * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check
  935. * the device class. Every device with something other than TrackedDevice_Invalid is associated with an
  936. * actual tracked device. */
  937. virtual ETrackedDeviceClass GetTrackedDeviceClass( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  938. /** Returns true if there is a device connected in this slot. */
  939. virtual bool IsTrackedDeviceConnected( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  940. /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */
  941. virtual bool GetBoolTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  942. /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */
  943. virtual float GetFloatTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  944. /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */
  945. virtual int32_t GetInt32TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  946. /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */
  947. virtual uint64_t GetUint64TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  948. /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */
  949. virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  950. /** Returns a string property. If the device index is not valid or the property is not a string type this function will
  951. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  952. * null. Strings will generally fit in buffers of k_unTrackingStringSize characters. */
  953. virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0;
  954. /** returns a string that corresponds with the specified property error. The string will be the name
  955. * of the error enum value for all valid error codes */
  956. virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0;
  957. // ------------------------------------
  958. // Event methods
  959. // ------------------------------------
  960. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  961. * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
  962. virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
  963. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  964. * this method returns false. Fills in the pose of the associated tracked device in the provided pose struct.
  965. * This pose will always be older than the call to this function and should not be used to render the device.
  966. uncbVREvent should be the size in bytes of the VREvent_t struct */
  967. virtual bool PollNextEventWithPose( ETrackingUniverseOrigin eOrigin, VREvent_t *pEvent, uint32_t uncbVREvent, vr::TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  968. /** returns the name of an EVREvent enum value */
  969. virtual const char *GetEventTypeNameFromEnum( EVREventType eType ) = 0;
  970. // ------------------------------------
  971. // Rendering helper methods
  972. // ------------------------------------
  973. /** Returns the stencil mesh information for the current HMD. If this HMD does not have a stencil mesh the vertex data and count will be
  974. * NULL and 0 respectively. This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering
  975. * each eye's view. The pixels covered by this mesh will never be seen by the user after the lens distortion is applied and based on visibility to the panels.
  976. * This will improve perf by letting the GPU early-reject pixels the user will never see before running the pixel shader.
  977. * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye.
  978. */
  979. virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye ) = 0;
  980. // ------------------------------------
  981. // Controller methods
  982. // ------------------------------------
  983. /** Fills the supplied struct with the current state of the controller. Returns false if the controller index
  984. * is invalid. */
  985. virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState ) = 0;
  986. /** fills the supplied struct with the current state of the controller and the provided pose with the pose of
  987. * the controller when the controller state was updated most recently. Use this form if you need a precise controller
  988. * pose as input to your application when the user presses or releases a button. */
  989. virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  990. /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller
  991. * and axis combination for 5ms. */
  992. virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0;
  993. /** returns the name of an EVRButtonId enum value */
  994. virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0;
  995. /** returns the name of an EVRControllerAxisType enum value */
  996. virtual const char *GetControllerAxisTypeNameFromEnum( EVRControllerAxisType eAxisType ) = 0;
  997. /** Tells OpenVR that this process wants exclusive access to controller button states and button events. Other apps will be notified that
  998. * they have lost input focus with a VREvent_InputFocusCaptured event. Returns false if input focus could not be captured for
  999. * some reason. */
  1000. virtual bool CaptureInputFocus() = 0;
  1001. /** Tells OpenVR that this process no longer wants exclusive access to button states and button events. Other apps will be notified
  1002. * that input focus has been released with a VREvent_InputFocusReleased event. */
  1003. virtual void ReleaseInputFocus() = 0;
  1004. /** Returns true if input focus is captured by another process. */
  1005. virtual bool IsInputFocusCapturedByAnotherProcess() = 0;
  1006. // ------------------------------------
  1007. // Debug Methods
  1008. // ------------------------------------
  1009. /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k,
  1010. * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated.
  1011. * The size of the response including its terminating null is returned. */
  1012. virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
  1013. // ------------------------------------
  1014. // Firmware methods
  1015. // ------------------------------------
  1016. /** Performs the actual firmware update if applicable.
  1017. * The following events will be sent, if VRFirmwareError_None was returned: VREvent_FirmwareUpdateStarted, VREvent_FirmwareUpdateFinished
  1018. * Use the properties Prop_Firmware_UpdateAvailable_Bool, Prop_Firmware_ManualUpdate_Bool, and Prop_Firmware_ManualUpdateURL_String
  1019. * to figure our whether a firmware update is available, and to figure out whether its a manual update
  1020. * Prop_Firmware_ManualUpdateURL_String should point to an URL describing the manual update process */
  1021. virtual vr::EVRFirmwareError PerformFirmwareUpdate( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1022. // ------------------------------------
  1023. // Application life cycle methods
  1024. // ------------------------------------
  1025. /** Call this to acknowledge to the system that VREvent_Quit has been received and that the process is exiting.
  1026. * This extends the timeout until the process is killed. */
  1027. virtual void AcknowledgeQuit_Exiting() = 0;
  1028. /** Call this to tell the system that the user is being prompted to save data. This
  1029. * halts the timeout and dismisses the dashboard (if it was up). Applications should be sure to actually
  1030. * prompt the user to save and then exit afterward, otherwise the user will be left in a confusing state. */
  1031. virtual void AcknowledgeQuit_UserPrompt() = 0;
  1032. };
  1033. static const char * const IVRSystem_Version = "IVRSystem_012";
  1034. }
  1035. // ivrapplications.h
  1036. namespace vr
  1037. {
  1038. /** Used for all errors reported by the IVRApplications interface */
  1039. enum EVRApplicationError
  1040. {
  1041. VRApplicationError_None = 0,
  1042. VRApplicationError_AppKeyAlreadyExists = 100, // Only one application can use any given key
  1043. VRApplicationError_NoManifest = 101, // the running application does not have a manifest
  1044. VRApplicationError_NoApplication = 102, // No application is running
  1045. VRApplicationError_InvalidIndex = 103,
  1046. VRApplicationError_UnknownApplication = 104, // the application could not be found
  1047. VRApplicationError_IPCFailed = 105, // An IPC failure caused the request to fail
  1048. VRApplicationError_ApplicationAlreadyRunning = 106,
  1049. VRApplicationError_InvalidManifest = 107,
  1050. VRApplicationError_InvalidApplication = 108,
  1051. VRApplicationError_LaunchFailed = 109, // the process didn't start
  1052. VRApplicationError_ApplicationAlreadyStarting = 110, // the system was already starting the same application
  1053. VRApplicationError_LaunchInProgress = 111, // The system was already starting a different application
  1054. VRApplicationError_OldApplicationQuitting = 112,
  1055. VRApplicationError_TransitionAborted = 113,
  1056. VRApplicationError_IsTemplate = 114, // error when you try to call LaunchApplication() on a template type app (use LaunchTemplateApplication)
  1057. VRApplicationError_BufferTooSmall = 200, // The provided buffer was too small to fit the requested data
  1058. VRApplicationError_PropertyNotSet = 201, // The requested property was not set
  1059. VRApplicationError_UnknownProperty = 202,
  1060. VRApplicationError_InvalidParameter = 203,
  1061. };
  1062. /** The maximum length of an application key */
  1063. static const uint32_t k_unMaxApplicationKeyLength = 128;
  1064. /** these are the properties available on applications. */
  1065. enum EVRApplicationProperty
  1066. {
  1067. VRApplicationProperty_Name_String = 0,
  1068. VRApplicationProperty_LaunchType_String = 11,
  1069. VRApplicationProperty_WorkingDirectory_String = 12,
  1070. VRApplicationProperty_BinaryPath_String = 13,
  1071. VRApplicationProperty_Arguments_String = 14,
  1072. VRApplicationProperty_URL_String = 15,
  1073. VRApplicationProperty_Description_String = 50,
  1074. VRApplicationProperty_NewsURL_String = 51,
  1075. VRApplicationProperty_ImagePath_String = 52,
  1076. VRApplicationProperty_Source_String = 53,
  1077. VRApplicationProperty_IsDashboardOverlay_Bool = 60,
  1078. VRApplicationProperty_IsTemplate_Bool = 61,
  1079. VRApplicationProperty_IsInstanced_Bool = 62,
  1080. VRApplicationProperty_LastLaunchTime_Uint64 = 70,
  1081. };
  1082. /** These are states the scene application startup process will go through. */
  1083. enum EVRApplicationTransitionState
  1084. {
  1085. VRApplicationTransition_None = 0,
  1086. VRApplicationTransition_OldAppQuitSent = 10,
  1087. VRApplicationTransition_WaitingForExternalLaunch = 11,
  1088. VRApplicationTransition_NewAppLaunched = 20,
  1089. };
  1090. struct AppOverrideKeys_t
  1091. {
  1092. const char *pchKey;
  1093. const char *pchValue;
  1094. };
  1095. class IVRApplications
  1096. {
  1097. public:
  1098. // --------------- Application management --------------- //
  1099. /** Adds an application manifest to the list to load when building the list of installed applications.
  1100. * Temporary manifests are not automatically loaded */
  1101. virtual EVRApplicationError AddApplicationManifest( const char *pchApplicationManifestFullPath, bool bTemporary = false ) = 0;
  1102. /** Removes an application manifest from the list to load when building the list of installed applications. */
  1103. virtual EVRApplicationError RemoveApplicationManifest( const char *pchApplicationManifestFullPath ) = 0;
  1104. /** Returns true if an application is installed */
  1105. virtual bool IsApplicationInstalled( const char *pchAppKey ) = 0;
  1106. /** Returns the number of applications available in the list */
  1107. virtual uint32_t GetApplicationCount() = 0;
  1108. /** Returns the key of the specified application. The index is at least 0 and is less than the return
  1109. * value of GetApplicationCount(). The buffer should be at least k_unMaxApplicationKeyLength in order to
  1110. * fit the key. */
  1111. virtual EVRApplicationError GetApplicationKeyByIndex( uint32_t unApplicationIndex, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1112. /** Returns the key of the application for the specified Process Id. The buffer should be at least
  1113. * k_unMaxApplicationKeyLength in order to fit the key. */
  1114. virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1115. /** Launches the application. The existing scene application will exit and then the new application will start.
  1116. * This call is not valid for dashboard overlay applications. */
  1117. virtual EVRApplicationError LaunchApplication( const char *pchAppKey ) = 0;
  1118. /** Launches an instance of an application of type template, with its app key being pchNewAppKey (which must be unique) and optionally override sections
  1119. * from the manifest file via AppOverrideKeys_t
  1120. */
  1121. virtual EVRApplicationError LaunchTemplateApplication( const char *pchTemplateAppKey, const char *pchNewAppKey, VR_ARRAY_COUNT( unKeys ) const AppOverrideKeys_t *pKeys, uint32_t unKeys ) = 0;
  1122. /** Launches the dashboard overlay application if it is not already running. This call is only valid for
  1123. * dashboard overlay applications. */
  1124. virtual EVRApplicationError LaunchDashboardOverlay( const char *pchAppKey ) = 0;
  1125. /** Cancel a pending launch for an application */
  1126. virtual bool CancelApplicationLaunch( const char *pchAppKey ) = 0;
  1127. /** Identifies a running application. OpenVR can't always tell which process started in response
  1128. * to a URL. This function allows a URL handler (or the process itself) to identify the app key
  1129. * for the now running application. Passing a process ID of 0 identifies the calling process.
  1130. * The application must be one that's known to the system via a call to AddApplicationManifest. */
  1131. virtual EVRApplicationError IdentifyApplication( uint32_t unProcessId, const char *pchAppKey ) = 0;
  1132. /** Returns the process ID for an application. Return 0 if the application was not found or is not running. */
  1133. virtual uint32_t GetApplicationProcessId( const char *pchAppKey ) = 0;
  1134. /** Returns a string for an applications error */
  1135. virtual const char *GetApplicationsErrorNameFromEnum( EVRApplicationError error ) = 0;
  1136. // --------------- Application properties --------------- //
  1137. /** Returns a value for an application property. The required buffer size to fit this value will be returned. */
  1138. virtual uint32_t GetApplicationPropertyString( const char *pchAppKey, EVRApplicationProperty eProperty, char *pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError *peError = nullptr ) = 0;
  1139. /** Returns a bool value for an application property. Returns false in all error cases. */
  1140. virtual bool GetApplicationPropertyBool( const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr ) = 0;
  1141. /** Returns a uint64 value for an application property. Returns 0 in all error cases. */
  1142. virtual uint64_t GetApplicationPropertyUint64( const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr ) = 0;
  1143. /** Sets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
  1144. virtual EVRApplicationError SetApplicationAutoLaunch( const char *pchAppKey, bool bAutoLaunch ) = 0;
  1145. /** Gets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
  1146. virtual bool GetApplicationAutoLaunch( const char *pchAppKey ) = 0;
  1147. // --------------- Transition methods --------------- //
  1148. /** Returns the app key for the application that is starting up */
  1149. virtual EVRApplicationError GetStartingApplication( char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1150. /** Returns the application transition state */
  1151. virtual EVRApplicationTransitionState GetTransitionState() = 0;
  1152. /** Returns errors that would prevent the specified application from launching immediately. Calling this function will
  1153. * cause the current scene application to quit, so only call it when you are actually about to launch something else.
  1154. * What the caller should do about these failures depends on the failure:
  1155. * VRApplicationError_OldApplicationQuitting - An existing application has been told to quit. Wait for a VREvent_ProcessQuit
  1156. * and try again.
  1157. * VRApplicationError_ApplicationAlreadyStarting - This application is already starting. This is a permanent failure.
  1158. * VRApplicationError_LaunchInProgress - A different application is already starting. This is a permanent failure.
  1159. * VRApplicationError_None - Go ahead and launch. Everything is clear.
  1160. */
  1161. virtual EVRApplicationError PerformApplicationPrelaunchCheck( const char *pchAppKey ) = 0;
  1162. /** Returns a string for an application transition state */
  1163. virtual const char *GetApplicationsTransitionStateNameFromEnum( EVRApplicationTransitionState state ) = 0;
  1164. /** Returns true if the outgoing scene app has requested a save prompt before exiting */
  1165. virtual bool IsQuitUserPromptRequested() = 0;
  1166. /** Starts a subprocess within the calling application. This
  1167. * suppresses all application transition UI and automatically identifies the new executable
  1168. * as part of the same application. On success the calling process should exit immediately.
  1169. * If working directory is NULL or "" the directory portion of the binary path will be
  1170. * the working directory. */
  1171. virtual EVRApplicationError LaunchInternalProcess( const char *pchBinaryPath, const char *pchArguments, const char *pchWorkingDirectory ) = 0;
  1172. };
  1173. static const char * const IVRApplications_Version = "IVRApplications_005";
  1174. } // namespace vr
  1175. // ivrsettings.h
  1176. namespace vr
  1177. {
  1178. enum EVRSettingsError
  1179. {
  1180. VRSettingsError_None = 0,
  1181. VRSettingsError_IPCFailed = 1,
  1182. VRSettingsError_WriteFailed = 2,
  1183. VRSettingsError_ReadFailed = 3,
  1184. };
  1185. // The maximum length of a settings key
  1186. static const uint32_t k_unMaxSettingsKeyLength = 128;
  1187. class IVRSettings
  1188. {
  1189. public:
  1190. virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
  1191. // Returns true if file sync occurred (force or settings dirty)
  1192. virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0;
  1193. virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, bool bDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  1194. virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
  1195. virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  1196. virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
  1197. virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, float flDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  1198. virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
  1199. virtual void GetString( const char *pchSection, const char *pchSettingsKey, char *pchValue, uint32_t unValueLen, const char *pchDefaultValue, EVRSettingsError *peError = nullptr ) = 0;
  1200. virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
  1201. virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
  1202. virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1203. };
  1204. //-----------------------------------------------------------------------------
  1205. static const char * const IVRSettings_Version = "IVRSettings_001";
  1206. //-----------------------------------------------------------------------------
  1207. // steamvr keys
  1208. static const char * const k_pch_SteamVR_Section = "steamvr";
  1209. static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
  1210. static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
  1211. static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
  1212. static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
  1213. static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
  1214. static const char * const k_pch_SteamVR_EnableDistortion_Bool = "enableDistortion";
  1215. static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
  1216. static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
  1217. static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
  1218. static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
  1219. static const char * const k_pch_SteamVR_IPD_Float = "ipd";
  1220. static const char * const k_pch_SteamVR_Background_String = "background";
  1221. static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
  1222. static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
  1223. static const char * const k_pch_SteamVR_Environment_String = "environment";
  1224. static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
  1225. static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
  1226. static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
  1227. static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
  1228. static const char * const k_pch_SteamVR_PowerOffOnExit_Bool = "powerOffOnExit";
  1229. static const char * const k_pch_SteamVR_StandbyAppRunningTimeout_Float = "standbyAppRunningTimeout";
  1230. static const char * const k_pch_SteamVR_StandbyNoAppTimeout_Float = "standbyNoAppTimeout";
  1231. static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode";
  1232. static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
  1233. static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
  1234. static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
  1235. static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
  1236. static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
  1237. static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
  1238. static const char * const k_pch_SteamVR_RenderTargetMultiplier_Float = "renderTargetMultiplier";
  1239. static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowReprojection";
  1240. //-----------------------------------------------------------------------------
  1241. // lighthouse keys
  1242. static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
  1243. static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
  1244. static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
  1245. static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
  1246. static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
  1247. static const char * const k_pch_Lighthouse_LighthouseName_String = "lighthousename";
  1248. static const char * const k_pch_Lighthouse_MaxIncidenceAngleDegrees_Float = "maxincidenceangledegrees";
  1249. static const char * const k_pch_Lighthouse_UseLighthouseDirect_Bool = "uselighthousedirect";
  1250. static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
  1251. //-----------------------------------------------------------------------------
  1252. // null keys
  1253. static const char * const k_pch_Null_Section = "driver_null";
  1254. static const char * const k_pch_Null_EnableNullDriver_Bool = "enable";
  1255. static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
  1256. static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
  1257. static const char * const k_pch_Null_WindowX_Int32 = "windowX";
  1258. static const char * const k_pch_Null_WindowY_Int32 = "windowY";
  1259. static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
  1260. static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
  1261. static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
  1262. static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
  1263. static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
  1264. static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
  1265. //-----------------------------------------------------------------------------
  1266. // user interface keys
  1267. static const char * const k_pch_UserInterface_Section = "userinterface";
  1268. static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
  1269. static const char * const k_pch_UserInterface_EnableScreenshots_Bool = "EnableScreenshots";
  1270. //-----------------------------------------------------------------------------
  1271. // notification keys
  1272. static const char * const k_pch_Notifications_Section = "notifications";
  1273. static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
  1274. //-----------------------------------------------------------------------------
  1275. // keyboard keys
  1276. static const char * const k_pch_Keyboard_Section = "keyboard";
  1277. static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
  1278. static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
  1279. static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
  1280. static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
  1281. static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
  1282. static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
  1283. static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
  1284. //-----------------------------------------------------------------------------
  1285. // perf keys
  1286. static const char * const k_pch_Perf_Section = "perfcheck";
  1287. static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
  1288. static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
  1289. static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
  1290. static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
  1291. static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
  1292. static const char * const k_pch_Perf_TestData_Float = "perfTestData";
  1293. //-----------------------------------------------------------------------------
  1294. // collision bounds keys
  1295. static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
  1296. static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
  1297. static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
  1298. static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
  1299. static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
  1300. static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
  1301. static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
  1302. static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
  1303. static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
  1304. static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
  1305. //-----------------------------------------------------------------------------
  1306. // camera keys
  1307. static const char * const k_pch_Camera_Section = "camera";
  1308. static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
  1309. static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
  1310. static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
  1311. static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
  1312. static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
  1313. static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
  1314. static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
  1315. static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
  1316. //-----------------------------------------------------------------------------
  1317. // audio keys
  1318. static const char * const k_pch_audio_Section = "audio";
  1319. static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
  1320. static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
  1321. static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
  1322. static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
  1323. static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
  1324. static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
  1325. //-----------------------------------------------------------------------------
  1326. // model skin keys
  1327. static const char * const k_pch_modelskin_Section = "modelskins";
  1328. } // namespace vr
  1329. // ivrchaperone.h
  1330. namespace vr
  1331. {
  1332. #if defined(__linux__) || defined(__APPLE__)
  1333. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  1334. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  1335. // The 64-bit version of gcc has the alignment requirement for these types set to
  1336. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  1337. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  1338. #pragma pack( push, 4 )
  1339. #else
  1340. #pragma pack( push, 8 )
  1341. #endif
  1342. enum ChaperoneCalibrationState
  1343. {
  1344. // OK!
  1345. ChaperoneCalibrationState_OK = 1, // Chaperone is fully calibrated and working correctly
  1346. // Warnings
  1347. ChaperoneCalibrationState_Warning = 100,
  1348. ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101, // A base station thinks that it might have moved
  1349. ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, // There are less base stations than when calibrated
  1350. ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, // Seated bounds haven't been calibrated for the current tracking center
  1351. // Errors
  1352. ChaperoneCalibrationState_Error = 200, // The UniverseID is invalid
  1353. ChaperoneCalibrationState_Error_BaseStationUninitalized = 201, // Tracking center hasn't be calibrated for at least one of the base stations
  1354. ChaperoneCalibrationState_Error_BaseStationConflict = 202, // Tracking center is calibrated, but base stations disagree on the tracking space
  1355. ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, // Play Area hasn't been calibrated for the current tracking center
  1356. ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, // Collision Bounds haven't been calibrated for the current tracking center
  1357. };
  1358. /** HIGH LEVEL TRACKING SPACE ASSUMPTIONS:
  1359. * 0,0,0 is the preferred standing area center.
  1360. * 0Y is the floor height.
  1361. * -Z is the preferred forward facing direction. */
  1362. class IVRChaperone
  1363. {
  1364. public:
  1365. /** Get the current state of Chaperone calibration. This state can change at any time during a session due to physical base station changes. **/
  1366. virtual ChaperoneCalibrationState GetCalibrationState() = 0;
  1367. /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z.
  1368. * Tracking space center (0,0,0) is the center of the Play Area. **/
  1369. virtual bool GetPlayAreaSize( float *pSizeX, float *pSizeZ ) = 0;
  1370. /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds).
  1371. * Corners are in counter-clockwise order.
  1372. * Standing center (0,0,0) is the center of the Play Area.
  1373. * It's a rectangle.
  1374. * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
  1375. * Height of every corner is 0Y (on the floor). **/
  1376. virtual bool GetPlayAreaRect( HmdQuad_t *rect ) = 0;
  1377. /** Reload Chaperone data from the .vrchap file on disk. */
  1378. virtual void ReloadInfo( void ) = 0;
  1379. /** Optionally give the chaperone system a hit about the color and brightness in the scene **/
  1380. virtual void SetSceneColor( HmdColor_t color ) = 0;
  1381. /** Get the current chaperone bounds draw color and brightness **/
  1382. virtual void GetBoundsColor( HmdColor_t *pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, HmdColor_t *pOutputCameraColor ) = 0;
  1383. /** Determine whether the bounds are showing right now **/
  1384. virtual bool AreBoundsVisible() = 0;
  1385. /** Force the bounds to show, mostly for utilities **/
  1386. virtual void ForceBoundsVisible( bool bForce ) = 0;
  1387. };
  1388. static const char * const IVRChaperone_Version = "IVRChaperone_003";
  1389. #pragma pack( pop )
  1390. }
  1391. // ivrchaperonesetup.h
  1392. namespace vr
  1393. {
  1394. enum EChaperoneConfigFile
  1395. {
  1396. EChaperoneConfigFile_Live = 1, // The live chaperone config, used by most applications and games
  1397. EChaperoneConfigFile_Temp = 2, // The temporary chaperone config, used to live-preview collision bounds in room setup
  1398. };
  1399. enum EChaperoneImportFlags
  1400. {
  1401. EChaperoneImport_BoundsOnly = 0x0001,
  1402. };
  1403. /** Manages the working copy of the chaperone info. By default this will be the same as the
  1404. * live copy. Any changes made with this interface will stay in the working copy until
  1405. * CommitWorkingCopy() is called, at which point the working copy and the live copy will be
  1406. * the same again. */
  1407. class IVRChaperoneSetup
  1408. {
  1409. public:
  1410. /** Saves the current working copy to disk */
  1411. virtual bool CommitWorkingCopy( EChaperoneConfigFile configFile ) = 0;
  1412. /** Reverts the working copy to match the live chaperone calibration.
  1413. * To modify existing data this MUST be do WHILE getting a non-error ChaperoneCalibrationStatus.
  1414. * Only after this should you do gets and sets on the existing data. */
  1415. virtual void RevertWorkingCopy() = 0;
  1416. /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z from the working copy.
  1417. * Tracking space center (0,0,0) is the center of the Play Area. */
  1418. virtual bool GetWorkingPlayAreaSize( float *pSizeX, float *pSizeZ ) = 0;
  1419. /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds) from the working copy.
  1420. * Corners are in clockwise order.
  1421. * Tracking space center (0,0,0) is the center of the Play Area.
  1422. * It's a rectangle.
  1423. * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
  1424. * Height of every corner is 0Y (on the floor). **/
  1425. virtual bool GetWorkingPlayAreaRect( HmdQuad_t *rect ) = 0;
  1426. /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
  1427. * into the buffer up to the max specified from the working copy. */
  1428. virtual bool GetWorkingCollisionBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1429. /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
  1430. * into the buffer up to the max specified. */
  1431. virtual bool GetLiveCollisionBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1432. /** Returns the preferred seated position from the working copy. */
  1433. virtual bool GetWorkingSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0;
  1434. /** Returns the standing origin from the working copy. */
  1435. virtual bool GetWorkingStandingZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatStandingZeroPoseToRawTrackingPose ) = 0;
  1436. /** Sets the Play Area in the working copy. */
  1437. virtual void SetWorkingPlayAreaSize( float sizeX, float sizeZ ) = 0;
  1438. /** Sets the Collision Bounds in the working copy. */
  1439. virtual void SetWorkingCollisionBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0;
  1440. /** Sets the preferred seated position in the working copy. */
  1441. virtual void SetWorkingSeatedZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatSeatedZeroPoseToRawTrackingPose ) = 0;
  1442. /** Sets the preferred standing position in the working copy. */
  1443. virtual void SetWorkingStandingZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatStandingZeroPoseToRawTrackingPose ) = 0;
  1444. /** Tear everything down and reload it from the file on disk */
  1445. virtual void ReloadFromDisk( EChaperoneConfigFile configFile ) = 0;
  1446. /** Returns the preferred seated position. */
  1447. virtual bool GetLiveSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0;
  1448. virtual void SetWorkingCollisionBoundsTagsInfo( VR_ARRAY_COUNT(unTagCount) uint8_t *pTagsBuffer, uint32_t unTagCount ) = 0;
  1449. virtual bool GetLiveCollisionBoundsTagsInfo( VR_OUT_ARRAY_COUNT(punTagCount) uint8_t *pTagsBuffer, uint32_t *punTagCount ) = 0;
  1450. virtual bool SetWorkingPhysicalBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0;
  1451. virtual bool GetLivePhysicalBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1452. virtual bool ExportLiveToBuffer( VR_OUT_STRING() char *pBuffer, uint32_t *pnBufferLength ) = 0;
  1453. virtual bool ImportFromBufferToWorking( const char *pBuffer, uint32_t nImportFlags ) = 0;
  1454. };
  1455. static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005";
  1456. }
  1457. // ivrcompositor.h
  1458. namespace vr
  1459. {
  1460. #if defined(__linux__) || defined(__APPLE__)
  1461. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  1462. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  1463. // The 64-bit version of gcc has the alignment requirement for these types set to
  1464. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  1465. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  1466. #pragma pack( push, 4 )
  1467. #else
  1468. #pragma pack( push, 8 )
  1469. #endif
  1470. /** Errors that can occur with the VR compositor */
  1471. enum EVRCompositorError
  1472. {
  1473. VRCompositorError_None = 0,
  1474. VRCompositorError_RequestFailed = 1,
  1475. VRCompositorError_IncompatibleVersion = 100,
  1476. VRCompositorError_DoNotHaveFocus = 101,
  1477. VRCompositorError_InvalidTexture = 102,
  1478. VRCompositorError_IsNotSceneApplication = 103,
  1479. VRCompositorError_TextureIsOnWrongDevice = 104,
  1480. VRCompositorError_TextureUsesUnsupportedFormat = 105,
  1481. VRCompositorError_SharedTexturesNotSupported = 106,
  1482. VRCompositorError_IndexOutOfRange = 107,
  1483. VRCompositorError_ScreenshotAlreadyInProgress = 108,
  1484. };
  1485. const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01;
  1486. const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02;
  1487. /** Provides a single frame's timing information to the app */
  1488. struct Compositor_FrameTiming
  1489. {
  1490. uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming )
  1491. uint32_t m_nFrameIndex;
  1492. uint32_t m_nNumFramePresents; // number of times this frame was presented
  1493. uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out
  1494. /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */
  1495. double m_flSystemTimeInSeconds;
  1496. /** These times may include work from other processes due to OS scheduling.
  1497. * The fewer packets of work these are broken up into, the less likely this will happen.
  1498. * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started
  1499. * processing that work earlier in the frame. */
  1500. float m_flSceneRenderGpuMs; // time spent rendering the scene
  1501. float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work
  1502. float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc.
  1503. float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame
  1504. float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time)
  1505. /** Miscellaneous measured intervals. */
  1506. float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses
  1507. float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long)
  1508. float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure)
  1509. float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue)
  1510. /** The following are all relative to this frame's SystemTimeInSeconds */
  1511. float m_flWaitGetPosesCalledMs;
  1512. float m_flNewPosesReadyMs;
  1513. float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit
  1514. float m_flCompositorUpdateStartMs;
  1515. float m_flCompositorUpdateEndMs;
  1516. float m_flCompositorRenderStartMs;
  1517. vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame
  1518. int32_t m_nFidelityLevel; // app reported value
  1519. uint32_t m_nReprojectionFlags;
  1520. };
  1521. /** Cumulative stats for current application. These are not cleared until a new app connects,
  1522. * but they do stop accumulating once the associated app disconnects. */
  1523. struct Compositor_CumulativeStats
  1524. {
  1525. uint32_t m_nPid; // Process id associated with these stats (may no longer be running).
  1526. uint32_t m_nNumFramePresents; // total number of times we called present (includes reprojected frames)
  1527. uint32_t m_nNumDroppedFrames; // total number of times an old frame was re-scanned out (without reprojection)
  1528. uint32_t m_nNumReprojectedFrames; // total number of times a frame was scanned out a second time with reprojection
  1529. /** Values recorded at startup before application has fully faded in the first time. */
  1530. uint32_t m_nNumFramePresentsOnStartup;
  1531. uint32_t m_nNumDroppedFramesOnStartup;
  1532. uint32_t m_nNumReprojectedFramesOnStartup;
  1533. /** Applications may explicitly fade to the compositor. This is usually to handle level transitions, and loading often causes
  1534. * system wide hitches. The following stats are collected during this period. Does not include values recorded during startup. */
  1535. uint32_t m_nNumLoading;
  1536. uint32_t m_nNumFramePresentsLoading;
  1537. uint32_t m_nNumDroppedFramesLoading;
  1538. uint32_t m_nNumReprojectedFramesLoading;
  1539. /** If we don't get a new frame from the app in less than 2.5 frames, then we assume the app has hung and start
  1540. * fading back to the compositor. The following stats are a result of this, and are a subset of those recorded above.
  1541. * Does not include values recorded during start up or loading. */
  1542. uint32_t m_nNumTimedOut;
  1543. uint32_t m_nNumFramePresentsTimedOut;
  1544. uint32_t m_nNumDroppedFramesTimedOut;
  1545. uint32_t m_nNumReprojectedFramesTimedOut;
  1546. };
  1547. #pragma pack( pop )
  1548. /** Allows the application to interact with the compositor */
  1549. class IVRCompositor
  1550. {
  1551. public:
  1552. /** Sets tracking space returned by WaitGetPoses */
  1553. virtual void SetTrackingSpace( ETrackingUniverseOrigin eOrigin ) = 0;
  1554. /** Gets current tracking space returned by WaitGetPoses */
  1555. virtual ETrackingUniverseOrigin GetTrackingSpace() = 0;
  1556. /** Returns pose(s) to use to render scene (and optionally poses predicted two frames out for gameplay). */
  1557. virtual EVRCompositorError WaitGetPoses( VR_ARRAY_COUNT(unRenderPoseArrayCount) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount,
  1558. VR_ARRAY_COUNT(unGamePoseArrayCount) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0;
  1559. /** Get the last set of poses returned by WaitGetPoses. */
  1560. virtual EVRCompositorError GetLastPoses( VR_ARRAY_COUNT( unRenderPoseArrayCount ) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount,
  1561. VR_ARRAY_COUNT( unGamePoseArrayCount ) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0;
  1562. /** Interface for accessing last set of poses returned by WaitGetPoses one at a time.
  1563. * Returns VRCompositorError_IndexOutOfRange if unDeviceIndex not less than k_unMaxTrackedDeviceCount otherwise VRCompositorError_None.
  1564. * It is okay to pass NULL for either pose if you only want one of the values. */
  1565. virtual EVRCompositorError GetLastPoseForTrackedDeviceIndex( TrackedDeviceIndex_t unDeviceIndex, TrackedDevicePose_t *pOutputPose, TrackedDevicePose_t *pOutputGamePose ) = 0;
  1566. /** Updated scene texture to display. If pBounds is NULL the entire texture will be used. If called from an OpenGL app, consider adding a glFlush after
  1567. * Submitting both frames to signal the driver to start processing, otherwise it may wait until the command buffer fills up, causing the app to miss frames.
  1568. *
  1569. * OpenGL dirty state:
  1570. * glBindTexture
  1571. */
  1572. virtual EVRCompositorError Submit( EVREye eEye, const Texture_t *pTexture, const VRTextureBounds_t* pBounds = 0, EVRSubmitFlags nSubmitFlags = Submit_Default ) = 0;
  1573. /** Clears the frame that was sent with the last call to Submit. This will cause the
  1574. * compositor to show the grid until Submit is called again. */
  1575. virtual void ClearLastSubmittedFrame() = 0;
  1576. /** Call immediately after presenting your app's window (i.e. companion window) to unblock the compositor.
  1577. * This is an optional call, which only needs to be used if you can't instead call WaitGetPoses immediately after Present.
  1578. * For example, if your engine's render and game loop are not on separate threads, or blocking the render thread until 3ms before the next vsync would
  1579. * introduce a deadlock of some sort. This function tells the compositor that you have finished all rendering after having Submitted buffers for both
  1580. * eyes, and it is free to start its rendering work. This should only be called from the same thread you are rendering on. */
  1581. virtual void PostPresentHandoff() = 0;
  1582. /** Returns true if timing data is filled it. Sets oldest timing info if nFramesAgo is larger than the stored history.
  1583. * Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function. */
  1584. virtual bool GetFrameTiming( Compositor_FrameTiming *pTiming, uint32_t unFramesAgo = 0 ) = 0;
  1585. /** Returns the time in seconds left in the current (as identified by FrameTiming's frameIndex) frame.
  1586. * Due to "running start", this value may roll over to the next frame before ever reaching 0.0. */
  1587. virtual float GetFrameTimeRemaining() = 0;
  1588. /** Fills out stats accumulated for the last connected application. Pass in sizeof( Compositor_CumulativeStats ) as second parameter. */
  1589. virtual void GetCumulativeStats( Compositor_CumulativeStats *pStats, uint32_t nStatsSizeInBytes ) = 0;
  1590. /** Fades the view on the HMD to the specified color. The fade will take fSeconds, and the color values are between
  1591. * 0.0 and 1.0. This color is faded on top of the scene based on the alpha parameter. Removing the fade color instantly
  1592. * would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). Values are in un-premultiplied alpha space. */
  1593. virtual void FadeToColor( float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground = false ) = 0;
  1594. /** Fading the Grid in or out in fSeconds */
  1595. virtual void FadeGrid( float fSeconds, bool bFadeIn ) = 0;
  1596. /** Override the skybox used in the compositor (e.g. for during level loads when the app can't feed scene images fast enough)
  1597. * Order is Front, Back, Left, Right, Top, Bottom. If only a single texture is passed, it is assumed in lat-long format.
  1598. * If two are passed, it is assumed a lat-long stereo pair. */
  1599. virtual EVRCompositorError SetSkyboxOverride( VR_ARRAY_COUNT( unTextureCount ) const Texture_t *pTextures, uint32_t unTextureCount ) = 0;
  1600. /** Resets compositor skybox back to defaults. */
  1601. virtual void ClearSkyboxOverride() = 0;
  1602. /** Brings the compositor window to the front. This is useful for covering any other window that may be on the HMD
  1603. * and is obscuring the compositor window. */
  1604. virtual void CompositorBringToFront() = 0;
  1605. /** Pushes the compositor window to the back. This is useful for allowing other applications to draw directly to the HMD. */
  1606. virtual void CompositorGoToBack() = 0;
  1607. /** Tells the compositor process to clean up and exit. You do not need to call this function at shutdown. Under normal
  1608. * circumstances the compositor will manage its own life cycle based on what applications are running. */
  1609. virtual void CompositorQuit() = 0;
  1610. /** Return whether the compositor is fullscreen */
  1611. virtual bool IsFullscreen() = 0;
  1612. /** Returns the process ID of the process that is currently rendering the scene */
  1613. virtual uint32_t GetCurrentSceneFocusProcess() = 0;
  1614. /** Returns the process ID of the process that rendered the last frame (or 0 if the compositor itself rendered the frame.)
  1615. * Returns 0 when fading out from an app and the app's process Id when fading into an app. */
  1616. virtual uint32_t GetLastFrameRenderer() = 0;
  1617. /** Returns true if the current process has the scene focus */
  1618. virtual bool CanRenderScene() = 0;
  1619. /** Creates a window on the primary monitor to display what is being shown in the headset. */
  1620. virtual void ShowMirrorWindow() = 0;
  1621. /** Closes the mirror window. */
  1622. virtual void HideMirrorWindow() = 0;
  1623. /** Returns true if the mirror window is shown. */
  1624. virtual bool IsMirrorWindowVisible() = 0;
  1625. /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */
  1626. virtual void CompositorDumpImages() = 0;
  1627. /** Let an app know it should be rendering with low resources. */
  1628. virtual bool ShouldAppRenderWithLowResources() = 0;
  1629. /** Override interleaved reprojection logic to force on. */
  1630. virtual void ForceInterleavedReprojectionOn( bool bOverride ) = 0;
  1631. /** Force reconnecting to the compositor process. */
  1632. virtual void ForceReconnectProcess() = 0;
  1633. /** Temporarily suspends rendering (useful for finer control over scene transitions). */
  1634. virtual void SuspendRendering( bool bSuspend ) = 0;
  1635. /** Request a screenshot of the requested type, application
  1636. * will get an event that the screen shot has started. The
  1637. * application should turn off any stenciling and max out
  1638. * quality for the next frames and include the Screenshot flag
  1639. * when calling Submit so that the compositor knows the
  1640. * screenshot. The application should keep the higher qualtity
  1641. * and submitted with the ScreenShot flag until gets a
  1642. * screenshot End event. It can take several frames for a
  1643. * cubemap to be capture for example. The first file is a
  1644. * boring 2D view used for preview, the second is the actual
  1645. * capture of the requested type. They are the same for
  1646. * VRScreenshotType_Mono */
  1647. virtual vr::EVRCompositorError RequestScreenshot( vr::EVRScreenshotType type, const char *pchDestinationFileName, const char *pchVRDestinationFileName ) = 0;
  1648. /** Returns the current screenshot type if a screenshot is currently being captured **/
  1649. virtual vr::EVRScreenshotType GetCurrentScreenshotType() = 0;
  1650. /** Opens a shared D3D11 texture with the undistorted composited image for each eye. */
  1651. virtual vr::EVRCompositorError GetMirrorTextureD3D11( vr::EVREye eEye, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView ) = 0;
  1652. /** Access to mirror textures from OpenGL. */
  1653. virtual vr::EVRCompositorError GetMirrorTextureGL( vr::EVREye eEye, vr::glUInt_t *pglTextureId, vr::glSharedTextureHandle_t *pglSharedTextureHandle ) = 0;
  1654. virtual bool ReleaseSharedGLTexture( vr::glUInt_t glTextureId, vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  1655. virtual void LockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  1656. virtual void UnlockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  1657. };
  1658. static const char * const IVRCompositor_Version = "IVRCompositor_015";
  1659. } // namespace vr
  1660. // ivrnotifications.h
  1661. namespace vr
  1662. {
  1663. #if defined(__linux__) || defined(__APPLE__)
  1664. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  1665. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  1666. // The 64-bit version of gcc has the alignment requirement for these types set to
  1667. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  1668. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  1669. #pragma pack( push, 4 )
  1670. #else
  1671. #pragma pack( push, 8 )
  1672. #endif
  1673. // Used for passing graphic data
  1674. struct NotificationBitmap_t
  1675. {
  1676. NotificationBitmap_t()
  1677. : m_pImageData( nullptr )
  1678. , m_nWidth( 0 )
  1679. , m_nHeight( 0 )
  1680. , m_nBytesPerPixel( 0 )
  1681. {
  1682. };
  1683. void *m_pImageData;
  1684. int32_t m_nWidth;
  1685. int32_t m_nHeight;
  1686. int32_t m_nBytesPerPixel;
  1687. };
  1688. /** Be aware that the notification type is used as 'priority' to pick the next notification */
  1689. enum EVRNotificationType
  1690. {
  1691. /** Transient notifications are automatically hidden after a period of time set by the user.
  1692. * They are used for things like information and chat messages that do not require user interaction. */
  1693. EVRNotificationType_Transient = 0,
  1694. /** Persistent notifications are shown to the user until they are hidden by calling RemoveNotification().
  1695. * They are used for things like phone calls and alarms that require user interaction. */
  1696. EVRNotificationType_Persistent = 1,
  1697. /** System notifications are shown no matter what. It is expected, that the ulUserValue is used as ID.
  1698. * If there is already a system notification in the queue with that ID it is not accepted into the queue
  1699. * to prevent spamming with system notification */
  1700. EVRNotificationType_Transient_SystemWithUserValue = 2,
  1701. };
  1702. enum EVRNotificationStyle
  1703. {
  1704. /** Creates a notification with minimal external styling. */
  1705. EVRNotificationStyle_None = 0,
  1706. /** Used for notifications about overlay-level status. In Steam this is used for events like downloads completing. */
  1707. EVRNotificationStyle_Application = 100,
  1708. /** Used for notifications about contacts that are unknown or not available. In Steam this is used for friend invitations and offline friends. */
  1709. EVRNotificationStyle_Contact_Disabled = 200,
  1710. /** Used for notifications about contacts that are available but inactive. In Steam this is used for friends that are online but not playing a game. */
  1711. EVRNotificationStyle_Contact_Enabled = 201,
  1712. /** Used for notifications about contacts that are available and active. In Steam this is used for friends that are online and currently running a game. */
  1713. EVRNotificationStyle_Contact_Active = 202,
  1714. };
  1715. static const uint32_t k_unNotificationTextMaxSize = 256;
  1716. typedef uint32_t VRNotificationId;
  1717. #pragma pack( pop )
  1718. /** Allows notification sources to interact with the VR system
  1719. This current interface is not yet implemented. Do not use yet. */
  1720. class IVRNotifications
  1721. {
  1722. public:
  1723. /** Create a notification and enqueue it to be shown to the user.
  1724. * An overlay handle is required to create a notification, as otherwise it would be impossible for a user to act on it.
  1725. * To create a two-line notification, use a line break ('\n') to split the text into two lines.
  1726. * The pImage argument may be NULL, in which case the specified overlay's icon will be used instead. */
  1727. virtual EVRNotificationError CreateNotification( VROverlayHandle_t ulOverlayHandle, uint64_t ulUserValue, EVRNotificationType type, const char *pchText, EVRNotificationStyle style, const NotificationBitmap_t *pImage, /* out */ VRNotificationId *pNotificationId ) = 0;
  1728. /** Destroy a notification, hiding it first if it currently shown to the user. */
  1729. virtual EVRNotificationError RemoveNotification( VRNotificationId notificationId ) = 0;
  1730. };
  1731. static const char * const IVRNotifications_Version = "IVRNotifications_002";
  1732. } // namespace vr
  1733. // ivroverlay.h
  1734. namespace vr
  1735. {
  1736. /** The maximum length of an overlay key in bytes, counting the terminating null character. */
  1737. static const uint32_t k_unVROverlayMaxKeyLength = 128;
  1738. /** The maximum length of an overlay name in bytes, counting the terminating null character. */
  1739. static const uint32_t k_unVROverlayMaxNameLength = 128;
  1740. /** The maximum number of overlays that can exist in the system at one time. */
  1741. static const uint32_t k_unMaxOverlayCount = 32;
  1742. /** Types of input supported by VR Overlays */
  1743. enum VROverlayInputMethod
  1744. {
  1745. VROverlayInputMethod_None = 0, // No input events will be generated automatically for this overlay
  1746. VROverlayInputMethod_Mouse = 1, // Tracked controllers will get mouse events automatically
  1747. };
  1748. /** Allows the caller to figure out which overlay transform getter to call. */
  1749. enum VROverlayTransformType
  1750. {
  1751. VROverlayTransform_Absolute = 0,
  1752. VROverlayTransform_TrackedDeviceRelative = 1,
  1753. VROverlayTransform_SystemOverlay = 2,
  1754. VROverlayTransform_TrackedComponent = 3,
  1755. };
  1756. /** Overlay control settings */
  1757. enum VROverlayFlags
  1758. {
  1759. VROverlayFlags_None = 0,
  1760. // The following only take effect when rendered using the high quality render path (see SetHighQualityOverlay).
  1761. VROverlayFlags_Curved = 1,
  1762. VROverlayFlags_RGSS4X = 2,
  1763. // Set this flag on a dashboard overlay to prevent a tab from showing up for that overlay
  1764. VROverlayFlags_NoDashboardTab = 3,
  1765. // Set this flag on a dashboard that is able to deal with gamepad focus events
  1766. VROverlayFlags_AcceptsGamepadEvents = 4,
  1767. // Indicates that the overlay should dim/brighten to show gamepad focus
  1768. VROverlayFlags_ShowGamepadFocus = 5,
  1769. // When in VROverlayInputMethod_Mouse you can optionally enable sending VRScroll_t
  1770. VROverlayFlags_SendVRScrollEvents = 6,
  1771. VROverlayFlags_SendVRTouchpadEvents = 7,
  1772. // If set this will render a vertical scroll wheel on the primary controller,
  1773. // only needed if not using VROverlayFlags_SendVRScrollEvents but you still want to represent a scroll wheel
  1774. VROverlayFlags_ShowTouchPadScrollWheel = 8,
  1775. // If this is set ownership and render access to the overlay are transferred
  1776. // to the new scene process on a call to IVRApplications::LaunchInternalProcess
  1777. VROverlayFlags_TransferOwnershipToInternalProcess = 9,
  1778. // If set, renders 50% of the texture in each eye, side by side
  1779. VROverlayFlags_SideBySide_Parallel = 10, // Texture is left/right
  1780. VROverlayFlags_SideBySide_Crossed = 11, // Texture is crossed and right/left
  1781. VROverlayFlags_Panorama = 12, // Texture is a panorama
  1782. VROverlayFlags_StereoPanorama = 13, // Texture is a stereo panorama
  1783. };
  1784. struct VROverlayIntersectionParams_t
  1785. {
  1786. HmdVector3_t vSource;
  1787. HmdVector3_t vDirection;
  1788. ETrackingUniverseOrigin eOrigin;
  1789. };
  1790. struct VROverlayIntersectionResults_t
  1791. {
  1792. HmdVector3_t vPoint;
  1793. HmdVector3_t vNormal;
  1794. HmdVector2_t vUVs;
  1795. float fDistance;
  1796. };
  1797. // Input modes for the Big Picture gamepad text entry
  1798. enum EGamepadTextInputMode
  1799. {
  1800. k_EGamepadTextInputModeNormal = 0,
  1801. k_EGamepadTextInputModePassword = 1,
  1802. k_EGamepadTextInputModeSubmit = 2,
  1803. };
  1804. // Controls number of allowed lines for the Big Picture gamepad text entry
  1805. enum EGamepadTextInputLineMode
  1806. {
  1807. k_EGamepadTextInputLineModeSingleLine = 0,
  1808. k_EGamepadTextInputLineModeMultipleLines = 1
  1809. };
  1810. /** Directions for changing focus between overlays with the gamepad */
  1811. enum EOverlayDirection
  1812. {
  1813. OverlayDirection_Up = 0,
  1814. OverlayDirection_Down = 1,
  1815. OverlayDirection_Left = 2,
  1816. OverlayDirection_Right = 3,
  1817. OverlayDirection_Count = 4,
  1818. };
  1819. class IVROverlay
  1820. {
  1821. public:
  1822. // ---------------------------------------------
  1823. // Overlay management methods
  1824. // ---------------------------------------------
  1825. /** Finds an existing overlay with the specified key. */
  1826. virtual EVROverlayError FindOverlay( const char *pchOverlayKey, VROverlayHandle_t * pOverlayHandle ) = 0;
  1827. /** Creates a new named overlay. All overlays start hidden and with default settings. */
  1828. virtual EVROverlayError CreateOverlay( const char *pchOverlayKey, const char *pchOverlayFriendlyName, VROverlayHandle_t * pOverlayHandle ) = 0;
  1829. /** Destroys the specified overlay. When an application calls VR_Shutdown all overlays created by that app are
  1830. * automatically destroyed. */
  1831. virtual EVROverlayError DestroyOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1832. /** Specify which overlay to use the high quality render path. This overlay will be composited in during the distortion pass which
  1833. * results in it drawing on top of everything else, but also at a higher quality as it samples the source texture directly rather than
  1834. * rasterizing into each eye's render texture first. Because if this, only one of these is supported at any given time. It is most useful
  1835. * for overlays that are expected to take up most of the user's view (e.g. streaming video).
  1836. * This mode does not support mouse input to your overlay. */
  1837. virtual EVROverlayError SetHighQualityOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1838. /** Returns the overlay handle of the current overlay being rendered using the single high quality overlay render path.
  1839. * Otherwise it will return k_ulOverlayHandleInvalid. */
  1840. virtual vr::VROverlayHandle_t GetHighQualityOverlay() = 0;
  1841. /** Fills the provided buffer with the string key of the overlay. Returns the size of buffer required to store the key, including
  1842. * the terminating null character. k_unVROverlayMaxKeyLength will be enough bytes to fit the string. */
  1843. virtual uint32_t GetOverlayKey( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0;
  1844. /** Fills the provided buffer with the friendly name of the overlay. Returns the size of buffer required to store the key, including
  1845. * the terminating null character. k_unVROverlayMaxNameLength will be enough bytes to fit the string. */
  1846. virtual uint32_t GetOverlayName( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0;
  1847. /** Gets the raw image data from an overlay. Overlay image data is always returned as RGBA data, 4 bytes per pixel. If the buffer is not large enough, width and height
  1848. * will be set and VROverlayError_ArrayTooSmall is returned. */
  1849. virtual EVROverlayError GetOverlayImageData( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unBufferSize, uint32_t *punWidth, uint32_t *punHeight ) = 0;
  1850. /** returns a string that corresponds with the specified overlay error. The string will be the name
  1851. * of the error enum value for all valid error codes */
  1852. virtual const char *GetOverlayErrorNameFromEnum( EVROverlayError error ) = 0;
  1853. // ---------------------------------------------
  1854. // Overlay rendering methods
  1855. // ---------------------------------------------
  1856. /** Sets the pid that is allowed to render to this overlay (the creator pid is always allow to render),
  1857. * by default this is the pid of the process that made the overlay */
  1858. virtual EVROverlayError SetOverlayRenderingPid( VROverlayHandle_t ulOverlayHandle, uint32_t unPID ) = 0;
  1859. /** Gets the pid that is allowed to render to this overlay */
  1860. virtual uint32_t GetOverlayRenderingPid( VROverlayHandle_t ulOverlayHandle ) = 0;
  1861. /** Specify flag setting for a given overlay */
  1862. virtual EVROverlayError SetOverlayFlag( VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled ) = 0;
  1863. /** Sets flag setting for a given overlay */
  1864. virtual EVROverlayError GetOverlayFlag( VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool *pbEnabled ) = 0;
  1865. /** Sets the color tint of the overlay quad. Use 0.0 to 1.0 per channel. */
  1866. virtual EVROverlayError SetOverlayColor( VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue ) = 0;
  1867. /** Gets the color tint of the overlay quad. */
  1868. virtual EVROverlayError GetOverlayColor( VROverlayHandle_t ulOverlayHandle, float *pfRed, float *pfGreen, float *pfBlue ) = 0;
  1869. /** Sets the alpha of the overlay quad. Use 1.0 for 100 percent opacity to 0.0 for 0 percent opacity. */
  1870. virtual EVROverlayError SetOverlayAlpha( VROverlayHandle_t ulOverlayHandle, float fAlpha ) = 0;
  1871. /** Gets the alpha of the overlay quad. By default overlays are rendering at 100 percent alpha (1.0). */
  1872. virtual EVROverlayError GetOverlayAlpha( VROverlayHandle_t ulOverlayHandle, float *pfAlpha ) = 0;
  1873. /** Sets the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
  1874. virtual EVROverlayError SetOverlayWidthInMeters( VROverlayHandle_t ulOverlayHandle, float fWidthInMeters ) = 0;
  1875. /** Returns the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
  1876. virtual EVROverlayError GetOverlayWidthInMeters( VROverlayHandle_t ulOverlayHandle, float *pfWidthInMeters ) = 0;
  1877. /** For high-quality curved overlays only, sets the distance range in meters from the overlay used to automatically curve
  1878. * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
  1879. virtual EVROverlayError SetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters ) = 0;
  1880. /** For high-quality curved overlays only, gets the distance range in meters from the overlay used to automatically curve
  1881. * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
  1882. virtual EVROverlayError GetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float *pfMinDistanceInMeters, float *pfMaxDistanceInMeters ) = 0;
  1883. /** Sets the colorspace the overlay texture's data is in. Defaults to 'auto'.
  1884. * If the texture needs to be resolved, you should call SetOverlayTexture with the appropriate colorspace instead. */
  1885. virtual EVROverlayError SetOverlayTextureColorSpace( VROverlayHandle_t ulOverlayHandle, EColorSpace eTextureColorSpace ) = 0;
  1886. /** Gets the overlay's current colorspace setting. */
  1887. virtual EVROverlayError GetOverlayTextureColorSpace( VROverlayHandle_t ulOverlayHandle, EColorSpace *peTextureColorSpace ) = 0;
  1888. /** Sets the part of the texture to use for the overlay. UV Min is the upper left corner and UV Max is the lower right corner. */
  1889. virtual EVROverlayError SetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, const VRTextureBounds_t *pOverlayTextureBounds ) = 0;
  1890. /** Gets the part of the texture to use for the overlay. UV Min is the upper left corner and UV Max is the lower right corner. */
  1891. virtual EVROverlayError GetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, VRTextureBounds_t *pOverlayTextureBounds ) = 0;
  1892. /** Returns the transform type of this overlay. */
  1893. virtual EVROverlayError GetOverlayTransformType( VROverlayHandle_t ulOverlayHandle, VROverlayTransformType *peTransformType ) = 0;
  1894. /** Sets the transform to absolute tracking origin. */
  1895. virtual EVROverlayError SetOverlayTransformAbsolute( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToOverlayTransform ) = 0;
  1896. /** Gets the transform if it is absolute. Returns an error if the transform is some other type. */
  1897. virtual EVROverlayError GetOverlayTransformAbsolute( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin *peTrackingOrigin, HmdMatrix34_t *pmatTrackingOriginToOverlayTransform ) = 0;
  1898. /** Sets the transform to relative to the transform of the specified tracked device. */
  1899. virtual EVROverlayError SetOverlayTransformTrackedDeviceRelative( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unTrackedDevice, const HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform ) = 0;
  1900. /** Gets the transform if it is relative to a tracked device. Returns an error if the transform is some other type. */
  1901. virtual EVROverlayError GetOverlayTransformTrackedDeviceRelative( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punTrackedDevice, HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform ) = 0;
  1902. /** Sets the transform to draw the overlay on a rendermodel component mesh instead of a quad. This will only draw when the system is
  1903. * drawing the device. Overlays with this transform type cannot receive mouse events. */
  1904. virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, const char *pchComponentName ) = 0;
  1905. /** Gets the transform information when the overlay is rendering on a component. */
  1906. virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, char *pchComponentName, uint32_t unComponentNameSize ) = 0;
  1907. /** Shows the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
  1908. virtual EVROverlayError ShowOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1909. /** Hides the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
  1910. virtual EVROverlayError HideOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1911. /** Returns true if the overlay is visible. */
  1912. virtual bool IsOverlayVisible( VROverlayHandle_t ulOverlayHandle ) = 0;
  1913. /** Get the transform in 3d space associated with a specific 2d point in the overlay's coordinate space (where 0,0 is the lower left). -Z points out of the overlay */
  1914. virtual EVROverlayError GetTransformForOverlayCoordinates( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, HmdVector2_t coordinatesInOverlay, HmdMatrix34_t *pmatTransform ) = 0;
  1915. // ---------------------------------------------
  1916. // Overlay input methods
  1917. // ---------------------------------------------
  1918. /** Returns true and fills the event with the next event on the overlay's event queue, if there is one.
  1919. * If there are no events this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
  1920. virtual bool PollNextOverlayEvent( VROverlayHandle_t ulOverlayHandle, VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
  1921. /** Returns the current input settings for the specified overlay. */
  1922. virtual EVROverlayError GetOverlayInputMethod( VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod *peInputMethod ) = 0;
  1923. /** Sets the input settings for the specified overlay. */
  1924. virtual EVROverlayError SetOverlayInputMethod( VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod eInputMethod ) = 0;
  1925. /** Gets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
  1926. * typically the size of the underlying UI in pixels. */
  1927. virtual EVROverlayError GetOverlayMouseScale( VROverlayHandle_t ulOverlayHandle, HmdVector2_t *pvecMouseScale ) = 0;
  1928. /** Sets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
  1929. * typically the size of the underlying UI in pixels (not in world space). */
  1930. virtual EVROverlayError SetOverlayMouseScale( VROverlayHandle_t ulOverlayHandle, const HmdVector2_t *pvecMouseScale ) = 0;
  1931. /** Computes the overlay-space pixel coordinates of where the ray intersects the overlay with the
  1932. * specified settings. Returns false if there is no intersection. */
  1933. virtual bool ComputeOverlayIntersection( VROverlayHandle_t ulOverlayHandle, const VROverlayIntersectionParams_t *pParams, VROverlayIntersectionResults_t *pResults ) = 0;
  1934. /** Processes mouse input from the specified controller as though it were a mouse pointed at a compositor overlay with the
  1935. * specified settings. The controller is treated like a laser pointer on the -z axis. The point where the laser pointer would
  1936. * intersect with the overlay is the mouse position, the trigger is left mouse, and the track pad is right mouse.
  1937. *
  1938. * Return true if the controller is pointed at the overlay and an event was generated. */
  1939. virtual bool HandleControllerOverlayInteractionAsMouse( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unControllerDeviceIndex ) = 0;
  1940. /** Returns true if the specified overlay is the hover target. An overlay is the hover target when it is the last overlay "moused over"
  1941. * by the virtual mouse pointer */
  1942. virtual bool IsHoverTargetOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1943. /** Returns the current Gamepad focus overlay */
  1944. virtual vr::VROverlayHandle_t GetGamepadFocusOverlay() = 0;
  1945. /** Sets the current Gamepad focus overlay */
  1946. virtual EVROverlayError SetGamepadFocusOverlay( VROverlayHandle_t ulNewFocusOverlay ) = 0;
  1947. /** Sets an overlay's neighbor. This will also set the neighbor of the "to" overlay
  1948. * to point back to the "from" overlay. If an overlay's neighbor is set to invalid both
  1949. * ends will be cleared */
  1950. virtual EVROverlayError SetOverlayNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom, VROverlayHandle_t ulTo ) = 0;
  1951. /** Changes the Gamepad focus from one overlay to one of its neighbors. Returns VROverlayError_NoNeighbor if there is no
  1952. * neighbor in that direction */
  1953. virtual EVROverlayError MoveGamepadFocusToNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom ) = 0;
  1954. // ---------------------------------------------
  1955. // Overlay texture methods
  1956. // ---------------------------------------------
  1957. /** Texture to draw for the overlay. This function can only be called by the overlay's creator or renderer process (see SetOverlayRenderingPid) .
  1958. *
  1959. * OpenGL dirty state:
  1960. * glBindTexture
  1961. */
  1962. virtual EVROverlayError SetOverlayTexture( VROverlayHandle_t ulOverlayHandle, const Texture_t *pTexture ) = 0;
  1963. /** Use this to tell the overlay system to release the texture set for this overlay. */
  1964. virtual EVROverlayError ClearOverlayTexture( VROverlayHandle_t ulOverlayHandle ) = 0;
  1965. /** Separate interface for providing the data as a stream of bytes, but there is an upper bound on data
  1966. * that can be sent. This function can only be called by the overlay's renderer process. */
  1967. virtual EVROverlayError SetOverlayRaw( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unDepth ) = 0;
  1968. /** Separate interface for providing the image through a filename: can be png or jpg, and should not be bigger than 1920x1080.
  1969. * This function can only be called by the overlay's renderer process */
  1970. virtual EVROverlayError SetOverlayFromFile( VROverlayHandle_t ulOverlayHandle, const char *pchFilePath ) = 0;
  1971. /** Get the native texture handle/device for an overlay you have created.
  1972. * On windows this handle will be a ID3D11ShaderResourceView with a ID3D11Texture2D bound.
  1973. *
  1974. * The texture will always be sized to match the backing texture you supplied in SetOverlayTexture above.
  1975. *
  1976. * You MUST call ReleaseNativeOverlayHandle() with pNativeTextureHandle once you are done with this texture.
  1977. *
  1978. * pNativeTextureHandle is an OUTPUT, it will be a pointer to a ID3D11ShaderResourceView *.
  1979. * pNativeTextureRef is an INPUT and should be a ID3D11Resource *. The device used by pNativeTextureRef will be used to bind pNativeTextureHandle.
  1980. */
  1981. virtual EVROverlayError GetOverlayTexture( VROverlayHandle_t ulOverlayHandle, void **pNativeTextureHandle, void *pNativeTextureRef, uint32_t *pWidth, uint32_t *pHeight, uint32_t *pNativeFormat, EGraphicsAPIConvention *pAPI, EColorSpace *pColorSpace ) = 0;
  1982. /** Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
  1983. * so only do it once you stop rendering this texture.
  1984. */
  1985. virtual EVROverlayError ReleaseNativeOverlayHandle( VROverlayHandle_t ulOverlayHandle, void *pNativeTextureHandle ) = 0;
  1986. /** Get the size of the overlay texture */
  1987. virtual EVROverlayError GetOverlayTextureSize( VROverlayHandle_t ulOverlayHandle, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  1988. // ----------------------------------------------
  1989. // Dashboard Overlay Methods
  1990. // ----------------------------------------------
  1991. /** Creates a dashboard overlay and returns its handle */
  1992. virtual EVROverlayError CreateDashboardOverlay( const char *pchOverlayKey, const char *pchOverlayFriendlyName, VROverlayHandle_t * pMainHandle, VROverlayHandle_t *pThumbnailHandle ) = 0;
  1993. /** Returns true if the dashboard is visible */
  1994. virtual bool IsDashboardVisible() = 0;
  1995. /** returns true if the dashboard is visible and the specified overlay is the active system Overlay */
  1996. virtual bool IsActiveDashboardOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  1997. /** Sets the dashboard overlay to only appear when the specified process ID has scene focus */
  1998. virtual EVROverlayError SetDashboardOverlaySceneProcess( VROverlayHandle_t ulOverlayHandle, uint32_t unProcessId ) = 0;
  1999. /** Gets the process ID that this dashboard overlay requires to have scene focus */
  2000. virtual EVROverlayError GetDashboardOverlaySceneProcess( VROverlayHandle_t ulOverlayHandle, uint32_t *punProcessId ) = 0;
  2001. /** Shows the dashboard. */
  2002. virtual void ShowDashboard( const char *pchOverlayToShow ) = 0;
  2003. /** Returns the tracked device that has the laser pointer in the dashboard */
  2004. virtual vr::TrackedDeviceIndex_t GetPrimaryDashboardDevice() = 0;
  2005. // ---------------------------------------------
  2006. // Keyboard methods
  2007. // ---------------------------------------------
  2008. /** Show the virtual keyboard to accept input **/
  2009. virtual EVROverlayError ShowKeyboard( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue ) = 0;
  2010. virtual EVROverlayError ShowKeyboardForOverlay( VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue ) = 0;
  2011. /** Get the text that was entered into the text input **/
  2012. virtual uint32_t GetKeyboardText( VR_OUT_STRING() char *pchText, uint32_t cchText ) = 0;
  2013. /** Hide the virtual keyboard **/
  2014. virtual void HideKeyboard() = 0;
  2015. /** Set the position of the keyboard in world space **/
  2016. virtual void SetKeyboardTransformAbsolute( ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToKeyboardTransform ) = 0;
  2017. /** Set the position of the keyboard in overlay space by telling it to avoid a rectangle in the overlay. Rectangle coords have (0,0) in the bottom left **/
  2018. virtual void SetKeyboardPositionForOverlay( VROverlayHandle_t ulOverlayHandle, HmdRect2_t avoidRect ) = 0;
  2019. };
  2020. static const char * const IVROverlay_Version = "IVROverlay_012";
  2021. } // namespace vr
  2022. // ivrrendermodels.h
  2023. namespace vr
  2024. {
  2025. static const char * const k_pch_Controller_Component_GDC2015 = "gdc2015"; // Canonical coordinate system of the gdc 2015 wired controller, provided for backwards compatibility
  2026. static const char * const k_pch_Controller_Component_Base = "base"; // For controllers with an unambiguous 'base'.
  2027. static const char * const k_pch_Controller_Component_Tip = "tip"; // For controllers with an unambiguous 'tip' (used for 'laser-pointing')
  2028. static const char * const k_pch_Controller_Component_HandGrip = "handgrip"; // Neutral, ambidextrous hand-pose when holding controller. On plane between neutrally posed index finger and thumb
  2029. static const char * const k_pch_Controller_Component_Status = "status"; // 1:1 aspect ratio status area, with canonical [0,1] uv mapping
  2030. #if defined(__linux__) || defined(__APPLE__)
  2031. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  2032. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  2033. // The 64-bit version of gcc has the alignment requirement for these types set to
  2034. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  2035. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  2036. #pragma pack( push, 4 )
  2037. #else
  2038. #pragma pack( push, 8 )
  2039. #endif
  2040. /** Errors that can occur with the VR compositor */
  2041. enum EVRRenderModelError
  2042. {
  2043. VRRenderModelError_None = 0,
  2044. VRRenderModelError_Loading = 100,
  2045. VRRenderModelError_NotSupported = 200,
  2046. VRRenderModelError_InvalidArg = 300,
  2047. VRRenderModelError_InvalidModel = 301,
  2048. VRRenderModelError_NoShapes = 302,
  2049. VRRenderModelError_MultipleShapes = 303,
  2050. VRRenderModelError_TooManyVertices = 304,
  2051. VRRenderModelError_MultipleTextures = 305,
  2052. VRRenderModelError_BufferTooSmall = 306,
  2053. VRRenderModelError_NotEnoughNormals = 307,
  2054. VRRenderModelError_NotEnoughTexCoords = 308,
  2055. VRRenderModelError_InvalidTexture = 400,
  2056. };
  2057. typedef uint32_t VRComponentProperties;
  2058. enum EVRComponentProperty
  2059. {
  2060. VRComponentProperty_IsStatic = (1 << 0),
  2061. VRComponentProperty_IsVisible = (1 << 1),
  2062. VRComponentProperty_IsTouched = (1 << 2),
  2063. VRComponentProperty_IsPressed = (1 << 3),
  2064. VRComponentProperty_IsScrolled = (1 << 4),
  2065. };
  2066. /** Describes state information about a render-model component, including transforms and other dynamic properties */
  2067. struct RenderModel_ComponentState_t
  2068. {
  2069. HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model
  2070. HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface )
  2071. VRComponentProperties uProperties;
  2072. };
  2073. /** A single vertex in a render model */
  2074. struct RenderModel_Vertex_t
  2075. {
  2076. HmdVector3_t vPosition; // position in meters in device space
  2077. HmdVector3_t vNormal;
  2078. float rfTextureCoord[2];
  2079. };
  2080. /** A texture map for use on a render model */
  2081. struct RenderModel_TextureMap_t
  2082. {
  2083. uint16_t unWidth, unHeight; // width and height of the texture map in pixels
  2084. const uint8_t *rubTextureMapData; // Map texture data. All textures are RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub
  2085. };
  2086. /** Session unique texture identifier. Rendermodels which share the same texture will have the same id.
  2087. IDs <0 denote the texture is not present */
  2088. typedef int32_t TextureID_t;
  2089. const TextureID_t INVALID_TEXTURE_ID = -1;
  2090. struct RenderModel_t
  2091. {
  2092. const RenderModel_Vertex_t *rVertexData; // Vertex data for the mesh
  2093. uint32_t unVertexCount; // Number of vertices in the vertex data
  2094. const uint16_t *rIndexData; // Indices into the vertex data for each triangle
  2095. uint32_t unTriangleCount; // Number of triangles in the mesh. Index count is 3 * TriangleCount
  2096. TextureID_t diffuseTextureId; // Session unique texture identifier. Rendermodels which share the same texture will have the same id. <0 == texture not present
  2097. };
  2098. struct RenderModel_ControllerMode_State_t
  2099. {
  2100. bool bScrollWheelVisible; // is this controller currently set to be in a scroll wheel mode
  2101. };
  2102. #pragma pack( pop )
  2103. class IVRRenderModels
  2104. {
  2105. public:
  2106. /** Loads and returns a render model for use in the application. pchRenderModelName should be a render model name
  2107. * from the Prop_RenderModelName_String property or an absolute path name to a render model on disk.
  2108. *
  2109. * The resulting render model is valid until VR_Shutdown() is called or until FreeRenderModel() is called. When the
  2110. * application is finished with the render model it should call FreeRenderModel() to free the memory associated
  2111. * with the model.
  2112. *
  2113. * The method returns VRRenderModelError_Loading while the render model is still being loaded.
  2114. * The method returns VRRenderModelError_None once loaded successfully, otherwise will return an error. */
  2115. virtual EVRRenderModelError LoadRenderModel_Async( const char *pchRenderModelName, RenderModel_t **ppRenderModel ) = 0;
  2116. /** Frees a previously returned render model
  2117. * It is safe to call this on a null ptr. */
  2118. virtual void FreeRenderModel( RenderModel_t *pRenderModel ) = 0;
  2119. /** Loads and returns a texture for use in the application. */
  2120. virtual EVRRenderModelError LoadTexture_Async( TextureID_t textureId, RenderModel_TextureMap_t **ppTexture ) = 0;
  2121. /** Frees a previously returned texture
  2122. * It is safe to call this on a null ptr. */
  2123. virtual void FreeTexture( RenderModel_TextureMap_t *pTexture ) = 0;
  2124. /** Creates a D3D11 texture and loads data into it. */
  2125. virtual EVRRenderModelError LoadTextureD3D11_Async( TextureID_t textureId, void *pD3D11Device, void **ppD3D11Texture2D ) = 0;
  2126. /** Helper function to copy the bits into an existing texture. */
  2127. virtual EVRRenderModelError LoadIntoTextureD3D11_Async( TextureID_t textureId, void *pDstTexture ) = 0;
  2128. /** Use this to free textures created with LoadTextureD3D11_Async instead of calling Release on them. */
  2129. virtual void FreeTextureD3D11( void *pD3D11Texture2D ) = 0;
  2130. /** Use this to get the names of available render models. Index does not correlate to a tracked device index, but
  2131. * is only used for iterating over all available render models. If the index is out of range, this function will return 0.
  2132. * Otherwise, it will return the size of the buffer required for the name. */
  2133. virtual uint32_t GetRenderModelName( uint32_t unRenderModelIndex, VR_OUT_STRING() char *pchRenderModelName, uint32_t unRenderModelNameLen ) = 0;
  2134. /** Returns the number of available render models. */
  2135. virtual uint32_t GetRenderModelCount() = 0;
  2136. /** Returns the number of components of the specified render model.
  2137. * Components are useful when client application wish to draw, label, or otherwise interact with components of tracked objects.
  2138. * Examples controller components:
  2139. * renderable things such as triggers, buttons
  2140. * non-renderable things which include coordinate systems such as 'tip', 'base', a neutral controller agnostic hand-pose
  2141. * If all controller components are enumerated and rendered, it will be equivalent to drawing the traditional render model
  2142. * Returns 0 if components not supported, >0 otherwise */
  2143. virtual uint32_t GetComponentCount( const char *pchRenderModelName ) = 0;
  2144. /** Use this to get the names of available components. Index does not correlate to a tracked device index, but
  2145. * is only used for iterating over all available components. If the index is out of range, this function will return 0.
  2146. * Otherwise, it will return the size of the buffer required for the name. */
  2147. virtual uint32_t GetComponentName( const char *pchRenderModelName, uint32_t unComponentIndex, VR_OUT_STRING( ) char *pchComponentName, uint32_t unComponentNameLen ) = 0;
  2148. /** Get the button mask for all buttons associated with this component
  2149. * If no buttons (or axes) are associated with this component, return 0
  2150. * Note: multiple components may be associated with the same button. Ex: two grip buttons on a single controller.
  2151. * Note: A single component may be associated with multiple buttons. Ex: A trackpad which also provides "D-pad" functionality */
  2152. virtual uint64_t GetComponentButtonMask( const char *pchRenderModelName, const char *pchComponentName ) = 0;
  2153. /** Use this to get the render model name for the specified rendermode/component combination, to be passed to LoadRenderModel.
  2154. * If the component name is out of range, this function will return 0.
  2155. * Otherwise, it will return the size of the buffer required for the name. */
  2156. virtual uint32_t GetComponentRenderModelName( const char *pchRenderModelName, const char *pchComponentName, VR_OUT_STRING( ) char *pchComponentRenderModelName, uint32_t unComponentRenderModelNameLen ) = 0;
  2157. /** Use this to query information about the component, as a function of the controller state.
  2158. *
  2159. * For dynamic controller components (ex: trigger) values will reflect component motions
  2160. * For static components this will return a consistent value independent of the VRControllerState_t
  2161. *
  2162. * If the pchRenderModelName or pchComponentName is invalid, this will return false (and transforms will be set to identity).
  2163. * Otherwise, return true
  2164. * Note: For dynamic objects, visibility may be dynamic. (I.e., true/false will be returned based on controller state and controller mode state ) */
  2165. virtual bool GetComponentState( const char *pchRenderModelName, const char *pchComponentName, const vr::VRControllerState_t *pControllerState, const RenderModel_ControllerMode_State_t *pState, RenderModel_ComponentState_t *pComponentState ) = 0;
  2166. /** Returns true if the render model has a component with the specified name */
  2167. virtual bool RenderModelHasComponent( const char *pchRenderModelName, const char *pchComponentName ) = 0;
  2168. /** Returns the URL of the thumbnail image for this rendermodel */
  2169. virtual uint32_t GetRenderModelThumbnailURL( const char *pchRenderModelName, VR_OUT_STRING() char *pchThumbnailURL, uint32_t unThumbnailURLLen, vr::EVRRenderModelError *peError ) = 0;
  2170. /** Provides a render model path that will load the unskinned model if the model name provided has been replace by the user. If the model
  2171. * hasn't been replaced the path value will still be a valid path to load the model. Pass this to LoadRenderModel_Async, etc. to load the
  2172. * model. */
  2173. virtual uint32_t GetRenderModelOriginalPath( const char *pchRenderModelName, VR_OUT_STRING() char *pchOriginalPath, uint32_t unOriginalPathLen, vr::EVRRenderModelError *peError ) = 0;
  2174. /** Returns a string for a render model error */
  2175. virtual const char *GetRenderModelErrorNameFromEnum( vr::EVRRenderModelError error ) = 0;
  2176. };
  2177. static const char * const IVRRenderModels_Version = "IVRRenderModels_005";
  2178. }
  2179. // ivrextendeddisplay.h
  2180. namespace vr
  2181. {
  2182. /** NOTE: Use of this interface is not recommended in production applications. It will not work for displays which use
  2183. * direct-to-display mode. It is also incompatible with the VR compositor and is not available when the compositor is running. */
  2184. class IVRExtendedDisplay
  2185. {
  2186. public:
  2187. /** Size and position that the window needs to be on the VR display. */
  2188. virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  2189. /** Gets the viewport in the frame buffer to draw the output of the distortion into */
  2190. virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  2191. /** [D3D10/11 Only]
  2192. * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs
  2193. * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
  2194. */
  2195. virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex ) = 0;
  2196. };
  2197. static const char * const IVRExtendedDisplay_Version = "IVRExtendedDisplay_001";
  2198. }
  2199. // ivrtrackedcamera.h
  2200. namespace vr
  2201. {
  2202. class IVRTrackedCamera
  2203. {
  2204. public:
  2205. /** Returns a string for an error */
  2206. virtual const char *GetCameraErrorNameFromEnum( vr::EVRTrackedCameraError eCameraError ) = 0;
  2207. /** For convenience, same as tracked property request Prop_HasCamera_Bool */
  2208. virtual vr::EVRTrackedCameraError HasCamera( vr::TrackedDeviceIndex_t nDeviceIndex, bool *pHasCamera ) = 0;
  2209. /** Gets size of the image frame. */
  2210. virtual vr::EVRTrackedCameraError GetCameraFrameSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pnWidth, uint32_t *pnHeight, uint32_t *pnFrameBufferSize ) = 0;
  2211. virtual vr::EVRTrackedCameraError GetCameraIntrinisics( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0;
  2212. virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
  2213. /** Acquiring streaming service permits video streaming for the caller. Releasing hints the system that video services do not need to be maintained for this client.
  2214. * If the camera has not already been activated, a one time spin up may incur some auto exposure as well as initial streaming frame delays.
  2215. * The camera should be considered a global resource accessible for shared consumption but not exclusive to any caller.
  2216. * The camera may go inactive due to lack of active consumers or headset idleness. */
  2217. virtual vr::EVRTrackedCameraError AcquireVideoStreamingService( vr::TrackedDeviceIndex_t nDeviceIndex, vr::TrackedCameraHandle_t *pHandle ) = 0;
  2218. virtual vr::EVRTrackedCameraError ReleaseVideoStreamingService( vr::TrackedCameraHandle_t hTrackedCamera ) = 0;
  2219. /** Copies the image frame into a caller's provided buffer. The image data is currently provided as RGBA data, 4 bytes per pixel.
  2220. * A caller can provide null for the framebuffer or frameheader if not desired. Requesting the frame header first, followed by the frame buffer allows
  2221. * the caller to determine if the frame as advanced per the frame header sequence.
  2222. * If there is no frame available yet, due to initial camera spinup or re-activation, the error will be VRTrackedCameraError_NoFrameAvailable.
  2223. * Ideally a caller should be polling at ~16ms intervals */
  2224. virtual vr::EVRTrackedCameraError GetVideoStreamFrameBuffer( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pFrameBuffer, uint32_t nFrameBufferSize, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0;
  2225. };
  2226. static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_002";
  2227. } // namespace vr
  2228. // End
  2229. #endif // _OPENVR_API
  2230. namespace vr
  2231. {
  2232. /** Finds the active installation of the VR API and initializes it. The provided path must be absolute
  2233. * or relative to the current working directory. These are the local install versions of the equivalent
  2234. * functions in steamvr.h and will work without a local Steam install.
  2235. *
  2236. * This path is to the "root" of the VR API install. That's the directory with
  2237. * the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
  2238. */
  2239. inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType );
  2240. /** unloads vrclient.dll. Any interface pointers from the interface are
  2241. * invalid after this point */
  2242. inline void VR_Shutdown();
  2243. /** Returns true if there is an HMD attached. This check is as lightweight as possible and
  2244. * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants
  2245. * to know if initializing VR is a possibility but isn't ready to take that step yet.
  2246. */
  2247. VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent();
  2248. /** Returns true if the OpenVR runtime is installed. */
  2249. VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled();
  2250. /** Returns where the OpenVR runtime is installed. */
  2251. VR_INTERFACE const char *VR_CALLTYPE VR_RuntimePath();
  2252. /** Returns the name of the enum value for an EVRInitError. This function may be called outside of VR_Init()/VR_Shutdown(). */
  2253. VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsSymbol( EVRInitError error );
  2254. /** Returns an english string for an EVRInitError. Applications should call VR_GetVRInitErrorAsSymbol instead and
  2255. * use that as a key to look up their own localized error message. This function may be called outside of VR_Init()/VR_Shutdown(). */
  2256. VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription( EVRInitError error );
  2257. /** Returns the interface of the specified version. This method must be called after VR_Init. The
  2258. * pointer returned is valid until VR_Shutdown is called.
  2259. */
  2260. VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError );
  2261. /** Returns whether the interface of the specified version exists.
  2262. */
  2263. VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid( const char *pchInterfaceVersion );
  2264. /** Returns a token that represents whether the VR interface handles need to be reloaded */
  2265. VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken();
  2266. // These typedefs allow old enum names from SDK 0.9.11 to be used in applications.
  2267. // They will go away in the future.
  2268. typedef EVRInitError HmdError;
  2269. typedef EVREye Hmd_Eye;
  2270. typedef EGraphicsAPIConvention GraphicsAPIConvention;
  2271. typedef EColorSpace ColorSpace;
  2272. typedef ETrackingResult HmdTrackingResult;
  2273. typedef ETrackedDeviceClass TrackedDeviceClass;
  2274. typedef ETrackingUniverseOrigin TrackingUniverseOrigin;
  2275. typedef ETrackedDeviceProperty TrackedDeviceProperty;
  2276. typedef ETrackedPropertyError TrackedPropertyError;
  2277. typedef EVRSubmitFlags VRSubmitFlags_t;
  2278. typedef EVRState VRState_t;
  2279. typedef ECollisionBoundsStyle CollisionBoundsStyle_t;
  2280. typedef EVROverlayError VROverlayError;
  2281. typedef EVRFirmwareError VRFirmwareError;
  2282. typedef EVRCompositorError VRCompositorError;
  2283. inline uint32_t &VRToken()
  2284. {
  2285. static uint32_t token;
  2286. return token;
  2287. }
  2288. class COpenVRContext
  2289. {
  2290. public:
  2291. COpenVRContext() { Clear(); }
  2292. void Clear();
  2293. inline void CheckClear()
  2294. {
  2295. if ( VRToken() != VR_GetInitToken() )
  2296. {
  2297. Clear();
  2298. VRToken() = VR_GetInitToken();
  2299. }
  2300. }
  2301. IVRSystem *VRSystem()
  2302. {
  2303. CheckClear();
  2304. if ( m_pVRSystem == nullptr )
  2305. {
  2306. EVRInitError eError;
  2307. m_pVRSystem = ( IVRSystem * )VR_GetGenericInterface( IVRSystem_Version, &eError );
  2308. }
  2309. return m_pVRSystem;
  2310. }
  2311. IVRChaperone *VRChaperone()
  2312. {
  2313. CheckClear();
  2314. if ( m_pVRChaperone == nullptr )
  2315. {
  2316. EVRInitError eError;
  2317. m_pVRChaperone = ( IVRChaperone * )VR_GetGenericInterface( IVRChaperone_Version, &eError );
  2318. }
  2319. return m_pVRChaperone;
  2320. }
  2321. IVRChaperoneSetup *VRChaperoneSetup()
  2322. {
  2323. CheckClear();
  2324. if ( m_pVRChaperoneSetup == nullptr )
  2325. {
  2326. EVRInitError eError;
  2327. m_pVRChaperoneSetup = ( IVRChaperoneSetup * )VR_GetGenericInterface( IVRChaperoneSetup_Version, &eError );
  2328. }
  2329. return m_pVRChaperoneSetup;
  2330. }
  2331. IVRCompositor *VRCompositor()
  2332. {
  2333. CheckClear();
  2334. if ( m_pVRCompositor == nullptr )
  2335. {
  2336. EVRInitError eError;
  2337. m_pVRCompositor = ( IVRCompositor * )VR_GetGenericInterface( IVRCompositor_Version, &eError );
  2338. }
  2339. return m_pVRCompositor;
  2340. }
  2341. IVROverlay *VROverlay()
  2342. {
  2343. CheckClear();
  2344. if ( m_pVROverlay == nullptr )
  2345. {
  2346. EVRInitError eError;
  2347. m_pVROverlay = ( IVROverlay * )VR_GetGenericInterface( IVROverlay_Version, &eError );
  2348. }
  2349. return m_pVROverlay;
  2350. }
  2351. IVRRenderModels *VRRenderModels()
  2352. {
  2353. CheckClear();
  2354. if ( m_pVRRenderModels == nullptr )
  2355. {
  2356. EVRInitError eError;
  2357. m_pVRRenderModels = ( IVRRenderModels * )VR_GetGenericInterface( IVRRenderModels_Version, &eError );
  2358. }
  2359. return m_pVRRenderModels;
  2360. }
  2361. IVRExtendedDisplay *VRExtendedDisplay()
  2362. {
  2363. CheckClear();
  2364. if ( m_pVRExtendedDisplay == nullptr )
  2365. {
  2366. EVRInitError eError;
  2367. m_pVRExtendedDisplay = ( IVRExtendedDisplay * )VR_GetGenericInterface( IVRExtendedDisplay_Version, &eError );
  2368. }
  2369. return m_pVRExtendedDisplay;
  2370. }
  2371. IVRSettings *VRSettings()
  2372. {
  2373. CheckClear();
  2374. if ( m_pVRSettings == nullptr )
  2375. {
  2376. EVRInitError eError;
  2377. m_pVRSettings = ( IVRSettings * )VR_GetGenericInterface( IVRSettings_Version, &eError );
  2378. }
  2379. return m_pVRSettings;
  2380. }
  2381. IVRApplications *VRApplications()
  2382. {
  2383. CheckClear();
  2384. if ( m_pVRApplications == nullptr )
  2385. {
  2386. EVRInitError eError;
  2387. m_pVRApplications = ( IVRApplications * )VR_GetGenericInterface( IVRApplications_Version, &eError );
  2388. }
  2389. return m_pVRApplications;
  2390. }
  2391. IVRTrackedCamera *VRTrackedCamera()
  2392. {
  2393. CheckClear();
  2394. if ( m_pVRTrackedCamera == nullptr )
  2395. {
  2396. EVRInitError eError;
  2397. m_pVRTrackedCamera = ( IVRTrackedCamera * )VR_GetGenericInterface( IVRTrackedCamera_Version, &eError );
  2398. }
  2399. return m_pVRTrackedCamera;
  2400. }
  2401. private:
  2402. IVRSystem *m_pVRSystem;
  2403. IVRChaperone *m_pVRChaperone;
  2404. IVRChaperoneSetup *m_pVRChaperoneSetup;
  2405. IVRCompositor *m_pVRCompositor;
  2406. IVROverlay *m_pVROverlay;
  2407. IVRRenderModels *m_pVRRenderModels;
  2408. IVRExtendedDisplay *m_pVRExtendedDisplay;
  2409. IVRSettings *m_pVRSettings;
  2410. IVRApplications *m_pVRApplications;
  2411. IVRTrackedCamera *m_pVRTrackedCamera;
  2412. };
  2413. inline COpenVRContext &OpenVRInternal_ModuleContext()
  2414. {
  2415. static void *ctx[ sizeof( COpenVRContext ) / sizeof( void * ) ];
  2416. return *( COpenVRContext * )ctx; // bypass zero-init constructor
  2417. }
  2418. inline IVRSystem *VR_CALLTYPE VRSystem() { return OpenVRInternal_ModuleContext().VRSystem(); }
  2419. inline IVRChaperone *VR_CALLTYPE VRChaperone() { return OpenVRInternal_ModuleContext().VRChaperone(); }
  2420. inline IVRChaperoneSetup *VR_CALLTYPE VRChaperoneSetup() { return OpenVRInternal_ModuleContext().VRChaperoneSetup(); }
  2421. inline IVRCompositor *VR_CALLTYPE VRCompositor() { return OpenVRInternal_ModuleContext().VRCompositor(); }
  2422. inline IVROverlay *VR_CALLTYPE VROverlay() { return OpenVRInternal_ModuleContext().VROverlay(); }
  2423. inline IVRRenderModels *VR_CALLTYPE VRRenderModels() { return OpenVRInternal_ModuleContext().VRRenderModels(); }
  2424. inline IVRApplications *VR_CALLTYPE VRApplications() { return OpenVRInternal_ModuleContext().VRApplications(); }
  2425. inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleContext().VRSettings(); }
  2426. inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); }
  2427. inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); }
  2428. inline void COpenVRContext::Clear()
  2429. {
  2430. m_pVRSystem = nullptr;
  2431. m_pVRChaperone = nullptr;
  2432. m_pVRChaperoneSetup = nullptr;
  2433. m_pVRCompositor = nullptr;
  2434. m_pVROverlay = nullptr;
  2435. m_pVRRenderModels = nullptr;
  2436. m_pVRExtendedDisplay = nullptr;
  2437. m_pVRSettings = nullptr;
  2438. m_pVRApplications = nullptr;
  2439. m_pVRTrackedCamera = nullptr;
  2440. }
  2441. VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal( EVRInitError *peError, EVRApplicationType eApplicationType );
  2442. VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal();
  2443. /** Finds the active installation of vrclient.dll and initializes it */
  2444. inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType )
  2445. {
  2446. IVRSystem *pVRSystem = nullptr;
  2447. EVRInitError eError;
  2448. VRToken() = VR_InitInternal( &eError, eApplicationType );
  2449. COpenVRContext &ctx = OpenVRInternal_ModuleContext();
  2450. ctx.Clear();
  2451. if ( eError == VRInitError_None )
  2452. {
  2453. if ( VR_IsInterfaceVersionValid( IVRSystem_Version ) )
  2454. {
  2455. pVRSystem = VRSystem();
  2456. }
  2457. else
  2458. {
  2459. VR_ShutdownInternal();
  2460. eError = VRInitError_Init_InterfaceNotFound;
  2461. }
  2462. }
  2463. if ( peError )
  2464. *peError = eError;
  2465. return pVRSystem;
  2466. }
  2467. /** unloads vrclient.dll. Any interface pointers from the interface are
  2468. * invalid after this point */
  2469. inline void VR_Shutdown()
  2470. {
  2471. VR_ShutdownInternal();
  2472. }
  2473. }