Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1094 lines
44 KiB

  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. namespace vr
  10. {
  11. #if defined(__linux__) || defined(__APPLE__)
  12. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  13. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  14. // The 64-bit version of gcc has the alignment requirement for these types set to
  15. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  16. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  17. #pragma pack( push, 4 )
  18. #else
  19. #pragma pack( push, 8 )
  20. #endif
  21. // right-handed system
  22. // +y is up
  23. // +x is to the right
  24. // -z is going away from you
  25. // Distance unit is meters
  26. struct HmdMatrix34_t
  27. {
  28. float m[3][4];
  29. };
  30. struct HmdMatrix44_t
  31. {
  32. float m[4][4];
  33. };
  34. struct HmdVector3_t
  35. {
  36. float v[3];
  37. };
  38. struct HmdVector3d_t
  39. {
  40. double v[3];
  41. };
  42. struct HmdVector2_t
  43. {
  44. float v[2];
  45. };
  46. struct HmdQuaternion_t
  47. {
  48. double w, x, y, z;
  49. };
  50. struct HmdQuad_t
  51. {
  52. HmdVector3_t vCorners[ 4 ];
  53. };
  54. /** Used to return the post-distortion UVs for each color channel.
  55. * UVs range from 0 to 1 with 0,0 in the upper left corner of the
  56. * source render target. The 0,0 to 1,1 range covers a single eye. */
  57. struct DistortionCoordinates_t
  58. {
  59. float rfRed[2];
  60. float rfGreen[2];
  61. float rfBlue[2];
  62. };
  63. enum Hmd_Eye
  64. {
  65. Eye_Left = 0,
  66. Eye_Right = 1
  67. };
  68. enum GraphicsAPIConvention
  69. {
  70. API_DirectX = 0, // Normalized Z goes from 0 at the viewer to 1 at the far clip plane
  71. API_OpenGL = 1, // Normalized Z goes from 1 at the viewer to -1 at the far clip plane
  72. };
  73. enum HmdTrackingResult
  74. {
  75. TrackingResult_Uninitialized = 1,
  76. TrackingResult_Calibrating_InProgress = 100,
  77. TrackingResult_Calibrating_OutOfRange = 101,
  78. TrackingResult_Running_OK = 200,
  79. TrackingResult_Running_OutOfRange = 201,
  80. };
  81. static const uint32_t k_unTrackingStringSize = 32;
  82. static const uint32_t k_unMaxTrackedDeviceCount = 16;
  83. static const uint32_t k_unTrackedDeviceIndex_Hmd = 0;
  84. /** Describes what kind of object is being tracked at a given ID */
  85. enum TrackedDeviceClass
  86. {
  87. TrackedDeviceClass_Invalid = 0, // the ID was not valid.
  88. TrackedDeviceClass_HMD = 1, // Head-Mounted Displays
  89. TrackedDeviceClass_Controller = 2, // Tracked controllers
  90. TrackedDeviceClass_TrackingReference = 4, // Camera and base stations that serve as tracking reference points
  91. TrackedDeviceClass_Other = 1000,
  92. };
  93. /** describes a single pose for a tracked object */
  94. struct TrackedDevicePose_t
  95. {
  96. HmdMatrix34_t mDeviceToAbsoluteTracking;
  97. HmdVector3_t vVelocity; // velocity in tracker space in m/s
  98. HmdVector3_t vAngularVelocity; // angular velocity in radians/s (?)
  99. HmdTrackingResult eTrackingResult;
  100. bool bPoseIsValid;
  101. // This indicates that there is a device connected for this spot in the pose array.
  102. // It could go from true to false if the user unplugs the device.
  103. bool bDeviceIsConnected;
  104. };
  105. /** Identifies which style of tracking origin the application wants to use
  106. * for the poses it is requesting */
  107. enum TrackingUniverseOrigin
  108. {
  109. TrackingUniverseSeated = 0, // Poses are provided relative to the seated zero pose
  110. TrackingUniverseStanding = 1, // Poses are provided relative to the safe bounds configured by the user
  111. TrackingUniverseRawAndUncalibrated = 2, // Poses are provided in the coordinate system defined by the driver. You probably don't want this one.
  112. };
  113. /** Each entry in this enum represents a property that can be retrieved about a
  114. * tracked device. Many fields are only valid for one TrackedDeviceClass. */
  115. enum TrackedDeviceProperty
  116. {
  117. // general properties that apply to all device classes
  118. Prop_TrackingSystemName_String = 1000,
  119. Prop_ModelNumber_String = 1001,
  120. Prop_SerialNumber_String = 1002,
  121. Prop_RenderModelName_String = 1003,
  122. Prop_WillDriftInYaw_Bool = 1004,
  123. Prop_ManufacturerName_String = 1005,
  124. Prop_TrackingFirmwareVersion_String = 1006,
  125. Prop_HardwareRevision_String = 1007,
  126. // Properties that are unique to TrackedDeviceClass_HMD
  127. Prop_ReportsTimeSinceVSync_Bool = 2000,
  128. Prop_SecondsFromVsyncToPhotons_Float = 2001,
  129. Prop_DisplayFrequency_Float = 2002,
  130. Prop_UserIpdMeters_Float = 2003,
  131. Prop_CurrentUniverseId_Uint64 = 2004,
  132. Prop_PreviousUniverseId_Uint64 = 2005,
  133. Prop_DisplayFirmwareVersion_String = 2006,
  134. // Properties that are unique to TrackedDeviceClass_Controller
  135. Prop_AttachedDeviceId_String = 3000,
  136. Prop_SupportedButtons_Uint64 = 3001,
  137. Prop_Axis0Type_Int32 = 3002, // Return value is of type EVRControllerAxisType
  138. Prop_Axis1Type_Int32 = 3003, // Return value is of type EVRControllerAxisType
  139. Prop_Axis2Type_Int32 = 3004, // Return value is of type EVRControllerAxisType
  140. Prop_Axis3Type_Int32 = 3005, // Return value is of type EVRControllerAxisType
  141. Prop_Axis4Type_Int32 = 3006, // Return value is of type EVRControllerAxisType
  142. // Properties that are unique to TrackedDeviceClass_TrackingReference
  143. Prop_FieldOfViewLeftDegrees_Float = 4000,
  144. Prop_FieldOfViewRightDegrees_Float = 4001,
  145. Prop_FieldOfViewTopDegrees_Float = 4002,
  146. Prop_FieldOfViewBottomDegrees_Float = 4003,
  147. Prop_TrackingRangeMinimumMeters_Float = 4004,
  148. Prop_TrackingRangeMaximumMeters_Float = 4005,
  149. };
  150. /** Used to pass device IDs to API calls */
  151. typedef uint32_t TrackedDeviceIndex_t;
  152. static const uint32_t k_unTrackedDeviceIndexInvalid = 0xFFFFFFFF;
  153. /** No string property will ever be longer than this length */
  154. static const uint32_t k_unMaxPropertyStringSize = 32 * 1024;
  155. /** Used to return errors that occur when reading properties. */
  156. enum TrackedPropertyError
  157. {
  158. TrackedProp_Success = 0,
  159. TrackedProp_WrongDataType = 1,
  160. TrackedProp_WrongDeviceClass = 2,
  161. TrackedProp_BufferTooSmall = 3,
  162. TrackedProp_UnknownProperty = 4,
  163. TrackedProp_InvalidDevice = 5,
  164. TrackedProp_CouldNotContactServer = 6,
  165. TrackedProp_ValueNotProvidedByDevice = 7,
  166. TrackedProp_StringExceedsMaximumLength = 8,
  167. };
  168. /** a single vertex in a render model */
  169. struct RenderModel_Vertex_t
  170. {
  171. HmdVector3_t vPosition; // position in meters in device space
  172. HmdVector3_t vNormal;
  173. float rfTextureCoord[ 2 ];
  174. };
  175. /** A texture map for use on a render model */
  176. struct RenderModel_TextureMap_t
  177. {
  178. uint16_t unWidth, unHeight; // width and height of the texture map in pixels
  179. const uint8_t *rubTextureMapData; // Map texture data. All textures are RGBA with 8 bits per channel per pixel. Data size is width * height * 4ub
  180. };
  181. /** Contains everything a game needs to render a single tracked or static object for the user. */
  182. struct RenderModel_t
  183. {
  184. uint64_t ulInternalHandle; // Used internally by SteamVR
  185. const RenderModel_Vertex_t *rVertexData; // Vertex data for the mesh
  186. uint32_t unVertexCount; // Number of vertices in the vertex data
  187. const uint16_t *rIndexData; // Indices into the vertex data for each triangle
  188. uint32_t unTriangleCount; // Number of triangles in the mesh. Index count is 3 * TriangleCount
  189. RenderModel_TextureMap_t diffuseTexture; // RGBA diffuse texture for the model
  190. };
  191. /** The types of events that could be posted (and what the parameters mean for each event type) */
  192. enum EVREventType
  193. {
  194. VREvent_None = 0,
  195. VREvent_TrackedDeviceActivated = 100,
  196. VREvent_TrackedDeviceDeactivated = 101,
  197. VREvent_TrackedDeviceUpdated = 102,
  198. VREvent_ButtonPress = 200, // data is controller
  199. VREvent_ButtonUnpress = 201, // data is controller
  200. VREvent_ButtonTouch = 202, // data is controller
  201. VREvent_ButtonUntouch = 203, // data is controller
  202. VREvent_MouseMove = 300, // data is mouse
  203. VREvent_MouseButtonDown = 301, // data is mouse
  204. VREvent_MouseButtonUp = 302, // data is mouse
  205. VREvent_InputFocusCaptured = 400, // data is process
  206. VREvent_InputFocusReleased = 401, // data is process
  207. };
  208. /** VR controller button and axis IDs */
  209. enum EVRButtonId
  210. {
  211. k_EButton_System = 0,
  212. k_EButton_ApplicationMenu = 1,
  213. k_EButton_Grip = 2,
  214. k_EButton_Axis0 = 32,
  215. k_EButton_Axis1 = 33,
  216. k_EButton_Axis2 = 34,
  217. k_EButton_Axis3 = 35,
  218. k_EButton_Axis4 = 36,
  219. // aliases for well known controllers
  220. k_EButton_SteamVR_Touchpad = k_EButton_Axis0,
  221. k_EButton_SteamVR_Trigger = k_EButton_Axis1,
  222. k_EButton_Max = 64
  223. };
  224. inline uint64_t ButtonMaskFromId( EVRButtonId id ) { return 1ull << id; }
  225. /** used for controller button events */
  226. struct VREvent_Controller_t
  227. {
  228. EVRButtonId button;
  229. };
  230. /** used for simulated mouse events in overlay space */
  231. enum EVRMouseButton
  232. {
  233. VRMouseButton_Left = 0x0001,
  234. VRMouseButton_Right = 0x0002,
  235. VRMouseButton_Middle = 0x0004,
  236. };
  237. /** used for simulated mouse events in overlay space */
  238. struct VREvent_Mouse_t
  239. {
  240. float x, y;
  241. EVRMouseButton button;
  242. };
  243. /** Used for events about processes */
  244. struct VREvent_Process_t
  245. {
  246. uint32_t pid;
  247. uint32_t oldPid;
  248. };
  249. /** Not actually used for any events. It is just used to reserve
  250. * space in the union for future event types */
  251. struct VREvent_Reserved_t
  252. {
  253. uint64_t reserved0;
  254. uint64_t reserved1;
  255. };
  256. /** If you change this you must manually update openvr_interop.cs.py */
  257. typedef union
  258. {
  259. VREvent_Reserved_t reserved;
  260. VREvent_Controller_t controller;
  261. VREvent_Mouse_t mouse;
  262. VREvent_Process_t process;
  263. } VREvent_Data_t;
  264. /** An event posted by the server to all running applications */
  265. struct VREvent_t
  266. {
  267. EVREventType eventType;
  268. TrackedDeviceIndex_t trackedDeviceIndex;
  269. VREvent_Data_t data;
  270. float eventAgeSeconds;
  271. };
  272. /** The mesh to draw into the stencil (or depth) buffer to perform
  273. * early stencil (or depth) kills of pixels that will never appear on the HMD.
  274. * This mesh draws on all the pixels that will be hidden after distortion.
  275. *
  276. * If the HMD does not provide a visible area mesh pVertexData will be
  277. * NULL and unTriangleCount will be 0. */
  278. struct HiddenAreaMesh_t
  279. {
  280. const HmdVector2_t *pVertexData;
  281. uint32_t unTriangleCount;
  282. };
  283. /** Identifies what kind of axis is on the controller at index n. Read this type
  284. * with pVRSystem->Get( nControllerDeviceIndex, Prop_Axis0Type_Int32 + n );
  285. */
  286. enum EVRControllerAxisType
  287. {
  288. k_eControllerAxis_None = 0,
  289. k_eControllerAxis_TrackPad = 1,
  290. k_eControllerAxis_Joystick = 2,
  291. k_eControllerAxis_Trigger = 3, // Analog trigger data is in the X axis
  292. };
  293. /** contains information about one axis on the controller */
  294. struct VRControllerAxis_t
  295. {
  296. 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.
  297. float y; // Ranges from -1.0 to 1.0 for joysticks and track pads. Is always 0.0 for triggers.
  298. };
  299. /** the number of axes in the controller state */
  300. static const uint32_t k_unControllerStateAxisCount = 5;
  301. /** Holds all the state of a controller at one moment in time. */
  302. struct VRControllerState001_t
  303. {
  304. // If packet num matches that on your prior call, then the controller state hasn't been changed since
  305. // your last call and there is no need to process it
  306. uint32_t unPacketNum;
  307. // bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
  308. uint64_t ulButtonPressed;
  309. uint64_t ulButtonTouched;
  310. // Axis data for the controller's analog inputs
  311. VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
  312. };
  313. typedef VRControllerState001_t VRControllerState_t;
  314. /** determines how to provide output to the application of various event processing functions. */
  315. enum EVRControllerEventOutputType
  316. {
  317. ControllerEventOutput_OSEvents = 0,
  318. ControllerEventOutput_VREvents = 1,
  319. };
  320. /** Allows the application to customize how the overlay appears in the compositor */
  321. struct Compositor_OverlaySettings
  322. {
  323. uint32_t size; // sizeof(Compositor_OverlaySettings)
  324. bool curved, antialias;
  325. float scale, distance, alpha;
  326. float uOffset, vOffset, uScale, vScale;
  327. float gridDivs, gridWidth, gridScale;
  328. HmdMatrix44_t transform;
  329. };
  330. /** error codes returned by Vr_Init */
  331. enum HmdError
  332. {
  333. HmdError_None = 0,
  334. HmdError_Unknown = 1,
  335. HmdError_Init_InstallationNotFound = 100,
  336. HmdError_Init_InstallationCorrupt = 101,
  337. HmdError_Init_VRClientDLLNotFound = 102,
  338. HmdError_Init_FileNotFound = 103,
  339. HmdError_Init_FactoryNotFound = 104,
  340. HmdError_Init_InterfaceNotFound = 105,
  341. HmdError_Init_InvalidInterface = 106,
  342. HmdError_Init_UserConfigDirectoryInvalid = 107,
  343. HmdError_Init_HmdNotFound = 108,
  344. HmdError_Init_NotInitialized = 109,
  345. HmdError_Init_PathRegistryNotFound = 110,
  346. HmdError_Init_NoConfigPath = 111,
  347. HmdError_Init_NoLogPath = 112,
  348. HmdError_Init_PathRegistryNotWritable = 113,
  349. HmdError_Driver_Failed = 200,
  350. HmdError_Driver_Unknown = 201,
  351. HmdError_Driver_HmdUnknown = 202,
  352. HmdError_Driver_NotLoaded = 203,
  353. HmdError_Driver_RuntimeOutOfDate = 204,
  354. HmdError_Driver_HmdInUse = 205,
  355. HmdError_IPC_ServerInitFailed = 300,
  356. HmdError_IPC_ConnectFailed = 301,
  357. HmdError_IPC_SharedStateInitFailed = 302,
  358. HmdError_IPC_CompositorInitFailed = 303,
  359. HmdError_IPC_MutexInitFailed = 304,
  360. HmdError_VendorSpecific_UnableToConnectToOculusRuntime = 1000,
  361. HmdError_Steam_SteamInstallationNotFound = 2000,
  362. };
  363. #pragma pack( pop )
  364. }
  365. // vrannotation.h
  366. #ifdef __clang__
  367. # define VR_CLANG_ATTR(ATTR) __attribute__((annotate( ATTR )))
  368. #else
  369. # define VR_CLANG_ATTR(ATTR)
  370. #endif
  371. #define VR_METHOD_DESC(DESC) VR_CLANG_ATTR( "desc:" #DESC ";" )
  372. #define VR_IGNOREATTR() VR_CLANG_ATTR( "ignore" )
  373. #define VR_OUT_STRUCT() VR_CLANG_ATTR( "out_struct: ;" )
  374. #define VR_OUT_STRING() VR_CLANG_ATTR( "out_string: ;" )
  375. #define VR_OUT_ARRAY_CALL(COUNTER,FUNCTION,PARAMS) VR_CLANG_ATTR( "out_array_call:" #COUNTER "," #FUNCTION "," #PARAMS ";" )
  376. #define VR_OUT_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "out_array_count:" #COUNTER ";" )
  377. #define VR_ARRAY_COUNT(COUNTER) VR_CLANG_ATTR( "array_count:" #COUNTER ";" )
  378. #define VR_ARRAY_COUNT_D(COUNTER, DESC) VR_CLANG_ATTR( "array_count:" #COUNTER ";desc:" #DESC )
  379. #define VR_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "buffer_count:" #COUNTER ";" )
  380. #define VR_OUT_BUFFER_COUNT(COUNTER) VR_CLANG_ATTR( "out_buffer_count:" #COUNTER ";" )
  381. #define VR_OUT_STRING_COUNT(COUNTER) VR_CLANG_ATTR( "out_string_count:" #COUNTER ";" )
  382. // ivrsystem.h
  383. namespace vr
  384. {
  385. class IVRSystem
  386. {
  387. public:
  388. // ------------------------------------
  389. // Display Methods
  390. // ------------------------------------
  391. /** Size and position that the window needs to be on the VR display. */
  392. virtual void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  393. /** Suggested size for the intermediate render target that the distortion pulls from. */
  394. virtual void GetRecommendedRenderTargetSize( uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  395. /** Gets the viewport in the frame buffer to draw the output of the distortion into */
  396. virtual void GetEyeOutputViewport( Hmd_Eye eEye, uint32_t *pnX, uint32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) = 0;
  397. /** The projection matrix for the specified eye */
  398. virtual HmdMatrix44_t GetProjectionMatrix( Hmd_Eye eEye, float fNearZ, float fFarZ, GraphicsAPIConvention eProjType ) = 0;
  399. /** The components necessary to build your own projection matrix in case your
  400. * application is doing something fancy like infinite Z */
  401. virtual void GetProjectionRaw( Hmd_Eye eEye, float *pfLeft, float *pfRight, float *pfTop, float *pfBottom ) = 0;
  402. /** Returns the result of the distortion function for the specified eye and input UVs. UVs go from 0,0 in
  403. * the upper left of that eye's viewport and 1,1 in the lower right of that eye's viewport. */
  404. virtual DistortionCoordinates_t ComputeDistortion( Hmd_Eye eEye, float fU, float fV ) = 0;
  405. /** Returns the transform from eye space to the head space. Eye space is the per-eye flavor of head
  406. * space that provides stereo disparity. Instead of Model * View * Projection the sequence is Model * View * Eye^-1 * Projection.
  407. * Normally View and Eye^-1 will be multiplied together and treated as View in your application.
  408. */
  409. virtual HmdMatrix34_t GetEyeToHeadTransform( Hmd_Eye eEye ) = 0;
  410. /** Returns the number of elapsed seconds since the last recorded vsync event. This
  411. * will come from a vsync timer event in the timer if possible or from the application-reported
  412. * time if that is not available. If no vsync times are available the function will
  413. * return zero for vsync time and frame counter and return false from the method. */
  414. virtual bool GetTimeSinceLastVsync( float *pfSecondsSinceLastVsync, uint64_t *pulFrameCounter ) = 0;
  415. /** [D3D9 Only]
  416. * Returns the adapter index that the user should pass into CreateDevice to set up D3D9 in such
  417. * a way that it can go full screen exclusive on the HMD. Returns -1 if there was an error.
  418. */
  419. virtual int32_t GetD3D9AdapterIndex() = 0;
  420. /** [D3D10/11 Only]
  421. * Returns the adapter index and output index that the user should pass into EnumAdapters and EnumOutputs
  422. * to create the device and swap chain in DX10 and DX11. If an error occurs both indices will be set to -1.
  423. */
  424. virtual void GetDXGIOutputInfo( int32_t *pnAdapterIndex, int32_t *pnAdapterOutputIndex ) = 0;
  425. /** [Windows Only]
  426. * Notifies the system that the VR output will appear in a particular window.
  427. */
  428. virtual bool AttachToWindow( void *hWnd ) = 0;
  429. // ------------------------------------
  430. // Tracking Methods
  431. // ------------------------------------
  432. /** The pose that the tracker thinks that the HMD will be in at the specified number of seconds into the
  433. * future. Pass 0 to get the state at the instant the method is called. Most of the time the application should
  434. * calculate the time until the photons will be emitted from the display and pass that time into the method.
  435. *
  436. * This is roughly analogous to the inverse of the view matrix in most applications, though
  437. * many games will need to do some additional rotation or translation on top of the rotation
  438. * and translation provided by the head pose.
  439. *
  440. * For devices where bPoseIsValid is true the application can use the pose to position the device
  441. * in question. The provided array can be any size up to k_unMaxTrackedDeviceCount.
  442. *
  443. * Seated experiences should call this method with TrackingUniverseSeated and receive poses relative
  444. * to the seated zero pose. Standing experiences should call this method with TrackingUniverseStanding
  445. * and receive poses relative to the chaperone soft bounds. TrackingUniverseRawAndUncalibrated should
  446. * probably not be used unless the application is the chaperone calibration tool itself, but will provide
  447. * poses relative to the hardware-specific coordinate system in the driver.
  448. */
  449. virtual void GetDeviceToAbsoluteTrackingPose( TrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, VR_ARRAY_COUNT(unTrackedDevicePoseArrayCount) TrackedDevicePose_t *pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount ) = 0;
  450. /** Sets the zero pose for the seated tracker coordinate system to the current position and yaw of the HMD. After
  451. * ResetSeatedZeroPose all GetDeviceToAbsoluteTrackingPose calls that pass TrackingUniverseSeated as the origin
  452. * will be relative to this new zero pose. The new zero coordinate system will not change the fact that the Y axis
  453. * is up in the real world, so the next pose returned from GetDeviceToAbsoluteTrackingPose after a call to
  454. * ResetSeatedZeroPose may not be exactly an identity matrix. */
  455. virtual void ResetSeatedZeroPose() = 0;
  456. /** Returns the transform from the seated zero pose to the standing absolute tracking system. This allows
  457. * applications to represent the seated origin to used or transform object positions from one coordinate
  458. * system to the other.
  459. *
  460. * The seated origin may or may not be inside the soft or hard bounds returned by IVRChaperone. Its position
  461. * depends on what the user has set in the chaperone calibration tool and previous calls to ResetSeatedZeroPose. */
  462. virtual HmdMatrix34_t GetSeatedZeroPoseToStandingAbsoluteTrackingPose() = 0;
  463. // ------------------------------------
  464. // RenderModel methods
  465. // ------------------------------------
  466. /** Loads and returns a render model for use in the application. pchRenderModelName should be a render model name
  467. * from the Prop_RenderModelName_String property or an absolute path name to a render model on disk.
  468. *
  469. * The resulting render model is valid until VR_Shutdown() is called or until FreeRenderModel() is called. When the
  470. * application is finished with the render model it should call FreeRenderModel() to free the memory associated
  471. * with the model.
  472. *
  473. * The method returns false if the model could not be loaded.
  474. *
  475. * The API expects that this function will be called at startup or when tracked devices are connected and disconnected.
  476. * If it is called every frame it will hurt performance.
  477. */
  478. virtual bool LoadRenderModel( const char *pchRenderModelName, RenderModel_t *pRenderModel ) = 0;
  479. /** Frees a previously returned render model */
  480. virtual void FreeRenderModel( RenderModel_t *pRenderModel ) = 0;
  481. // ------------------------------------
  482. // Property methods
  483. // ------------------------------------
  484. /** Returns the device class of a tracked device. If there has not been a device connected in this slot
  485. * since the application started this function will return TrackedDevice_Invalid. For previous detected
  486. * devices the function will return the previously observed device class.
  487. *
  488. * To determine which devices exist on the system, just loop from 0 to k_unMaxTrackedDeviceCount and check
  489. * the device class. Every device with something other than TrackedDevice_Invalid is associated with an
  490. * actual tracked device. */
  491. virtual TrackedDeviceClass GetTrackedDeviceClass( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  492. /** Returns true if there is a device connected in this slot. */
  493. virtual bool IsTrackedDeviceConnected( vr::TrackedDeviceIndex_t unDeviceIndex ) = 0;
  494. /** Returns a bool property. If the device index is not valid or the property is not a bool type this function will return false. */
  495. virtual bool GetBoolTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, TrackedPropertyError *pError = 0L ) = 0;
  496. /** Returns a float property. If the device index is not valid or the property is not a float type this function will return 0. */
  497. virtual float GetFloatTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, TrackedPropertyError *pError = 0L ) = 0;
  498. /** Returns an int property. If the device index is not valid or the property is not a int type this function will return 0. */
  499. virtual int32_t GetInt32TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, TrackedPropertyError *pError = 0L ) = 0;
  500. /** Returns a uint64 property. If the device index is not valid or the property is not a uint64 type this function will return 0. */
  501. virtual uint64_t GetUint64TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, TrackedPropertyError *pError = 0L ) = 0;
  502. /** Returns a matrix property. If the device index is not valid or the property is not a matrix type, this function will return identity. */
  503. virtual HmdMatrix34_t GetMatrix34TrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, TrackedPropertyError *pError = 0L ) = 0;
  504. /** Returns a string property. If the device index is not valid or the property is not a float type this function will
  505. * return 0. Otherwise it returns the length of the number of bytes necessary to hold this string including the trailing
  506. * null. Strings will generally fit in buffers of k_unTrackingStringSize characters. */
  507. virtual uint32_t GetStringTrackedDeviceProperty( vr::TrackedDeviceIndex_t unDeviceIndex, TrackedDeviceProperty prop, VR_OUT_STRING() char *pchValue, uint32_t unBufferSize, TrackedPropertyError *pError = 0L ) = 0;
  508. /** returns a string that corresponds with the specified property error. The string will be the name
  509. * of the error enum value for all valid error codes */
  510. virtual const char *GetPropErrorNameFromEnum( TrackedPropertyError error ) = 0;
  511. // ------------------------------------
  512. // Event methods
  513. // ------------------------------------
  514. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  515. * this method returns false */
  516. virtual bool PollNextEvent( VREvent_t *pEvent ) = 0;
  517. /** Returns true and fills the event with the next event on the queue if there is one. If there are no events
  518. * this method returns false. Fills in the pose of the associated tracked device in the provided pose struct.
  519. * This pose will always be older than the call to this function and should not be used to render the device. */
  520. virtual bool PollNextEventWithPose( TrackingUniverseOrigin eOrigin, vr::VREvent_t *pEvent, vr::TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  521. /** returns the name of an EVREvent enum value */
  522. virtual const char *GetEventTypeNameFromEnum( EVREventType eType ) = 0;
  523. // ------------------------------------
  524. // Rendering helper methods
  525. // ------------------------------------
  526. /** Returns the stencil mesh information for the current HMD. If this HMD does not have a stencil mesh the vertex data and count will be
  527. * NULL and 0 respectively. This mesh is meant to be rendered into the stencil buffer (or into the depth buffer setting nearz) before rendering
  528. * each eye's view. The pixels covered by this mesh will never be seen by the user after the lens distortion is applied and based on visibility to the panels.
  529. * This will improve perf by letting the GPU early-reject pixels the user will never see before running the pixel shader.
  530. * NOTE: Render this mesh with backface culling disabled since the winding order of the vertices can be different per-HMD or per-eye.
  531. */
  532. virtual HiddenAreaMesh_t GetHiddenAreaMesh( Hmd_Eye eEye ) = 0;
  533. // ------------------------------------
  534. // Controller methods
  535. // ------------------------------------
  536. /** Fills the supplied struct with the current state of the controller. Returns false if the controller index
  537. * is invalid. */
  538. virtual bool GetControllerState( vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState ) = 0;
  539. /** fills the supplied struct with the current state of the controller and the provided pose with the pose of
  540. * the controller when the controller state was updated most recently. Use this form if you need a precise controller
  541. * pose as input to your application when the user presses or releases a button. */
  542. virtual bool GetControllerStateWithPose( TrackingUniverseOrigin eOrigin, vr::TrackedDeviceIndex_t unControllerDeviceIndex, vr::VRControllerState_t *pControllerState, TrackedDevicePose_t *pTrackedDevicePose ) = 0;
  543. /** Trigger a single haptic pulse on a controller. After this call the application may not trigger another haptic pulse on this controller
  544. * and axis combination for 5ms. */
  545. virtual void TriggerHapticPulse( vr::TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec ) = 0;
  546. /** returns the name of an EVRButtonId enum value */
  547. virtual const char *GetButtonIdNameFromEnum( EVRButtonId eButtonId ) = 0;
  548. /** returns the name of an EVRControllerAxisType enum value */
  549. virtual const char *GetControllerAxisTypeNameFromEnum( EVRControllerAxisType eAxisType ) = 0;
  550. /** Processes mouse input from the specified controller as though it were a mouse pointed at a compositor overlay with the
  551. * specified settings. The controller is treated like a laser pointer on the -z axis. The point where the laser pointer would
  552. * intersect with the overlay is the mouse position, the trigger is left mouse, and the track pad is right mouse. When using
  553. * system event output the caller should ensure that it has focus so that it receives the system events.
  554. *
  555. * Return true if the controller is pointed at the overlay and an event was generated. */
  556. virtual bool HandleControllerOverlayInteractionAsMouse( const vr::Compositor_OverlaySettings & overlaySettings,
  557. vr::HmdVector2_t vecWindowClientPositionOnScreen, vr::HmdVector2_t vecWindowClientSize,
  558. vr::TrackedDeviceIndex_t unControllerDeviceIndex,
  559. vr::EVRControllerEventOutputType eOutputType
  560. ) = 0;
  561. /** Tells OpenVR that this process wants exclusive access to controller button states and button events. Other apps will be notified that
  562. * they have lost input focus with a VREvent_InputFocusCaptured event. Returns false if input focus could not be captured for
  563. * some reason. */
  564. virtual bool CaptureInputFocus() = 0;
  565. /** Tells OpenVR that this process no longer wants exclusive access to button states and button events. Other apps will be notified
  566. * that input focus has been released with a VREvent_InputFocusReleased event. */
  567. virtual void ReleaseInputFocus() = 0;
  568. /** Returns true if input focus is captured by another process. */
  569. virtual bool IsInputFocusCapturedByAnotherProcess() = 0;
  570. };
  571. static const char * const IVRSystem_Version = "IVRSystem_003";
  572. }
  573. // ivrchaperone.h
  574. namespace vr
  575. {
  576. #if defined(__linux__) || defined(__APPLE__)
  577. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  578. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  579. // The 64-bit version of gcc has the alignment requirement for these types set to
  580. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  581. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  582. #pragma pack( push, 4 )
  583. #else
  584. #pragma pack( push, 8 )
  585. #endif
  586. enum ChaperoneCalibrationState
  587. {
  588. // OK!
  589. ChaperoneCalibrationState_OK = 1, // Chaperone is fully calibrated and working correctly
  590. // Warnings
  591. ChaperoneCalibrationState_Warning = 100,
  592. ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101, // A base station thinks that it might have moved
  593. ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, // There are less base stations than when calibrated
  594. ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, // Seated bounds haven't been calibrated for the current tracking center
  595. // Errors
  596. ChaperoneCalibrationState_Error = 200,
  597. ChaperoneCalibrationState_Error_BaseStationUninitalized = 201, // Tracking center hasn't be calibrated for at least one of the base stations
  598. ChaperoneCalibrationState_Error_BaseStationConflict = 202, // Tracking center is calibrated, but base stations disagree on the tracking space
  599. ChaperoneCalibrationState_Error_SoftBoundsInvalid = 203, // Soft bounds haven't been calibrated for the current tracking center
  600. ChaperoneCalibrationState_Error_HardBoundsInvalid = 204, // Hard bounds haven't been calibrated for the current tracking center
  601. };
  602. /** SOFT BOUNDS ASSUMPTIONS
  603. * Corners are in clockwise order.
  604. * Tracking space center (0,0,0) is contained within the Soft Bounds.
  605. * Angles of corners are between 25 and 155 degrees.
  606. * Quadrilateral formed is convex.
  607. * One side will run parallel to the X axis.
  608. * Height of every corner is 0Y (on the floor). */
  609. struct ChaperoneSoftBoundsInfo_t
  610. {
  611. HmdQuad_t quadCorners;
  612. };
  613. struct ChaperoneSeatedBoundsInfo_t
  614. {
  615. HmdVector3_t vSeatedHeadPosition;
  616. HmdVector3_t vDeskEdgePositions[ 2 ];
  617. };
  618. /** HIGH LEVEL TRACKING SPACE ASSUMPTIONS:
  619. * 0,0,0 is the preferred standing area center.
  620. * 0Y is the floor height.
  621. * -Z is the preferred forward facing direction. */
  622. class IVRChaperone
  623. {
  624. public:
  625. /** Get the current state of Chaperone calibration. This state can change at any time during a session due to physical base station changes. */
  626. virtual ChaperoneCalibrationState GetCalibrationState() = 0;
  627. /** Returns the 4 corner positions of the Soft Bounds (also know as Safe Zone and Play Space). */
  628. virtual bool GetSoftBoundsInfo( ChaperoneSoftBoundsInfo_t *pInfo ) = 0;
  629. /** Returns the quads representing the Hard Bounds (static physical obstacles). */
  630. virtual bool GetHardBoundsInfo( VR_OUT_ARRAY_COUNT(punQuadsCount) HmdQuad_t *pQuadsBuffer, uint32_t* punQuadsCount ) = 0;
  631. /** Returns the preferred seated position and front edge of their desk. */
  632. virtual bool GetSeatedBoundsInfo( ChaperoneSeatedBoundsInfo_t *pInfo ) = 0;
  633. };
  634. static const char * const IVRChaperone_Version = "IVRChaperone_002";
  635. #pragma pack( pop )
  636. }
  637. // ivrcompositor.h
  638. namespace vr
  639. {
  640. #if defined(__linux__) || defined(__APPLE__)
  641. // The 32-bit version of gcc has the alignment requirement for uint64 and double set to
  642. // 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
  643. // The 64-bit version of gcc has the alignment requirement for these types set to
  644. // 8 meaning that unless we use #pragma pack(4) our structures will get bigger.
  645. // The 64-bit structure packing has to match the 32-bit structure packing for each platform.
  646. #pragma pack( push, 4 )
  647. #else
  648. #pragma pack( push, 8 )
  649. #endif
  650. /** Identifies the graphics API for the associated device */
  651. enum Compositor_DeviceType
  652. {
  653. Compositor_DeviceType_None,
  654. Compositor_DeviceType_D3D9,
  655. Compositor_DeviceType_D3D9Ex,
  656. Compositor_DeviceType_D3D10,
  657. Compositor_DeviceType_D3D11,
  658. Compositor_DeviceType_OpenGL
  659. };
  660. /** Provides a single frame's timing information to the app */
  661. struct Compositor_FrameTiming
  662. {
  663. uint32_t size; // sizeof(Compositor_FrameTiming)
  664. double frameStart;
  665. float frameVSync; // seconds from frame start
  666. uint32_t droppedFrames;
  667. uint32_t frameIndex;
  668. vr::TrackedDevicePose_t pose;
  669. };
  670. /** Allows the application to control what part of the provided texture will be used in the
  671. * frame buffer. */
  672. struct Compositor_TextureBounds
  673. {
  674. float uMin, vMin;
  675. float uMax, vMax;
  676. };
  677. #pragma pack( pop )
  678. /** Allows the application to interact with the compositor */
  679. class IVRCompositor
  680. {
  681. public:
  682. /** Returns the last error that occurred in the compositor */
  683. virtual uint32_t GetLastError( VR_OUT_STRING() char* pchBuffer, uint32_t unBufferSize ) = 0;
  684. /** Turns vsync on or off on the compositor window */
  685. virtual void SetVSync( bool bVSync ) = 0;
  686. /** Returns true if vsync is enabled in the compositor window */
  687. virtual bool GetVSync() = 0;
  688. /** Sets gamma for the compositor window */
  689. virtual void SetGamma( float fGamma ) = 0;
  690. /** Returns the gamma for the compositor window */
  691. virtual float GetGamma() = 0;
  692. /** Sets the graphics device or context for the application that is going to feed
  693. * images to the compositor. The type of the pDevice parameter must match the
  694. * type that is provided:
  695. * Compositor_DeviceType_D3D9 IDirect3DDevice9*
  696. * Compositor_DeviceType_D3D9Ex IDirect3DDevice9Ex*
  697. * Compositor_DeviceType_D3D10 ID3D10Device*
  698. * Compositor_DeviceType_D3D11 ID3D11Device*
  699. * Compositor_DeviceType_OpenGL HGLRC
  700. *
  701. * Note: D3D9 and D3D9Ex are not implemented at this time
  702. */
  703. virtual void SetGraphicsDevice( Compositor_DeviceType eType, void* pDevice ) = 0;
  704. /** Returns pose(s) to use to render scene. */
  705. virtual void WaitGetPoses( VR_ARRAY_COUNT(unPoseArrayCount) TrackedDevicePose_t* pPoseArray, uint32_t unPoseArrayCount ) = 0;
  706. /** Updated scene texture to display. If pBounds is NULL the entire texture will be used.
  707. *
  708. * OpenGL dirty state:
  709. * glBindTexture
  710. */
  711. virtual void Submit( Hmd_Eye eEye, void* pTexture, Compositor_TextureBounds* pBounds ) = 0;
  712. /** Clears the frame that was sent with the last call to Submit. This will cause the
  713. * compositor to show the grid until Submit is called again. */
  714. virtual void ClearLastSubmittedFrame() = 0;
  715. /** returns the default settings that will be used for the overlay texture. Fetching these defaults
  716. * can be useful if you mostly want the default values but want to change a few settings. */
  717. virtual void GetOverlayDefaults( Compositor_OverlaySettings* pSettings ) = 0;
  718. /** Texture to draw over the scene at distortion time. This texture will appear over the world on a quad.
  719. * The pSettings parameter controls the size and position of the quad. */
  720. virtual void SetOverlay(void* pTexture, Compositor_OverlaySettings* pSettings ) = 0;
  721. /** Separate interface for providing the data as a stream of bytes, but there is an upper bound on data that can be sent */
  722. virtual void SetOverlayRaw(void* buffer, uint32_t width, uint32_t height, uint32_t depth, Compositor_OverlaySettings* pSettings ) = 0;
  723. /** Separate interface for providing the image through a filename:
  724. * can be png or jpg, and should not be bigger than 1920x1080 */
  725. virtual void SetOverlayFromFile( const char *pchFilePath, Compositor_OverlaySettings* pSettings ) = 0;
  726. /** Removes the scene overlay texture. */
  727. virtual void ClearOverlay() = 0;
  728. /** Returns true if timing data is filled it. Sets oldest timing info if nFramesAgo is larger than the stored history.
  729. * Be sure to set timing.size = sizeof(Compositor_FrameTiming) on struct passed in before calling this function. */
  730. virtual bool GetFrameTiming( Compositor_FrameTiming *pTiming, uint32_t unFramesAgo = 0 ) = 0;
  731. /** Fades the view on the HMD to the specified color. The fade will take fSeconds, and the color values are between
  732. * 0.0 and 1.0. This color is faded on top of the scene based on the alpha parameter. Removing the fade color instantly
  733. * would be FadeToColor( 0.0, 0.0, 0.0, 0.0, 0.0 ). */
  734. virtual void FadeToColor( float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground = false ) = 0;
  735. /** Fading the Grid in or out in fSeconds */
  736. virtual void FadeGrid( float fSeconds, bool bFadeIn ) = 0;
  737. /** Brings the compositor window to the front. This is useful for covering any other window that may be on the HMD
  738. * and is obscuring the compositor window. */
  739. virtual void CompositorBringToFront() = 0;
  740. /** Pushes the compositor window to the back. This is useful for allowing other applications to draw directly to the HMD. */
  741. virtual void CompositorGoToBack() = 0;
  742. /** Tells the compositor process to clean up and exit. You do not need to call this function at shutdown. Under normal
  743. * circumstances the compositor will manage its own life cycle based on what applications are running. */
  744. virtual void CompositorQuit() = 0;
  745. /** Return whether the compositor is fullscreen */
  746. virtual bool IsFullscreen() = 0;
  747. /** Computes the overlay-space pixel coordinates of where the ray intersects the overlay with the
  748. * specified settings. Returns false if there is no intersection. */
  749. virtual bool ComputeOverlayIntersection( const Compositor_OverlaySettings* pSettings, float fAspectRatio, vr::TrackingUniverseOrigin eOrigin, vr::HmdVector3_t vSource, vr::HmdVector3_t vDirection, vr::HmdVector2_t *pvecIntersectionUV, vr::HmdVector3_t *pvecIntersectionTrackingSpace ) = 0;
  750. /** Sets tracking space returned by WaitGetPoses */
  751. virtual void SetTrackingSpace( TrackingUniverseOrigin eOrigin ) = 0;
  752. /** Gets current tracking space returned by WaitGetPoses */
  753. virtual TrackingUniverseOrigin GetTrackingSpace() = 0;
  754. };
  755. static const char * const IVRCompositor_Version = "IVRCompositor_005";
  756. } // namespace vr
  757. // ivrcontrolpanel.h
  758. namespace vr
  759. {
  760. class IVRControlPanel
  761. {
  762. public:
  763. // ------------------------------------
  764. // Driver enumeration methods
  765. // ------------------------------------
  766. /** the number of active drivers */
  767. virtual uint32_t GetDriverCount() = 0;
  768. /** The ID of the specified driver as a UTF-8 string. Returns the length of the ID in bytes. If
  769. * the buffer is not large enough to fit the ID an empty string will be returned. In general, 128 bytes
  770. * will be enough to fit any ID. */
  771. virtual uint32_t GetDriverId( uint32_t unDriverIndex, char *pchBuffer, uint32_t unBufferLen ) = 0;
  772. // ------------------------------------
  773. // Display Enumeration Methods
  774. // ------------------------------------
  775. /** the number of active displays on the specified driver */
  776. virtual uint32_t GetDriverDisplayCount( const char *pchDriverId ) = 0;
  777. /** The ID of the specified display in the specified driver as a UTF-8 string. Returns the
  778. * length of the ID in bytes. If the buffer is not large enough to fit the ID an empty
  779. * string will be returned. In general, 128 bytes will be enough to fit any ID. */
  780. virtual uint32_t GetDriverDisplayId( const char *pchDriverId, uint32_t unDisplayIndex, char *pchBuffer, uint32_t unBufferLen ) = 0;
  781. // ------------------------------------
  782. // Display Detail Methods
  783. // ------------------------------------
  784. /** The model name of the specified driver in the specified driver as a UTF-8 string. Returns the
  785. * length of the model name in bytes. If the buffer is not large enough to fit the model name an empty
  786. * string will be returned. In general, 128 bytes will be enough to fit any model name. Returns 0 if
  787. * the display or driver was not found. */
  788. virtual uint32_t GetDriverDisplayModelNumber( const char *pchDriverId, const char *pchDisplayId, char *pchBuffer, uint32_t unBufferLen ) = 0;
  789. /** The serial number of the specified driver in the specified driver as a UTF-8 string. Returns the
  790. * length of the serial number in bytes. If the buffer is not large enough to fit the serial number an empty
  791. * string will be returned. In general, 128 bytes will be enough to fit any model name. Returns 0 if
  792. * the display or driver was not found. */
  793. virtual uint32_t GetDriverDisplaySerialNumber( const char *pchDriverId, const char *pchDisplayId, char *pchBuffer, uint32_t unBufferLen ) = 0;
  794. /** Returns the IVRSystem interface for the current display that matches the specified version number.
  795. * This is usually unnecessary and the return value of VR_Init can be used without calling this method. */
  796. VR_IGNOREATTR()
  797. virtual class IVRSystem *GetCurrentDisplayInterface( const char *pchHmdInterfaceVersion ) = 0;
  798. // ------------------------------------
  799. // Shared Resource Methods
  800. // ------------------------------------
  801. /** Loads the specified resource into the provided buffer if large enough.
  802. * Returns the size in bytes of the buffer required to hold the specified resource. */
  803. virtual uint32_t LoadSharedResource( const char *pchResourceName, char *pchBuffer, uint32_t unBufferLen ) = 0;
  804. // ------------------------------------
  805. // IPD Methods
  806. // ------------------------------------
  807. /** Gets the current IPD (Interpupillary Distance) in meters. */
  808. virtual float GetIPD() = 0;
  809. /** Sets the current IPD (Interpupillary Distance) in meters. */
  810. virtual void SetIPD( float fIPD ) = 0;
  811. // ------------------------------------
  812. // Compositor Methods
  813. // ------------------------------------
  814. /** Returns the IVRCompositor interface that matches the specified interface version. This will only
  815. * return the compositor interface if it has already been initialized by the current process. */
  816. virtual class IVRCompositor *GetCurrentCompositorInterface( const char *pchInterfaceVersion ) = 0;
  817. };
  818. static const char * const IVRControlPanel_Version = "IVRControlPanel_001";
  819. }// End
  820. #endif // _OPENVR_API
  821. namespace vr
  822. {
  823. // figure out how to import from the VR API dll
  824. #if defined(_WIN32)
  825. #ifdef VR_API_EXPORT
  826. #define VR_INTERFACE extern "C" __declspec( dllexport )
  827. #else
  828. #define VR_INTERFACE extern "C" __declspec( dllimport )
  829. #endif
  830. #elif defined(GNUC) || defined(COMPILER_GCC)
  831. #ifdef VR_API_EXPORT
  832. #define VR_INTERFACE extern "C" __attribute__((visibility("default")))
  833. #else
  834. #define VR_INTERFACE extern "C"
  835. #endif
  836. #else
  837. #error "Unsupported Platform."
  838. #endif
  839. #if defined( _WIN32 )
  840. #define VR_CALLTYPE __cdecl
  841. #else
  842. #define VR_CALLTYPE
  843. #endif
  844. /** Finds the active installation of the VR API and initializes it. The provided path must be absolute
  845. * or relative to the current working directory. These are the local install versions of the equivalent
  846. * functions in steamvr.h and will work without a local Steam install.
  847. *
  848. * This path is to the "root" of the VR API install. That's the directory with
  849. * the "drivers" directory and a platform (i.e. "win32") directory in it, not the directory with the DLL itself.
  850. */
  851. VR_INTERFACE vr::IVRSystem *VR_CALLTYPE VR_Init( vr::HmdError *peError );
  852. /** unloads vrclient.dll. Any interface pointers from the interface are
  853. * invalid after this point */
  854. VR_INTERFACE void VR_CALLTYPE VR_Shutdown();
  855. /** Returns true if there is an HMD attached. This check is as lightweight as possible and
  856. * can be called outside of VR_Init/VR_Shutdown. It should be used when an application wants
  857. * to know if initializing VR is a possibility but isn't ready to take that step yet.
  858. */
  859. VR_INTERFACE bool VR_CALLTYPE VR_IsHmdPresent();
  860. /** Returns the string version of an HMD error. This function may be called outside of VR_Init()/VR_Shutdown(). */
  861. VR_INTERFACE const char *VR_CALLTYPE VR_GetStringForHmdError( vr::HmdError error );
  862. /** Returns the interface of the specified version. This method must be called after VR_Init. The
  863. * pointer returned is valid until VR_Shutdown is called.
  864. */
  865. VR_INTERFACE void *VR_CALLTYPE VR_GetGenericInterface( const char *pchInterfaceVersion, vr::HmdError *peError );
  866. }