Crate ovr_sys

source ·
Expand description

This crate provides raw unsafe bindings to LibOVR, the Oculus Rift runtime library.

The currently targeted version of LibOVR is 1.15.0

Good API documentation is provided here, transformed from the original doxygen documentation. More high level documentation can be found on the Oculus developer web site. Example code has been translated from C to mostly equivalent Rust (TODO: except in the DirectX module).

The bindings are generated directly from the LibOVR headers, and some conventions have been followed when translating from the C code.

  • Each enum has been translated into a type definition (defined to be i32) and a collection of constants. This preserves the ability to easily use them as bitflags.

  • Alignment requirements on structs have been implemented using dummy zero-sized array fields. When initialising these fields, the value [] will suffice.

  • Where the layout of structs differs between 32-bit and 64-bit platforms due to dummy padding fields, conditional compilation is used. For this reason it is recommended to not construct the affected structs in a typical fashion as this may result in code that compiles on one but not both architectures (due to missing/spurious padding field).

    A reasonable approach is to use .. struct initialisation syntax, like so:

    let init_params = ovrInitParams {
        Flags: ovrInit_RequestVersion,
        RequestedMinorVersion: OVR_MINOR_VERSION,
        LogCallback: None,
        UserData: 0,
        ConnectionTimeoutMS: 0,
        .. mem::uninitialized()
    };

    Like all unsafe code uses of ::std::mem::uninitialized() should be scrutinised for mistakes.

  • Function-like C macros have been translated into functions with the same name.

Optional features are provided in sub-modules. These features are audio, directx, opengl and vulkan. These sub-modules will only be present if the corresponding feature has been enabled in the Cargo manifest. opengl is enabled by default.

Modules

LibOVR functions for performing OpenGL interop.

Structs

Boundary system look and feel
Provides boundary test information
A RGBA color with normalized f32 components.
Return values for ovr_Detect.
Provides information about the last error.
Rendering information for each eye. Computed by ovr_GetRenderDesc() based on the specified FOV. Note that the rendering viewport is not included here as it can be specified separately and modified per frame by passing different Viewport values in the layer structure.
Describes the up, down, left, and right angles of the field of view.
Identifies a graphics device in a platform-specific way. For Windows this is a LUID type.
Haptics buffer descriptor, contains amplitude samples used for Touch vibration
State of the Haptics playback for Touch vibration
This is a complete descriptor of the HMD.
Parameters for ovr_Initialize.
ovrInputState describes the complete controller input state, including Oculus Touch, and XBox gamepad. If multiple inputs are connected and used at the same time, their inputs are combined.
Describes a layer that specifies a monoscopic or stereoscopic view.
Describes a layer that specifies a monoscopic or stereoscopic view.
Defines properties shared by all ovrLayer structs, such as ovrLayerEyeFov.
Describes a layer of Quad type, which is a single quad in world or viewer space.
A 4x4 matrix with f32 elements.
Description used to create a mirror texture.
This is a complete descriptor of the performance stats provided by the SDK
Contains the performance stats for a given SDK compositor frame
A full pose (rigid body) configuration with first and second derivatives.
Position and orientation together.
A quaternion rotation.
A 2D rectangle with a position and size. All components are integers.
Specifies status information for the current session.
A 2D size with integer components.
Description used to create a texture swap chain.
Projection information for ovrLayerEyeFovDepth.
Describes the Touch Haptics engine. Currently, those values will NOT change during a session.
Specifies the description of a single sensor.
Specifies the pose for a single sensor.
Tracking state at a given absolute time (describes predicted HMD pose, etc.). Returned by ovr_GetTrackingState.
A 2D vector with f32 components.
A 2D vector with integer components.
A 3D vector with f32 components.
Contains the data necessary to properly calculate position info for various layer types.

Constants

