1
0

openvr_mingw.hpp 217 KB

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