openvr.h 147 KB

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