Not currently supported on PC. Would require a DirectX 11.1 device.
Not currently supported on PC. Would require a DirectX 11.1 device.
Not currently supported on PC. Would require a DirectX 11.1 device.
Not supported for OpenGL applications
Not supported for OpenGL applications
Not supported for OpenGL applications
Introduced in v1.10
Outer boundary - closely represents user setup walls
Play area - safe rectangular area inside outer boundary which can optionally be used to restrict user interactions and motion.
A button on XBox controllers and right Touch controller. Select button on Oculus Remote.
B button on XBox controllers and right Touch controller. Back button on Oculus Remote.
Back on Xbox 360 controller. View button on XBox One controller. Not present on Touch controllers or Oculus Remote.
Down button on XBox controllers and Oculus Remote. Not present on Touch controllers.
Start on XBox 360 controller. Menu on XBox One controller and Left Touch controller. Should be referred to as the Menu button in user-facing documentation.
Home button on XBox controllers. Oculus button on Touch controllers and Oculus Remote.
Bit mask of all buttons on the left Touch controller
Left shoulder button on XBox controllers. Not present on Touch controllers or Oculus Remote.
Left thumbstick on XBox controllers and Touch controllers. Not present on Oculus Remote.
Left button on XBox controllers and Oculus Remote. Not present on Touch controllers.
Bit mask of all buttons that are for private usage by Oculus
Bit mask of all buttons on the right Touch controller
Right shoulder button on XBox controllers. Not present on Touch controllers or Oculus Remote.
Right thumbstick on XBox controllers and Touch controllers. Not present on Oculus Remote.
Right button on XBox controllers and Oculus Remote. Not present on Touch controllers.
Up button on XBox controllers and Oculus Remote. Not present on Touch controllers.
Volume button on Oculus Remote. Not present on XBox or Touch controllers.
Volume button on Oculus Remote. Not present on XBox or Touch controllers.
X button on XBox controllers and left Touch controller. Not present on Oculus Remote.
Y button on XBox controllers and left Touch controller. Not present on Oculus Remote.
Operate on or query whichever controller is active.
Renders screen-space crosshair at infinity for Stereo Debugging
Turns off the Stereo Debug HUD
Renders Quad in world for Stereo Debugging
Renders Quad+crosshair in world for Stereo Debugging
Application declared itself as an invisible type and is not allowed to submit frames.
Generic COM error.
Failure to find the specified audio device.
The client failed to call ovr_Destroy on an active session before calling ovr_Shutdown. Or the client crashed.
The client failed to call ovr_Shutdown or the client crashed.
Client version too old to connect to service
Content protection is not available for the display
Specified device type isn’t available.
No supported VR display system found, but disabled or driverless adapter found.
The given request is disallowed under the current conditions.
Unable to initialize the HMD display.
In the event of a system-wide graphics reset or cable unplug this is returned to the app.
Initialization of the DisplayManager failed.
Display portion of HMD is plugged into an incompatible port (ex: IGP)
HMD removed from the display adapter
Graphics device has been reset (TDR, etc…)
The system is using hybrid graphics (Optimus, etc…), which is not support.
The graphics hardware is not supported
The operating system version is incompatible.
Generic initialization error.
The headset was in an invalid orientation for the requested operation (e.g. vertically oriented during ovr_RecenterPose).
Function call is invalid for object’s current state
Invalid parameter provided. See error info or log for details.
Invalid ovrSession parameter provided.
Calling application has leaked resources
Couldn’t load LibOVRRT.
LibOVRRT path failure.
LibOVRRT signature check failure.
LibOVRRT symbol resolution failure.
LibOVRRT version incompatibility.
Failure to allocate memory.
Result of a bad calibration block due to lengths
Chosen rendering adapters between client and service do not match
Result of a missing calibration block
The given HMD doesn’t exist.
No valid VR display system found.
The system or component has not been initialized.
Feature or API is obsolete and no longer supported.
Result of an old calibration block
The graphics driver is out of date.
The operating system is out of date.
Attempting to re-initialize with a different version.
Failed to connect to the service because remote connections to the service are not allowed.
A runtime exception occurred. The application is required to shutdown LibOVR and re-initialize it before this error state will be cleared.
Unable to start the server. Is it already running?
Couldn’t connect to the OVR Service.
The service watchdog discovered a deadlock.
Generic service error. See error info or log for details.
OVR Service version incompatibility.
ovr_CommitTextureSwapChain was called too many times on a texture swapchain without calling submit to use the chain.
The ovrTextureSwapChain is in an incomplete or inconsistent state. Ensure ovr_CommitTextureSwapChain was called at least once first.
The operation timed out.
Failed to get the interface for an attached tracker
Function call is not supported on this hardware/software
\internal Count of enumerated elements.
The left eye, from the viewer’s perspective.
The right eye, from the viewer’s perspective.
ovrBool value of false.
Enqueue buffer for later playback
(read only) Specifies that the HMD is a virtual debug device.
When a debug library is requested, a slower debugging version of the library will run which can be used to help solve problems in the library and debug application code.
When a version is requested, the LibOVR runtime respects the RequestedMinorVersion field and verifies that the RequestedMinorVersion is supported. Normally when you specify this flag you simply use OVR_MINOR_VERSION for ovrInitParams::RequestedMinorVersion, though you could use a lower version than OVR_MINOR_VERSION to specify previous version behavior.
Mark this surface as “headlocked”, which means it is specified relative to the HMD and moves with it, rather than being specified relative to sensor/torso space and remaining still while the head moves.
ovrLayerFlag_HighQuality enables 4x anisotropic sampling during the composition of the layer.
ovrLayerFlag_TextureOriginAtBottomLeft: the opposite is TopLeft. Generally this is false for D3D, true for OpenGL.
Shows info about a specific layer
Turns off the layer HUD
Layer is disabled.
Described by ovrLayerEyeFov.
Described by ovrLayerEyeMatrix.
Described by ovrLayerQuad. Previously called ovrLayerType_QuadInWorld.
Debug-level log event.
Error-level log event.
Info-level log event.
Specifies the maximum number of layers supported by ovr_SubmitFrame.
Maximum number of frames of performance stats provided back to the caller of ovr_GetPerfStats
Shows render timing info for application
Shows render timing info for OVR compositor
Shows latency related timing info
Turns off the performance HUD
Shows performance summary and headroom
Shows SDK & HMD version Info
Enable if the application is rendering with OpenGL and expects a projection matrix with a clipping range of (-w to w). Ignore this flag if your application already handles the conversion from D3D range (0 to w) to OpenGL.
When this flag is used, the zfar value pushed into ovrMatrix4f_Projection() will be ignored NOTE: Enable only if ovrProjection_FarLessThanNear is also enabled where the far clipping plane will be pushed to infinity.
After the projection transform is applied, far values stored in the depth buffer will be less than closer depth values. NOTE: Enable only if the application is using a floating-point depth buffer for proper precision.
Enable if using left-handed transformations in your application.
Use for generating a default projection matrix that is:
Orientation is currently tracked (connected and in use).
Position is currently tracked (false if out of range).
Boundary is invalid due to sensor change or was not setup.
Device is not available for the requested operation.
Returned from a call to SubmitFrame. The call succeeded, but what the app rendered will not be visible on the HMD. Ideally the app should continue calling SubmitFrame, but not do any rendering. When the result becomes ovrSuccess, rendering should continue as usual.
The chain buffers can be bound as depth and/or stencil buffers
The application can write into the chain with pixel shader
The application can write to the chain with compute shader
DX only: Allow generation of the mip chain on the GPU via the GenerateMips call. This flag requires that RenderTarget binding also be specified.
DX only: The underlying texture is created with a TYPELESS equivalent of the format specified in the texture desc. The SDK will still access the texture using the format specified in the texture desc, but the app can create views with different formats if this is specified.
Texture swap chain contains protected content, and requires HDCP connection in order to display to HMD. Also prevents mirroring or other redirection of any frame containing this contents
2D textures.
External 2D texture. Not used on PC
Cube maps. Not currently supported on PC.
Bit mask of all the button touches on the left controller
Bit mask of all left controller poses
Bit mask of all the button touches on the right controller
Finger pose state Derived internally based on distance, proximity to sensors and filtering.
Bit mask of all right controller poses
The sensor is present, else the sensor is absent or offline.
The sensor has a valid pose, else the pose is unavailable. This will only be set if ovrTracker_Connected is set.
Supports yaw drift correction via a magnetometer or other means.
Supports orientation tracking (IMU).
Supports positional tracking.
Tracking system origin reported at eye (HMD) height
Tracking system origin reported at floor height
ovrBool value of true.
These bits are writable by user code.

