openvr.h 188 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932
  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. // Forward declarations to avoid requiring vulkan.h
  12. struct VkDevice_T;
  13. struct VkPhysicalDevice_T;
  14. struct VkInstance_T;
  15. struct VkQueue_T;
  16. // Forward declarations to avoid requiring d3d12.h
  17. struct ID3D12Resource;
  18. struct ID3D12CommandQueue;
  19. namespace vr
  20. {
  21. #pragma pack( push, 8 )
  22. typedef void* glSharedTextureHandle_t;
  23. typedef int32_t glInt_t;
  24. typedef uint32_t glUInt_t;
  25. // right-handed system
  26. // +y is up
  27. // +x is to the right
  28. // -z is forward
  29. // Distance unit is meters
  30. struct HmdMatrix34_t
  31. {
  32. float m[3][4];
  33. };
  34. struct HmdMatrix44_t
  35. {
  36. float m[4][4];
  37. };
  38. struct HmdVector3_t
  39. {
  40. float v[3];
  41. };
  42. struct HmdVector4_t
  43. {
  44. float v[4];
  45. };
  46. struct HmdVector3d_t
  47. {
  48. double v[3];
  49. };
  50. struct HmdVector2_t
  51. {
  52. float v[2];
  53. };
  54. struct HmdQuaternion_t
  55. {
  56. double w, x, y, z;
  57. };
  58. struct HmdColor_t
  59. {
  60. float r, g, b, a;
  61. };
  62. struct HmdQuad_t
  63. {
  64. HmdVector3_t vCorners[ 4 ];
  65. };
  66. struct HmdRect2_t
  67. {
  68. HmdVector2_t vTopLeft;
  69. HmdVector2_t vBottomRight;
  70. };
  71. /** Used to return the post-distortion UVs for each color channel.
  72. * UVs range from 0 to 1 with 0,0 in the upper left corner of the
  73. * source render target. The 0,0 to 1,1 range covers a single eye. */
  74. struct DistortionCoordinates_t
  75. {
  76. float rfRed[2];
  77. float rfGreen[2];
  78. float rfBlue[2];
  79. };
  80. enum EVREye
  81. {
  82. Eye_Left = 0,
  83. Eye_Right = 1
  84. };
  85. enum ETextureType
  86. {
  87. TextureType_DirectX = 0, // Handle is an ID3D11Texture
  88. TextureType_OpenGL = 1, // Handle is an OpenGL texture name or an OpenGL render buffer name, depending on submit flags
  89. TextureType_Vulkan = 2, // Handle is a pointer to a VRVulkanTextureData_t structure
  90. TextureType_IOSurface = 3, // Handle is a macOS cross-process-sharable IOSurfaceRef
  91. TextureType_DirectX12 = 4, // Handle is a pointer to a D3D12TextureData_t structure
  92. };
  93. enum EColorSpace
  94. {
  95. ColorSpace_Auto = 0, // Assumes 'gamma' for 8-bit per component formats, otherwise 'linear'. This mirrors the DXGI formats which have _SRGB variants.
  96. ColorSpace_Gamma = 1, // Texture data can be displayed directly on the display without any conversion (a.k.a. display native format).
  97. ColorSpace_Linear = 2, // Same as gamma but has been converted to a linear representation using DXGI's sRGB conversion algorithm.
  98. };
  99. struct Texture_t
  100. {
  101. void* handle; // See ETextureType definition above
  102. ETextureType eType;
  103. EColorSpace eColorSpace;
  104. };
  105. // Handle to a shared texture (HANDLE on Windows obtained using OpenSharedResource).
  106. typedef uint64_t SharedTextureHandle_t;
  107. #define INVALID_SHARED_TEXTURE_HANDLE ((vr::SharedTextureHandle_t)0)
  108. enum ETrackingResult
  109. {
  110. TrackingResult_Uninitialized = 1,
  111. TrackingResult_Calibrating_InProgress = 100,
  112. TrackingResult_Calibrating_OutOfRange = 101,
  113. TrackingResult_Running_OK = 200,
  114. TrackingResult_Running_OutOfRange = 201,
  115. };
  116. typedef uint32_t DriverId_t;
  117. static const uint32_t k_nDriverNone = 0xFFFFFFFF;
  118. static const uint32_t k_unMaxDriverDebugResponseSize = 32768;
  119. /** Used to pass device IDs to API calls */
  120. typedef uint32_t TrackedDeviceIndex_t;
  121. static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
  122. static const uint32_t k_unMaxTrackedDeviceCount = 64;
  123. static const uint32_t k_unTrackedDeviceIndexOther = 0xFFFFFFFE;
  124. static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
  125. /** Describes what kind of object is being tracked at a given ID */
  126. enum ETrackedDeviceClass
  127. {
  128. TrackedDeviceClass_Invalid = 0, // the ID was not valid.
  129. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
  130. TrackedDeviceClass_Controller = 2, // Tracked controllers
  131. TrackedDeviceClass_GenericTracker = 3, // Generic trackers, similar to controllers
  132. TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
  133. TrackedDeviceClass_DisplayRedirect = 5, // Accessories that aren't necessarily tracked themselves, but may redirect video output from other tracked devices
  134. };
  135. /** Describes what specific role associated with a tracked device */
  136. enum ETrackedControllerRole
  137. {
  138. TrackedControllerRole_Invalid = 0, // Invalid value for controller type
  139. TrackedControllerRole_LeftHand = 1, // Tracked device associated with the left hand
  140. TrackedControllerRole_RightHand = 2, // Tracked device associated with the right hand
  141. };
  142. /** describes a single pose for a tracked object */
  143. struct TrackedDevicePose_t
  144. {
  145. HmdMatrix34_t mDeviceToAbsoluteTracking;
  146. HmdVector3_t vVelocity; // velocity in tracker space in m/s
  147. HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
  148. ETrackingResult eTrackingResult;
  149. bool bPoseIsValid;
  150. // This indicates that there is a device connected for this spot in the pose array.
  151. // It could go from true to false if the user unplugs the device.
  152. bool bDeviceIsConnected;
  153. };
  154. /** Identifies which style of tracking origin the application wants to use
  155. * for the poses it is requesting */
  156. enum ETrackingUniverseOrigin
  157. {
  158. TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
  159. TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
  160. TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. It has Y up and is unified for devices of the same driver. You usually don't want this one.
  161. };
  162. // Refers to a single container of properties
  163. typedef uint64_t PropertyContainerHandle_t;
  164. typedef uint32_t PropertyTypeTag_t;
  165. static const PropertyContainerHandle_t k_ulInvalidPropertyContainer = 0;
  166. static const PropertyTypeTag_t k_unInvalidPropertyTag = 0;
  167. // Use these tags to set/get common types as struct properties
  168. static const PropertyTypeTag_t k_unFloatPropertyTag = 1;
  169. static const PropertyTypeTag_t k_unInt32PropertyTag = 2;
  170. static const PropertyTypeTag_t k_unUint64PropertyTag = 3;
  171. static const PropertyTypeTag_t k_unBoolPropertyTag = 4;
  172. static const PropertyTypeTag_t k_unStringPropertyTag = 5;
  173. static const PropertyTypeTag_t k_unHmdMatrix34PropertyTag = 20;
  174. static const PropertyTypeTag_t k_unHmdMatrix44PropertyTag = 21;
  175. static const PropertyTypeTag_t k_unHmdVector3PropertyTag = 22;
  176. static const PropertyTypeTag_t k_unHmdVector4PropertyTag = 23;
  177. static const PropertyTypeTag_t k_unHiddenAreaPropertyTag = 30;
  178. static const PropertyTypeTag_t k_unPathHandleInfoTag = 31;
  179. static const PropertyTypeTag_t k_unActionPropertyTag = 32;
  180. static const PropertyTypeTag_t k_unInputValuePropertyTag = 33;
  181. static const PropertyTypeTag_t k_unWildcardPropertyTag = 34;
  182. static const PropertyTypeTag_t k_unHapticVibrationPropertyTag = 35;
  183. static const PropertyTypeTag_t k_unOpenVRInternalReserved_Start = 1000;
  184. static const PropertyTypeTag_t k_unOpenVRInternalReserved_End = 10000;
  185. /** Each entry in this enum represents a property that can be retrieved about a
  186. * tracked device. Many fields are only valid for one ETrackedDeviceClass. */
  187. enum ETrackedDeviceProperty
  188. {
  189. Prop_Invalid = 0,
  190. // general properties that apply to all device classes
  191. Prop_TrackingSystemName_String = 1000,
  192. Prop_ModelNumber_String = 1001,
  193. Prop_SerialNumber_String = 1002,
  194. Prop_RenderModelName_String = 1003,
  195. Prop_WillDriftInYaw_Bool = 1004,
  196. Prop_ManufacturerName_String = 1005,
  197. Prop_TrackingFirmwareVersion_String = 1006,
  198. Prop_HardwareRevision_String = 1007,
  199. Prop_AllWirelessDongleDescriptions_String = 1008,
  200. Prop_ConnectedWirelessDongle_String = 1009,
  201. Prop_DeviceIsWireless_Bool = 1010,
  202. Prop_DeviceIsCharging_Bool = 1011,
  203. Prop_DeviceBatteryPercentage_Float = 1012, // 0 is empty, 1 is full
  204. Prop_StatusDisplayTransform_Matrix34 = 1013,
  205. Prop_Firmware_UpdateAvailable_Bool = 1014,
  206. Prop_Firmware_ManualUpdate_Bool = 1015,
  207. Prop_Firmware_ManualUpdateURL_String = 1016,
  208. Prop_HardwareRevision_Uint64 = 1017,
  209. Prop_FirmwareVersion_Uint64 = 1018,
  210. Prop_FPGAVersion_Uint64 = 1019,
  211. Prop_VRCVersion_Uint64 = 1020,
  212. Prop_RadioVersion_Uint64 = 1021,
  213. Prop_DongleVersion_Uint64 = 1022,
  214. Prop_BlockServerShutdown_Bool = 1023,
  215. Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024,
  216. Prop_ContainsProximitySensor_Bool = 1025,
  217. Prop_DeviceProvidesBatteryStatus_Bool = 1026,
  218. Prop_DeviceCanPowerOff_Bool = 1027,
  219. Prop_Firmware_ProgrammingTarget_String = 1028,
  220. Prop_DeviceClass_Int32 = 1029,
  221. Prop_HasCamera_Bool = 1030,
  222. Prop_DriverVersion_String = 1031,
  223. Prop_Firmware_ForceUpdateRequired_Bool = 1032,
  224. Prop_ViveSystemButtonFixRequired_Bool = 1033,
  225. Prop_ParentDriver_Uint64 = 1034,
  226. Prop_ResourceRoot_String = 1035,
  227. Prop_RegisteredDeviceType_String = 1036,
  228. Prop_InputProfilePath_String = 1037, // input profile to use for this device in the input system. Will default to tracking system name if this isn't provided
  229. // Properties that are unique to TrackedDeviceClass_HMD
  230. Prop_ReportsTimeSinceVSync_Bool = 2000,
  231. Prop_SecondsFromVsyncToPhotons_Float = 2001,
  232. Prop_DisplayFrequency_Float = 2002,
  233. Prop_UserIpdMeters_Float = 2003,
  234. Prop_CurrentUniverseId_Uint64 = 2004,
  235. Prop_PreviousUniverseId_Uint64 = 2005,
  236. Prop_DisplayFirmwareVersion_Uint64 = 2006,
  237. Prop_IsOnDesktop_Bool = 2007,
  238. Prop_DisplayMCType_Int32 = 2008,
  239. Prop_DisplayMCOffset_Float = 2009,
  240. Prop_DisplayMCScale_Float = 2010,
  241. Prop_EdidVendorID_Int32 = 2011,
  242. Prop_DisplayMCImageLeft_String = 2012,
  243. Prop_DisplayMCImageRight_String = 2013,
  244. Prop_DisplayGCBlackClamp_Float = 2014,
  245. Prop_EdidProductID_Int32 = 2015,
  246. Prop_CameraToHeadTransform_Matrix34 = 2016,
  247. Prop_DisplayGCType_Int32 = 2017,
  248. Prop_DisplayGCOffset_Float = 2018,
  249. Prop_DisplayGCScale_Float = 2019,
  250. Prop_DisplayGCPrescale_Float = 2020,
  251. Prop_DisplayGCImage_String = 2021,
  252. Prop_LensCenterLeftU_Float = 2022,
  253. Prop_LensCenterLeftV_Float = 2023,
  254. Prop_LensCenterRightU_Float = 2024,
  255. Prop_LensCenterRightV_Float = 2025,
  256. Prop_UserHeadToEyeDepthMeters_Float = 2026,
  257. Prop_CameraFirmwareVersion_Uint64 = 2027,
  258. Prop_CameraFirmwareDescription_String = 2028,
  259. Prop_DisplayFPGAVersion_Uint64 = 2029,
  260. Prop_DisplayBootloaderVersion_Uint64 = 2030,
  261. Prop_DisplayHardwareVersion_Uint64 = 2031,
  262. Prop_AudioFirmwareVersion_Uint64 = 2032,
  263. Prop_CameraCompatibilityMode_Int32 = 2033,
  264. Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034,
  265. Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035,
  266. Prop_DisplaySuppressed_Bool = 2036,
  267. Prop_DisplayAllowNightMode_Bool = 2037,
  268. Prop_DisplayMCImageWidth_Int32 = 2038,
  269. Prop_DisplayMCImageHeight_Int32 = 2039,
  270. Prop_DisplayMCImageNumChannels_Int32 = 2040,
  271. Prop_DisplayMCImageData_Binary = 2041,
  272. Prop_SecondsFromPhotonsToVblank_Float = 2042,
  273. Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043,
  274. Prop_DisplayDebugMode_Bool = 2044,
  275. Prop_GraphicsAdapterLuid_Uint64 = 2045,
  276. Prop_DriverProvidedChaperonePath_String = 2048,
  277. Prop_ExpectedTrackingReferenceCount_Int32 = 2049, // expected number of sensors or basestations to reserve UI space for
  278. Prop_ExpectedControllerCount_Int32 = 2050, // expected number of tracked controllers to reserve UI space for
  279. Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, // placeholder icon for "left" controller if not yet detected/loaded
  280. Prop_NamedIconPathControllerRightDeviceOff_String = 2052, // placeholder icon for "right" controller if not yet detected/loaded
  281. Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, // placeholder icon for sensor/base if not yet detected/loaded
  282. Prop_DoNotApplyPrediction_Bool = 2054,
  283. Prop_CameraToHeadTransforms_Matrix34_Array = 2055,
  284. Prop_DriverIsDrawingControllers_Bool = 2057,
  285. Prop_DriverRequestsApplicationPause_Bool = 2058,
  286. Prop_DriverRequestsReducedRendering_Bool = 2059,
  287. // Properties that are unique to TrackedDeviceClass_Controller
  288. Prop_AttachedDeviceId_String = 3000,
  289. Prop_SupportedButtons_Uint64 = 3001,
  290. Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
  291. Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
  292. Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
  293. Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
  294. Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
  295. Prop_ControllerRoleHint_Int32 = 3007, // Return value is of type ETrackedControllerRole
  296. // Properties that are unique to TrackedDeviceClass_TrackingReference
  297. Prop_FieldOfViewLeftDegrees_Float = 4000,
  298. Prop_FieldOfViewRightDegrees_Float = 4001,
  299. Prop_FieldOfViewTopDegrees_Float = 4002,
  300. Prop_FieldOfViewBottomDegrees_Float = 4003,
  301. Prop_TrackingRangeMinimumMeters_Float = 4004,
  302. Prop_TrackingRangeMaximumMeters_Float = 4005,
  303. Prop_ModeLabel_String = 4006,
  304. // Properties that are used for user interface like icons names
  305. Prop_IconPathName_String = 5000, // DEPRECATED. Value not referenced. Now expected to be part of icon path properties.
  306. Prop_NamedIconPathDeviceOff_String = 5001, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  307. Prop_NamedIconPathDeviceSearching_String = 5002, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  308. Prop_NamedIconPathDeviceSearchingAlert_String = 5003, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  309. Prop_NamedIconPathDeviceReady_String = 5004, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  310. Prop_NamedIconPathDeviceReadyAlert_String = 5005, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  311. Prop_NamedIconPathDeviceNotReady_String = 5006, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  312. Prop_NamedIconPathDeviceStandby_String = 5007, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  313. Prop_NamedIconPathDeviceAlertLow_String = 5008, // {driver}/icons/icon_filename - PNG for static icon, or GIF for animation, 50x32 for headsets and 32x32 for others
  314. // Properties that are used by helpers, but are opaque to applications
  315. Prop_DisplayHiddenArea_Binary_Start = 5100,
  316. Prop_DisplayHiddenArea_Binary_End = 5150,
  317. Prop_ParentContainer = 5151,
  318. // Properties that are unique to drivers
  319. Prop_UserConfigPath_String = 6000,
  320. Prop_InstallPath_String = 6001,
  321. Prop_HasDisplayComponent_Bool = 6002,
  322. Prop_HasControllerComponent_Bool = 6003,
  323. Prop_HasCameraComponent_Bool = 6004,
  324. Prop_HasDriverDirectModeComponent_Bool = 6005,
  325. Prop_HasVirtualDisplayComponent_Bool = 6006,
  326. // Properties that are set internally based on other information provided by drivers
  327. Prop_ControllerType_String = 7000,
  328. Prop_LegacyInputProfile_String = 7001,
  329. // Vendors are free to expose private debug data in this reserved region
  330. Prop_VendorSpecific_Reserved_Start = 10000,
  331. Prop_VendorSpecific_Reserved_End = 10999,
  332. Prop_TrackedDeviceProperty_Max = 1000000,
  333. };
  334. /** No string property will ever be longer than this length */
  335. static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
  336. /** Used to return errors that occur when reading properties. */
  337. enum ETrackedPropertyError
  338. {
  339. TrackedProp_Success = 0,
  340. TrackedProp_WrongDataType = 1,
  341. TrackedProp_WrongDeviceClass = 2,
  342. TrackedProp_BufferTooSmall = 3,
  343. TrackedProp_UnknownProperty = 4, // Driver has not set the property (and may not ever).
  344. TrackedProp_InvalidDevice = 5,
  345. TrackedProp_CouldNotContactServer = 6,
  346. TrackedProp_ValueNotProvidedByDevice = 7,
  347. TrackedProp_StringExceedsMaximumLength = 8,
  348. TrackedProp_NotYetAvailable = 9, // The property value isn't known yet, but is expected soon. Call again later.
  349. TrackedProp_PermissionDenied = 10,
  350. TrackedProp_InvalidOperation = 11,
  351. TrackedProp_CannotWriteToWildcards = 12,
  352. };
  353. /** Allows the application to control what part of the provided texture will be used in the
  354. * frame buffer. */
  355. struct VRTextureBounds_t
  356. {
  357. float uMin, vMin;
  358. float uMax, vMax;
  359. };
  360. /** Allows specifying pose used to render provided scene texture (if different from value returned by WaitGetPoses). */
  361. struct VRTextureWithPose_t : public Texture_t
  362. {
  363. HmdMatrix34_t mDeviceToAbsoluteTracking; // Actual pose used to render scene textures.
  364. };
  365. struct VRTextureDepthInfo_t
  366. {
  367. void* handle; // See ETextureType definition above
  368. HmdMatrix44_t mProjection;
  369. HmdVector2_t vRange; // 0..1
  370. };
  371. struct VRTextureWithDepth_t : public Texture_t
  372. {
  373. VRTextureDepthInfo_t depth;
  374. };
  375. struct VRTextureWithPoseAndDepth_t : public VRTextureWithPose_t
  376. {
  377. VRTextureDepthInfo_t depth;
  378. };
  379. /** Allows the application to control how scene textures are used by the compositor when calling Submit. */
  380. enum EVRSubmitFlags
  381. {
  382. // Simple render path. App submits rendered left and right eye images with no lens distortion correction applied.
  383. Submit_Default = 0x00,
  384. // App submits final left and right eye images with lens distortion already applied (lens distortion makes the images appear
  385. // barrel distorted with chromatic aberration correction applied). The app would have used the data returned by
  386. // vr::IVRSystem::ComputeDistortion() to apply the correct distortion to the rendered images before calling Submit().
  387. Submit_LensDistortionAlreadyApplied = 0x01,
  388. // If the texture pointer passed in is actually a renderbuffer (e.g. for MSAA in OpenGL) then set this flag.
  389. Submit_GlRenderBuffer = 0x02,
  390. // Do not use
  391. Submit_Reserved = 0x04,
  392. // Set to indicate that pTexture is a pointer to a VRTextureWithPose_t.
  393. // This flag can be combined with Submit_TextureWithDepth to pass a VRTextureWithPoseAndDepth_t.
  394. Submit_TextureWithPose = 0x08,
  395. // Set to indicate that pTexture is a pointer to a VRTextureWithDepth_t.
  396. // This flag can be combined with Submit_TextureWithPose to pass a VRTextureWithPoseAndDepth_t.
  397. Submit_TextureWithDepth = 0x10,
  398. };
  399. /** Data required for passing Vulkan textures to IVRCompositor::Submit.
  400. * Be sure to call OpenVR_Shutdown before destroying these resources. */
  401. struct VRVulkanTextureData_t
  402. {
  403. uint64_t m_nImage; // VkImage
  404. VkDevice_T *m_pDevice;
  405. VkPhysicalDevice_T *m_pPhysicalDevice;
  406. VkInstance_T *m_pInstance;
  407. VkQueue_T *m_pQueue;
  408. uint32_t m_nQueueFamilyIndex;
  409. uint32_t m_nWidth, m_nHeight, m_nFormat, m_nSampleCount;
  410. };
  411. /** Data required for passing D3D12 textures to IVRCompositor::Submit.
  412. * Be sure to call OpenVR_Shutdown before destroying these resources. */
  413. struct D3D12TextureData_t
  414. {
  415. ID3D12Resource *m_pResource;
  416. ID3D12CommandQueue *m_pCommandQueue;
  417. uint32_t m_nNodeMask;
  418. };
  419. /** Status of the overall system or tracked objects */
  420. enum EVRState
  421. {
  422. VRState_Undefined = -1,
  423. VRState_Off = 0,
  424. VRState_Searching = 1,
  425. VRState_Searching_Alert = 2,
  426. VRState_Ready = 3,
  427. VRState_Ready_Alert = 4,
  428. VRState_NotReady = 5,
  429. VRState_Standby = 6,
  430. VRState_Ready_Alert_Low = 7,
  431. };
  432. /** The types of events that could be posted (and what the parameters mean for each event type) */
  433. enum EVREventType
  434. {
  435. VREvent_None = 0,
  436. VREvent_TrackedDeviceActivated = 100,
  437. VREvent_TrackedDeviceDeactivated = 101,
  438. VREvent_TrackedDeviceUpdated = 102,
  439. VREvent_TrackedDeviceUserInteractionStarted = 103,
  440. VREvent_TrackedDeviceUserInteractionEnded = 104,
  441. VREvent_IpdChanged = 105,
  442. VREvent_EnterStandbyMode = 106,
  443. VREvent_LeaveStandbyMode = 107,
  444. VREvent_TrackedDeviceRoleChanged = 108,
  445. VREvent_WatchdogWakeUpRequested = 109,
  446. VREvent_LensDistortionChanged = 110,
  447. VREvent_PropertyChanged = 111,
  448. VREvent_WirelessDisconnect = 112,
  449. VREvent_WirelessReconnect = 113,
  450. VREvent_ButtonPress = 200, // data is controller
  451. VREvent_ButtonUnpress = 201, // data is controller
  452. VREvent_ButtonTouch = 202, // data is controller
  453. VREvent_ButtonUntouch = 203, // data is controller
  454. VREvent_DualAnalog_Press = 250, // data is dualAnalog
  455. VREvent_DualAnalog_Unpress = 251, // data is dualAnalog
  456. VREvent_DualAnalog_Touch = 252, // data is dualAnalog
  457. VREvent_DualAnalog_Untouch = 253, // data is dualAnalog
  458. VREvent_DualAnalog_Move = 254, // data is dualAnalog
  459. VREvent_DualAnalog_ModeSwitch1 = 255, // data is dualAnalog
  460. VREvent_DualAnalog_ModeSwitch2 = 256, // data is dualAnalog
  461. VREvent_DualAnalog_Cancel = 257, // data is dualAnalog
  462. VREvent_MouseMove = 300, // data is mouse
  463. VREvent_MouseButtonDown = 301, // data is mouse
  464. VREvent_MouseButtonUp = 302, // data is mouse
  465. VREvent_FocusEnter = 303, // data is overlay
  466. VREvent_FocusLeave = 304, // data is overlay
  467. VREvent_Scroll = 305, // data is mouse
  468. VREvent_TouchPadMove = 306, // data is mouse
  469. VREvent_OverlayFocusChanged = 307, // data is overlay, global event
  470. VREvent_InputFocusCaptured = 400, // data is process DEPRECATED
  471. VREvent_InputFocusReleased = 401, // data is process DEPRECATED
  472. VREvent_SceneFocusLost = 402, // data is process
  473. VREvent_SceneFocusGained = 403, // data is process
  474. VREvent_SceneApplicationChanged = 404, // data is process - The App actually drawing the scene changed (usually to or from the compositor)
  475. VREvent_SceneFocusChanged = 405, // data is process - New app got access to draw the scene
  476. VREvent_InputFocusChanged = 406, // data is process
  477. VREvent_SceneApplicationSecondaryRenderingStarted = 407, // data is process
  478. VREvent_HideRenderModels = 410, // Sent to the scene application to request hiding render models temporarily
  479. VREvent_ShowRenderModels = 411, // Sent to the scene application to request restoring render model visibility
  480. VREvent_ConsoleOpened = 420,
  481. VREvent_ConsoleClosed = 421,
  482. VREvent_OverlayShown = 500,
  483. VREvent_OverlayHidden = 501,
  484. VREvent_DashboardActivated = 502,
  485. VREvent_DashboardDeactivated = 503,
  486. VREvent_DashboardThumbSelected = 504, // Sent to the overlay manager - data is overlay
  487. VREvent_DashboardRequested = 505, // Sent to the overlay manager - data is overlay
  488. VREvent_ResetDashboard = 506, // Send to the overlay manager
  489. VREvent_RenderToast = 507, // Send to the dashboard to render a toast - data is the notification ID
  490. VREvent_ImageLoaded = 508, // Sent to overlays when a SetOverlayRaw or SetOverlayFromFile call finishes loading
  491. VREvent_ShowKeyboard = 509, // Sent to keyboard renderer in the dashboard to invoke it
  492. VREvent_HideKeyboard = 510, // Sent to keyboard renderer in the dashboard to hide it
  493. VREvent_OverlayGamepadFocusGained = 511, // Sent to an overlay when IVROverlay::SetFocusOverlay is called on it
  494. VREvent_OverlayGamepadFocusLost = 512, // Send to an overlay when it previously had focus and IVROverlay::SetFocusOverlay is called on something else
  495. VREvent_OverlaySharedTextureChanged = 513,
  496. VREvent_DashboardGuideButtonDown = 514,
  497. VREvent_DashboardGuideButtonUp = 515,
  498. VREvent_ScreenshotTriggered = 516, // Screenshot button combo was pressed, Dashboard should request a screenshot
  499. VREvent_ImageFailed = 517, // Sent to overlays when a SetOverlayRaw or SetOverlayfromFail fails to load
  500. VREvent_DashboardOverlayCreated = 518,
  501. // Screenshot API
  502. VREvent_RequestScreenshot = 520, // Sent by vrclient application to compositor to take a screenshot
  503. VREvent_ScreenshotTaken = 521, // Sent by compositor to the application that the screenshot has been taken
  504. VREvent_ScreenshotFailed = 522, // Sent by compositor to the application that the screenshot failed to be taken
  505. VREvent_SubmitScreenshotToDashboard = 523, // Sent by compositor to the dashboard that a completed screenshot was submitted
  506. VREvent_ScreenshotProgressToDashboard = 524, // Sent by compositor to the dashboard that a completed screenshot was submitted
  507. VREvent_PrimaryDashboardDeviceChanged = 525,
  508. VREvent_Notification_Shown = 600,
  509. VREvent_Notification_Hidden = 601,
  510. VREvent_Notification_BeginInteraction = 602,
  511. VREvent_Notification_Destroyed = 603,
  512. VREvent_Quit = 700, // data is process
  513. VREvent_ProcessQuit = 701, // data is process
  514. VREvent_QuitAborted_UserPrompt = 702, // data is process
  515. VREvent_QuitAcknowledged = 703, // data is process
  516. VREvent_DriverRequestedQuit = 704, // The driver has requested that SteamVR shut down
  517. VREvent_ChaperoneDataHasChanged = 800,
  518. VREvent_ChaperoneUniverseHasChanged = 801,
  519. VREvent_ChaperoneTempDataHasChanged = 802,
  520. VREvent_ChaperoneSettingsHaveChanged = 803,
  521. VREvent_SeatedZeroPoseReset = 804,
  522. VREvent_AudioSettingsHaveChanged = 820,
  523. VREvent_BackgroundSettingHasChanged = 850,
  524. VREvent_CameraSettingsHaveChanged = 851,
  525. VREvent_ReprojectionSettingHasChanged = 852,
  526. VREvent_ModelSkinSettingsHaveChanged = 853,
  527. VREvent_EnvironmentSettingsHaveChanged = 854,
  528. VREvent_PowerSettingsHaveChanged = 855,
  529. VREvent_EnableHomeAppSettingsHaveChanged = 856,
  530. VREvent_SteamVRSectionSettingChanged = 857,
  531. VREvent_LighthouseSectionSettingChanged = 858,
  532. VREvent_NullSectionSettingChanged = 859,
  533. VREvent_UserInterfaceSectionSettingChanged = 860,
  534. VREvent_NotificationsSectionSettingChanged = 861,
  535. VREvent_KeyboardSectionSettingChanged = 862,
  536. VREvent_PerfSectionSettingChanged = 863,
  537. VREvent_DashboardSectionSettingChanged = 864,
  538. VREvent_WebInterfaceSectionSettingChanged = 865,
  539. VREvent_StatusUpdate = 900,
  540. VREvent_WebInterface_InstallDriverCompleted = 950,
  541. VREvent_MCImageUpdated = 1000,
  542. VREvent_FirmwareUpdateStarted = 1100,
  543. VREvent_FirmwareUpdateFinished = 1101,
  544. VREvent_KeyboardClosed = 1200,
  545. VREvent_KeyboardCharInput = 1201,
  546. VREvent_KeyboardDone = 1202, // Sent when DONE button clicked on keyboard
  547. VREvent_ApplicationTransitionStarted = 1300,
  548. VREvent_ApplicationTransitionAborted = 1301,
  549. VREvent_ApplicationTransitionNewAppStarted = 1302,
  550. VREvent_ApplicationListUpdated = 1303,
  551. VREvent_ApplicationMimeTypeLoad = 1304,
  552. VREvent_ApplicationTransitionNewAppLaunchComplete = 1305,
  553. VREvent_ProcessConnected = 1306,
  554. VREvent_ProcessDisconnected = 1307,
  555. VREvent_Compositor_MirrorWindowShown = 1400,
  556. VREvent_Compositor_MirrorWindowHidden = 1401,
  557. VREvent_Compositor_ChaperoneBoundsShown = 1410,
  558. VREvent_Compositor_ChaperoneBoundsHidden = 1411,
  559. VREvent_TrackedCamera_StartVideoStream = 1500,
  560. VREvent_TrackedCamera_StopVideoStream = 1501,
  561. VREvent_TrackedCamera_PauseVideoStream = 1502,
  562. VREvent_TrackedCamera_ResumeVideoStream = 1503,
  563. VREvent_TrackedCamera_EditingSurface = 1550,
  564. VREvent_PerformanceTest_EnableCapture = 1600,
  565. VREvent_PerformanceTest_DisableCapture = 1601,
  566. VREvent_PerformanceTest_FidelityLevel = 1602,
  567. VREvent_MessageOverlay_Closed = 1650,
  568. VREvent_MessageOverlayCloseRequested = 1651,
  569. VREvent_Input_HapticVibration = 1700, // data is hapticVibration
  570. // Vendors are free to expose private events in this reserved region
  571. VREvent_VendorSpecific_Reserved_Start = 10000,
  572. VREvent_VendorSpecific_Reserved_End = 19999,
  573. };
  574. /** Level of Hmd activity */
  575. // UserInteraction_Timeout means the device is in the process of timing out.
  576. // InUse = ( k_EDeviceActivityLevel_UserInteraction || k_EDeviceActivityLevel_UserInteraction_Timeout )
  577. // VREvent_TrackedDeviceUserInteractionStarted fires when the devices transitions from Standby -> UserInteraction or Idle -> UserInteraction.
  578. // VREvent_TrackedDeviceUserInteractionEnded fires when the devices transitions from UserInteraction_Timeout -> Idle
  579. enum EDeviceActivityLevel
  580. {
  581. k_EDeviceActivityLevel_Unknown = -1,
  582. k_EDeviceActivityLevel_Idle = 0, // No activity for the last 10 seconds
  583. k_EDeviceActivityLevel_UserInteraction = 1, // Activity (movement or prox sensor) is happening now
  584. k_EDeviceActivityLevel_UserInteraction_Timeout = 2, // No activity for the last 0.5 seconds
  585. k_EDeviceActivityLevel_Standby = 3, // Idle for at least 5 seconds (configurable in Settings -> Power Management)
  586. };
  587. /** VR controller button and axis IDs */
  588. enum EVRButtonId
  589. {
  590. k_EButton_System = 0,
  591. k_EButton_ApplicationMenu = 1,
  592. k_EButton_Grip = 2,
  593. k_EButton_DPad_Left = 3,
  594. k_EButton_DPad_Up = 4,
  595. k_EButton_DPad_Right = 5,
  596. k_EButton_DPad_Down = 6,
  597. k_EButton_A = 7,
  598. k_EButton_ProximitySensor = 31,
  599. k_EButton_Axis0 = 32,
  600. k_EButton_Axis1 = 33,
  601. k_EButton_Axis2 = 34,
  602. k_EButton_Axis3 = 35,
  603. k_EButton_Axis4 = 36,
  604. // aliases for well known controllers
  605. k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
  606. k_EButton_SteamVR_Trigger = k_EButton_Axis1,
  607. k_EButton_Dashboard_Back = k_EButton_Grip,
  608. k_EButton_Max = 64
  609. };
  610. inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
  611. /** used for controller button events */
  612. struct VREvent_Controller_t
  613. {
  614. uint32_t button; // EVRButtonId enum
  615. };
  616. /** used for simulated mouse events in overlay space */
  617. enum EVRMouseButton
  618. {
  619. VRMouseButton_Left = 0x0001,
  620. VRMouseButton_Right = 0x0002,
  621. VRMouseButton_Middle = 0x0004,
  622. };
  623. /** used for simulated mouse events in overlay space */
  624. struct VREvent_Mouse_t
  625. {
  626. float x, y; // co-ords are in GL space, bottom left of the texture is 0,0
  627. uint32_t button; // EVRMouseButton enum
  628. };
  629. /** used for simulated mouse wheel scroll in overlay space */
  630. struct VREvent_Scroll_t
  631. {
  632. float xdelta, ydelta; // movement in fraction of the pad traversed since last delta, 1.0 for a full swipe
  633. uint32_t repeatCount;
  634. };
  635. /** when in mouse input mode you can receive data from the touchpad, these events are only sent if the users finger
  636. is on the touchpad (or just released from it). These events are sent to overlays with the VROverlayFlags_SendVRTouchpadEvents
  637. flag set.
  638. **/
  639. struct VREvent_TouchPadMove_t
  640. {
  641. // true if the users finger is detected on the touch pad
  642. bool bFingerDown;
  643. // How long the finger has been down in seconds
  644. float flSecondsFingerDown;
  645. // These values indicate the starting finger position (so you can do some basic swipe stuff)
  646. float fValueXFirst;
  647. float fValueYFirst;
  648. // This is the raw sampled coordinate without deadzoning
  649. float fValueXRaw;
  650. float fValueYRaw;
  651. };
  652. /** notification related events. Details will still change at this point */
  653. struct VREvent_Notification_t
  654. {
  655. uint64_t ulUserValue;
  656. uint32_t notificationId;
  657. };
  658. /** Used for events about processes */
  659. struct VREvent_Process_t
  660. {
  661. uint32_t pid;
  662. uint32_t oldPid;
  663. bool bForced;
  664. };
  665. /** Used for a few events about overlays */
  666. struct VREvent_Overlay_t
  667. {
  668. uint64_t overlayHandle;
  669. };
  670. /** Used for a few events about overlays */
  671. struct VREvent_Status_t
  672. {
  673. uint32_t statusState; // EVRState enum
  674. };
  675. /** Used for keyboard events **/
  676. struct VREvent_Keyboard_t
  677. {
  678. char cNewInput[8]; // Up to 11 bytes of new input
  679. uint64_t uUserValue; // Possible flags about the new input
  680. };
  681. struct VREvent_Ipd_t
  682. {
  683. float ipdMeters;
  684. };
  685. struct VREvent_Chaperone_t
  686. {
  687. uint64_t m_nPreviousUniverse;
  688. uint64_t m_nCurrentUniverse;
  689. };
  690. /** Not actually used for any events */
  691. struct VREvent_Reserved_t
  692. {
  693. uint64_t reserved0;
  694. uint64_t reserved1;
  695. };
  696. struct VREvent_PerformanceTest_t
  697. {
  698. uint32_t m_nFidelityLevel;
  699. };
  700. struct VREvent_SeatedZeroPoseReset_t
  701. {
  702. bool bResetBySystemMenu;
  703. };
  704. struct VREvent_Screenshot_t
  705. {
  706. uint32_t handle;
  707. uint32_t type;
  708. };
  709. struct VREvent_ScreenshotProgress_t
  710. {
  711. float progress;
  712. };
  713. struct VREvent_ApplicationLaunch_t
  714. {
  715. uint32_t pid;
  716. uint32_t unArgsHandle;
  717. };
  718. struct VREvent_EditingCameraSurface_t
  719. {
  720. uint64_t overlayHandle;
  721. uint32_t nVisualMode;
  722. };
  723. struct VREvent_MessageOverlay_t
  724. {
  725. uint32_t unVRMessageOverlayResponse; // vr::VRMessageOverlayResponse enum
  726. };
  727. struct VREvent_Property_t
  728. {
  729. PropertyContainerHandle_t container;
  730. ETrackedDeviceProperty prop;
  731. };
  732. enum EDualAnalogWhich
  733. {
  734. k_EDualAnalog_Left = 0,
  735. k_EDualAnalog_Right = 1,
  736. };
  737. struct VREvent_DualAnalog_t
  738. {
  739. float x, y; // coordinates are -1..1 analog values
  740. float transformedX, transformedY; // transformed by the center and radius numbers provided by the overlay
  741. EDualAnalogWhich which;
  742. };
  743. struct VREvent_HapticVibration_t
  744. {
  745. uint64_t containerHandle; // property container handle of the device with the haptic component
  746. uint64_t componentHandle; // Which haptic component needs to vibrate
  747. float fDurationSeconds;
  748. float fFrequency;
  749. float fAmplitude;
  750. };
  751. /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py */
  752. typedef union
  753. {
  754. VREvent_Reserved_t reserved;
  755. VREvent_Controller_t controller;
  756. VREvent_Mouse_t mouse;
  757. VREvent_Scroll_t scroll;
  758. VREvent_Process_t process;
  759. VREvent_Notification_t notification;
  760. VREvent_Overlay_t overlay;
  761. VREvent_Status_t status;
  762. VREvent_Keyboard_t keyboard;
  763. VREvent_Ipd_t ipd;
  764. VREvent_Chaperone_t chaperone;
  765. VREvent_PerformanceTest_t performanceTest;
  766. VREvent_TouchPadMove_t touchPadMove;
  767. VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset;
  768. VREvent_Screenshot_t screenshot;
  769. VREvent_ScreenshotProgress_t screenshotProgress;
  770. VREvent_ApplicationLaunch_t applicationLaunch;
  771. VREvent_EditingCameraSurface_t cameraSurface;
  772. VREvent_MessageOverlay_t messageOverlay;
  773. VREvent_Property_t property;
  774. VREvent_DualAnalog_t dualAnalog;
  775. VREvent_HapticVibration_t hapticVibration;
  776. } VREvent_Data_t;
  777. #if defined(__linux__) || defined(__APPLE__)
  778. // This structure was originally defined mis-packed on Linux, preserved for
  779. // compatibility.
  780. #pragma pack( push, 4 )
  781. #endif
  782. /** An event posted by the server to all running applications */
  783. struct VREvent_t
  784. {
  785. uint32_t eventType; // EVREventType enum
  786. TrackedDeviceIndex_t trackedDeviceIndex;
  787. float eventAgeSeconds;
  788. // event data must be the end of the struct as its size is variable
  789. VREvent_Data_t data;
  790. };
  791. #if defined(__linux__) || defined(__APPLE__)
  792. #pragma pack( pop )
  793. #endif
  794. enum EVRInputError
  795. {
  796. VRInputError_None = 0,
  797. VRInputError_NameNotFound = 1,
  798. VRInputError_WrongType = 2,
  799. VRInputError_InvalidHandle = 3,
  800. VRInputError_InvalidParam = 4,
  801. VRInputError_NoSteam = 5,
  802. VRInputError_MaxCapacityReached = 6,
  803. VRInputError_IPCError = 7,
  804. VRInputError_NoActiveActionSet = 8,
  805. VRInputError_InvalidDevice = 9,
  806. };
  807. /** The mesh to draw into the stencil (or depth) buffer to perform
  808. * early stencil (or depth) kills of pixels that will never appear on the HMD.
  809. * This mesh draws on all the pixels that will be hidden after distortion.
  810. *
  811. * If the HMD does not provide a visible area mesh pVertexData will be
  812. * NULL and unTriangleCount will be 0. */
  813. struct HiddenAreaMesh_t
  814. {
  815. const HmdVector2_t *pVertexData;
  816. uint32_t unTriangleCount;
  817. };
  818. enum EHiddenAreaMeshType
  819. {
  820. k_eHiddenAreaMesh_Standard = 0,
  821. k_eHiddenAreaMesh_Inverse = 1,
  822. k_eHiddenAreaMesh_LineLoop = 2,
  823. k_eHiddenAreaMesh_Max = 3,
  824. };
  825. /** Identifies what kind of axis is on the controller at index n. Read this type
  826. * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
  827. */
  828. enum EVRControllerAxisType
  829. {
  830. k_eControllerAxis_None = 0,
  831. k_eControllerAxis_TrackPad = 1,
  832. k_eControllerAxis_Joystick = 2,
  833. k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
  834. };
  835. /** contains information about one axis on the controller */
  836. struct VRControllerAxis_t
  837. {
  838. float x; // Ranges from -1.0 to 1.0 for joysticks and track pads. Ranges from 0.0 to 1.0 for triggers were 0 is fully released.
  839. float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
  840. };
  841. /** the number of axes in the controller state */
  842. static const uint32_t k_unControllerStateAxisCount = 5;
  843. #if defined(__linux__) || defined(__APPLE__)
  844. // This structure was originally defined mis-packed on Linux, preserved for
  845. // compatibility.
  846. #pragma pack( push, 4 )
  847. #endif
  848. /** Holds all the state of a controller at one moment in time. */
  849. struct VRControllerState001_t
  850. {
  851. // If packet num matches that on your prior call, then the controller state hasn't been changed since
  852. // your last call and there is no need to process it
  853. uint32_t unPacketNum;
  854. // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
  855. uint64_t ulButtonPressed;
  856. uint64_t ulButtonTouched;
  857. // Axis data for the controller's analog inputs
  858. VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
  859. };
  860. #if defined(__linux__) || defined(__APPLE__)
  861. #pragma pack( pop )
  862. #endif
  863. typedef VRControllerState001_t VRControllerState_t;
  864. /** determines how to provide output to the application of various event processing functions. */
  865. enum EVRControllerEventOutputType
  866. {
  867. ControllerEventOutput_OSEvents = 0,
  868. ControllerEventOutput_VREvents = 1,
  869. };
  870. /** Collision Bounds Style */
  871. enum ECollisionBoundsStyle
  872. {
  873. COLLISION_BOUNDS_STYLE_BEGINNER = 0,
  874. COLLISION_BOUNDS_STYLE_INTERMEDIATE,
  875. COLLISION_BOUNDS_STYLE_SQUARES,
  876. COLLISION_BOUNDS_STYLE_ADVANCED,
  877. COLLISION_BOUNDS_STYLE_NONE,
  878. COLLISION_BOUNDS_STYLE_COUNT
  879. };
  880. /** Allows the application to customize how the overlay appears in the compositor */
  881. struct Compositor_OverlaySettings
  882. {
  883. uint32_t size; // sizeof(Compositor_OverlaySettings)
  884. bool curved, antialias;
  885. float scale, distance, alpha;
  886. float uOffset, vOffset, uScale, vScale;
  887. float gridDivs, gridWidth, gridScale;
  888. HmdMatrix44_t transform;
  889. };
  890. /** used to refer to a single VR overlay */
  891. typedef uint64_t VROverlayHandle_t;
  892. static const VROverlayHandle_t k_ulOverlayHandleInvalid = 0;
  893. /** Errors that can occur around VR overlays */
  894. enum EVROverlayError
  895. {
  896. VROverlayError_None = 0,
  897. VROverlayError_UnknownOverlay = 10,
  898. VROverlayError_InvalidHandle = 11,
  899. VROverlayError_PermissionDenied = 12,
  900. VROverlayError_OverlayLimitExceeded = 13, // No more overlays could be created because the maximum number already exist
  901. VROverlayError_WrongVisibilityType = 14,
  902. VROverlayError_KeyTooLong = 15,
  903. VROverlayError_NameTooLong = 16,
  904. VROverlayError_KeyInUse = 17,
  905. VROverlayError_WrongTransformType = 18,
  906. VROverlayError_InvalidTrackedDevice = 19,
  907. VROverlayError_InvalidParameter = 20,
  908. VROverlayError_ThumbnailCantBeDestroyed = 21,
  909. VROverlayError_ArrayTooSmall = 22,
  910. VROverlayError_RequestFailed = 23,
  911. VROverlayError_InvalidTexture = 24,
  912. VROverlayError_UnableToLoadFile = 25,
  913. VROverlayError_KeyboardAlreadyInUse = 26,
  914. VROverlayError_NoNeighbor = 27,
  915. VROverlayError_TooManyMaskPrimitives = 29,
  916. VROverlayError_BadMaskPrimitive = 30,
  917. VROverlayError_TextureAlreadyLocked = 31,
  918. VROverlayError_TextureLockCapacityReached = 32,
  919. VROverlayError_TextureNotLocked = 33,
  920. };
  921. /** enum values to pass in to VR_Init to identify whether the application will
  922. * draw a 3D scene. */
  923. enum EVRApplicationType
  924. {
  925. VRApplication_Other = 0, // Some other kind of application that isn't covered by the other entries
  926. VRApplication_Scene = 1, // Application will submit 3D frames
  927. VRApplication_Overlay = 2, // Application only interacts with overlays
  928. VRApplication_Background = 3, // Application should not start SteamVR if it's not already running, and should not
  929. // keep it running if everything else quits.
  930. VRApplication_Utility = 4, // Init should not try to load any drivers. The application needs access to utility
  931. // interfaces (like IVRSettings and IVRApplications) but not hardware.
  932. VRApplication_VRMonitor = 5, // Reserved for vrmonitor
  933. VRApplication_SteamWatchdog = 6,// Reserved for Steam
  934. VRApplication_Bootstrapper = 7, // Start up SteamVR
  935. VRApplication_Max
  936. };
  937. /** error codes for firmware */
  938. enum EVRFirmwareError
  939. {
  940. VRFirmwareError_None = 0,
  941. VRFirmwareError_Success = 1,
  942. VRFirmwareError_Fail = 2,
  943. };
  944. /** error codes for notifications */
  945. enum EVRNotificationError
  946. {
  947. VRNotificationError_OK = 0,
  948. VRNotificationError_InvalidNotificationId = 100,
  949. VRNotificationError_NotificationQueueFull = 101,
  950. VRNotificationError_InvalidOverlayHandle = 102,
  951. VRNotificationError_SystemWithUserValueAlreadyExists = 103,
  952. };
  953. /** error codes returned by Vr_Init */
  954. // Please add adequate error description to https://developer.valvesoftware.com/w/index.php?title=Category:SteamVRHelp
  955. enum EVRInitError
  956. {
  957. VRInitError_None = 0,
  958. VRInitError_Unknown = 1,
  959. VRInitError_Init_InstallationNotFound = 100,
  960. VRInitError_Init_InstallationCorrupt = 101,
  961. VRInitError_Init_VRClientDLLNotFound = 102,
  962. VRInitError_Init_FileNotFound = 103,
  963. VRInitError_Init_FactoryNotFound = 104,
  964. VRInitError_Init_InterfaceNotFound = 105,
  965. VRInitError_Init_InvalidInterface = 106,
  966. VRInitError_Init_UserConfigDirectoryInvalid = 107,
  967. VRInitError_Init_HmdNotFound = 108,
  968. VRInitError_Init_NotInitialized = 109,
  969. VRInitError_Init_PathRegistryNotFound = 110,
  970. VRInitError_Init_NoConfigPath = 111,
  971. VRInitError_Init_NoLogPath = 112,
  972. VRInitError_Init_PathRegistryNotWritable = 113,
  973. VRInitError_Init_AppInfoInitFailed = 114,
  974. VRInitError_Init_Retry = 115, // Used internally to cause retries to vrserver
  975. VRInitError_Init_InitCanceledByUser = 116, // The calling application should silently exit. The user canceled app startup
  976. VRInitError_Init_AnotherAppLaunching = 117,
  977. VRInitError_Init_SettingsInitFailed = 118,
  978. VRInitError_Init_ShuttingDown = 119,
  979. VRInitError_Init_TooManyObjects = 120,
  980. VRInitError_Init_NoServerForBackgroundApp = 121,
  981. VRInitError_Init_NotSupportedWithCompositor = 122,
  982. VRInitError_Init_NotAvailableToUtilityApps = 123,
  983. VRInitError_Init_Internal = 124,
  984. VRInitError_Init_HmdDriverIdIsNone = 125,
  985. VRInitError_Init_HmdNotFoundPresenceFailed = 126,
  986. VRInitError_Init_VRMonitorNotFound = 127,
  987. VRInitError_Init_VRMonitorStartupFailed = 128,
  988. VRInitError_Init_LowPowerWatchdogNotSupported = 129,
  989. VRInitError_Init_InvalidApplicationType = 130,
  990. VRInitError_Init_NotAvailableToWatchdogApps = 131,
  991. VRInitError_Init_WatchdogDisabledInSettings = 132,
  992. VRInitError_Init_VRDashboardNotFound = 133,
  993. VRInitError_Init_VRDashboardStartupFailed = 134,
  994. VRInitError_Init_VRHomeNotFound = 135,
  995. VRInitError_Init_VRHomeStartupFailed = 136,
  996. VRInitError_Init_RebootingBusy = 137,
  997. VRInitError_Init_FirmwareUpdateBusy = 138,
  998. VRInitError_Init_FirmwareRecoveryBusy = 139,
  999. VRInitError_Init_USBServiceBusy = 140,
  1000. VRInitError_Driver_Failed = 200,
  1001. VRInitError_Driver_Unknown = 201,
  1002. VRInitError_Driver_HmdUnknown = 202,
  1003. VRInitError_Driver_NotLoaded = 203,
  1004. VRInitError_Driver_RuntimeOutOfDate = 204,
  1005. VRInitError_Driver_HmdInUse = 205,
  1006. VRInitError_Driver_NotCalibrated = 206,
  1007. VRInitError_Driver_CalibrationInvalid = 207,
  1008. VRInitError_Driver_HmdDisplayNotFound = 208,
  1009. VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209,
  1010. // VRInitError_Driver_HmdDisplayNotFoundAfterFix = 210, // not needed: here for historic reasons
  1011. VRInitError_Driver_HmdDriverIdOutOfBounds = 211,
  1012. VRInitError_Driver_HmdDisplayMirrored = 212,
  1013. VRInitError_IPC_ServerInitFailed = 300,
  1014. VRInitError_IPC_ConnectFailed = 301,
  1015. VRInitError_IPC_SharedStateInitFailed = 302,
  1016. VRInitError_IPC_CompositorInitFailed = 303,
  1017. VRInitError_IPC_MutexInitFailed = 304,
  1018. VRInitError_IPC_Failed = 305,
  1019. VRInitError_IPC_CompositorConnectFailed = 306,
  1020. VRInitError_IPC_CompositorInvalidConnectResponse = 307,
  1021. VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308,
  1022. VRInitError_Compositor_Failed = 400,
  1023. VRInitError_Compositor_D3D11HardwareRequired = 401,
  1024. VRInitError_Compositor_FirmwareRequiresUpdate = 402,
  1025. VRInitError_Compositor_OverlayInitFailed = 403,
  1026. VRInitError_Compositor_ScreenshotsInitFailed = 404,
  1027. VRInitError_Compositor_UnableToCreateDevice = 405,
  1028. VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
  1029. VRInitError_VendorSpecific_WindowsNotInDevMode = 1001,
  1030. VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101,
  1031. VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102,
  1032. VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103,
  1033. VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104,
  1034. VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105,
  1035. VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106,
  1036. VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107,
  1037. VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108,
  1038. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109,
  1039. VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110,
  1040. VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111,
  1041. VRInitError_VendorSpecific_HmdFound_UserDataError = 1112,
  1042. VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113,
  1043. VRInitError_Steam_SteamInstallationNotFound = 2000,
  1044. };
  1045. enum EVRScreenshotType
  1046. {
  1047. VRScreenshotType_None = 0,
  1048. VRScreenshotType_Mono = 1, // left eye only
  1049. VRScreenshotType_Stereo = 2,
  1050. VRScreenshotType_Cubemap = 3,
  1051. VRScreenshotType_MonoPanorama = 4,
  1052. VRScreenshotType_StereoPanorama = 5
  1053. };
  1054. enum EVRScreenshotPropertyFilenames
  1055. {
  1056. VRScreenshotPropertyFilenames_Preview = 0,
  1057. VRScreenshotPropertyFilenames_VR = 1,
  1058. };
  1059. enum EVRTrackedCameraError
  1060. {
  1061. VRTrackedCameraError_None = 0,
  1062. VRTrackedCameraError_OperationFailed = 100,
  1063. VRTrackedCameraError_InvalidHandle = 101,
  1064. VRTrackedCameraError_InvalidFrameHeaderVersion = 102,
  1065. VRTrackedCameraError_OutOfHandles = 103,
  1066. VRTrackedCameraError_IPCFailure = 104,
  1067. VRTrackedCameraError_NotSupportedForThisDevice = 105,
  1068. VRTrackedCameraError_SharedMemoryFailure = 106,
  1069. VRTrackedCameraError_FrameBufferingFailure = 107,
  1070. VRTrackedCameraError_StreamSetupFailure = 108,
  1071. VRTrackedCameraError_InvalidGLTextureId = 109,
  1072. VRTrackedCameraError_InvalidSharedTextureHandle = 110,
  1073. VRTrackedCameraError_FailedToGetGLTextureId = 111,
  1074. VRTrackedCameraError_SharedTextureFailure = 112,
  1075. VRTrackedCameraError_NoFrameAvailable = 113,
  1076. VRTrackedCameraError_InvalidArgument = 114,
  1077. VRTrackedCameraError_InvalidFrameBufferSize = 115,
  1078. };
  1079. enum EVRTrackedCameraFrameType
  1080. {
  1081. VRTrackedCameraFrameType_Distorted = 0, // This is the camera video frame size in pixels, still distorted.
  1082. VRTrackedCameraFrameType_Undistorted, // In pixels, an undistorted inscribed rectangle region without invalid regions. This size is subject to changes shortly.
  1083. VRTrackedCameraFrameType_MaximumUndistorted, // In pixels, maximum undistorted with invalid regions. Non zero alpha component identifies valid regions.
  1084. MAX_CAMERA_FRAME_TYPES
  1085. };
  1086. typedef uint64_t TrackedCameraHandle_t;
  1087. #define INVALID_TRACKED_CAMERA_HANDLE ((vr::TrackedCameraHandle_t)0)
  1088. struct CameraVideoStreamFrameHeader_t
  1089. {
  1090. EVRTrackedCameraFrameType eFrameType;
  1091. uint32_t nWidth;
  1092. uint32_t nHeight;
  1093. uint32_t nBytesPerPixel;
  1094. uint32_t nFrameSequence;
  1095. TrackedDevicePose_t standingTrackedDevicePose;
  1096. };
  1097. // Screenshot types
  1098. typedef uint32_t ScreenshotHandle_t;
  1099. static const uint32_t k_unScreenshotHandleInvalid = 0;
  1100. /** Frame timing data provided by direct mode drivers. */
  1101. struct DriverDirectMode_FrameTiming
  1102. {
  1103. uint32_t m_nSize; // Set to sizeof( DriverDirectMode_FrameTiming )
  1104. uint32_t m_nNumFramePresents; // number of times frame was presented
  1105. uint32_t m_nNumMisPresented; // number of times frame was presented on a vsync other than it was originally predicted to
  1106. uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out (i.e. compositor missed vsync)
  1107. uint32_t m_nReprojectionFlags;
  1108. };
  1109. #pragma pack( pop )
  1110. // figure out how to import from the VR API dll
  1111. #if defined(_WIN32)
  1112. #ifdef VR_API_EXPORT
  1113. #define VR_INTERFACE extern "C" __declspec( dllexport )
  1114. #else
  1115. #define VR_INTERFACE extern "C" __declspec( dllimport )
  1116. #endif
  1117. #elif defined(__GNUC__) || defined(COMPILER_GCC) || defined(__APPLE__)
  1118. #ifdef VR_API_EXPORT
  1119. #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
  1120. #else
  1121. #define VR_INTERFACE extern "C"
  1122. #endif
  1123. #else
  1124. #error "Unsupported Platform."
  1125. #endif
  1126. #if defined( _WIN32 )
  1127. #define VR_CALLTYPE __cdecl
  1128. #else
  1129. #define VR_CALLTYPE
  1130. #endif
  1131. } // namespace vr
  1132. #endif // _INCLUDE_VRTYPES_H
  1133. // vrannotation.h
  1134. #ifdef API_GEN
  1135. # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
  1136. #else
  1137. # define VR_CLANG_ATTR(ATTR)
  1138. #endif
  1139. #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
  1140. #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
  1141. #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
  1142. #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
  1143. #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
  1144. #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
  1145. #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
  1146. #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
  1147. #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
  1148. #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
  1149. #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
  1150. // ivrsystem.h
  1151. namespace vr
  1152. {
  1153. class IVRSystem
  1154. {
  1155. public:
  1156. // ------------------------------------
  1157. // Display Methods
  1158. // ------------------------------------
  1159. /** Suggested size for the intermediate render target that the distortion pulls from. */
  1160. virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  1161. /** The projection matrix for the specified eye */
  1162. virtual HmdMatrix44_t GetProjectionMatrix( EVREye eEye, float fNearZ, float fFarZ ) = 0;
  1163. /** The components necessary to build your own projection matrix in case your
  1164. * application is doing something fancy like infinite Z */
  1165. virtual void GetProjectionRaw( EVREye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
  1166. /** Gets the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
  1167. * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport.
  1168. * Returns true for success. Otherwise, returns false, and distortion coordinates are not suitable. */
  1169. virtual bool ComputeDistortion( EVREye eEye, float fU, float fV, DistortionCoordinates_t *pDistortionCoordinates ) = 0;
  1170. /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head
  1171. * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection.
  1172. * Normally View and Eye^-1 will be multiplied together and treated as View in your application.
  1173. */
  1174. virtual HmdMatrix34_t GetEyeToHeadTransform( EVREye eEye ) = 0;
  1175. /** Returns the number of elapsed seconds since the last recorded vsync event. This
  1176. * will come from a vsync timer event in the timer if possible or from the application-reported
  1177. * time if that is not available. If no vsync times are available the function will
  1178. * return zero for vsync time and frame counter and return false from the method. */
  1179. virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0;
  1180. /** [D3D9 Only]
  1181. * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
  1182. * a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
  1183. */
  1184. virtual int32_t GetD3D9AdapterIndex() = 0;
  1185. /** [D3D10/11 Only]
  1186. * Returns the adapter index that the user should pass into EnumAdapters to create the device
  1187. * and swap chain in DX10 and DX11. If an error occurs the index will be set to -1.
  1188. */
  1189. virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex ) = 0;
  1190. /**
  1191. * Returns platform- and texture-type specific adapter identification so that applications and the
  1192. * compositor are creating textures and swap chains on the same GPU. If an error occurs the device
  1193. * will be set to 0.
  1194. * pInstance is an optional parameter that is required only when textureType is TextureType_Vulkan.
  1195. * [D3D10/11/12 Only (D3D9 Not Supported)]
  1196. * Returns the adapter LUID that identifies the GPU attached to the HMD. The user should
  1197. * enumerate all adapters using IDXGIFactory::EnumAdapters and IDXGIAdapter::GetDesc to find
  1198. * the adapter with the matching LUID, or use IDXGIFactory4::EnumAdapterByLuid.
  1199. * The discovered IDXGIAdapter should be used to create the device and swap chain.
  1200. * [Vulkan Only]
  1201. * Returns the VkPhysicalDevice that should be used by the application.
  1202. * pInstance must be the instance the application will use to query for the VkPhysicalDevice. The application
  1203. * must create the VkInstance with extensions returned by IVRCompositor::GetVulkanInstanceExtensionsRequired enabled.
  1204. * [macOS Only]
  1205. * For TextureType_IOSurface returns the id<MTLDevice> that should be used by the application.
  1206. * On 10.13+ for TextureType_OpenGL returns the 'registryId' of the renderer which should be used
  1207. * by the application. See Apple Technical Q&A QA1168 for information on enumerating GL Renderers, and the
  1208. * new kCGLRPRegistryIDLow and kCGLRPRegistryIDHigh CGLRendererProperty values in the 10.13 SDK.
  1209. * Pre 10.13 for TextureType_OpenGL returns 0, as there is no dependable way to correlate the HMDs MTLDevice
  1210. * with a GL Renderer.
  1211. */
  1212. virtual void GetOutputDevice( uint64_t *pnDevice, ETextureType textureType, VkInstance_T *pInstance = nullptr ) = 0;
  1213. // ------------------------------------
  1214. // Display Mode methods
  1215. // ------------------------------------
  1216. /** Use to determine if the headset display is part of the desktop (i.e. extended) or hidden (i.e. direct mode). */
  1217. virtual bool IsDisplayOnDesktop() = 0;
  1218. /** Set the display visibility (true = extended, false = direct mode). Return value of true indicates that the change was successful. */
  1219. virtual bool SetDisplayVisibility( bool bIsVisibleOnDesktop ) = 0;
  1220. // ------------------------------------
  1221. // Tracking Methods
  1222. // ------------------------------------
  1223. /** The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
  1224. * future. Pass 0 to get the state at the instant the method is called. Most of the time the application should
  1225. * calculate the time until the photons will be emitted from the display and pass that time into the method.
  1226. *
  1227. * This is roughly analogous to the inverse of the view matrix in most applications, though
  1228. * many games will need to do some additional rotation or translation on top of the rotation
  1229. * and translation provided by the head pose.
  1230. *
  1231. * For devices where bPoseIsValid is true the application can use the pose to position the device
  1232. * in question. The provided array can be any size up to k_unMaxTrackedDeviceCount.
  1233. *
  1234. * Seated experiences should call this method with TrackingUniverseSeated and receive poses relative
  1235. * to the seated zero pose. Standing experiences should call this method with TrackingUniverseStanding
  1236. * and receive poses relative to the Chaperone Play Area. TrackingUniverseRawAndUncalibrated should
  1237. * probably not be used unless the application is the Chaperone calibration tool itself, but will provide
  1238. * poses relative to the hardware-specific coordinate system in the driver.
  1239. */
  1240. virtual void GetDeviceToAbsoluteTrackingPose( ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, VR_ARRAY_COUNT(unTrackedDevicePoseArrayCount) TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0;
  1241. /** Sets the zero pose for the seated tracker coordinate system to the current position and yaw of the HMD. After
  1242. * ResetSeatedZeroPose all GetDeviceToAbsoluteTrackingPose calls that pass TrackingUniverseSeated as the origin
  1243. * will be relative to this new zero pose. The new zero coordinate system will not change the fact that the Y axis
  1244. * is up in the real world, so the next pose returned from GetDeviceToAbsoluteTrackingPose after a call to
  1245. * ResetSeatedZeroPose may not be exactly an identity matrix.
  1246. *
  1247. * NOTE: This function overrides the user's previously saved seated zero pose and should only be called as the result of a user action.
  1248. * Users are also able to set their seated zero pose via the OpenVR Dashboard.
  1249. **/
  1250. virtual void ResetSeatedZeroPose() = 0;
  1251. /** Returns the transform from the seated zero pose to the standing absolute tracking system. This allows
  1252. * applications to represent the seated origin to used or transform object positions from one coordinate
  1253. * system to the other.
  1254. *
  1255. * The seated origin may or may not be inside the Play Area or Collision Bounds returned by IVRChaperone. Its position
  1256. * depends on what the user has set from the Dashboard settings and previous calls to ResetSeatedZeroPose. */
  1257. virtual HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() = 0;
  1258. /** Returns the transform from the tracking origin to the standing absolute tracking system. This allows
  1259. * applications to convert from raw tracking space to the calibrated standing coordinate system. */
  1260. virtual HmdMatrix34_t GetRawZeroPoseToStandingAbsoluteTrackingPose() = 0;
  1261. /** Get a sorted array of device indices of a given class of tracked devices (e.g. controllers). Devices are sorted right to left
  1262. * relative to the specified tracked device (default: hmd -- pass in -1 for absolute tracking space). Returns the number of devices
  1263. * in the list, or the size of the array needed if not large enough. */
  1264. 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;
  1265. /** Returns the level of activity on the device. */
  1266. virtual EDeviceActivityLevel GetTrackedDeviceActivityLevel( vr::TrackedDeviceIndex_t unDeviceId ) = 0;
  1267. /** Convenience utility to apply the specified transform to the specified pose.
  1268. * This properly transforms all pose components, including velocity and angular velocity
  1269. */
  1270. virtual void ApplyTransform( TrackedDevicePose_t *pOutputPose, const TrackedDevicePose_t *pTrackedDevicePose, const HmdMatrix34_t *pTransform ) = 0;
  1271. /** Returns the device index associated with a specific role, for example the left hand or the right hand. */
  1272. virtual vr::TrackedDeviceIndex_t GetTrackedDeviceIndexForControllerRole( vr::ETrackedControllerRole unDeviceType ) = 0;
  1273. /** Returns the controller type associated with a device index. */
  1274. virtual vr::ETrackedControllerRole GetControllerRoleForTrackedDeviceIndex( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1275. // ------------------------------------
  1276. // Property methods
  1277. // ------------------------------------
  1278. /** Returns the device class of a tracked device. If there has not been a device connected in this slot
  1279. * since the application started this function will return TrackedDevice_Invalid. For previous detected
  1280. * devices the function will return the previously observed device class.
  1281. *
  1282. * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check
  1283. * the device class. Every device with something other than TrackedDevice_Invalid is associated with an
  1284. * actual tracked device. */
  1285. virtual ETrackedDeviceClass GetTrackedDeviceClass( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1286. /** Returns true if there is a device connected in this slot. */
  1287. virtual bool IsTrackedDeviceConnected( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1288. /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */
  1289. virtual bool GetBoolTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1290. /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */
  1291. virtual float GetFloatTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1292. /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */
  1293. virtual int32_t GetInt32TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1294. /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */
  1295. virtual uint64_t GetUint64TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1296. /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */
  1297. virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError *pError = 0L ) = 0;
  1298. /** Returns an array of one type of property. If the device index is not valid or the property is not a single value or an array of the specified type,
  1299. * this function will return 0. Otherwise it returns the number of bytes necessary to hold the array of properties. If unBufferSize is
  1300. * greater than the returned size and pBuffer is non-NULL, pBuffer is filled with the contents of array of properties. */
  1301. virtual uint32_t GetArrayTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, PropertyTypeTag_t propType, void *pBuffer, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0;
  1302. /** Returns a string property. If the device index is not valid or the property is not a string type this function will
  1303. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  1304. * null. Strings will always fit in buffers of k_unMaxPropertyStringSize characters. */
  1305. virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, ETrackedPropertyError *pError = 0L ) = 0;
  1306. /** returns a string that corresponds with the specified property error. The string will be the name
  1307. * of the error enum value for all valid error codes */
  1308. virtual const char *GetPropErrorNameFromEnum( ETrackedPropertyError error ) = 0;
  1309. // ------------------------------------
  1310. // Event methods
  1311. // ------------------------------------
  1312. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  1313. * this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
  1314. virtual bool PollNextEvent( VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
  1315. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  1316. * this method returns false. Fills in the pose of the associated tracked device in the provided pose struct.
  1317. * This pose will always be older than the call to this function and should not be used to render the device.
  1318. uncbVREvent should be the size in bytes of the VREvent_t struct */
  1319. virtual bool PollNextEventWithPose( ETrackingUniverseOrigin eOrigin, VREvent_t *pEvent, uint32_t uncbVREvent, vr::TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  1320. /** returns the name of an EVREvent enum value */
  1321. virtual const char *GetEventTypeNameFromEnum( EVREventType eType ) = 0;
  1322. // ------------------------------------
  1323. // Rendering helper methods
  1324. // ------------------------------------
  1325. /** Returns the hidden area mesh for the current HMD. The pixels covered by this mesh will never be seen by the user after the lens distortion is
  1326. * applied based on visibility to the panels. If this HMD does not have a hidden area mesh, the vertex data and count will be NULL and 0 respectively.
  1327. * This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering each eye's view.
  1328. * This will improve performance by letting the GPU early-reject pixels the user will never see before running the pixel shader.
  1329. * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye.
  1330. * Setting the bInverse argument to true will produce the visible area mesh that is commonly used in place of full-screen quads. The visible area mesh covers all of the pixels the hidden area mesh does not cover.
  1331. * Setting the bLineLoop argument will return a line loop of vertices in HiddenAreaMesh_t->pVertexData with HiddenAreaMesh_t->unTriangleCount set to the number of vertices.
  1332. */
  1333. virtual HiddenAreaMesh_t GetHiddenAreaMesh( EVREye eEye, EHiddenAreaMeshType type = k_eHiddenAreaMesh_Standard ) = 0;
  1334. // ------------------------------------
  1335. // Controller methods
  1336. // ------------------------------------
  1337. /** Fills the supplied struct with the current state of the controller. Returns false if the controller index
  1338. * is invalid. */
  1339. virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize ) = 0;
  1340. /** fills the supplied struct with the current state of the controller and the provided pose with the pose of
  1341. * the controller when the controller state was updated most recently. Use this form if you need a precise controller
  1342. * pose as input to your application when the user presses or releases a button. */
  1343. virtual bool GetControllerStateWithPose( ETrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, uint32_t unControllerStateSize, TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  1344. /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller
  1345. * and axis combination for 5ms. */
  1346. virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0;
  1347. /** returns the name of an EVRButtonId enum value */
  1348. virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0;
  1349. /** returns the name of an EVRControllerAxisType enum value */
  1350. virtual const char *GetControllerAxisTypeNameFromEnum( EVRControllerAxisType eAxisType ) = 0;
  1351. /** Returns true if this application is receiving input from the system. This would return false if
  1352. * system-related functionality is consuming the input stream. */
  1353. virtual bool IsInputAvailable() = 0;
  1354. /** Returns true SteamVR is drawing controllers on top of the application. Applications should consider
  1355. * not drawing anything attached to the user's hands in this case. */
  1356. virtual bool IsSteamVRDrawingControllers() = 0;
  1357. /** Returns true if the user has put SteamVR into a mode that is distracting them from the application.
  1358. * For applications where this is appropriate, the application should pause ongoing activity. */
  1359. virtual bool ShouldApplicationPause() = 0;
  1360. /** Returns true if SteamVR is doing significant rendering work and the game should do what it can to reduce
  1361. * its own workload. One common way to do this is to reduce the size of the render target provided for each eye. */
  1362. virtual bool ShouldApplicationReduceRenderingWork() = 0;
  1363. // ------------------------------------
  1364. // Debug Methods
  1365. // ------------------------------------
  1366. /** Sends a request to the driver for the specified device and returns the response. The maximum response size is 32k,
  1367. * but this method can be called with a smaller buffer. If the response exceeds the size of the buffer, it is truncated.
  1368. * The size of the response including its terminating null is returned. */
  1369. virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, VR_OUT_STRING() char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0;
  1370. // ------------------------------------
  1371. // Firmware methods
  1372. // ------------------------------------
  1373. /** Performs the actual firmware update if applicable.
  1374. * The following events will be sent, if VRFirmwareError_None was returned: VREvent_FirmwareUpdateStarted, VREvent_FirmwareUpdateFinished
  1375. * Use the properties Prop_Firmware_UpdateAvailable_Bool, Prop_Firmware_ManualUpdate_Bool, and Prop_Firmware_ManualUpdateURL_String
  1376. * to figure our whether a firmware update is available, and to figure out whether its a manual update
  1377. * Prop_Firmware_ManualUpdateURL_String should point to an URL describing the manual update process */
  1378. virtual vr::EVRFirmwareError PerformFirmwareUpdate( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  1379. // ------------------------------------
  1380. // Application life cycle methods
  1381. // ------------------------------------
  1382. /** Call this to acknowledge to the system that VREvent_Quit has been received and that the process is exiting.
  1383. * This extends the timeout until the process is killed. */
  1384. virtual void AcknowledgeQuit_Exiting() = 0;
  1385. /** Call this to tell the system that the user is being prompted to save data. This
  1386. * halts the timeout and dismisses the dashboard (if it was up). Applications should be sure to actually
  1387. * prompt the user to save and then exit afterward, otherwise the user will be left in a confusing state. */
  1388. virtual void AcknowledgeQuit_UserPrompt() = 0;
  1389. };
  1390. static const char * const IVRSystem_Version = "IVRSystem_019";
  1391. }
  1392. // ivrapplications.h
  1393. namespace vr
  1394. {
  1395. /** Used for all errors reported by the IVRApplications interface */
  1396. enum EVRApplicationError
  1397. {
  1398. VRApplicationError_None = 0,
  1399. VRApplicationError_AppKeyAlreadyExists = 100, // Only one application can use any given key
  1400. VRApplicationError_NoManifest = 101, // the running application does not have a manifest
  1401. VRApplicationError_NoApplication = 102, // No application is running
  1402. VRApplicationError_InvalidIndex = 103,
  1403. VRApplicationError_UnknownApplication = 104, // the application could not be found
  1404. VRApplicationError_IPCFailed = 105, // An IPC failure caused the request to fail
  1405. VRApplicationError_ApplicationAlreadyRunning = 106,
  1406. VRApplicationError_InvalidManifest = 107,
  1407. VRApplicationError_InvalidApplication = 108,
  1408. VRApplicationError_LaunchFailed = 109, // the process didn't start
  1409. VRApplicationError_ApplicationAlreadyStarting = 110, // the system was already starting the same application
  1410. VRApplicationError_LaunchInProgress = 111, // The system was already starting a different application
  1411. VRApplicationError_OldApplicationQuitting = 112,
  1412. VRApplicationError_TransitionAborted = 113,
  1413. VRApplicationError_IsTemplate = 114, // error when you try to call LaunchApplication() on a template type app (use LaunchTemplateApplication)
  1414. VRApplicationError_SteamVRIsExiting = 115,
  1415. VRApplicationError_BufferTooSmall = 200, // The provided buffer was too small to fit the requested data
  1416. VRApplicationError_PropertyNotSet = 201, // The requested property was not set
  1417. VRApplicationError_UnknownProperty = 202,
  1418. VRApplicationError_InvalidParameter = 203,
  1419. };
  1420. /** The maximum length of an application key */
  1421. static const uint32_t k_unMaxApplicationKeyLength = 128;
  1422. /** these are the properties available on applications. */
  1423. enum EVRApplicationProperty
  1424. {
  1425. VRApplicationProperty_Name_String = 0,
  1426. VRApplicationProperty_LaunchType_String = 11,
  1427. VRApplicationProperty_WorkingDirectory_String = 12,
  1428. VRApplicationProperty_BinaryPath_String = 13,
  1429. VRApplicationProperty_Arguments_String = 14,
  1430. VRApplicationProperty_URL_String = 15,
  1431. VRApplicationProperty_Description_String = 50,
  1432. VRApplicationProperty_NewsURL_String = 51,
  1433. VRApplicationProperty_ImagePath_String = 52,
  1434. VRApplicationProperty_Source_String = 53,
  1435. VRApplicationProperty_ActionManifestURL_String = 54,
  1436. VRApplicationProperty_IsDashboardOverlay_Bool = 60,
  1437. VRApplicationProperty_IsTemplate_Bool = 61,
  1438. VRApplicationProperty_IsInstanced_Bool = 62,
  1439. VRApplicationProperty_IsInternal_Bool = 63,
  1440. VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64,
  1441. VRApplicationProperty_LastLaunchTime_Uint64 = 70,
  1442. };
  1443. /** These are states the scene application startup process will go through. */
  1444. enum EVRApplicationTransitionState
  1445. {
  1446. VRApplicationTransition_None = 0,
  1447. VRApplicationTransition_OldAppQuitSent = 10,
  1448. VRApplicationTransition_WaitingForExternalLaunch = 11,
  1449. VRApplicationTransition_NewAppLaunched = 20,
  1450. };
  1451. struct AppOverrideKeys_t
  1452. {
  1453. const char *pchKey;
  1454. const char *pchValue;
  1455. };
  1456. /** Currently recognized mime types */
  1457. static const char * const k_pch_MimeType_HomeApp = "vr/home";
  1458. static const char * const k_pch_MimeType_GameTheater = "vr/game_theater";
  1459. class IVRApplications
  1460. {
  1461. public:
  1462. // --------------- Application management --------------- //
  1463. /** Adds an application manifest to the list to load when building the list of installed applications.
  1464. * Temporary manifests are not automatically loaded */
  1465. virtual EVRApplicationError AddApplicationManifest( const char *pchApplicationManifestFullPath, bool bTemporary = false ) = 0;
  1466. /** Removes an application manifest from the list to load when building the list of installed applications. */
  1467. virtual EVRApplicationError RemoveApplicationManifest( const char *pchApplicationManifestFullPath ) = 0;
  1468. /** Returns true if an application is installed */
  1469. virtual bool IsApplicationInstalled( const char *pchAppKey ) = 0;
  1470. /** Returns the number of applications available in the list */
  1471. virtual uint32_t GetApplicationCount() = 0;
  1472. /** Returns the key of the specified application. The index is at least 0 and is less than the return
  1473. * value of GetApplicationCount(). The buffer should be at least k_unMaxApplicationKeyLength in order to
  1474. * fit the key. */
  1475. virtual EVRApplicationError GetApplicationKeyByIndex( uint32_t unApplicationIndex, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1476. /** Returns the key of the application for the specified Process Id. The buffer should be at least
  1477. * k_unMaxApplicationKeyLength in order to fit the key. */
  1478. virtual EVRApplicationError GetApplicationKeyByProcessId( uint32_t unProcessId, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1479. /** Launches the application. The existing scene application will exit and then the new application will start.
  1480. * This call is not valid for dashboard overlay applications. */
  1481. virtual EVRApplicationError LaunchApplication( const char *pchAppKey ) = 0;
  1482. /** Launches an instance of an application of type template, with its app key being pchNewAppKey (which must be unique) and optionally override sections
  1483. * from the manifest file via AppOverrideKeys_t
  1484. */
  1485. virtual EVRApplicationError LaunchTemplateApplication( const char *pchTemplateAppKey, const char *pchNewAppKey, VR_ARRAY_COUNT( unKeys ) const AppOverrideKeys_t *pKeys, uint32_t unKeys ) = 0;
  1486. /** launches the application currently associated with this mime type and passes it the option args, typically the filename or object name of the item being launched */
  1487. virtual vr::EVRApplicationError LaunchApplicationFromMimeType( const char *pchMimeType, const char *pchArgs ) = 0;
  1488. /** Launches the dashboard overlay application if it is not already running. This call is only valid for
  1489. * dashboard overlay applications. */
  1490. virtual EVRApplicationError LaunchDashboardOverlay( const char *pchAppKey ) = 0;
  1491. /** Cancel a pending launch for an application */
  1492. virtual bool CancelApplicationLaunch( const char *pchAppKey ) = 0;
  1493. /** Identifies a running application. OpenVR can't always tell which process started in response
  1494. * to a URL. This function allows a URL handler (or the process itself) to identify the app key
  1495. * for the now running application. Passing a process ID of 0 identifies the calling process.
  1496. * The application must be one that's known to the system via a call to AddApplicationManifest. */
  1497. virtual EVRApplicationError IdentifyApplication( uint32_t unProcessId, const char *pchAppKey ) = 0;
  1498. /** Returns the process ID for an application. Return 0 if the application was not found or is not running. */
  1499. virtual uint32_t GetApplicationProcessId( const char *pchAppKey ) = 0;
  1500. /** Returns a string for an applications error */
  1501. virtual const char *GetApplicationsErrorNameFromEnum( EVRApplicationError error ) = 0;
  1502. // --------------- Application properties --------------- //
  1503. /** Returns a value for an application property. The required buffer size to fit this value will be returned. */
  1504. virtual uint32_t GetApplicationPropertyString( const char *pchAppKey, EVRApplicationProperty eProperty, VR_OUT_STRING() char *pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError *peError = nullptr ) = 0;
  1505. /** Returns a bool value for an application property. Returns false in all error cases. */
  1506. virtual bool GetApplicationPropertyBool( const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr ) = 0;
  1507. /** Returns a uint64 value for an application property. Returns 0 in all error cases. */
  1508. virtual uint64_t GetApplicationPropertyUint64( const char *pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError *peError = nullptr ) = 0;
  1509. /** Sets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
  1510. virtual EVRApplicationError SetApplicationAutoLaunch( const char *pchAppKey, bool bAutoLaunch ) = 0;
  1511. /** Gets the application auto-launch flag. This is only valid for applications which return true for VRApplicationProperty_IsDashboardOverlay_Bool. */
  1512. virtual bool GetApplicationAutoLaunch( const char *pchAppKey ) = 0;
  1513. /** Adds this mime-type to the list of supported mime types for this application*/
  1514. virtual EVRApplicationError SetDefaultApplicationForMimeType( const char *pchAppKey, const char *pchMimeType ) = 0;
  1515. /** return the app key that will open this mime type */
  1516. virtual bool GetDefaultApplicationForMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1517. /** Get the list of supported mime types for this application, comma-delimited */
  1518. virtual bool GetApplicationSupportedMimeTypes( const char *pchAppKey, VR_OUT_STRING() char *pchMimeTypesBuffer, uint32_t unMimeTypesBuffer ) = 0;
  1519. /** Get the list of app-keys that support this mime type, comma-delimited, the return value is number of bytes you need to return the full string */
  1520. virtual uint32_t GetApplicationsThatSupportMimeType( const char *pchMimeType, VR_OUT_STRING() char *pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer ) = 0;
  1521. /** Get the args list from an app launch that had the process already running, you call this when you get a VREvent_ApplicationMimeTypeLoad */
  1522. virtual uint32_t GetApplicationLaunchArguments( uint32_t unHandle, VR_OUT_STRING() char *pchArgs, uint32_t unArgs ) = 0;
  1523. // --------------- Transition methods --------------- //
  1524. /** Returns the app key for the application that is starting up */
  1525. virtual EVRApplicationError GetStartingApplication( VR_OUT_STRING() char *pchAppKeyBuffer, uint32_t unAppKeyBufferLen ) = 0;
  1526. /** Returns the application transition state */
  1527. virtual EVRApplicationTransitionState GetTransitionState() = 0;
  1528. /** Returns errors that would prevent the specified application from launching immediately. Calling this function will
  1529. * cause the current scene application to quit, so only call it when you are actually about to launch something else.
  1530. * What the caller should do about these failures depends on the failure:
  1531. * VRApplicationError_OldApplicationQuitting - An existing application has been told to quit. Wait for a VREvent_ProcessQuit
  1532. * and try again.
  1533. * VRApplicationError_ApplicationAlreadyStarting - This application is already starting. This is a permanent failure.
  1534. * VRApplicationError_LaunchInProgress - A different application is already starting. This is a permanent failure.
  1535. * VRApplicationError_None - Go ahead and launch. Everything is clear.
  1536. */
  1537. virtual EVRApplicationError PerformApplicationPrelaunchCheck( const char *pchAppKey ) = 0;
  1538. /** Returns a string for an application transition state */
  1539. virtual const char *GetApplicationsTransitionStateNameFromEnum( EVRApplicationTransitionState state ) = 0;
  1540. /** Returns true if the outgoing scene app has requested a save prompt before exiting */
  1541. virtual bool IsQuitUserPromptRequested() = 0;
  1542. /** Starts a subprocess within the calling application. This
  1543. * suppresses all application transition UI and automatically identifies the new executable
  1544. * as part of the same application. On success the calling process should exit immediately.
  1545. * If working directory is NULL or "" the directory portion of the binary path will be
  1546. * the working directory. */
  1547. virtual EVRApplicationError LaunchInternalProcess( const char *pchBinaryPath, const char *pchArguments, const char *pchWorkingDirectory ) = 0;
  1548. /** Returns the current scene process ID according to the application system. A scene process will get scene
  1549. * focus once it starts rendering, but it will appear here once it calls VR_Init with the Scene application
  1550. * type. */
  1551. virtual uint32_t GetCurrentSceneProcessId() = 0;
  1552. };
  1553. static const char * const IVRApplications_Version = "IVRApplications_006";
  1554. } // namespace vr
  1555. // ivrsettings.h
  1556. namespace vr
  1557. {
  1558. enum EVRSettingsError
  1559. {
  1560. VRSettingsError_None = 0,
  1561. VRSettingsError_IPCFailed = 1,
  1562. VRSettingsError_WriteFailed = 2,
  1563. VRSettingsError_ReadFailed = 3,
  1564. VRSettingsError_JsonParseFailed = 4,
  1565. VRSettingsError_UnsetSettingHasNoDefault = 5, // This will be returned if the setting does not appear in the appropriate default file and has not been set
  1566. };
  1567. // The maximum length of a settings key
  1568. static const uint32_t k_unMaxSettingsKeyLength = 128;
  1569. class IVRSettings
  1570. {
  1571. public:
  1572. virtual const char *GetSettingsErrorNameFromEnum( EVRSettingsError eError ) = 0;
  1573. // Returns true if file sync occurred (force or settings dirty)
  1574. virtual bool Sync( bool bForce = false, EVRSettingsError *peError = nullptr ) = 0;
  1575. virtual void SetBool( const char *pchSection, const char *pchSettingsKey, bool bValue, EVRSettingsError *peError = nullptr ) = 0;
  1576. virtual void SetInt32( const char *pchSection, const char *pchSettingsKey, int32_t nValue, EVRSettingsError *peError = nullptr ) = 0;
  1577. virtual void SetFloat( const char *pchSection, const char *pchSettingsKey, float flValue, EVRSettingsError *peError = nullptr ) = 0;
  1578. virtual void SetString( const char *pchSection, const char *pchSettingsKey, const char *pchValue, EVRSettingsError *peError = nullptr ) = 0;
  1579. // Users of the system need to provide a proper default in default.vrsettings in the resources/settings/ directory
  1580. // of either the runtime or the driver_xxx directory. Otherwise the default will be false, 0, 0.0 or ""
  1581. virtual bool GetBool( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1582. virtual int32_t GetInt32( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1583. virtual float GetFloat( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1584. virtual void GetString( const char *pchSection, const char *pchSettingsKey, VR_OUT_STRING() char *pchValue, uint32_t unValueLen, EVRSettingsError *peError = nullptr ) = 0;
  1585. virtual void RemoveSection( const char *pchSection, EVRSettingsError *peError = nullptr ) = 0;
  1586. virtual void RemoveKeyInSection( const char *pchSection, const char *pchSettingsKey, EVRSettingsError *peError = nullptr ) = 0;
  1587. };
  1588. //-----------------------------------------------------------------------------
  1589. static const char * const IVRSettings_Version = "IVRSettings_002";
  1590. //-----------------------------------------------------------------------------
  1591. // steamvr keys
  1592. static const char * const k_pch_SteamVR_Section = "steamvr";
  1593. static const char * const k_pch_SteamVR_RequireHmd_String = "requireHmd";
  1594. static const char * const k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver";
  1595. static const char * const k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd";
  1596. static const char * const k_pch_SteamVR_DisplayDebug_Bool = "displayDebug";
  1597. static const char * const k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe";
  1598. static const char * const k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX";
  1599. static const char * const k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY";
  1600. static const char * const k_pch_SteamVR_SendSystemButtonToAllApps_Bool= "sendSystemButtonToAllApps";
  1601. static const char * const k_pch_SteamVR_LogLevel_Int32 = "loglevel";
  1602. static const char * const k_pch_SteamVR_IPD_Float = "ipd";
  1603. static const char * const k_pch_SteamVR_Background_String = "background";
  1604. static const char * const k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection";
  1605. static const char * const k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight";
  1606. static const char * const k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius";
  1607. static const char * const k_pch_SteamVR_GridColor_String = "gridColor";
  1608. static const char * const k_pch_SteamVR_PlayAreaColor_String = "playAreaColor";
  1609. static const char * const k_pch_SteamVR_ShowStage_Bool = "showStage";
  1610. static const char * const k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers";
  1611. static const char * const k_pch_SteamVR_DirectMode_Bool = "directMode";
  1612. static const char * const k_pch_SteamVR_DirectModeEdidVid_Int32 = "directModeEdidVid";
  1613. static const char * const k_pch_SteamVR_DirectModeEdidPid_Int32 = "directModeEdidPid";
  1614. static const char * const k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers";
  1615. static const char * const k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees";
  1616. static const char * const k_pch_SteamVR_BaseStationPowerManagement_Bool = "basestationPowerManagement";
  1617. static const char * const k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses";
  1618. static const char * const k_pch_SteamVR_SupersampleScale_Float = "supersampleScale";
  1619. static const char * const k_pch_SteamVR_AllowAsyncReprojection_Bool = "allowAsyncReprojection";
  1620. static const char * const k_pch_SteamVR_AllowReprojection_Bool = "allowInterleavedReprojection";
  1621. static const char * const k_pch_SteamVR_ForceReprojection_Bool = "forceReprojection";
  1622. static const char * const k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking";
  1623. static const char * const k_pch_SteamVR_DefaultMirrorView_Int32 = "defaultMirrorView";
  1624. static const char * const k_pch_SteamVR_ShowMirrorView_Bool = "showMirrorView";
  1625. static const char * const k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry";
  1626. static const char * const k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch";
  1627. static const char * const k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch";
  1628. static const char * const k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch";
  1629. static const char * const k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard";
  1630. static const char * const k_pch_SteamVR_EnableHomeApp = "enableHomeApp";
  1631. static const char * const k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec";
  1632. static const char * const k_pch_SteamVR_RetailDemo_Bool = "retailDemo";
  1633. static const char * const k_pch_SteamVR_IpdOffset_Float = "ipdOffset";
  1634. static const char * const k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering";
  1635. static const char * const k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync";
  1636. static const char * const k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode";
  1637. static const char * const k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver";
  1638. static const char * const k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor";
  1639. //-----------------------------------------------------------------------------
  1640. // lighthouse keys
  1641. static const char * const k_pch_Lighthouse_Section = "driver_lighthouse";
  1642. static const char * const k_pch_Lighthouse_DisableIMU_Bool = "disableimu";
  1643. static const char * const k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd";
  1644. static const char * const k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation";
  1645. static const char * const k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug";
  1646. static const char * const k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation";
  1647. static const char * const k_pch_Lighthouse_DBHistory_Bool = "dbhistory";
  1648. static const char * const k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth";
  1649. //-----------------------------------------------------------------------------
  1650. // null keys
  1651. static const char * const k_pch_Null_Section = "driver_null";
  1652. static const char * const k_pch_Null_SerialNumber_String = "serialNumber";
  1653. static const char * const k_pch_Null_ModelNumber_String = "modelNumber";
  1654. static const char * const k_pch_Null_WindowX_Int32 = "windowX";
  1655. static const char * const k_pch_Null_WindowY_Int32 = "windowY";
  1656. static const char * const k_pch_Null_WindowWidth_Int32 = "windowWidth";
  1657. static const char * const k_pch_Null_WindowHeight_Int32 = "windowHeight";
  1658. static const char * const k_pch_Null_RenderWidth_Int32 = "renderWidth";
  1659. static const char * const k_pch_Null_RenderHeight_Int32 = "renderHeight";
  1660. static const char * const k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons";
  1661. static const char * const k_pch_Null_DisplayFrequency_Float = "displayFrequency";
  1662. //-----------------------------------------------------------------------------
  1663. // user interface keys
  1664. static const char * const k_pch_UserInterface_Section = "userinterface";
  1665. static const char * const k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop";
  1666. static const char * const k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray";
  1667. static const char * const k_pch_UserInterface_Screenshots_Bool = "screenshots";
  1668. static const char * const k_pch_UserInterface_ScreenshotType_Int = "screenshotType";
  1669. //-----------------------------------------------------------------------------
  1670. // notification keys
  1671. static const char * const k_pch_Notifications_Section = "notifications";
  1672. static const char * const k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb";
  1673. //-----------------------------------------------------------------------------
  1674. // keyboard keys
  1675. static const char * const k_pch_Keyboard_Section = "keyboard";
  1676. static const char * const k_pch_Keyboard_TutorialCompletions = "TutorialCompletions";
  1677. static const char * const k_pch_Keyboard_ScaleX = "ScaleX";
  1678. static const char * const k_pch_Keyboard_ScaleY = "ScaleY";
  1679. static const char * const k_pch_Keyboard_OffsetLeftX = "OffsetLeftX";
  1680. static const char * const k_pch_Keyboard_OffsetRightX = "OffsetRightX";
  1681. static const char * const k_pch_Keyboard_OffsetY = "OffsetY";
  1682. static const char * const k_pch_Keyboard_Smoothing = "Smoothing";
  1683. //-----------------------------------------------------------------------------
  1684. // perf keys
  1685. static const char * const k_pch_Perf_Section = "perfcheck";
  1686. static const char * const k_pch_Perf_HeuristicActive_Bool = "heuristicActive";
  1687. static const char * const k_pch_Perf_NotifyInHMD_Bool = "warnInHMD";
  1688. static const char * const k_pch_Perf_NotifyOnlyOnce_Bool = "warnOnlyOnce";
  1689. static const char * const k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore";
  1690. static const char * const k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit";
  1691. static const char * const k_pch_Perf_TestData_Float = "perfTestData";
  1692. static const char * const k_pch_Perf_LinuxGPUProfiling_Bool = "linuxGPUProfiling";
  1693. //-----------------------------------------------------------------------------
  1694. // collision bounds keys
  1695. static const char * const k_pch_CollisionBounds_Section = "collisionBounds";
  1696. static const char * const k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle";
  1697. static const char * const k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn";
  1698. static const char * const k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn";
  1699. static const char * const k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn";
  1700. static const char * const k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance";
  1701. static const char * const k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR";
  1702. static const char * const k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG";
  1703. static const char * const k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB";
  1704. static const char * const k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA";
  1705. //-----------------------------------------------------------------------------
  1706. // camera keys
  1707. static const char * const k_pch_Camera_Section = "camera";
  1708. static const char * const k_pch_Camera_EnableCamera_Bool = "enableCamera";
  1709. static const char * const k_pch_Camera_EnableCameraInDashboard_Bool = "enableCameraInDashboard";
  1710. static const char * const k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds";
  1711. static const char * const k_pch_Camera_EnableCameraForRoomView_Bool = "enableCameraForRoomView";
  1712. static const char * const k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR";
  1713. static const char * const k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG";
  1714. static const char * const k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB";
  1715. static const char * const k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA";
  1716. static const char * const k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength";
  1717. //-----------------------------------------------------------------------------
  1718. // audio keys
  1719. static const char * const k_pch_audio_Section = "audio";
  1720. static const char * const k_pch_audio_OnPlaybackDevice_String = "onPlaybackDevice";
  1721. static const char * const k_pch_audio_OnRecordDevice_String = "onRecordDevice";
  1722. static const char * const k_pch_audio_OnPlaybackMirrorDevice_String = "onPlaybackMirrorDevice";
  1723. static const char * const k_pch_audio_OffPlaybackDevice_String = "offPlaybackDevice";
  1724. static const char * const k_pch_audio_OffRecordDevice_String = "offRecordDevice";
  1725. static const char * const k_pch_audio_VIVEHDMIGain = "viveHDMIGain";
  1726. //-----------------------------------------------------------------------------
  1727. // power management keys
  1728. static const char * const k_pch_Power_Section = "power";
  1729. static const char * const k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit";
  1730. static const char * const k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout";
  1731. static const char * const k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout";
  1732. static const char * const k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout";
  1733. static const char * const k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress";
  1734. static const char * const k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby";
  1735. //-----------------------------------------------------------------------------
  1736. // dashboard keys
  1737. static const char * const k_pch_Dashboard_Section = "dashboard";
  1738. static const char * const k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard";
  1739. static const char * const k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode";
  1740. //-----------------------------------------------------------------------------
  1741. // model skin keys
  1742. static const char * const k_pch_modelskin_Section = "modelskins";
  1743. //-----------------------------------------------------------------------------
  1744. // driver keys - These could be checked in any driver_<name> section
  1745. static const char * const k_pch_Driver_Enable_Bool = "enable";
  1746. } // namespace vr
  1747. // ivrchaperone.h
  1748. namespace vr
  1749. {
  1750. #pragma pack( push, 8 )
  1751. enum ChaperoneCalibrationState
  1752. {
  1753. // OK!
  1754. ChaperoneCalibrationState_OK = 1, // Chaperone is fully calibrated and working correctly
  1755. // Warnings
  1756. ChaperoneCalibrationState_Warning = 100,
  1757. ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101, // A base station thinks that it might have moved
  1758. ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, // There are less base stations than when calibrated
  1759. ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, // Seated bounds haven't been calibrated for the current tracking center
  1760. // Errors
  1761. ChaperoneCalibrationState_Error = 200, // The UniverseID is invalid
  1762. ChaperoneCalibrationState_Error_BaseStationUninitialized = 201, // Tracking center hasn't be calibrated for at least one of the base stations
  1763. ChaperoneCalibrationState_Error_BaseStationConflict = 202, // Tracking center is calibrated, but base stations disagree on the tracking space
  1764. ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, // Play Area hasn't been calibrated for the current tracking center
  1765. ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, // Collision Bounds haven't been calibrated for the current tracking center
  1766. };
  1767. /** HIGH LEVEL TRACKING SPACE ASSUMPTIONS:
  1768. * 0,0,0 is the preferred standing area center.
  1769. * 0Y is the floor height.
  1770. * -Z is the preferred forward facing direction. */
  1771. class IVRChaperone
  1772. {
  1773. public:
  1774. /** Get the current state of Chaperone calibration. This state can change at any time during a session due to physical base station changes. **/
  1775. virtual ChaperoneCalibrationState GetCalibrationState() = 0;
  1776. /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z.
  1777. * Tracking space center (0,0,0) is the center of the Play Area. **/
  1778. virtual bool GetPlayAreaSize( float *pSizeX, float *pSizeZ ) = 0;
  1779. /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds).
  1780. * Corners are in counter-clockwise order.
  1781. * Standing center (0,0,0) is the center of the Play Area.
  1782. * It's a rectangle.
  1783. * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
  1784. * Height of every corner is 0Y (on the floor). **/
  1785. virtual bool GetPlayAreaRect( HmdQuad_t *rect ) = 0;
  1786. /** Reload Chaperone data from the .vrchap file on disk. */
  1787. virtual void ReloadInfo( void ) = 0;
  1788. /** Optionally give the chaperone system a hit about the color and brightness in the scene **/
  1789. virtual void SetSceneColor( HmdColor_t color ) = 0;
  1790. /** Get the current chaperone bounds draw color and brightness **/
  1791. virtual void GetBoundsColor( HmdColor_t *pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, HmdColor_t *pOutputCameraColor ) = 0;
  1792. /** Determine whether the bounds are showing right now **/
  1793. virtual bool AreBoundsVisible() = 0;
  1794. /** Force the bounds to show, mostly for utilities **/
  1795. virtual void ForceBoundsVisible( bool bForce ) = 0;
  1796. };
  1797. static const char * const IVRChaperone_Version = "IVRChaperone_003";
  1798. #pragma pack( pop )
  1799. }
  1800. // ivrchaperonesetup.h
  1801. namespace vr
  1802. {
  1803. enum EChaperoneConfigFile
  1804. {
  1805. EChaperoneConfigFile_Live = 1, // The live chaperone config, used by most applications and games
  1806. EChaperoneConfigFile_Temp = 2, // The temporary chaperone config, used to live-preview collision bounds in room setup
  1807. };
  1808. enum EChaperoneImportFlags
  1809. {
  1810. EChaperoneImport_BoundsOnly = 0x0001,
  1811. };
  1812. /** Manages the working copy of the chaperone info. By default this will be the same as the
  1813. * live copy. Any changes made with this interface will stay in the working copy until
  1814. * CommitWorkingCopy() is called, at which point the working copy and the live copy will be
  1815. * the same again. */
  1816. class IVRChaperoneSetup
  1817. {
  1818. public:
  1819. /** Saves the current working copy to disk */
  1820. virtual bool CommitWorkingCopy( EChaperoneConfigFile configFile ) = 0;
  1821. /** Reverts the working copy to match the live chaperone calibration.
  1822. * To modify existing data this MUST be do WHILE getting a non-error ChaperoneCalibrationStatus.
  1823. * Only after this should you do gets and sets on the existing data. */
  1824. virtual void RevertWorkingCopy() = 0;
  1825. /** Returns the width and depth of the Play Area (formerly named Soft Bounds) in X and Z from the working copy.
  1826. * Tracking space center (0,0,0) is the center of the Play Area. */
  1827. virtual bool GetWorkingPlayAreaSize( float *pSizeX, float *pSizeZ ) = 0;
  1828. /** Returns the 4 corner positions of the Play Area (formerly named Soft Bounds) from the working copy.
  1829. * Corners are in clockwise order.
  1830. * Tracking space center (0,0,0) is the center of the Play Area.
  1831. * It's a rectangle.
  1832. * 2 sides are parallel to the X axis and 2 sides are parallel to the Z axis.
  1833. * Height of every corner is 0Y (on the floor). **/
  1834. virtual bool GetWorkingPlayAreaRect( HmdQuad_t *rect ) = 0;
  1835. /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
  1836. * into the buffer up to the max specified from the working copy. */
  1837. virtual bool GetWorkingCollisionBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1838. /** Returns the number of Quads if the buffer points to null. Otherwise it returns Quads
  1839. * into the buffer up to the max specified. */
  1840. virtual bool GetLiveCollisionBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1841. /** Returns the preferred seated position from the working copy. */
  1842. virtual bool GetWorkingSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0;
  1843. /** Returns the standing origin from the working copy. */
  1844. virtual bool GetWorkingStandingZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatStandingZeroPoseToRawTrackingPose ) = 0;
  1845. /** Sets the Play Area in the working copy. */
  1846. virtual void SetWorkingPlayAreaSize( float sizeX, float sizeZ ) = 0;
  1847. /** Sets the Collision Bounds in the working copy. */
  1848. virtual void SetWorkingCollisionBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0;
  1849. /** Sets the preferred seated position in the working copy. */
  1850. virtual void SetWorkingSeatedZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatSeatedZeroPoseToRawTrackingPose ) = 0;
  1851. /** Sets the preferred standing position in the working copy. */
  1852. virtual void SetWorkingStandingZeroPoseToRawTrackingPose( const HmdMatrix34_t *pMatStandingZeroPoseToRawTrackingPose ) = 0;
  1853. /** Tear everything down and reload it from the file on disk */
  1854. virtual void ReloadFromDisk( EChaperoneConfigFile configFile ) = 0;
  1855. /** Returns the preferred seated position. */
  1856. virtual bool GetLiveSeatedZeroPoseToRawTrackingPose( HmdMatrix34_t *pmatSeatedZeroPoseToRawTrackingPose ) = 0;
  1857. virtual void SetWorkingCollisionBoundsTagsInfo( VR_ARRAY_COUNT(unTagCount) uint8_t *pTagsBuffer, uint32_t unTagCount ) = 0;
  1858. virtual bool GetLiveCollisionBoundsTagsInfo( VR_OUT_ARRAY_COUNT(punTagCount) uint8_t *pTagsBuffer, uint32_t *punTagCount ) = 0;
  1859. virtual bool SetWorkingPhysicalBoundsInfo( VR_ARRAY_COUNT(unQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t unQuadsCount ) = 0;
  1860. virtual bool GetLivePhysicalBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  1861. virtual bool ExportLiveToBuffer( VR_OUT_STRING() char *pBuffer, uint32_t *pnBufferLength ) = 0;
  1862. virtual bool ImportFromBufferToWorking( const char *pBuffer, uint32_t nImportFlags ) = 0;
  1863. };
  1864. static const char * const IVRChaperoneSetup_Version = "IVRChaperoneSetup_005";
  1865. }
  1866. // ivrcompositor.h
  1867. namespace vr
  1868. {
  1869. #pragma pack( push, 8 )
  1870. /** Errors that can occur with the VR compositor */
  1871. enum EVRCompositorError
  1872. {
  1873. VRCompositorError_None = 0,
  1874. VRCompositorError_RequestFailed = 1,
  1875. VRCompositorError_IncompatibleVersion = 100,
  1876. VRCompositorError_DoNotHaveFocus = 101,
  1877. VRCompositorError_InvalidTexture = 102,
  1878. VRCompositorError_IsNotSceneApplication = 103,
  1879. VRCompositorError_TextureIsOnWrongDevice = 104,
  1880. VRCompositorError_TextureUsesUnsupportedFormat = 105,
  1881. VRCompositorError_SharedTexturesNotSupported = 106,
  1882. VRCompositorError_IndexOutOfRange = 107,
  1883. VRCompositorError_AlreadySubmitted = 108,
  1884. VRCompositorError_InvalidBounds = 109,
  1885. };
  1886. /** Timing mode passed to SetExplicitTimingMode(); see that function for documentation */
  1887. enum EVRCompositorTimingMode
  1888. {
  1889. VRCompositorTimingMode_Implicit = 0,
  1890. VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1,
  1891. VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2,
  1892. };
  1893. const uint32_t VRCompositor_ReprojectionReason_Cpu = 0x01;
  1894. const uint32_t VRCompositor_ReprojectionReason_Gpu = 0x02;
  1895. const uint32_t VRCompositor_ReprojectionAsync = 0x04; // This flag indicates the async reprojection mode is active,
  1896. // but does not indicate if reprojection actually happened or not.
  1897. // Use the ReprojectionReason flags above to check if reprojection
  1898. // was actually applied (i.e. scene texture was reused).
  1899. // NumFramePresents > 1 also indicates the scene texture was reused,
  1900. // and also the number of times that it was presented in total.
  1901. /** Provides a single frame's timing information to the app */
  1902. struct Compositor_FrameTiming
  1903. {
  1904. uint32_t m_nSize; // Set to sizeof( Compositor_FrameTiming )
  1905. uint32_t m_nFrameIndex;
  1906. uint32_t m_nNumFramePresents; // number of times this frame was presented
  1907. uint32_t m_nNumMisPresented; // number of times this frame was presented on a vsync other than it was originally predicted to
  1908. uint32_t m_nNumDroppedFrames; // number of additional times previous frame was scanned out
  1909. uint32_t m_nReprojectionFlags;
  1910. /** Absolute time reference for comparing frames. This aligns with the vsync that running start is relative to. */
  1911. double m_flSystemTimeInSeconds;
  1912. /** These times may include work from other processes due to OS scheduling.
  1913. * The fewer packets of work these are broken up into, the less likely this will happen.
  1914. * GPU work can be broken up by calling Flush. This can sometimes be useful to get the GPU started
  1915. * processing that work earlier in the frame. */
  1916. float m_flPreSubmitGpuMs; // time spent rendering the scene (gpu work submitted between WaitGetPoses and second Submit)
  1917. float m_flPostSubmitGpuMs; // additional time spent rendering by application (e.g. companion window)
  1918. float m_flTotalRenderGpuMs; // time between work submitted immediately after present (ideally vsync) until the end of compositor submitted work
  1919. float m_flCompositorRenderGpuMs; // time spend performing distortion correction, rendering chaperone, overlays, etc.
  1920. float m_flCompositorRenderCpuMs; // time spent on cpu submitting the above work for this frame
  1921. float m_flCompositorIdleCpuMs; // time spent waiting for running start (application could have used this much more time)
  1922. /** Miscellaneous measured intervals. */
  1923. float m_flClientFrameIntervalMs; // time between calls to WaitGetPoses
  1924. float m_flPresentCallCpuMs; // time blocked on call to present (usually 0.0, but can go long)
  1925. float m_flWaitForPresentCpuMs; // time spent spin-waiting for frame index to change (not near-zero indicates wait object failure)
  1926. float m_flSubmitFrameMs; // time spent in IVRCompositor::Submit (not near-zero indicates driver issue)
  1927. /** The following are all relative to this frame's SystemTimeInSeconds */
  1928. float m_flWaitGetPosesCalledMs;
  1929. float m_flNewPosesReadyMs;
  1930. float m_flNewFrameReadyMs; // second call to IVRCompositor::Submit
  1931. float m_flCompositorUpdateStartMs;
  1932. float m_flCompositorUpdateEndMs;
  1933. float m_flCompositorRenderStartMs;
  1934. vr::TrackedDevicePose_t m_HmdPose; // pose used by app to render this frame
  1935. };
  1936. /** Cumulative stats for current application. These are not cleared until a new app connects,
  1937. * but they do stop accumulating once the associated app disconnects. */
  1938. struct Compositor_CumulativeStats
  1939. {
  1940. uint32_t m_nPid; // Process id associated with these stats (may no longer be running).
  1941. uint32_t m_nNumFramePresents; // total number of times we called present (includes reprojected frames)
  1942. uint32_t m_nNumDroppedFrames; // total number of times an old frame was re-scanned out (without reprojection)
  1943. uint32_t m_nNumReprojectedFrames; // total number of times a frame was scanned out a second time (with reprojection)
  1944. /** Values recorded at startup before application has fully faded in the first time. */
  1945. uint32_t m_nNumFramePresentsOnStartup;
  1946. uint32_t m_nNumDroppedFramesOnStartup;
  1947. uint32_t m_nNumReprojectedFramesOnStartup;
  1948. /** Applications may explicitly fade to the compositor. This is usually to handle level transitions, and loading often causes
  1949. * system wide hitches. The following stats are collected during this period. Does not include values recorded during startup. */
  1950. uint32_t m_nNumLoading;
  1951. uint32_t m_nNumFramePresentsLoading;
  1952. uint32_t m_nNumDroppedFramesLoading;
  1953. uint32_t m_nNumReprojectedFramesLoading;
  1954. /** 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
  1955. * fading back to the compositor. The following stats are a result of this, and are a subset of those recorded above.
  1956. * Does not include values recorded during start up or loading. */
  1957. uint32_t m_nNumTimedOut;
  1958. uint32_t m_nNumFramePresentsTimedOut;
  1959. uint32_t m_nNumDroppedFramesTimedOut;
  1960. uint32_t m_nNumReprojectedFramesTimedOut;
  1961. };
  1962. #pragma pack( pop )
  1963. /** Allows the application to interact with the compositor */
  1964. class IVRCompositor
  1965. {
  1966. public:
  1967. /** Sets tracking space returned by WaitGetPoses */
  1968. virtual void SetTrackingSpace( ETrackingUniverseOrigin eOrigin ) = 0;
  1969. /** Gets current tracking space returned by WaitGetPoses */
  1970. virtual ETrackingUniverseOrigin GetTrackingSpace() = 0;
  1971. /** Scene applications should call this function to get poses to render with (and optionally poses predicted an additional frame out to use for gameplay).
  1972. * This function will block until "running start" milliseconds before the start of the frame, and should be called at the last moment before needing to
  1973. * start rendering.
  1974. *
  1975. * Return codes:
  1976. * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene)
  1977. * - DoNotHaveFocus (some other app has taken focus - this will throttle the call to 10hz to reduce the impact on that app)
  1978. */
  1979. virtual EVRCompositorError WaitGetPoses( VR_ARRAY_COUNT(unRenderPoseArrayCount) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount,
  1980. VR_ARRAY_COUNT(unGamePoseArrayCount) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0;
  1981. /** Get the last set of poses returned by WaitGetPoses. */
  1982. virtual EVRCompositorError GetLastPoses( VR_ARRAY_COUNT( unRenderPoseArrayCount ) TrackedDevicePose_t* pRenderPoseArray, uint32_t unRenderPoseArrayCount,
  1983. VR_ARRAY_COUNT( unGamePoseArrayCount ) TrackedDevicePose_t* pGamePoseArray, uint32_t unGamePoseArrayCount ) = 0;
  1984. /** Interface for accessing last set of poses returned by WaitGetPoses one at a time.
  1985. * Returns VRCompositorError_IndexOutOfRange if unDeviceIndex not less than k_unMaxTrackedDeviceCount otherwise VRCompositorError_None.
  1986. * It is okay to pass NULL for either pose if you only want one of the values. */
  1987. virtual EVRCompositorError GetLastPoseForTrackedDeviceIndex( TrackedDeviceIndex_t unDeviceIndex, TrackedDevicePose_t *pOutputPose, TrackedDevicePose_t *pOutputGamePose ) = 0;
  1988. /** 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
  1989. * 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.
  1990. *
  1991. * OpenGL dirty state:
  1992. * glBindTexture
  1993. *
  1994. * Return codes:
  1995. * - IsNotSceneApplication (make sure to call VR_Init with VRApplicaiton_Scene)
  1996. * - DoNotHaveFocus (some other app has taken focus)
  1997. * - TextureIsOnWrongDevice (application did not use proper AdapterIndex - see IVRSystem.GetDXGIOutputInfo)
  1998. * - SharedTexturesNotSupported (application needs to call CreateDXGIFactory1 or later before creating DX device)
  1999. * - TextureUsesUnsupportedFormat (scene textures must be compatible with DXGI sharing rules - e.g. uncompressed, no mips, etc.)
  2000. * - InvalidTexture (usually means bad arguments passed in)
  2001. * - AlreadySubmitted (app has submitted two left textures or two right textures in a single frame - i.e. before calling WaitGetPoses again)
  2002. */
  2003. virtual EVRCompositorError Submit( EVREye eEye, const Texture_t *pTexture, const VRTextureBounds_t* pBounds = 0, EVRSubmitFlags nSubmitFlags = Submit_Default ) = 0;
  2004. /** Clears the frame that was sent with the last call to Submit. This will cause the
  2005. * compositor to show the grid until Submit is called again. */
  2006. virtual void ClearLastSubmittedFrame() = 0;
  2007. /** Call immediately after presenting your app's window (i.e. companion window) to unblock the compositor.
  2008. * This is an optional call, which only needs to be used if you can't instead call WaitGetPoses immediately after Present.
  2009. * 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
  2010. * introduce a deadlock of some sort. This function tells the compositor that you have finished all rendering after having Submitted buffers for both
  2011. * eyes, and it is free to start its rendering work. This should only be called from the same thread you are rendering on. */
  2012. virtual void PostPresentHandoff() = 0;
  2013. /** Returns true if timing data is filled it. Sets oldest timing info if nFramesAgo is larger than the stored history.
  2014. * Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function. */
  2015. virtual bool GetFrameTiming( Compositor_FrameTiming *pTiming, uint32_t unFramesAgo = 0 ) = 0;
  2016. /** Interface for copying a range of timing data. Frames are returned in ascending order (oldest to newest) with the last being the most recent frame.
  2017. * Only the first entry's m_nSize needs to be set, as the rest will be inferred from that. Returns total number of entries filled out. */
  2018. virtual uint32_t GetFrameTimings( Compositor_FrameTiming *pTiming, uint32_t nFrames ) = 0;
  2019. /** Returns the time in seconds left in the current (as identified by FrameTiming's frameIndex) frame.
  2020. * Due to "running start", this value may roll over to the next frame before ever reaching 0.0. */
  2021. virtual float GetFrameTimeRemaining() = 0;
  2022. /** Fills out stats accumulated for the last connected application. Pass in sizeof( Compositor_CumulativeStats ) as second parameter. */
  2023. virtual void GetCumulativeStats( Compositor_CumulativeStats *pStats, uint32_t nStatsSizeInBytes ) = 0;
  2024. /** Fades the view on the HMD to the specified color. The fade will take fSeconds, and the color values are between
  2025. * 0.0 and 1.0. This color is faded on top of the scene based on the alpha parameter. Removing the fade color instantly
  2026. * would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). Values are in un-premultiplied alpha space. */
  2027. virtual void FadeToColor( float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground = false ) = 0;
  2028. /** Get current fade color value. */
  2029. virtual HmdColor_t GetCurrentFadeColor( bool bBackground = false ) = 0;
  2030. /** Fading the Grid in or out in fSeconds */
  2031. virtual void FadeGrid( float fSeconds, bool bFadeIn ) = 0;
  2032. /** Get current alpha value of grid. */
  2033. virtual float GetCurrentGridAlpha() = 0;
  2034. /** Override the skybox used in the compositor (e.g. for during level loads when the app can't feed scene images fast enough)
  2035. * Order is Front, Back, Left, Right, Top, Bottom. If only a single texture is passed, it is assumed in lat-long format.
  2036. * If two are passed, it is assumed a lat-long stereo pair. */
  2037. virtual EVRCompositorError SetSkyboxOverride( VR_ARRAY_COUNT( unTextureCount ) const Texture_t *pTextures, uint32_t unTextureCount ) = 0;
  2038. /** Resets compositor skybox back to defaults. */
  2039. virtual void ClearSkyboxOverride() = 0;
  2040. /** Brings the compositor window to the front. This is useful for covering any other window that may be on the HMD
  2041. * and is obscuring the compositor window. */
  2042. virtual void CompositorBringToFront() = 0;
  2043. /** Pushes the compositor window to the back. This is useful for allowing other applications to draw directly to the HMD. */
  2044. virtual void CompositorGoToBack() = 0;
  2045. /** Tells the compositor process to clean up and exit. You do not need to call this function at shutdown. Under normal
  2046. * circumstances the compositor will manage its own life cycle based on what applications are running. */
  2047. virtual void CompositorQuit() = 0;
  2048. /** Return whether the compositor is fullscreen */
  2049. virtual bool IsFullscreen() = 0;
  2050. /** Returns the process ID of the process that is currently rendering the scene */
  2051. virtual uint32_t GetCurrentSceneFocusProcess() = 0;
  2052. /** Returns the process ID of the process that rendered the last frame (or 0 if the compositor itself rendered the frame.)
  2053. * Returns 0 when fading out from an app and the app's process Id when fading into an app. */
  2054. virtual uint32_t GetLastFrameRenderer() = 0;
  2055. /** Returns true if the current process has the scene focus */
  2056. virtual bool CanRenderScene() = 0;
  2057. /** Creates a window on the primary monitor to display what is being shown in the headset. */
  2058. virtual void ShowMirrorWindow() = 0;
  2059. /** Closes the mirror window. */
  2060. virtual void HideMirrorWindow() = 0;
  2061. /** Returns true if the mirror window is shown. */
  2062. virtual bool IsMirrorWindowVisible() = 0;
  2063. /** Writes all images that the compositor knows about (including overlays) to a 'screenshots' folder in the SteamVR runtime root. */
  2064. virtual void CompositorDumpImages() = 0;
  2065. /** Let an app know it should be rendering with low resources. */
  2066. virtual bool ShouldAppRenderWithLowResources() = 0;
  2067. /** Override interleaved reprojection logic to force on. */
  2068. virtual void ForceInterleavedReprojectionOn( bool bOverride ) = 0;
  2069. /** Force reconnecting to the compositor process. */
  2070. virtual void ForceReconnectProcess() = 0;
  2071. /** Temporarily suspends rendering (useful for finer control over scene transitions). */
  2072. virtual void SuspendRendering( bool bSuspend ) = 0;
  2073. /** Opens a shared D3D11 texture with the undistorted composited image for each eye. Use ReleaseMirrorTextureD3D11 when finished
  2074. * instead of calling Release on the resource itself. */
  2075. virtual vr::EVRCompositorError GetMirrorTextureD3D11( vr::EVREye eEye, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView ) = 0;
  2076. virtual void ReleaseMirrorTextureD3D11( void *pD3D11ShaderResourceView ) = 0;
  2077. /** Access to mirror textures from OpenGL. */
  2078. virtual vr::EVRCompositorError GetMirrorTextureGL( vr::EVREye eEye, vr::glUInt_t *pglTextureId, vr::glSharedTextureHandle_t *pglSharedTextureHandle ) = 0;
  2079. virtual bool ReleaseSharedGLTexture( vr::glUInt_t glTextureId, vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  2080. virtual void LockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  2081. virtual void UnlockGLSharedTextureForAccess( vr::glSharedTextureHandle_t glSharedTextureHandle ) = 0;
  2082. /** [Vulkan Only]
  2083. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  2084. * null. The string will be a space separated list of-required instance extensions to enable in VkCreateInstance */
  2085. virtual uint32_t GetVulkanInstanceExtensionsRequired( VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0;
  2086. /** [Vulkan only]
  2087. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  2088. * null. The string will be a space separated list of required device extensions to enable in VkCreateDevice */
  2089. virtual uint32_t GetVulkanDeviceExtensionsRequired( VkPhysicalDevice_T *pPhysicalDevice, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0;
  2090. /** [ Vulkan/D3D12 Only ]
  2091. * There are two purposes for SetExplicitTimingMode:
  2092. * 1. To get a more accurate GPU timestamp for when the frame begins in Vulkan/D3D12 applications.
  2093. * 2. (Optional) To avoid having WaitGetPoses access the Vulkan queue so that the queue can be accessed from
  2094. * another thread while WaitGetPoses is executing.
  2095. *
  2096. * More accurate GPU timestamp for the start of the frame is achieved by the application calling
  2097. * SubmitExplicitTimingData immediately before its first submission to the Vulkan/D3D12 queue.
  2098. * This is more accurate because normally this GPU timestamp is recorded during WaitGetPoses. In D3D11,
  2099. * WaitGetPoses queues a GPU timestamp write, but it does not actually get submitted to the GPU until the
  2100. * application flushes. By using SubmitExplicitTimingData, the timestamp is recorded at the same place for
  2101. * Vulkan/D3D12 as it is for D3D11, resulting in a more accurate GPU time measurement for the frame.
  2102. *
  2103. * Avoiding WaitGetPoses accessing the Vulkan queue can be achieved using SetExplicitTimingMode as well. If this is desired,
  2104. * the application should set the timing mode to Explicit_ApplicationPerformsPostPresentHandoff and *MUST* call PostPresentHandoff
  2105. * itself. If these conditions are met, then WaitGetPoses is guaranteed not to access the queue. Note that PostPresentHandoff
  2106. * and SubmitExplicitTimingData will access the queue, so only WaitGetPoses becomes safe for accessing the queue from another
  2107. * thread. */
  2108. virtual void SetExplicitTimingMode( EVRCompositorTimingMode eTimingMode ) = 0;
  2109. /** [ Vulkan/D3D12 Only ]
  2110. * Submit explicit timing data. When SetExplicitTimingMode is true, this must be called immediately before
  2111. * the application's first vkQueueSubmit (Vulkan) or ID3D12CommandQueue::ExecuteCommandLists (D3D12) of each frame.
  2112. * This function will insert a GPU timestamp write just before the application starts its rendering. This function
  2113. * will perform a vkQueueSubmit on Vulkan so must not be done simultaneously with VkQueue operations on another thread.
  2114. * Returns VRCompositorError_RequestFailed if SetExplicitTimingMode is not enabled. */
  2115. virtual EVRCompositorError SubmitExplicitTimingData() = 0;
  2116. };
  2117. static const char * const IVRCompositor_Version = "IVRCompositor_022";
  2118. } // namespace vr
  2119. // ivrnotifications.h
  2120. namespace vr
  2121. {
  2122. #pragma pack( push, 8 )
  2123. // Used for passing graphic data
  2124. struct NotificationBitmap_t
  2125. {
  2126. NotificationBitmap_t()
  2127. : m_pImageData( nullptr )
  2128. , m_nWidth( 0 )
  2129. , m_nHeight( 0 )
  2130. , m_nBytesPerPixel( 0 )
  2131. {
  2132. };
  2133. void *m_pImageData;
  2134. int32_t m_nWidth;
  2135. int32_t m_nHeight;
  2136. int32_t m_nBytesPerPixel;
  2137. };
  2138. /** Be aware that the notification type is used as 'priority' to pick the next notification */
  2139. enum EVRNotificationType
  2140. {
  2141. /** Transient notifications are automatically hidden after a period of time set by the user.
  2142. * They are used for things like information and chat messages that do not require user interaction. */
  2143. EVRNotificationType_Transient = 0,
  2144. /** Persistent notifications are shown to the user until they are hidden by calling RemoveNotification().
  2145. * They are used for things like phone calls and alarms that require user interaction. */
  2146. EVRNotificationType_Persistent = 1,
  2147. /** System notifications are shown no matter what. It is expected, that the ulUserValue is used as ID.
  2148. * If there is already a system notification in the queue with that ID it is not accepted into the queue
  2149. * to prevent spamming with system notification */
  2150. EVRNotificationType_Transient_SystemWithUserValue = 2,
  2151. };
  2152. enum EVRNotificationStyle
  2153. {
  2154. /** Creates a notification with minimal external styling. */
  2155. EVRNotificationStyle_None = 0,
  2156. /** Used for notifications about overlay-level status. In Steam this is used for events like downloads completing. */
  2157. EVRNotificationStyle_Application = 100,
  2158. /** Used for notifications about contacts that are unknown or not available. In Steam this is used for friend invitations and offline friends. */
  2159. EVRNotificationStyle_Contact_Disabled = 200,
  2160. /** 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. */
  2161. EVRNotificationStyle_Contact_Enabled = 201,
  2162. /** 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. */
  2163. EVRNotificationStyle_Contact_Active = 202,
  2164. };
  2165. static const uint32_t k_unNotificationTextMaxSize = 256;
  2166. typedef uint32_t VRNotificationId;
  2167. #pragma pack( pop )
  2168. /** Allows notification sources to interact with the VR system
  2169. This current interface is not yet implemented. Do not use yet. */
  2170. class IVRNotifications
  2171. {
  2172. public:
  2173. /** Create a notification and enqueue it to be shown to the user.
  2174. * An overlay handle is required to create a notification, as otherwise it would be impossible for a user to act on it.
  2175. * To create a two-line notification, use a line break ('\n') to split the text into two lines.
  2176. * The pImage argument may be NULL, in which case the specified overlay's icon will be used instead. */
  2177. virtual EVRNotificationError CreateNotification( VROverlayHandle_t ulOverlayHandle, uint64_t ulUserValue, EVRNotificationType type, const char *pchText, EVRNotificationStyle style, const NotificationBitmap_t *pImage, /* out */ VRNotificationId *pNotificationId ) = 0;
  2178. /** Destroy a notification, hiding it first if it currently shown to the user. */
  2179. virtual EVRNotificationError RemoveNotification( VRNotificationId notificationId ) = 0;
  2180. };
  2181. static const char * const IVRNotifications_Version = "IVRNotifications_002";
  2182. } // namespace vr
  2183. // ivroverlay.h
  2184. namespace vr
  2185. {
  2186. /** The maximum length of an overlay key in bytes, counting the terminating null character. */
  2187. static const uint32_t k_unVROverlayMaxKeyLength = 128;
  2188. /** The maximum length of an overlay name in bytes, counting the terminating null character. */
  2189. static const uint32_t k_unVROverlayMaxNameLength = 128;
  2190. /** The maximum number of overlays that can exist in the system at one time. */
  2191. static const uint32_t k_unMaxOverlayCount = 64;
  2192. /** The maximum number of overlay intersection mask primitives per overlay */
  2193. static const uint32_t k_unMaxOverlayIntersectionMaskPrimitivesCount = 32;
  2194. /** Types of input supported by VR Overlays */
  2195. enum VROverlayInputMethod
  2196. {
  2197. VROverlayInputMethod_None = 0, // No input events will be generated automatically for this overlay
  2198. VROverlayInputMethod_Mouse = 1, // Tracked controllers will get mouse events automatically
  2199. VROverlayInputMethod_DualAnalog = 2, // Analog inputs from tracked controllers are turned into DualAnalog events
  2200. };
  2201. /** Allows the caller to figure out which overlay transform getter to call. */
  2202. enum VROverlayTransformType
  2203. {
  2204. VROverlayTransform_Absolute = 0,
  2205. VROverlayTransform_TrackedDeviceRelative = 1,
  2206. VROverlayTransform_SystemOverlay = 2,
  2207. VROverlayTransform_TrackedComponent = 3,
  2208. };
  2209. /** Overlay control settings */
  2210. enum VROverlayFlags
  2211. {
  2212. VROverlayFlags_None = 0,
  2213. // The following only take effect when rendered using the high quality render path (see SetHighQualityOverlay).
  2214. VROverlayFlags_Curved = 1,
  2215. VROverlayFlags_RGSS4X = 2,
  2216. // Set this flag on a dashboard overlay to prevent a tab from showing up for that overlay
  2217. VROverlayFlags_NoDashboardTab = 3,
  2218. // Set this flag on a dashboard that is able to deal with gamepad focus events
  2219. VROverlayFlags_AcceptsGamepadEvents = 4,
  2220. // Indicates that the overlay should dim/brighten to show gamepad focus
  2221. VROverlayFlags_ShowGamepadFocus = 5,
  2222. // When in VROverlayInputMethod_Mouse you can optionally enable sending VRScroll_t
  2223. VROverlayFlags_SendVRScrollEvents = 6,
  2224. VROverlayFlags_SendVRTouchpadEvents = 7,
  2225. // If set this will render a vertical scroll wheel on the primary controller,
  2226. // only needed if not using VROverlayFlags_SendVRScrollEvents but you still want to represent a scroll wheel
  2227. VROverlayFlags_ShowTouchPadScrollWheel = 8,
  2228. // If this is set ownership and render access to the overlay are transferred
  2229. // to the new scene process on a call to IVRApplications::LaunchInternalProcess
  2230. VROverlayFlags_TransferOwnershipToInternalProcess = 9,
  2231. // If set, renders 50% of the texture in each eye, side by side
  2232. VROverlayFlags_SideBySide_Parallel = 10, // Texture is left/right
  2233. VROverlayFlags_SideBySide_Crossed = 11, // Texture is crossed and right/left
  2234. VROverlayFlags_Panorama = 12, // Texture is a panorama
  2235. VROverlayFlags_StereoPanorama = 13, // Texture is a stereo panorama
  2236. // If this is set on an overlay owned by the scene application that overlay
  2237. // will be sorted with the "Other" overlays on top of all other scene overlays
  2238. VROverlayFlags_SortWithNonSceneOverlays = 14,
  2239. // If set, the overlay will be shown in the dashboard, otherwise it will be hidden.
  2240. VROverlayFlags_VisibleInDashboard = 15,
  2241. };
  2242. enum VRMessageOverlayResponse
  2243. {
  2244. VRMessageOverlayResponse_ButtonPress_0 = 0,
  2245. VRMessageOverlayResponse_ButtonPress_1 = 1,
  2246. VRMessageOverlayResponse_ButtonPress_2 = 2,
  2247. VRMessageOverlayResponse_ButtonPress_3 = 3,
  2248. VRMessageOverlayResponse_CouldntFindSystemOverlay = 4,
  2249. VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay= 5,
  2250. VRMessageOverlayResponse_ApplicationQuit = 6
  2251. };
  2252. struct VROverlayIntersectionParams_t
  2253. {
  2254. HmdVector3_t vSource;
  2255. HmdVector3_t vDirection;
  2256. ETrackingUniverseOrigin eOrigin;
  2257. };
  2258. struct VROverlayIntersectionResults_t
  2259. {
  2260. HmdVector3_t vPoint;
  2261. HmdVector3_t vNormal;
  2262. HmdVector2_t vUVs;
  2263. float fDistance;
  2264. };
  2265. // Input modes for the Big Picture gamepad text entry
  2266. enum EGamepadTextInputMode
  2267. {
  2268. k_EGamepadTextInputModeNormal = 0,
  2269. k_EGamepadTextInputModePassword = 1,
  2270. k_EGamepadTextInputModeSubmit = 2,
  2271. };
  2272. // Controls number of allowed lines for the Big Picture gamepad text entry
  2273. enum EGamepadTextInputLineMode
  2274. {
  2275. k_EGamepadTextInputLineModeSingleLine = 0,
  2276. k_EGamepadTextInputLineModeMultipleLines = 1
  2277. };
  2278. /** Directions for changing focus between overlays with the gamepad */
  2279. enum EOverlayDirection
  2280. {
  2281. OverlayDirection_Up = 0,
  2282. OverlayDirection_Down = 1,
  2283. OverlayDirection_Left = 2,
  2284. OverlayDirection_Right = 3,
  2285. OverlayDirection_Count = 4,
  2286. };
  2287. enum EVROverlayIntersectionMaskPrimitiveType
  2288. {
  2289. OverlayIntersectionPrimitiveType_Rectangle,
  2290. OverlayIntersectionPrimitiveType_Circle,
  2291. };
  2292. struct IntersectionMaskRectangle_t
  2293. {
  2294. float m_flTopLeftX;
  2295. float m_flTopLeftY;
  2296. float m_flWidth;
  2297. float m_flHeight;
  2298. };
  2299. struct IntersectionMaskCircle_t
  2300. {
  2301. float m_flCenterX;
  2302. float m_flCenterY;
  2303. float m_flRadius;
  2304. };
  2305. /** NOTE!!! If you change this you MUST manually update openvr_interop.cs.py and openvr_api_flat.h.py */
  2306. typedef union
  2307. {
  2308. IntersectionMaskRectangle_t m_Rectangle;
  2309. IntersectionMaskCircle_t m_Circle;
  2310. } VROverlayIntersectionMaskPrimitive_Data_t;
  2311. struct VROverlayIntersectionMaskPrimitive_t
  2312. {
  2313. EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType;
  2314. VROverlayIntersectionMaskPrimitive_Data_t m_Primitive;
  2315. };
  2316. class IVROverlay
  2317. {
  2318. public:
  2319. // ---------------------------------------------
  2320. // Overlay management methods
  2321. // ---------------------------------------------
  2322. /** Finds an existing overlay with the specified key. */
  2323. virtual EVROverlayError FindOverlay( const char *pchOverlayKey, VROverlayHandle_t * pOverlayHandle ) = 0;
  2324. /** Creates a new named overlay. All overlays start hidden and with default settings. */
  2325. virtual EVROverlayError CreateOverlay( const char *pchOverlayKey, const char *pchOverlayName, VROverlayHandle_t * pOverlayHandle ) = 0;
  2326. /** Destroys the specified overlay. When an application calls VR_Shutdown all overlays created by that app are
  2327. * automatically destroyed. */
  2328. virtual EVROverlayError DestroyOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2329. /** Specify which overlay to use the high quality render path. This overlay will be composited in during the distortion pass which
  2330. * results in it drawing on top of everything else, but also at a higher quality as it samples the source texture directly rather than
  2331. * 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
  2332. * for overlays that are expected to take up most of the user's view (e.g. streaming video).
  2333. * This mode does not support mouse input to your overlay. */
  2334. virtual EVROverlayError SetHighQualityOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2335. /** Returns the overlay handle of the current overlay being rendered using the single high quality overlay render path.
  2336. * Otherwise it will return k_ulOverlayHandleInvalid. */
  2337. virtual vr::VROverlayHandle_t GetHighQualityOverlay() = 0;
  2338. /** Fills the provided buffer with the string key of the overlay. Returns the size of buffer required to store the key, including
  2339. * the terminating null character. k_unVROverlayMaxKeyLength will be enough bytes to fit the string. */
  2340. virtual uint32_t GetOverlayKey( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0;
  2341. /** Fills the provided buffer with the friendly name of the overlay. Returns the size of buffer required to store the key, including
  2342. * the terminating null character. k_unVROverlayMaxNameLength will be enough bytes to fit the string. */
  2343. virtual uint32_t GetOverlayName( VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, EVROverlayError *pError = 0L ) = 0;
  2344. /** set the name to use for this overlay */
  2345. virtual EVROverlayError SetOverlayName( VROverlayHandle_t ulOverlayHandle, const char *pchName ) = 0;
  2346. /** 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
  2347. * will be set and VROverlayError_ArrayTooSmall is returned. */
  2348. virtual EVROverlayError GetOverlayImageData( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unBufferSize, uint32_t *punWidth, uint32_t *punHeight ) = 0;
  2349. /** returns a string that corresponds with the specified overlay error. The string will be the name
  2350. * of the error enum value for all valid error codes */
  2351. virtual const char *GetOverlayErrorNameFromEnum( EVROverlayError error ) = 0;
  2352. // ---------------------------------------------
  2353. // Overlay rendering methods
  2354. // ---------------------------------------------
  2355. /** Sets the pid that is allowed to render to this overlay (the creator pid is always allow to render),
  2356. * by default this is the pid of the process that made the overlay */
  2357. virtual EVROverlayError SetOverlayRenderingPid( VROverlayHandle_t ulOverlayHandle, uint32_t unPID ) = 0;
  2358. /** Gets the pid that is allowed to render to this overlay */
  2359. virtual uint32_t GetOverlayRenderingPid( VROverlayHandle_t ulOverlayHandle ) = 0;
  2360. /** Specify flag setting for a given overlay */
  2361. virtual EVROverlayError SetOverlayFlag( VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled ) = 0;
  2362. /** Sets flag setting for a given overlay */
  2363. virtual EVROverlayError GetOverlayFlag( VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool *pbEnabled ) = 0;
  2364. /** Sets the color tint of the overlay quad. Use 0.0 to 1.0 per channel. */
  2365. virtual EVROverlayError SetOverlayColor( VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue ) = 0;
  2366. /** Gets the color tint of the overlay quad. */
  2367. virtual EVROverlayError GetOverlayColor( VROverlayHandle_t ulOverlayHandle, float *pfRed, float *pfGreen, float *pfBlue ) = 0;
  2368. /** Sets the alpha of the overlay quad. Use 1.0 for 100 percent opacity to 0.0 for 0 percent opacity. */
  2369. virtual EVROverlayError SetOverlayAlpha( VROverlayHandle_t ulOverlayHandle, float fAlpha ) = 0;
  2370. /** Gets the alpha of the overlay quad. By default overlays are rendering at 100 percent alpha (1.0). */
  2371. virtual EVROverlayError GetOverlayAlpha( VROverlayHandle_t ulOverlayHandle, float *pfAlpha ) = 0;
  2372. /** Sets the aspect ratio of the texels in the overlay. 1.0 means the texels are square. 2.0 means the texels
  2373. * are twice as wide as they are tall. Defaults to 1.0. */
  2374. virtual EVROverlayError SetOverlayTexelAspect( VROverlayHandle_t ulOverlayHandle, float fTexelAspect ) = 0;
  2375. /** Gets the aspect ratio of the texels in the overlay. Defaults to 1.0 */
  2376. virtual EVROverlayError GetOverlayTexelAspect( VROverlayHandle_t ulOverlayHandle, float *pfTexelAspect ) = 0;
  2377. /** Sets the rendering sort order for the overlay. Overlays are rendered this order:
  2378. * Overlays owned by the scene application
  2379. * Overlays owned by some other application
  2380. *
  2381. * Within a category overlays are rendered lowest sort order to highest sort order. Overlays with the same
  2382. * sort order are rendered back to front base on distance from the HMD.
  2383. *
  2384. * Sort order defaults to 0. */
  2385. virtual EVROverlayError SetOverlaySortOrder( VROverlayHandle_t ulOverlayHandle, uint32_t unSortOrder ) = 0;
  2386. /** Gets the sort order of the overlay. See SetOverlaySortOrder for how this works. */
  2387. virtual EVROverlayError GetOverlaySortOrder( VROverlayHandle_t ulOverlayHandle, uint32_t *punSortOrder ) = 0;
  2388. /** Sets the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
  2389. virtual EVROverlayError SetOverlayWidthInMeters( VROverlayHandle_t ulOverlayHandle, float fWidthInMeters ) = 0;
  2390. /** Returns the width of the overlay quad in meters. By default overlays are rendered on a quad that is 1 meter across */
  2391. virtual EVROverlayError GetOverlayWidthInMeters( VROverlayHandle_t ulOverlayHandle, float *pfWidthInMeters ) = 0;
  2392. /** For high-quality curved overlays only, sets the distance range in meters from the overlay used to automatically curve
  2393. * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
  2394. virtual EVROverlayError SetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float fMinDistanceInMeters, float fMaxDistanceInMeters ) = 0;
  2395. /** For high-quality curved overlays only, gets the distance range in meters from the overlay used to automatically curve
  2396. * the surface around the viewer. Min is distance is when the surface will be most curved. Max is when least curved. */
  2397. virtual EVROverlayError GetOverlayAutoCurveDistanceRangeInMeters( VROverlayHandle_t ulOverlayHandle, float *pfMinDistanceInMeters, float *pfMaxDistanceInMeters ) = 0;
  2398. /** Sets the colorspace the overlay texture's data is in. Defaults to 'auto'.
  2399. * If the texture needs to be resolved, you should call SetOverlayTexture with the appropriate colorspace instead. */
  2400. virtual EVROverlayError SetOverlayTextureColorSpace( VROverlayHandle_t ulOverlayHandle, EColorSpace eTextureColorSpace ) = 0;
  2401. /** Gets the overlay's current colorspace setting. */
  2402. virtual EVROverlayError GetOverlayTextureColorSpace( VROverlayHandle_t ulOverlayHandle, EColorSpace *peTextureColorSpace ) = 0;
  2403. /** 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. */
  2404. virtual EVROverlayError SetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, const VRTextureBounds_t *pOverlayTextureBounds ) = 0;
  2405. /** 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. */
  2406. virtual EVROverlayError GetOverlayTextureBounds( VROverlayHandle_t ulOverlayHandle, VRTextureBounds_t *pOverlayTextureBounds ) = 0;
  2407. /** Gets render model to draw behind this overlay */
  2408. virtual uint32_t GetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, HmdColor_t *pColor, vr::EVROverlayError *pError ) = 0;
  2409. /** Sets render model to draw behind this overlay and the vertex color to use, pass null for pColor to match the overlays vertex color.
  2410. The model is scaled by the same amount as the overlay, with a default of 1m. */
  2411. virtual vr::EVROverlayError SetOverlayRenderModel( vr::VROverlayHandle_t ulOverlayHandle, const char *pchRenderModel, const HmdColor_t *pColor ) = 0;
  2412. /** Returns the transform type of this overlay. */
  2413. virtual EVROverlayError GetOverlayTransformType( VROverlayHandle_t ulOverlayHandle, VROverlayTransformType *peTransformType ) = 0;
  2414. /** Sets the transform to absolute tracking origin. */
  2415. virtual EVROverlayError SetOverlayTransformAbsolute( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToOverlayTransform ) = 0;
  2416. /** Gets the transform if it is absolute. Returns an error if the transform is some other type. */
  2417. virtual EVROverlayError GetOverlayTransformAbsolute( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin *peTrackingOrigin, HmdMatrix34_t *pmatTrackingOriginToOverlayTransform ) = 0;
  2418. /** Sets the transform to relative to the transform of the specified tracked device. */
  2419. virtual EVROverlayError SetOverlayTransformTrackedDeviceRelative( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unTrackedDevice, const HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform ) = 0;
  2420. /** Gets the transform if it is relative to a tracked device. Returns an error if the transform is some other type. */
  2421. virtual EVROverlayError GetOverlayTransformTrackedDeviceRelative( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punTrackedDevice, HmdMatrix34_t *pmatTrackedDeviceToOverlayTransform ) = 0;
  2422. /** Sets the transform to draw the overlay on a rendermodel component mesh instead of a quad. This will only draw when the system is
  2423. * drawing the device. Overlays with this transform type cannot receive mouse events. */
  2424. virtual EVROverlayError SetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, const char *pchComponentName ) = 0;
  2425. /** Gets the transform information when the overlay is rendering on a component. */
  2426. virtual EVROverlayError GetOverlayTransformTrackedDeviceComponent( VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t *punDeviceIndex, VR_OUT_STRING() char *pchComponentName, uint32_t unComponentNameSize ) = 0;
  2427. /** Gets the transform if it is relative to another overlay. Returns an error if the transform is some other type. */
  2428. virtual vr::EVROverlayError GetOverlayTransformOverlayRelative( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t *ulOverlayHandleParent, HmdMatrix34_t *pmatParentOverlayToOverlayTransform ) = 0;
  2429. /** Sets the transform to relative to the transform of the specified overlay. This overlays visibility will also track the parents visibility */
  2430. virtual vr::EVROverlayError SetOverlayTransformOverlayRelative( VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulOverlayHandleParent, const HmdMatrix34_t *pmatParentOverlayToOverlayTransform ) = 0;
  2431. /** Shows the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
  2432. virtual EVROverlayError ShowOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2433. /** Hides the VR overlay. For dashboard overlays, only the Dashboard Manager is allowed to call this. */
  2434. virtual EVROverlayError HideOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2435. /** Returns true if the overlay is visible. */
  2436. virtual bool IsOverlayVisible( VROverlayHandle_t ulOverlayHandle ) = 0;
  2437. /** 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 */
  2438. virtual EVROverlayError GetTransformForOverlayCoordinates( VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, HmdVector2_t coordinatesInOverlay, HmdMatrix34_t *pmatTransform ) = 0;
  2439. // ---------------------------------------------
  2440. // Overlay input methods
  2441. // ---------------------------------------------
  2442. /** Returns true and fills the event with the next event on the overlay's event queue, if there is one.
  2443. * If there are no events this method returns false. uncbVREvent should be the size in bytes of the VREvent_t struct */
  2444. virtual bool PollNextOverlayEvent( VROverlayHandle_t ulOverlayHandle, VREvent_t *pEvent, uint32_t uncbVREvent ) = 0;
  2445. /** Returns the current input settings for the specified overlay. */
  2446. virtual EVROverlayError GetOverlayInputMethod( VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod *peInputMethod ) = 0;
  2447. /** Sets the input settings for the specified overlay. */
  2448. virtual EVROverlayError SetOverlayInputMethod( VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod eInputMethod ) = 0;
  2449. /** Gets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
  2450. * typically the size of the underlying UI in pixels. */
  2451. virtual EVROverlayError GetOverlayMouseScale( VROverlayHandle_t ulOverlayHandle, HmdVector2_t *pvecMouseScale ) = 0;
  2452. /** Sets the mouse scaling factor that is used for mouse events. The actual texture may be a different size, but this is
  2453. * typically the size of the underlying UI in pixels (not in world space). */
  2454. virtual EVROverlayError SetOverlayMouseScale( VROverlayHandle_t ulOverlayHandle, const HmdVector2_t *pvecMouseScale ) = 0;
  2455. /** Computes the overlay-space pixel coordinates of where the ray intersects the overlay with the
  2456. * specified settings. Returns false if there is no intersection. */
  2457. virtual bool ComputeOverlayIntersection( VROverlayHandle_t ulOverlayHandle, const VROverlayIntersectionParams_t *pParams, VROverlayIntersectionResults_t *pResults ) = 0;
  2458. /** Returns true if the specified overlay is the hover target. An overlay is the hover target when it is the last overlay "moused over"
  2459. * by the virtual mouse pointer */
  2460. virtual bool IsHoverTargetOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2461. /** Returns the current Gamepad focus overlay */
  2462. virtual vr::VROverlayHandle_t GetGamepadFocusOverlay() = 0;
  2463. /** Sets the current Gamepad focus overlay */
  2464. virtual EVROverlayError SetGamepadFocusOverlay( VROverlayHandle_t ulNewFocusOverlay ) = 0;
  2465. /** Sets an overlay's neighbor. This will also set the neighbor of the "to" overlay
  2466. * to point back to the "from" overlay. If an overlay's neighbor is set to invalid both
  2467. * ends will be cleared */
  2468. virtual EVROverlayError SetOverlayNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom, VROverlayHandle_t ulTo ) = 0;
  2469. /** Changes the Gamepad focus from one overlay to one of its neighbors. Returns VROverlayError_NoNeighbor if there is no
  2470. * neighbor in that direction */
  2471. virtual EVROverlayError MoveGamepadFocusToNeighbor( EOverlayDirection eDirection, VROverlayHandle_t ulFrom ) = 0;
  2472. /** Sets the analog input to Dual Analog coordinate scale for the specified overlay. */
  2473. virtual EVROverlayError SetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, const HmdVector2_t & vCenter, float fRadius ) = 0;
  2474. /** Gets the analog input to Dual Analog coordinate scale for the specified overlay. */
  2475. virtual EVROverlayError GetOverlayDualAnalogTransform( VROverlayHandle_t ulOverlay, EDualAnalogWhich eWhich, HmdVector2_t *pvCenter, float *pfRadius ) = 0;
  2476. // ---------------------------------------------
  2477. // Overlay texture methods
  2478. // ---------------------------------------------
  2479. /** Texture to draw for the overlay. This function can only be called by the overlay's creator or renderer process (see SetOverlayRenderingPid) .
  2480. *
  2481. * OpenGL dirty state:
  2482. * glBindTexture
  2483. */
  2484. virtual EVROverlayError SetOverlayTexture( VROverlayHandle_t ulOverlayHandle, const Texture_t *pTexture ) = 0;
  2485. /** Use this to tell the overlay system to release the texture set for this overlay. */
  2486. virtual EVROverlayError ClearOverlayTexture( VROverlayHandle_t ulOverlayHandle ) = 0;
  2487. /** Separate interface for providing the data as a stream of bytes, but there is an upper bound on data
  2488. * that can be sent. This function can only be called by the overlay's renderer process. */
  2489. virtual EVROverlayError SetOverlayRaw( VROverlayHandle_t ulOverlayHandle, void *pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unDepth ) = 0;
  2490. /** Separate interface for providing the image through a filename: can be png or jpg, and should not be bigger than 1920x1080.
  2491. * This function can only be called by the overlay's renderer process */
  2492. virtual EVROverlayError SetOverlayFromFile( VROverlayHandle_t ulOverlayHandle, const char *pchFilePath ) = 0;
  2493. /** Get the native texture handle/device for an overlay you have created.
  2494. * On windows this handle will be a ID3D11ShaderResourceView with a ID3D11Texture2D bound.
  2495. *
  2496. * The texture will always be sized to match the backing texture you supplied in SetOverlayTexture above.
  2497. *
  2498. * You MUST call ReleaseNativeOverlayHandle() with pNativeTextureHandle once you are done with this texture.
  2499. *
  2500. * pNativeTextureHandle is an OUTPUT, it will be a pointer to a ID3D11ShaderResourceView *.
  2501. * pNativeTextureRef is an INPUT and should be a ID3D11Resource *. The device used by pNativeTextureRef will be used to bind pNativeTextureHandle.
  2502. */
  2503. virtual EVROverlayError GetOverlayTexture( VROverlayHandle_t ulOverlayHandle, void **pNativeTextureHandle, void *pNativeTextureRef, uint32_t *pWidth, uint32_t *pHeight, uint32_t *pNativeFormat, ETextureType *pAPIType, EColorSpace *pColorSpace, VRTextureBounds_t *pTextureBounds ) = 0;
  2504. /** Release the pNativeTextureHandle provided from the GetOverlayTexture call, this allows the system to free the underlying GPU resources for this object,
  2505. * so only do it once you stop rendering this texture.
  2506. */
  2507. virtual EVROverlayError ReleaseNativeOverlayHandle( VROverlayHandle_t ulOverlayHandle, void *pNativeTextureHandle ) = 0;
  2508. /** Get the size of the overlay texture */
  2509. virtual EVROverlayError GetOverlayTextureSize( VROverlayHandle_t ulOverlayHandle, uint32_t *pWidth, uint32_t *pHeight ) = 0;
  2510. // ----------------------------------------------
  2511. // Dashboard Overlay Methods
  2512. // ----------------------------------------------
  2513. /** Creates a dashboard overlay and returns its handle */
  2514. virtual EVROverlayError CreateDashboardOverlay( const char *pchOverlayKey, const char *pchOverlayFriendlyName, VROverlayHandle_t * pMainHandle, VROverlayHandle_t *pThumbnailHandle ) = 0;
  2515. /** Returns true if the dashboard is visible */
  2516. virtual bool IsDashboardVisible() = 0;
  2517. /** returns true if the dashboard is visible and the specified overlay is the active system Overlay */
  2518. virtual bool IsActiveDashboardOverlay( VROverlayHandle_t ulOverlayHandle ) = 0;
  2519. /** Sets the dashboard overlay to only appear when the specified process ID has scene focus */
  2520. virtual EVROverlayError SetDashboardOverlaySceneProcess( VROverlayHandle_t ulOverlayHandle, uint32_t unProcessId ) = 0;
  2521. /** Gets the process ID that this dashboard overlay requires to have scene focus */
  2522. virtual EVROverlayError GetDashboardOverlaySceneProcess( VROverlayHandle_t ulOverlayHandle, uint32_t *punProcessId ) = 0;
  2523. /** Shows the dashboard. */
  2524. virtual void ShowDashboard( const char *pchOverlayToShow ) = 0;
  2525. /** Returns the tracked device that has the laser pointer in the dashboard */
  2526. virtual vr::TrackedDeviceIndex_t GetPrimaryDashboardDevice() = 0;
  2527. // ---------------------------------------------
  2528. // Keyboard methods
  2529. // ---------------------------------------------
  2530. /** Show the virtual keyboard to accept input **/
  2531. virtual EVROverlayError ShowKeyboard( EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, const char *pchDescription, uint32_t unCharMax, const char *pchExistingText, bool bUseMinimalMode, uint64_t uUserValue ) = 0;
  2532. 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;
  2533. /** Get the text that was entered into the text input **/
  2534. virtual uint32_t GetKeyboardText( VR_OUT_STRING() char *pchText, uint32_t cchText ) = 0;
  2535. /** Hide the virtual keyboard **/
  2536. virtual void HideKeyboard() = 0;
  2537. /** Set the position of the keyboard in world space **/
  2538. virtual void SetKeyboardTransformAbsolute( ETrackingUniverseOrigin eTrackingOrigin, const HmdMatrix34_t *pmatTrackingOriginToKeyboardTransform ) = 0;
  2539. /** 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 **/
  2540. virtual void SetKeyboardPositionForOverlay( VROverlayHandle_t ulOverlayHandle, HmdRect2_t avoidRect ) = 0;
  2541. // ---------------------------------------------
  2542. // Overlay input methods
  2543. // ---------------------------------------------
  2544. /** Sets a list of primitives to be used for controller ray intersection
  2545. * typically the size of the underlying UI in pixels (not in world space). */
  2546. virtual EVROverlayError SetOverlayIntersectionMask( VROverlayHandle_t ulOverlayHandle, VROverlayIntersectionMaskPrimitive_t *pMaskPrimitives, uint32_t unNumMaskPrimitives, uint32_t unPrimitiveSize = sizeof( VROverlayIntersectionMaskPrimitive_t ) ) = 0;
  2547. virtual EVROverlayError GetOverlayFlags( VROverlayHandle_t ulOverlayHandle, uint32_t *pFlags ) = 0;
  2548. // ---------------------------------------------
  2549. // Message box methods
  2550. // ---------------------------------------------
  2551. /** Show the message overlay. This will block and return you a result. **/
  2552. virtual VRMessageOverlayResponse ShowMessageOverlay( const char* pchText, const char* pchCaption, const char* pchButton0Text, const char* pchButton1Text = nullptr, const char* pchButton2Text = nullptr, const char* pchButton3Text = nullptr ) = 0;
  2553. /** If the calling process owns the overlay and it's open, this will close it. **/
  2554. virtual void CloseMessageOverlay() = 0;
  2555. };
  2556. static const char * const IVROverlay_Version = "IVROverlay_018";
  2557. } // namespace vr
  2558. // ivrrendermodels.h
  2559. namespace vr
  2560. {
  2561. static const char * const k_pch_Controller_Component_GDC2015 = "gdc2015"; // Canonical coordinate system of the gdc 2015 wired controller, provided for backwards compatibility
  2562. static const char * const k_pch_Controller_Component_Base = "base"; // For controllers with an unambiguous 'base'.
  2563. static const char * const k_pch_Controller_Component_Tip = "tip"; // For controllers with an unambiguous 'tip' (used for 'laser-pointing')
  2564. 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
  2565. static const char * const k_pch_Controller_Component_Status = "status"; // 1:1 aspect ratio status area, with canonical [0,1] uv mapping
  2566. #pragma pack( push, 8 )
  2567. /** Errors that can occur with the VR compositor */
  2568. enum EVRRenderModelError
  2569. {
  2570. VRRenderModelError_None = 0,
  2571. VRRenderModelError_Loading = 100,
  2572. VRRenderModelError_NotSupported = 200,
  2573. VRRenderModelError_InvalidArg = 300,
  2574. VRRenderModelError_InvalidModel = 301,
  2575. VRRenderModelError_NoShapes = 302,
  2576. VRRenderModelError_MultipleShapes = 303,
  2577. VRRenderModelError_TooManyVertices = 304,
  2578. VRRenderModelError_MultipleTextures = 305,
  2579. VRRenderModelError_BufferTooSmall = 306,
  2580. VRRenderModelError_NotEnoughNormals = 307,
  2581. VRRenderModelError_NotEnoughTexCoords = 308,
  2582. VRRenderModelError_InvalidTexture = 400,
  2583. };
  2584. typedef uint32_t VRComponentProperties;
  2585. enum EVRComponentProperty
  2586. {
  2587. VRComponentProperty_IsStatic = (1 << 0),
  2588. VRComponentProperty_IsVisible = (1 << 1),
  2589. VRComponentProperty_IsTouched = (1 << 2),
  2590. VRComponentProperty_IsPressed = (1 << 3),
  2591. VRComponentProperty_IsScrolled = (1 << 4),
  2592. };
  2593. /** Describes state information about a render-model component, including transforms and other dynamic properties */
  2594. struct RenderModel_ComponentState_t
  2595. {
  2596. HmdMatrix34_t mTrackingToComponentRenderModel; // Transform required when drawing the component render model
  2597. HmdMatrix34_t mTrackingToComponentLocal; // Transform available for attaching to a local component coordinate system (-Z out from surface )
  2598. VRComponentProperties uProperties;
  2599. };
  2600. /** A single vertex in a render model */
  2601. struct RenderModel_Vertex_t
  2602. {
  2603. HmdVector3_t vPosition; // position in meters in device space
  2604. HmdVector3_t vNormal;
  2605. float rfTextureCoord[2];
  2606. };
  2607. /** A texture map for use on a render model */
  2608. #if defined(__linux__) || defined(__APPLE__)
  2609. // This structure was originally defined mis-packed on Linux, preserved for
  2610. // compatibility.
  2611. #pragma pack( push, 4 )
  2612. #endif
  2613. struct RenderModel_TextureMap_t
  2614. {
  2615. uint16_t unWidth, unHeight; // width and height of the texture map in pixels
  2616. const uint8_t *rubTextureMapData; // Map texture data. All textures are RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub
  2617. };
  2618. #if defined(__linux__) || defined(__APPLE__)
  2619. #pragma pack( pop )
  2620. #endif
  2621. /** Session unique texture identifier. Rendermodels which share the same texture will have the same id.
  2622. IDs <0 denote the texture is not present */
  2623. typedef int32_t TextureID_t;
  2624. const TextureID_t INVALID_TEXTURE_ID = -1;
  2625. #if defined(__linux__) || defined(__APPLE__)
  2626. // This structure was originally defined mis-packed on Linux, preserved for
  2627. // compatibility.
  2628. #pragma pack( push, 4 )
  2629. #endif
  2630. struct RenderModel_t
  2631. {
  2632. const RenderModel_Vertex_t *rVertexData; // Vertex data for the mesh
  2633. uint32_t unVertexCount; // Number of vertices in the vertex data
  2634. const uint16_t *rIndexData; // Indices into the vertex data for each triangle
  2635. uint32_t unTriangleCount; // Number of triangles in the mesh. Index count is 3 * TriangleCount
  2636. TextureID_t diffuseTextureId; // Session unique texture identifier. Rendermodels which share the same texture will have the same id. <0 == texture not present
  2637. };
  2638. #if defined(__linux__) || defined(__APPLE__)
  2639. #pragma pack( pop )
  2640. #endif
  2641. struct RenderModel_ControllerMode_State_t
  2642. {
  2643. bool bScrollWheelVisible; // is this controller currently set to be in a scroll wheel mode
  2644. };
  2645. #pragma pack( pop )
  2646. class IVRRenderModels
  2647. {
  2648. public:
  2649. /** Loads and returns a render model for use in the application. pchRenderModelName should be a render model name
  2650. * from the Prop_RenderModelName_String property or an absolute path name to a render model on disk.
  2651. *
  2652. * The resulting render model is valid until VR_Shutdown() is called or until FreeRenderModel() is called. When the
  2653. * application is finished with the render model it should call FreeRenderModel() to free the memory associated
  2654. * with the model.
  2655. *
  2656. * The method returns VRRenderModelError_Loading while the render model is still being loaded.
  2657. * The method returns VRRenderModelError_None once loaded successfully, otherwise will return an error. */
  2658. virtual EVRRenderModelError LoadRenderModel_Async( const char *pchRenderModelName, RenderModel_t **ppRenderModel ) = 0;
  2659. /** Frees a previously returned render model
  2660. * It is safe to call this on a null ptr. */
  2661. virtual void FreeRenderModel( RenderModel_t *pRenderModel ) = 0;
  2662. /** Loads and returns a texture for use in the application. */
  2663. virtual EVRRenderModelError LoadTexture_Async( TextureID_t textureId, RenderModel_TextureMap_t **ppTexture ) = 0;
  2664. /** Frees a previously returned texture
  2665. * It is safe to call this on a null ptr. */
  2666. virtual void FreeTexture( RenderModel_TextureMap_t *pTexture ) = 0;
  2667. /** Creates a D3D11 texture and loads data into it. */
  2668. virtual EVRRenderModelError LoadTextureD3D11_Async( TextureID_t textureId, void *pD3D11Device, void **ppD3D11Texture2D ) = 0;
  2669. /** Helper function to copy the bits into an existing texture. */
  2670. virtual EVRRenderModelError LoadIntoTextureD3D11_Async( TextureID_t textureId, void *pDstTexture ) = 0;
  2671. /** Use this to free textures created with LoadTextureD3D11_Async instead of calling Release on them. */
  2672. virtual void FreeTextureD3D11( void *pD3D11Texture2D ) = 0;
  2673. /** Use this to get the names of available render models. Index does not correlate to a tracked device index, but
  2674. * is only used for iterating over all available render models. If the index is out of range, this function will return 0.
  2675. * Otherwise, it will return the size of the buffer required for the name. */
  2676. virtual uint32_t GetRenderModelName( uint32_t unRenderModelIndex, VR_OUT_STRING() char *pchRenderModelName, uint32_t unRenderModelNameLen ) = 0;
  2677. /** Returns the number of available render models. */
  2678. virtual uint32_t GetRenderModelCount() = 0;
  2679. /** Returns the number of components of the specified render model.
  2680. * Components are useful when client application wish to draw, label, or otherwise interact with components of tracked objects.
  2681. * Examples controller components:
  2682. * renderable things such as triggers, buttons
  2683. * non-renderable things which include coordinate systems such as 'tip', 'base', a neutral controller agnostic hand-pose
  2684. * If all controller components are enumerated and rendered, it will be equivalent to drawing the traditional render model
  2685. * Returns 0 if components not supported, >0 otherwise */
  2686. virtual uint32_t GetComponentCount( const char *pchRenderModelName ) = 0;
  2687. /** Use this to get the names of available components. Index does not correlate to a tracked device index, but
  2688. * is only used for iterating over all available components. If the index is out of range, this function will return 0.
  2689. * Otherwise, it will return the size of the buffer required for the name. */
  2690. virtual uint32_t GetComponentName( const char *pchRenderModelName, uint32_t unComponentIndex, VR_OUT_STRING( ) char *pchComponentName, uint32_t unComponentNameLen ) = 0;
  2691. /** Get the button mask for all buttons associated with this component
  2692. * If no buttons (or axes) are associated with this component, return 0
  2693. * Note: multiple components may be associated with the same button. Ex: two grip buttons on a single controller.
  2694. * Note: A single component may be associated with multiple buttons. Ex: A trackpad which also provides "D-pad" functionality */
  2695. virtual uint64_t GetComponentButtonMask( const char *pchRenderModelName, const char *pchComponentName ) = 0;
  2696. /** Use this to get the render model name for the specified rendermode/component combination, to be passed to LoadRenderModel.
  2697. * If the component name is out of range, this function will return 0.
  2698. * Otherwise, it will return the size of the buffer required for the name. */
  2699. virtual uint32_t GetComponentRenderModelName( const char *pchRenderModelName, const char *pchComponentName, VR_OUT_STRING( ) char *pchComponentRenderModelName, uint32_t unComponentRenderModelNameLen ) = 0;
  2700. /** Use this to query information about the component, as a function of the controller state.
  2701. *
  2702. * For dynamic controller components (ex: trigger) values will reflect component motions
  2703. * For static components this will return a consistent value independent of the VRControllerState_t
  2704. *
  2705. * If the pchRenderModelName or pchComponentName is invalid, this will return false (and transforms will be set to identity).
  2706. * Otherwise, return true
  2707. * Note: For dynamic objects, visibility may be dynamic. (I.e., true/false will be returned based on controller state and controller mode state ) */
  2708. 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;
  2709. /** Returns true if the render model has a component with the specified name */
  2710. virtual bool RenderModelHasComponent( const char *pchRenderModelName, const char *pchComponentName ) = 0;
  2711. /** Returns the URL of the thumbnail image for this rendermodel */
  2712. virtual uint32_t GetRenderModelThumbnailURL( const char *pchRenderModelName, VR_OUT_STRING() char *pchThumbnailURL, uint32_t unThumbnailURLLen, vr::EVRRenderModelError *peError ) = 0;
  2713. /** 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
  2714. * 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
  2715. * model. */
  2716. virtual uint32_t GetRenderModelOriginalPath( const char *pchRenderModelName, VR_OUT_STRING() char *pchOriginalPath, uint32_t unOriginalPathLen, vr::EVRRenderModelError *peError ) = 0;
  2717. /** Returns a string for a render model error */
  2718. virtual const char *GetRenderModelErrorNameFromEnum( vr::EVRRenderModelError error ) = 0;
  2719. };
  2720. static const char * const IVRRenderModels_Version = "IVRRenderModels_005";
  2721. }
  2722. // ivrextendeddisplay.h
  2723. namespace vr
  2724. {
  2725. /** NOTE: Use of this interface is not recommended in production applications. It will not work for displays which use
  2726. * direct-to-display mode. Creating our own window is also incompatible with the VR compositor and is not available when the compositor is running. */
  2727. class IVRExtendedDisplay
  2728. {
  2729. public:
  2730. /** Size and position that the window needs to be on the VR display. */
  2731. virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  2732. /** Gets the viewport in the frame buffer to draw the output of the distortion into */
  2733. virtual void GetEyeOutputViewport( EVREye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  2734. /** [D3D10/11 Only]
  2735. * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs
  2736. * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
  2737. */
  2738. virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex ) = 0;
  2739. };
  2740. static const char * const IVRExtendedDisplay_Version = "IVRExtendedDisplay_001";
  2741. }
  2742. // ivrtrackedcamera.h
  2743. namespace vr
  2744. {
  2745. class IVRTrackedCamera
  2746. {
  2747. public:
  2748. /** Returns a string for an error */
  2749. virtual const char *GetCameraErrorNameFromEnum( vr::EVRTrackedCameraError eCameraError ) = 0;
  2750. /** For convenience, same as tracked property request Prop_HasCamera_Bool */
  2751. virtual vr::EVRTrackedCameraError HasCamera( vr::TrackedDeviceIndex_t nDeviceIndex, bool *pHasCamera ) = 0;
  2752. /** Gets size of the image frame. */
  2753. virtual vr::EVRTrackedCameraError GetCameraFrameSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, uint32_t *pnWidth, uint32_t *pnHeight, uint32_t *pnFrameBufferSize ) = 0;
  2754. virtual vr::EVRTrackedCameraError GetCameraIntrinsics( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::HmdVector2_t *pFocalLength, vr::HmdVector2_t *pCenter ) = 0;
  2755. virtual vr::EVRTrackedCameraError GetCameraProjection( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, vr::HmdMatrix44_t *pProjection ) = 0;
  2756. /** 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.
  2757. * 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.
  2758. * The camera should be considered a global resource accessible for shared consumption but not exclusive to any caller.
  2759. * The camera may go inactive due to lack of active consumers or headset idleness. */
  2760. virtual vr::EVRTrackedCameraError AcquireVideoStreamingService( vr::TrackedDeviceIndex_t nDeviceIndex, vr::TrackedCameraHandle_t *pHandle ) = 0;
  2761. virtual vr::EVRTrackedCameraError ReleaseVideoStreamingService( vr::TrackedCameraHandle_t hTrackedCamera ) = 0;
  2762. /** Copies the image frame into a caller's provided buffer. The image data is currently provided as RGBA data, 4 bytes per pixel.
  2763. * A caller can provide null for the framebuffer or frameheader if not desired. Requesting the frame header first, followed by the frame buffer allows
  2764. * the caller to determine if the frame as advanced per the frame header sequence.
  2765. * If there is no frame available yet, due to initial camera spinup or re-activation, the error will be VRTrackedCameraError_NoFrameAvailable.
  2766. * Ideally a caller should be polling at ~16ms intervals */
  2767. virtual vr::EVRTrackedCameraError GetVideoStreamFrameBuffer( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pFrameBuffer, uint32_t nFrameBufferSize, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0;
  2768. /** Gets size of the image frame. */
  2769. virtual vr::EVRTrackedCameraError GetVideoStreamTextureSize( vr::TrackedDeviceIndex_t nDeviceIndex, vr::EVRTrackedCameraFrameType eFrameType, vr::VRTextureBounds_t *pTextureBounds, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  2770. /** Access a shared D3D11 texture for the specified tracked camera stream.
  2771. * The camera frame type VRTrackedCameraFrameType_Undistorted is not supported directly as a shared texture. It is an interior subregion of the shared texture VRTrackedCameraFrameType_MaximumUndistorted.
  2772. * Instead, use GetVideoStreamTextureSize() with VRTrackedCameraFrameType_Undistorted to determine the proper interior subregion bounds along with GetVideoStreamTextureD3D11() with
  2773. * VRTrackedCameraFrameType_MaximumUndistorted to provide the texture. The VRTrackedCameraFrameType_MaximumUndistorted will yield an image where the invalid regions are decoded
  2774. * by the alpha channel having a zero component. The valid regions all have a non-zero alpha component. The subregion as described by VRTrackedCameraFrameType_Undistorted
  2775. * guarantees a rectangle where all pixels are valid. */
  2776. virtual vr::EVRTrackedCameraError GetVideoStreamTextureD3D11( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, void *pD3D11DeviceOrResource, void **ppD3D11ShaderResourceView, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0;
  2777. /** Access a shared GL texture for the specified tracked camera stream */
  2778. virtual vr::EVRTrackedCameraError GetVideoStreamTextureGL( vr::TrackedCameraHandle_t hTrackedCamera, vr::EVRTrackedCameraFrameType eFrameType, vr::glUInt_t *pglTextureId, vr::CameraVideoStreamFrameHeader_t *pFrameHeader, uint32_t nFrameHeaderSize ) = 0;
  2779. virtual vr::EVRTrackedCameraError ReleaseVideoStreamTextureGL( vr::TrackedCameraHandle_t hTrackedCamera, vr::glUInt_t glTextureId ) = 0;
  2780. };
  2781. static const char * const IVRTrackedCamera_Version = "IVRTrackedCamera_003";
  2782. } // namespace vr
  2783. // ivrscreenshots.h
  2784. namespace vr
  2785. {
  2786. /** Errors that can occur with the VR compositor */
  2787. enum EVRScreenshotError
  2788. {
  2789. VRScreenshotError_None = 0,
  2790. VRScreenshotError_RequestFailed = 1,
  2791. VRScreenshotError_IncompatibleVersion = 100,
  2792. VRScreenshotError_NotFound = 101,
  2793. VRScreenshotError_BufferTooSmall = 102,
  2794. VRScreenshotError_ScreenshotAlreadyInProgress = 108,
  2795. };
  2796. /** Allows the application to generate screenshots */
  2797. class IVRScreenshots
  2798. {
  2799. public:
  2800. /** Request a screenshot of the requested type.
  2801. * A request of the VRScreenshotType_Stereo type will always
  2802. * work. Other types will depend on the underlying application
  2803. * support.
  2804. * The first file name is for the preview image and should be a
  2805. * regular screenshot (ideally from the left eye). The second
  2806. * is the VR screenshot in the correct format. They should be
  2807. * in the same aspect ratio. Formats per type:
  2808. * VRScreenshotType_Mono: the VR filename is ignored (can be
  2809. * nullptr), this is a normal flat single shot.
  2810. * VRScreenshotType_Stereo: The VR image should be a
  2811. * side-by-side with the left eye image on the left.
  2812. * VRScreenshotType_Cubemap: The VR image should be six square
  2813. * images composited horizontally.
  2814. * VRScreenshotType_StereoPanorama: above/below with left eye
  2815. * panorama being the above image. Image is typically square
  2816. * with the panorama being 2x horizontal.
  2817. *
  2818. * Note that the VR dashboard will call this function when
  2819. * the user presses the screenshot binding (currently System
  2820. * Button + Trigger). If Steam is running, the destination
  2821. * file names will be in %TEMP% and will be copied into
  2822. * Steam's screenshot library for the running application
  2823. * once SubmitScreenshot() is called.
  2824. * If Steam is not running, the paths will be in the user's
  2825. * documents folder under Documents\SteamVR\Screenshots.
  2826. * Other VR applications can call this to initiate a
  2827. * screenshot outside of user control.
  2828. * The destination file names do not need an extension,
  2829. * will be replaced with the correct one for the format
  2830. * which is currently .png. */
  2831. virtual vr::EVRScreenshotError RequestScreenshot( vr::ScreenshotHandle_t *pOutScreenshotHandle, vr::EVRScreenshotType type, const char *pchPreviewFilename, const char *pchVRFilename ) = 0;
  2832. /** Called by the running VR application to indicate that it
  2833. * wishes to be in charge of screenshots. If the
  2834. * application does not call this, the Compositor will only
  2835. * support VRScreenshotType_Stereo screenshots that will be
  2836. * captured without notification to the running app.
  2837. * Once hooked your application will receive a
  2838. * VREvent_RequestScreenshot event when the user presses the
  2839. * buttons to take a screenshot. */
  2840. virtual vr::EVRScreenshotError HookScreenshot( VR_ARRAY_COUNT( numTypes ) const vr::EVRScreenshotType *pSupportedTypes, int numTypes ) = 0;
  2841. /** When your application receives a
  2842. * VREvent_RequestScreenshot event, call these functions to get
  2843. * the details of the screenshot request. */
  2844. virtual vr::EVRScreenshotType GetScreenshotPropertyType( vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotError *pError ) = 0;
  2845. /** Get the filename for the preview or vr image (see
  2846. * vr::EScreenshotPropertyFilenames). The return value is
  2847. * the size of the string. */
  2848. virtual uint32_t GetScreenshotPropertyFilename( vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotPropertyFilenames filenameType, VR_OUT_STRING() char *pchFilename, uint32_t cchFilename, vr::EVRScreenshotError *pError ) = 0;
  2849. /** Call this if the application is taking the screen shot
  2850. * will take more than a few ms processing. This will result
  2851. * in an overlay being presented that shows a completion
  2852. * bar. */
  2853. virtual vr::EVRScreenshotError UpdateScreenshotProgress( vr::ScreenshotHandle_t screenshotHandle, float flProgress ) = 0;
  2854. /** Tells the compositor to take an internal screenshot of
  2855. * type VRScreenshotType_Stereo. It will take the current
  2856. * submitted scene textures of the running application and
  2857. * write them into the preview image and a side-by-side file
  2858. * for the VR image.
  2859. * This is similar to request screenshot, but doesn't ever
  2860. * talk to the application, just takes the shot and submits. */
  2861. virtual vr::EVRScreenshotError TakeStereoScreenshot( vr::ScreenshotHandle_t *pOutScreenshotHandle, const char *pchPreviewFilename, const char *pchVRFilename ) = 0;
  2862. /** Submit the completed screenshot. If Steam is running
  2863. * this will call into the Steam client and upload the
  2864. * screenshot to the screenshots section of the library for
  2865. * the running application. If Steam is not running, this
  2866. * function will display a notification to the user that the
  2867. * screenshot was taken. The paths should be full paths with
  2868. * extensions.
  2869. * File paths should be absolute including extensions.
  2870. * screenshotHandle can be k_unScreenshotHandleInvalid if this
  2871. * was a new shot taking by the app to be saved and not
  2872. * initiated by a user (achievement earned or something) */
  2873. virtual vr::EVRScreenshotError SubmitScreenshot( vr::ScreenshotHandle_t screenshotHandle, vr::EVRScreenshotType type, const char *pchSourcePreviewFilename, const char *pchSourceVRFilename ) = 0;
  2874. };
  2875. static const char * const IVRScreenshots_Version = "IVRScreenshots_001";
  2876. } // namespace vr
  2877. // ivrresources.h
  2878. namespace vr
  2879. {
  2880. class IVRResources
  2881. {
  2882. public:
  2883. // ------------------------------------
  2884. // Shared Resource Methods
  2885. // ------------------------------------
  2886. /** Loads the specified resource into the provided buffer if large enough.
  2887. * Returns the size in bytes of the buffer required to hold the specified resource. */
  2888. virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0;
  2889. /** Provides the full path to the specified resource. Resource names can include named directories for
  2890. * drivers and other things, and this resolves all of those and returns the actual physical path.
  2891. * pchResourceTypeDirectory is the subdirectory of resources to look in. */
  2892. virtual uint32_t GetResourceFullPath( const char *pchResourceName, const char *pchResourceTypeDirectory, VR_OUT_STRING() char *pchPathBuffer, uint32_t unBufferLen ) = 0;
  2893. };
  2894. static const char * const IVRResources_Version = "IVRResources_001";
  2895. }
  2896. // ivrdrivermanager.h
  2897. namespace vr
  2898. {
  2899. class IVRDriverManager
  2900. {
  2901. public:
  2902. virtual uint32_t GetDriverCount() const = 0;
  2903. /** Returns the length of the number of bytes necessary to hold this string including the trailing null. */
  2904. virtual uint32_t GetDriverName( vr::DriverId_t nDriver, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize ) = 0;
  2905. };
  2906. static const char * const IVRDriverManager_Version = "IVRDriverManager_001";
  2907. } // namespace vr
  2908. // End
  2909. #endif // _OPENVR_API
  2910. namespace vr
  2911. {
  2912. /** Finds the active installation of the VR API and initializes it. The provided path must be absolute
  2913. * or relative to the current working directory. These are the local install versions of the equivalent
  2914. * functions in steamvr.h and will work without a local Steam install.
  2915. *
  2916. * This path is to the "root" of the VR API install. That's the directory with
  2917. * the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
  2918. *
  2919. * pStartupInfo is reserved for future use.
  2920. */
  2921. inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo = nullptr );
  2922. /** unloads vrclient.dll. Any interface pointers from the interface are
  2923. * invalid after this point */
  2924. inline void VR_Shutdown();
  2925. /** Returns true if there is an HMD attached. This check is as lightweight as possible and
  2926. * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants
  2927. * to know if initializing VR is a possibility but isn't ready to take that step yet.
  2928. */
  2929. VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent();
  2930. /** Returns true if the OpenVR runtime is installed. */
  2931. VR_INTERFACE bool VR_CALLTYPE VR_IsRuntimeInstalled();
  2932. /** Returns where the OpenVR runtime is installed. */
  2933. VR_INTERFACE const char *VR_CALLTYPE VR_RuntimePath();
  2934. /** Returns the name of the enum value for an EVRInitError. This function may be called outside of VR_Init()/VR_Shutdown(). */
  2935. VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsSymbol( EVRInitError error );
  2936. /** Returns an English string for an EVRInitError. Applications should call VR_GetVRInitErrorAsSymbol instead and
  2937. * use that as a key to look up their own localized error message. This function may be called outside of VR_Init()/VR_Shutdown(). */
  2938. VR_INTERFACE const char *VR_CALLTYPE VR_GetVRInitErrorAsEnglishDescription( EVRInitError error );
  2939. /** Returns the interface of the specified version. This method must be called after VR_Init. The
  2940. * pointer returned is valid until VR_Shutdown is called.
  2941. */
  2942. VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError );
  2943. /** Returns whether the interface of the specified version exists.
  2944. */
  2945. VR_INTERFACE bool VR_CALLTYPE VR_IsInterfaceVersionValid( const char *pchInterfaceVersion );
  2946. /** Returns a token that represents whether the VR interface handles need to be reloaded */
  2947. VR_INTERFACE uint32_t VR_CALLTYPE VR_GetInitToken();
  2948. // These typedefs allow old enum names from SDK 0.9.11 to be used in applications.
  2949. // They will go away in the future.
  2950. typedef EVRInitError HmdError;
  2951. typedef EVREye Hmd_Eye;
  2952. typedef EColorSpace ColorSpace;
  2953. typedef ETrackingResult HmdTrackingResult;
  2954. typedef ETrackedDeviceClass TrackedDeviceClass;
  2955. typedef ETrackingUniverseOrigin TrackingUniverseOrigin;
  2956. typedef ETrackedDeviceProperty TrackedDeviceProperty;
  2957. typedef ETrackedPropertyError TrackedPropertyError;
  2958. typedef EVRSubmitFlags VRSubmitFlags_t;
  2959. typedef EVRState VRState_t;
  2960. typedef ECollisionBoundsStyle CollisionBoundsStyle_t;
  2961. typedef EVROverlayError VROverlayError;
  2962. typedef EVRFirmwareError VRFirmwareError;
  2963. typedef EVRCompositorError VRCompositorError;
  2964. typedef EVRScreenshotError VRScreenshotsError;
  2965. inline uint32_t &VRToken()
  2966. {
  2967. static uint32_t token;
  2968. return token;
  2969. }
  2970. class COpenVRContext
  2971. {
  2972. public:
  2973. COpenVRContext() { Clear(); }
  2974. void Clear();
  2975. inline void CheckClear()
  2976. {
  2977. if ( VRToken() != VR_GetInitToken() )
  2978. {
  2979. Clear();
  2980. VRToken() = VR_GetInitToken();
  2981. }
  2982. }
  2983. IVRSystem *VRSystem()
  2984. {
  2985. CheckClear();
  2986. if ( m_pVRSystem == nullptr )
  2987. {
  2988. EVRInitError eError;
  2989. m_pVRSystem = ( IVRSystem * )VR_GetGenericInterface( IVRSystem_Version, &eError );
  2990. }
  2991. return m_pVRSystem;
  2992. }
  2993. IVRChaperone *VRChaperone()
  2994. {
  2995. CheckClear();
  2996. if ( m_pVRChaperone == nullptr )
  2997. {
  2998. EVRInitError eError;
  2999. m_pVRChaperone = ( IVRChaperone * )VR_GetGenericInterface( IVRChaperone_Version, &eError );
  3000. }
  3001. return m_pVRChaperone;
  3002. }
  3003. IVRChaperoneSetup *VRChaperoneSetup()
  3004. {
  3005. CheckClear();
  3006. if ( m_pVRChaperoneSetup == nullptr )
  3007. {
  3008. EVRInitError eError;
  3009. m_pVRChaperoneSetup = ( IVRChaperoneSetup * )VR_GetGenericInterface( IVRChaperoneSetup_Version, &eError );
  3010. }
  3011. return m_pVRChaperoneSetup;
  3012. }
  3013. IVRCompositor *VRCompositor()
  3014. {
  3015. CheckClear();
  3016. if ( m_pVRCompositor == nullptr )
  3017. {
  3018. EVRInitError eError;
  3019. m_pVRCompositor = ( IVRCompositor * )VR_GetGenericInterface( IVRCompositor_Version, &eError );
  3020. }
  3021. return m_pVRCompositor;
  3022. }
  3023. IVROverlay *VROverlay()
  3024. {
  3025. CheckClear();
  3026. if ( m_pVROverlay == nullptr )
  3027. {
  3028. EVRInitError eError;
  3029. m_pVROverlay = ( IVROverlay * )VR_GetGenericInterface( IVROverlay_Version, &eError );
  3030. }
  3031. return m_pVROverlay;
  3032. }
  3033. IVRResources *VRResources()
  3034. {
  3035. CheckClear();
  3036. if ( m_pVRResources == nullptr )
  3037. {
  3038. EVRInitError eError;
  3039. m_pVRResources = (IVRResources *)VR_GetGenericInterface( IVRResources_Version, &eError );
  3040. }
  3041. return m_pVRResources;
  3042. }
  3043. IVRScreenshots *VRScreenshots()
  3044. {
  3045. CheckClear();
  3046. if ( m_pVRScreenshots == nullptr )
  3047. {
  3048. EVRInitError eError;
  3049. m_pVRScreenshots = ( IVRScreenshots * )VR_GetGenericInterface( IVRScreenshots_Version, &eError );
  3050. }
  3051. return m_pVRScreenshots;
  3052. }
  3053. IVRRenderModels *VRRenderModels()
  3054. {
  3055. CheckClear();
  3056. if ( m_pVRRenderModels == nullptr )
  3057. {
  3058. EVRInitError eError;
  3059. m_pVRRenderModels = ( IVRRenderModels * )VR_GetGenericInterface( IVRRenderModels_Version, &eError );
  3060. }
  3061. return m_pVRRenderModels;
  3062. }
  3063. IVRExtendedDisplay *VRExtendedDisplay()
  3064. {
  3065. CheckClear();
  3066. if ( m_pVRExtendedDisplay == nullptr )
  3067. {
  3068. EVRInitError eError;
  3069. m_pVRExtendedDisplay = ( IVRExtendedDisplay * )VR_GetGenericInterface( IVRExtendedDisplay_Version, &eError );
  3070. }
  3071. return m_pVRExtendedDisplay;
  3072. }
  3073. IVRSettings *VRSettings()
  3074. {
  3075. CheckClear();
  3076. if ( m_pVRSettings == nullptr )
  3077. {
  3078. EVRInitError eError;
  3079. m_pVRSettings = ( IVRSettings * )VR_GetGenericInterface( IVRSettings_Version, &eError );
  3080. }
  3081. return m_pVRSettings;
  3082. }
  3083. IVRApplications *VRApplications()
  3084. {
  3085. CheckClear();
  3086. if ( m_pVRApplications == nullptr )
  3087. {
  3088. EVRInitError eError;
  3089. m_pVRApplications = ( IVRApplications * )VR_GetGenericInterface( IVRApplications_Version, &eError );
  3090. }
  3091. return m_pVRApplications;
  3092. }
  3093. IVRTrackedCamera *VRTrackedCamera()
  3094. {
  3095. CheckClear();
  3096. if ( m_pVRTrackedCamera == nullptr )
  3097. {
  3098. EVRInitError eError;
  3099. m_pVRTrackedCamera = ( IVRTrackedCamera * )VR_GetGenericInterface( IVRTrackedCamera_Version, &eError );
  3100. }
  3101. return m_pVRTrackedCamera;
  3102. }
  3103. IVRDriverManager *VRDriverManager()
  3104. {
  3105. CheckClear();
  3106. if ( !m_pVRDriverManager )
  3107. {
  3108. EVRInitError eError;
  3109. m_pVRDriverManager = ( IVRDriverManager * )VR_GetGenericInterface( IVRDriverManager_Version, &eError );
  3110. }
  3111. return m_pVRDriverManager;
  3112. }
  3113. private:
  3114. IVRSystem *m_pVRSystem;
  3115. IVRChaperone *m_pVRChaperone;
  3116. IVRChaperoneSetup *m_pVRChaperoneSetup;
  3117. IVRCompositor *m_pVRCompositor;
  3118. IVROverlay *m_pVROverlay;
  3119. IVRResources *m_pVRResources;
  3120. IVRRenderModels *m_pVRRenderModels;
  3121. IVRExtendedDisplay *m_pVRExtendedDisplay;
  3122. IVRSettings *m_pVRSettings;
  3123. IVRApplications *m_pVRApplications;
  3124. IVRTrackedCamera *m_pVRTrackedCamera;
  3125. IVRScreenshots *m_pVRScreenshots;
  3126. IVRDriverManager *m_pVRDriverManager;
  3127. };
  3128. inline COpenVRContext &OpenVRInternal_ModuleContext()
  3129. {
  3130. static void *ctx[ sizeof( COpenVRContext ) / sizeof( void * ) ];
  3131. return *( COpenVRContext * )ctx; // bypass zero-init constructor
  3132. }
  3133. inline IVRSystem *VR_CALLTYPE VRSystem() { return OpenVRInternal_ModuleContext().VRSystem(); }
  3134. inline IVRChaperone *VR_CALLTYPE VRChaperone() { return OpenVRInternal_ModuleContext().VRChaperone(); }
  3135. inline IVRChaperoneSetup *VR_CALLTYPE VRChaperoneSetup() { return OpenVRInternal_ModuleContext().VRChaperoneSetup(); }
  3136. inline IVRCompositor *VR_CALLTYPE VRCompositor() { return OpenVRInternal_ModuleContext().VRCompositor(); }
  3137. inline IVROverlay *VR_CALLTYPE VROverlay() { return OpenVRInternal_ModuleContext().VROverlay(); }
  3138. inline IVRScreenshots *VR_CALLTYPE VRScreenshots() { return OpenVRInternal_ModuleContext().VRScreenshots(); }
  3139. inline IVRRenderModels *VR_CALLTYPE VRRenderModels() { return OpenVRInternal_ModuleContext().VRRenderModels(); }
  3140. inline IVRApplications *VR_CALLTYPE VRApplications() { return OpenVRInternal_ModuleContext().VRApplications(); }
  3141. inline IVRSettings *VR_CALLTYPE VRSettings() { return OpenVRInternal_ModuleContext().VRSettings(); }
  3142. inline IVRResources *VR_CALLTYPE VRResources() { return OpenVRInternal_ModuleContext().VRResources(); }
  3143. inline IVRExtendedDisplay *VR_CALLTYPE VRExtendedDisplay() { return OpenVRInternal_ModuleContext().VRExtendedDisplay(); }
  3144. inline IVRTrackedCamera *VR_CALLTYPE VRTrackedCamera() { return OpenVRInternal_ModuleContext().VRTrackedCamera(); }
  3145. inline IVRDriverManager *VR_CALLTYPE VRDriverManager() { return OpenVRInternal_ModuleContext().VRDriverManager(); }
  3146. inline void COpenVRContext::Clear()
  3147. {
  3148. m_pVRSystem = nullptr;
  3149. m_pVRChaperone = nullptr;
  3150. m_pVRChaperoneSetup = nullptr;
  3151. m_pVRCompositor = nullptr;
  3152. m_pVROverlay = nullptr;
  3153. m_pVRRenderModels = nullptr;
  3154. m_pVRExtendedDisplay = nullptr;
  3155. m_pVRSettings = nullptr;
  3156. m_pVRApplications = nullptr;
  3157. m_pVRTrackedCamera = nullptr;
  3158. m_pVRResources = nullptr;
  3159. m_pVRScreenshots = nullptr;
  3160. m_pVRDriverManager = nullptr;
  3161. }
  3162. VR_INTERFACE uint32_t VR_CALLTYPE VR_InitInternal2( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo );
  3163. VR_INTERFACE void VR_CALLTYPE VR_ShutdownInternal();
  3164. /** Finds the active installation of vrclient.dll and initializes it */
  3165. inline IVRSystem *VR_Init( EVRInitError *peError, EVRApplicationType eApplicationType, const char *pStartupInfo )
  3166. {
  3167. IVRSystem *pVRSystem = nullptr;
  3168. EVRInitError eError;
  3169. VRToken() = VR_InitInternal2( &eError, eApplicationType, pStartupInfo );
  3170. COpenVRContext &ctx = OpenVRInternal_ModuleContext();
  3171. ctx.Clear();
  3172. if ( eError == VRInitError_None )
  3173. {
  3174. if ( VR_IsInterfaceVersionValid( IVRSystem_Version ) )
  3175. {
  3176. pVRSystem = VRSystem();
  3177. }
  3178. else
  3179. {
  3180. VR_ShutdownInternal();
  3181. eError = VRInitError_Init_InterfaceNotFound;
  3182. }
  3183. }
  3184. if ( peError )
  3185. *peError = eError;
  3186. return pVRSystem;
  3187. }
  3188. /** unloads vrclient.dll. Any interface pointers from the interface are
  3189. * invalid after this point */
  3190. inline void VR_Shutdown()
  3191. {
  3192. VR_ShutdownInternal();
  3193. }
  3194. }