Functions

Indicates if an ovrResult indicates failure.
Indicates if an ovrResult indicates success.
Indicates if an ovrResult indicates an unqualified success.
Generates an orthographic sub-projection.
Used to generate projection from ovrEyeDesc::Fov.
Tracking poses provided by the SDK come in a right-handed coordinate system. If an application is passing in ovrProjection_LeftHanded into ovrMatrix4f_Projection, then it should also use this function to flip the HMD tracking poses to be left-handed.
Extracts the required data from the result of ovrMatrix4f_Projection.
Computes offset eye poses based on headPose returned by ovrTrackingState.
Clears the ShouldRecenter status bit in ovrSessionStatus.
Commits any pending changes to an ovrTextureSwapChain, and advances its current index
Creates a handle to a VR session.
Destroys the session.
MirrorTexture creation is rendering API-specific.
Destroys an ovrTextureSwapChain and frees all the resources associated with it.
Detects Oculus Runtime and Device Status
Reads a boolean property.
Gets the dimension of the Boundary System’s “play area” or “outer boundary”.
Gets the geometry of the Boundary System’s “play area” or “outer boundary” as 3D floor points.
Returns if the boundary is currently visible. Note: visibility is false if the user has turned off boundaries, otherwise, it’s true if the app has requested boundaries to be visible or if any tracked device is currently triggering it. This may not exactly match rendering due to fade-in and fade-out effects.
Returns controller types connected to the system OR’ed together.
Gets the Haptics engine playback state of a specific Touch controller.
Returns an array of poses, where each pose matches a device type provided by the deviceTypes array parameter.
Returns the predicted head pose in outHmdTrackingState and offset eye poses in outEyePoses.
Reads a f32 property.
Reads a f32 array property.
Calculates the recommended viewport size for rendering a given eye within the HMD with a given FOV cone.
Returns information about the current HMD.
Returns the most recent input state for controllers, without positional tracking info.
Reads an integer property.
Returns information about the most recent failed return value by the current thread for this library.
Retrieves performance stats for the VR app as well as the SDK compositor.
Gets the time of the specified frame midpoint.
Computes the distortion viewport, view adjust, and other rendering parameters for the specified eye.
Returns status information for the application.
Reads a string property.
Gets the current index in an ovrTextureSwapChain.
Gets the description of the buffers in an ovrTextureSwapChain
TextureSwapChain creation is rendering API-specific.
Returns global, absolute high-resolution time in seconds.
Gets information about Haptics engine for the specified Touch controller.
Returns the number of attached trackers.
Returns a given attached tracker description.
Returns the ovrTrackerPose for the given attached tracker.
Gets the tracking origin state
Returns tracking state reading based on the specified absolute system time.
Returns the version string representing the LibOVRRT version.
Identify client application info.
Initializes LibOVR
Re-centers the sensor position and orientation.
Requests boundary to be visible.
Resets the look and feel of the Boundary System to its default state.
Resets the accumulated stats reported in each ovrPerfStatsPerCompositorFrame back to zero.
Writes or creates a boolean property.
Sets the look and feel of the Boundary System.
Sets constant vibration (with specified frequency and amplitude) to a controller.
Writes or creates a f32 property.
Writes or creates a f32 array property.
Writes or creates an integer property.
Writes or creates a string property.
Sets the tracking origin type
Shuts down LibOVR
Allows manually tweaking the sensor position and orientation.
Submits a Haptics buffer (used for vibration) to Touch (only) controllers.
Submits layers for distortion and display.
Tests collision/proximity of position tracked devices (e.g. HMD and/or Touch) against the Boundary System. Note: this method is similar to ovr_BoundaryTestPoint but can be more precise as it may take into account device acceleration/momentum.
Tests collision/proximity of a 3D point against the Boundary System.
Writes a message string to the LibOVR tracing mechanism (if enabled).

Type Definitions

Boolean type
Boundary types that specified while using the boundary system
Describes button input types. Button inputs are combined; that is they will be reported as pressed if they are pressed on either one of the two devices. The ovrButton_Up/Down/Left/Right map to both XBox D-Pad and directional buttons. The ovrButton_Enter and ovrButton_Return map to Start and Back controller buttons, respectively.
Specifies which controller is connected; multiple can be connected at once.
Debug HUD is provided to help developers gauge and debug the fidelity of their app’s stereo rendering characteristics. Using the provided quad and crosshair guides, the developer can verify various aspects such as VR tracking units (e.g. meters), stereo camera-parallax properties (e.g. making sure objects at infinity are rendered with the proper separation), measuring VR geometry sizes and distances and more.
Public error types
Specifies which eye is being used for rendering. This type explicitly does not include a third “NoStereo” monoscopic option, as such is not required for an HMD-centered API.
Provides names for the left and right hand array indexes.
Haptics buffer submit mode
HMD capability bits reported by device.
Enumerates all HMD types that we support.
Initialization flags.
Identifies flags used by ovrLayerHeader and which are passed to ovr_SubmitFrame.
Layer HUD enables the HMD user to see information about a layer
Each layer type has an associated struct, such as ovrLayerEyeFov.
Signature of the logging callback function pointer type.
Logging levels
Performance HUD enables the HMD user to see information critical to the real-time operation of the VR application such as latency timing, and CPU & GPU performance metrics
Enumerates modifications to the projection matrix based on the application’s needs.
API call results are represented at the highest level by a single ovrResult.
Used as an opaque pointer to an OVR session.
Bit flags describing the current status of sensor tracking.
This is a general success result. Use OVR_SUCCESS to test for success.
Success is a value greater or equal to 0, while all error types are negative values.
The bindings required for texture swap chain.
The format of a texture.
Misc flags overriding particular behaviors of a texture swap chain
The type of texture resource.
Describes touch input types. These values map to capacitive touch values reported ovrInputState::Touch. Some of these values are mapped to button bits for consistency.
Position tracked devices
Specifies sensor flags.
Tracking capability bits reported by the device. Used with ovr_GetTrackingCaps.
Specifies the coordinate system ovrTrackingState returns tracking poses in. Used with ovr_SetTrackingOriginType()