### Example OpenVR Configuration File Source: https://github.com/valvesoftware/openvr/wiki/The-JSON-File-(Lighthouse-Devices) This is a comprehensive example of an OpenVR configuration file in JSON format. It includes settings for device properties, tracking transforms, and Lighthouse-specific configurations. ```json { "device" : { "eye_target_height_in_pixels" : 1080, "eye_target_width_in_pixels" : 960, "first_eye" : "eEYE_LEFT", "last_eye" : "eEYE_RIGHT", "num_windows" : 1, "persistence" : 0.01666999980807304, "physical_aspect_x_over_y" : 0.8000000119209290 }, "device_class" : "controller", "device_pid" : 8192, "device_serial_number" : "LHR-F8DE9EBE", "device_vid" : 10462, "display_edid" : [ "", "" ], "lens_separation" : 0.06230000033974648, "lighthouse_config" : { "channelMap" : [ 17, 15, 13, 21, 19 ], "modelNormals" : [ [ 0, 0, -1 ], [ -0.13309992849826813, 0.11159992963075638, -0.98479938507080078 ], [ 0.11159992963075638, 0.13309992849826813, -0.98479938507080078 ], [ 0.13309992849826813, -0.11159992963075638, -0.98479938507080078 ], [ -0.11159992963075638, -0.13309992849826813, -0.98479938507080078 ] ], "modelPoints" : [ [ -0.0015368221793323755, 0.017447538673877716, -0.0040629836730659008 ], [ -0.046612702310085297, 0.039085414260625839, 0.011825915426015854 ], [ 0.039518974721431732, 0.046799946576356888, 0.011834526434540749 ], [ 0.046315468847751617, -0.038777932524681091, 0.01167147234082222 ], [ -0.03922756016254425, -0.046778313815593719, 0.011606470681726933 ] ] }, "manufacturer" : "", "model_number" : "", "render_model" : "lighthouse_ufo", "revision" : 3, "tracking_to_eye_transform" : [ { "distortion" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "distortion_blue" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "distortion_red" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "extrinsics" : [ [ 1.0, 0.0, 0.0, 0.03115000016987324 ], [ 0.0, 1.0, 0.0, 0.0 ], [ 0.0, 0.0, 1.0, 0.0 ] ], "grow_for_undistort" : 0.0, "intrinsics" : [ [ 1.250, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, -1.0 ] ], "undistort_r2_cutoff" : 1.50 }, { "distortion" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "distortion_blue" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "distortion_red" : { "center_x" : 0.0, "center_y" : 0.0, "coeffs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "type" : "DISTORT_DPOLY3" }, "extrinsics" : [ [ 1.0, 0.0, 0.0, -0.03115000016987324 ], [ 0.0, 1.0, 0.0, 0.0 ], [ 0.0, 0.0, 1.0, 0.0 ] ], "grow_for_undistort" : 0.0, "intrinsics" : [ [ 1.250, 0.0, 0.0 ], [ 0.0, 1.0, 0.0 ], [ 0.0, 0.0, -1.0 ] ], "undistort_r2_cutoff" : 1.50 } ], "head" : { "plus_x" : [ 1, 0, 0 ], "plus_z" : [ 0, 0, 1 ], "position" : [ 0, 0, 0 ] }, "imu" : { "acc_bias" : [ 0, 0, 0 ], "acc_scale" : [ 1, 1, 1 ], "gyro_bias" : [ 0, 0, 0 ], "gyro_scale" : [ 1, 1, 1 ], "plus_x" : [ 0, 1, 0 ], "plus_z" : [ 1, 0, 0 ], "position" : [ 0.0034600000362843275, 0.0013079999480396509, 0.077326998114585876 ] }, "type" : "Lighthouse_HMD" } ``` -------------------------------- ### Complete VR Application Render Loop Source: https://context7.com/valvesoftware/openvr/llms.txt A complete example showing the standard VR rendering loop structure with initialization, input handling, stereo rendering, and frame submission. Requires OpenVR initialization and graphics setup. ```cpp #include class VRApplication { vr::IVRSystem* m_pHMD = nullptr; vr::TrackedDevicePose_t m_poses[vr::k_unMaxTrackedDeviceCount]; uint32_t m_renderWidth, m_renderHeight; public: bool Init() { vr::EVRInitError error; m_pHMD = vr::VR_Init(&error, vr::VRApplication_Scene); if (error != vr::VRInitError_None) { printf("VR Init failed: %s\n", vr::VR_GetVRInitErrorAsEnglishDescription(error)); return false; } if (!vr::VRCompositor()) { printf("Compositor not available\n"); return false; } m_pHMD->GetRecommendedRenderTargetSize(&m_renderWidth, &m_renderHeight); // Initialize graphics, create framebuffers... return true; } void RunMainLoop() { while (!shouldQuit) { // 1. Handle system events HandleVREvents(); // 2. Update input state UpdateInput(); // 3. Wait for poses (blocks until optimal render time) vr::VRCompositor()->WaitGetPoses( m_poses, vr::k_unMaxTrackedDeviceCount, nullptr, 0 ); // 4. Update game logic with new poses UpdateGameLogic(); // 5. Render both eyes RenderStereoTargets(); // 6. Submit frames to compositor SubmitFrames(); // 7. Render companion window (optional) RenderCompanionWindow(); SwapBuffers(); } } void RenderStereoTargets() { // Render left eye BindLeftEyeFramebuffer(); glViewport(0, 0, m_renderWidth, m_renderHeight); RenderScene(vr::Eye_Left); // Render right eye BindRightEyeFramebuffer(); glViewport(0, 0, m_renderWidth, m_renderHeight); RenderScene(vr::Eye_Right); } void SubmitFrames() { vr::Texture_t leftTex = { (void*)(uintptr_t)m_leftEyeTexture, vr::TextureType_OpenGL, vr::ColorSpace_Gamma }; vr::VRCompositor()->Submit(vr::Eye_Left, &leftTex); vr::Texture_t rightTex = { (void*)(uintptr_t)m_rightEyeTexture, vr::TextureType_OpenGL, vr::ColorSpace_Gamma }; vr::VRCompositor()->Submit(vr::Eye_Right, &rightTex); } void Shutdown() { if (m_pHMD) { vr::VR_Shutdown(); m_pHMD = nullptr; } } }; int main() { VRApplication app; if (!app.Init()) { return 1; } app.RunMainLoop(); app.Shutdown(); return 0; } ``` -------------------------------- ### Example: Creating and Updating Input Components in OpenVR Source: https://github.com/valvesoftware/openvr/blob/master/docs/Driver_API_Documentation.md This example demonstrates how to create scalar and boolean input components and then update their values. It shows the typical workflow of initializing components and then updating them with new data, using a time offset of 0. ```c++ //Make sure that these are also accessible when needed to update the components vr::VRInputComponentHandle_t trackpadX; vr::VRInputComponentHandle_t trackpadY; vr::VRInputComponentHandle_t trackpadTouch; vr::VRInputComponentHandle_t trackpadClick; vr::VRDriverInput()->CreateScalarComponent(props, "/input/trackpad/x", &trackpadX, vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateScalarComponent(props, "/input/trackpad/y", &trackpadY, vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateBooleanComponent(props, "/input/trackpad/touch", &trackpadTouch); vr::VRDriverInput()->CreateBooleanComponent(props, "/input/trackpad/click", &trackpadClick); //... some time later when the hardware sends data vr::VRDriverInput()->UpdateScalarComponent(trackpadX, myData.trackpadX, 0); vr::VRDriverInput()->UpdateScalarComponent(trackpadY, myData.trackpadY, 0); vr::VRDriverInput()->UpdateBooleanComponent(trackpadTouch, myData.trackpadTouch, 0); vr::VRDriverInput()->UpdateBooleanComponent(trackpadClick, myData.trackpadClick, 0); ``` -------------------------------- ### Example Action Manifest File Source: https://context7.com/valvesoftware/openvr/llms.txt An example JSON file defining actions, action sets, default bindings, and localization for the OpenVR action-based input system. This file maps physical controller inputs to semantic actions. ```json { "default_bindings": [ { "controller_type": "vive_controller", "binding_url": "bindings_vive.json" }, { "controller_type": "knuckles", "binding_url": "bindings_knuckles.json" } ], "actions": [ { "name": "/actions/gameplay/in/Grab", "type": "boolean" }, { "name": "/actions/gameplay/in/Teleport", "type": "boolean" }, { "name": "/actions/gameplay/in/Move", "type": "vector2" }, { "name": "/actions/gameplay/in/HandPose", "type": "pose" }, { "name": "/actions/gameplay/out/Haptic", "type": "vibration" } ], "action_sets": [ { "name": "/actions/gameplay", "usage": "leftright" } ], "localization": [ { "language_tag": "en_US", "/actions/gameplay/in/Grab": "Grab Object", "/actions/gameplay/in/Teleport": "Teleport" } ] } ``` -------------------------------- ### Example Default Bindings for Half-Life: Alyx Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/README.md This is an example of the 'default_bindings' structure for Half-Life: Alyx, specifying the binding URL for a 'sample_controller'. ```json { "default_bindings": [ { "app_key": "steam.app.546560", "binding_url": "default_bindings/steam.app.546560_sample_controller.json" } ] } ``` -------------------------------- ### Get OpenVR Runtime Path Source: https://github.com/valvesoftware/openvr/wiki/API-Documentation Retrieve the installation path of the OpenVR runtime using `VR_RuntimePath`. ```cpp char *vr::VR_RuntimePath() ``` -------------------------------- ### Get Pose Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Gets the initial pose of the device. Future poses should be provided via IServerDriverHost::TrackedDevicePoseUpdated(). ```cpp DriverPose_t GetPose() ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/CMakeLists.txt Initializes CMake version and sets the project name. The target name is used for the binary name. ```cmake cmake_minimum_required(VERSION 3.7.1) # This is your project name set(TARGET_NAME sample) # This is the name that the binary will be called (driver_) set(DRIVER_NAME "driver_${TARGET_NAME}") project(${TARGET_NAME}) ``` -------------------------------- ### Get Controller State Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Returns the initial state of a controller. ```cpp VRControllerState_t GetControllerState() ``` -------------------------------- ### Action Manifest Configuration Source: https://github.com/valvesoftware/openvr/wiki/SteamVR-Skeletal-Input Example of how to define a skeletal action in the application's action manifest file. ```APIDOC ## Action Manifest Configuration ### Description Defines a skeletal action for either the left or right hand within the application's action manifest file. ### Method N/A (Configuration File) ### Endpoint N/A (Action Manifest File) ### Parameters N/A ### Request Example ```json { "name": "/actions/demo/in/lefthand_anim", "type": "skeleton", "skeleton": "/skeleton/hand/left" } ``` ### Response N/A ``` -------------------------------- ### Example Projection Raw Values Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Illustrates typical values for GetProjectionRaw for a 90-degree FOV HMD. Note that 'bottom' and 'top' are reversed. ```c++ *pfLeft = -1.0; *pfRight = 1.0; *pfTop = -1.0; *pfBottom = 1.0; ``` -------------------------------- ### Example Usage of Component Updates Source: https://github.com/valvesoftware/openvr/blob/master/docs/Driver_API_Documentation.md Demonstrates the creation and subsequent updating of scalar and boolean components, simulating hardware data input. ```APIDOC ## Example Usage of Component Updates ### Description This example shows how to create scalar and boolean input components and then update their values based on simulated hardware data. ### Method Driver Input API Functions (C++) ### Endpoint N/A (Internal Driver Functions) ### Parameters None for this example snippet itself, but refers to parameters of `CreateScalarComponent`, `CreateBooleanComponent`, `UpdateScalarComponent`, and `UpdateBooleanComponent`. ### Request Example ```cpp // Assume 'props' is a valid VR_Init VRSettings object or similar context vr::VRInputComponentHandle_t trackpadX; vr::VRInputComponentHandle_t trackpadY; vr::VRInputComponentHandle_t trackpadTouch; vr::VRInputComponentHandle_t trackpadClick; // Create components vr::VRDriverInput()->CreateScalarComponent(props, "/input/trackpad/x", &trackpadX, vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateScalarComponent(props, "/input/trackpad/y", &trackpadY, vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateBooleanComponent(props, "/input/trackpad/touch", &trackpadTouch); vr::VRDriverInput()->CreateBooleanComponent(props, "/input/trackpad/click", &trackpadClick); // ... later, when hardware data is received (e.g., myData.trackpadX) // Update scalar components vr::VRDriverInput()->UpdateScalarComponent(trackpadX, myData.trackpadX, 0.0); vr::VRDriverInput()->UpdateScalarComponent(trackpadY, myData.trackpadY, 0.0); // Update boolean components vr::VRDriverInput()->UpdateBooleanComponent(trackpadTouch, myData.trackpadTouch, 0.0); vr::VRDriverInput()->UpdateBooleanComponent(trackpadClick, myData.trackpadClick, 0.0); ``` ### Response No direct response for this example, as it demonstrates internal driver logic. ``` -------------------------------- ### Get Action Handle Source: https://github.com/valvesoftware/openvr/wiki/SteamVR-Input Convert action paths into runtime-usable handles during application initialization. Use these handles when interacting with actions. ```cpp vr::VRInput()->GetActionHandle( "/actions/my_app/in/DoSomething" ); ``` -------------------------------- ### Utility Functions Source: https://github.com/valvesoftware/openvr/wiki/API-Documentation Utility functions for checking HMD presence, runtime installation status, and retrieving runtime paths. ```APIDOC ## Utility Functions ### Description Provides utility functions to query the status and location of the OpenVR runtime and connected HMDs. ## VR_IsHmdPresent ### Description Returns `true` if the system detects an HMD is present. This is a faster check than initializing the entire OpenVR API. ### Method `bool vr::VR_IsHmdPresent()` ### Endpoint None ### Parameters None ### Request Example ```c++ if (vr::VR_IsHmdPresent()) { // Enable VR-specific UI elements } ``` ### Response #### Success Response (200) - **bool**: `true` if an HMD is present, `false` otherwise. #### Response Example ```c++ // true or false ``` ## VR_IsRuntimeInstalled ### Description Returns `true` if the OpenVR runtime is installed on the system. ### Method `bool vr::VR_IsRuntimeInstalled()` ### Endpoint None ### Parameters None ### Request Example ```c++ if (vr::VR_IsRuntimeInstalled()) { // Proceed with VR initialization } ``` ### Response #### Success Response (200) - **bool**: `true` if the OpenVR runtime is installed, `false` otherwise. #### Response Example ```c++ // true or false ``` ## VR_RuntimePath ### Description Returns the installation path of the OpenVR runtime. ### Method `char *vr::VR_RuntimePath()` ### Endpoint None ### Parameters None ### Request Example ```c++ char* path = vr::VR_RuntimePath(); if (path) { // Use the path } ``` ### Response #### Success Response (200) - **char***: A pointer to a string containing the OpenVR runtime installation path. Returns `NULL` if the path cannot be determined. #### Response Example ```c++ "C:\Program Files (x86)\Steam\steamapps\common\SteamVR\" ``` ## VR_GetVRInitErrorAsSymbol ### Description Converts a `vr::EVRInitError` enum value into its string representation. This function can be called at any time. ### Method `const char *VR_GetVRInitErrorAsSymbol( vr::EVRInitError error );` ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **error** (`vr::EVRInitError`): The error code to convert to a string. ### Request Example ```c++ vr::EVRInitError eError = vr::VRInitError_Init_VRRuntimeNotFound; const char* errorSymbol = VR_GetVRInitErrorAsSymbol(eError); // errorSymbol will be "VRInitError_Init_VRRuntimeNotFound" ``` ### Response #### Success Response (200) - **const char***: A string representation of the `vr::EVRInitError` enum value. #### Response Example ```c++ "VRInitError_Init_VRRuntimeNotFound" ``` ## VR_GetGenericInterface ### Description Requests a specific OpenVR interface by its version string. Returns `NULL` if the interface is not found or if `vr::VR_Init()` has not been successfully called. ### Method `void *VR_GetGenericInterface( const char *pchInterfaceVersion, vr::EVRInitError *peError )` ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **pchInterfaceVersion** (`const char *`): The string name of the interface version to request (e.g., `IVRSystem_001`). * **peError** (`vr::EVRInitError *`): Output parameter to store any error code encountered. Will be `NULL` if the interface is successfully retrieved. ### Request Example ```c++ vr::EVRInitError eError = vr::VRInitError_None; void* pInterface = VR_GetGenericInterface("IVRSystem_001", &eError); if (eError == vr::VRInitError_None && pInterface != NULL) { vr::IVRSystem* pVRSystem = static_cast(pInterface); // Use the IVRSystem interface } ``` ### Response #### Success Response (200) - **void***: A pointer to the requested interface if found. Returns `NULL` on failure. #### Response Example ```c++ // A pointer to the requested interface, or NULL if not found or VR_Init failed. ``` ## VR_IsInterfaceVersionValid ### Description Checks if a given interface name and version string is supported by the currently installed OpenVR runtime. ### Method `bool VR_IsInterfaceVersionValid( const char *pchInterfaceVersion )` ### Endpoint None ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **pchInterfaceVersion** (`const char *`): The string name of the interface version to check (e.g., `IVRSystem_001`). ### Request Example ```c++ if (VR_IsInterfaceVersionValid("IVRSystem_001")) { // The interface version is supported } ``` ### Response #### Success Response (200) - **bool**: `true` if the interface version is valid and supported, `false` otherwise. #### Response Example ```c++ // true or false ``` ``` -------------------------------- ### Build Directory Setup Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/README.md Instructions for creating a build directory and running CMake to generate a solution file, typically for use with Visual Studio. ```bash mkdir build cd build cmake .. ``` -------------------------------- ### Navigate to Samples Directory and Create Build Directory Source: https://github.com/valvesoftware/openvr/blob/master/samples/README.md Change the current directory to 'samples' and create a 'build' subdirectory for build artifacts. This is the initial step for both Unix and Windows builds. ```bash cd samples mkdir build; cd build ``` -------------------------------- ### SteamVR Skeletal Input File Paths Source: https://github.com/valvesoftware/openvr/wiki/Hand-Skeleton Reference files for the skeletal hand models are provided with the SteamVR installation. These include both GLTF and FBX formats, with and without example meshes. ```text Steam\steamapps\common\SteamVR\resources\rendermodels\vr_glove\vr_glove_left_model.fbx Steam\steamapps\common\SteamVR\resources\rendermodels\vr_glove\vr_glove_left_model.glb Steam\steamapps\common\SteamVR\resources\rendermodels\vr_glove\vr_glove_right_model.fbx Steam\steamapps\common\SteamVR\resources\rendermodels\vr_glove\vr_glove_right_model.glb ``` ```text Steam\steamapps\common\SteamVR\resources\skeletons\vr_glove_left_skeleton.fbx Steam\steamapps\common\SteamVR\resources\skeletons\vr_glove_left_skeleton.glb Steam\steamapps\common\SteamVR\resources\skeletons\vr_glove_right_skeleton.fbx Steam\steamapps\common\SteamVR\resources\skeletons\vr_glove_right_skeleton.glb ``` -------------------------------- ### Get Pose Action Data Source: https://github.com/valvesoftware/openvr/wiki/SteamVR-Input Gets the pose of a pose or skeleton action as of a predicted time. ```APIDOC ## Get Pose Action Data ### Description Gets the pose of the pose action as of the prediction time. This is useful for synchronizing visuals with user movement. ### Method `EVRInputError IVRInput::GetPoseActionData( VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, InputPoseActionData_t *pActionData, uint32_t unActionDataSize )` ### Parameters #### Path Parameters - **action** (VRActionHandle_t) - Required - The handle of the pose or skeleton action to read the position for. - **eOrigin** (ETrackingUniverseOrigin) - Required - The tracking origin to return a pose relative to. - **fPredictedSecondsFromNow** (float) - Required - The time to generate a pose for. Pass in 0 to get poses relative to the most recent call to WaitGetPoses. - **pActionData** (InputPoseActionData_t *) - Required - A pointer to a InputPoseActionData_t struct. - **unActionDataSize** (uint32_t) - Required - Must be sizeof(InputPoseActionData_t) ### Request Example ```json { "action": "handle_to_pose_action", "eOrigin": "TrackingUniverseStanding", "fPredictedSecondsFromNow": 0.0, "pActionData": null, "unActionDataSize": "sizeof(InputPoseActionData_t)" } ``` ### Response #### Success Response (0 - VRInputError_None) - **bActive** (bool) - True if this action is bound to a present and active input source. - **activeOrigin** (VRInputValueHandle_t) - The input source that generated this state. - **pose** (TrackedDevicePose_t) - The pose of the action, including position and orientation. #### Response Example ```json { "bActive": true, "activeOrigin": "handle_to_origin", "pose": { "mDeviceToAbsoluteTracking": [ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0] ], "eTrackingState": "TrackingState_OwnedStationary", "bPoseIsValid": true } } ``` ``` -------------------------------- ### Include Directories Setup Source: https://github.com/valvesoftware/openvr/blob/master/samples/CMakeLists.txt Sets up include directories for the build, including OpenGL, GLEW, SDL2, Qt5, and OpenVR. Vulkan include directory is added conditionally for non-macOS systems. ```cmake include_directories( . ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} ${QT_INCLUDE_DIRS} ${OPENVR_INCLUDE_DIR} ) if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) include_directories(${VULKAN_INCLUDE_DIR}) endif() ``` -------------------------------- ### Get Overlay Transform Absolute Source: https://github.com/valvesoftware/openvr/wiki/IVROverlay::SetOverlayTransformAbsolute Gets the current absolute transform of an overlay, including the tracking origin it's relative to. ```APIDOC ## GET /OpenVR/GetOverlayTransformAbsolute ### Description Gets the current absolute transform of the overlay. Returns an error if the overlay transform is not VROverlayTransform_Absolute. ### Method GET ### Endpoint /OpenVR/GetOverlayTransformAbsolute ### Parameters #### Query Parameters - **ulOverlayHandle** (VROverlayHandle_t) - Required - Handle of the overlay to get absolute transform for ### Response #### Success Response (200) - **peTrackingOrigin** (TrackingUniverseOrigin *) - Receives tracking origin that the transform is relative to - **pmatTrackingOriginToOverlayTransform** (HmdMatrix34_t *) - Transform relative to the specified tracking origin - **result** (VROverlayError) - Indicates success or failure of the operation. #### Response Example ```json { "peTrackingOrigin": "TrackingUniverseStanding", "pmatTrackingOriginToOverlayTransform": { "m": [ [0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.7, 0.8], [0.9, 1.0, 1.1, 1.2] ] }, "result": "VROverlayError_None" } ``` ``` -------------------------------- ### PostPresent Implementation Steps Source: https://github.com/valvesoftware/openvr/wiki/Driver-direct-mode In your PostPresent implementation, block until 'running start', sample and submit tracked device poses, and call VsyncEvent with the time until the upcoming vsync for accurate prediction. ```cpp void IVRDriverDirectModeComponent::PostPresent(void* pTexture) { // 1) Block until running start // ... // 2) Sample and submit tracked device poses vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDevices]; // ... fill poses ... m_pServerDriverHost->TrackedDevicePoseUpdated(0, poses, vr::k_unMaxTrackedDevices); // 3) Call VsyncEvent with time until upcoming vsync double flSecondsUntilVsync = 0.0; // ... calculate flSecondsUntilVsync ... m_pServerDriverHost->VsyncEvent(flSecondsUntilVsync); } ``` -------------------------------- ### Get Compositor_FrameTiming Size in C# Source: https://github.com/valvesoftware/openvr/wiki/Compositor_FrameTiming Use this code to get the size of the Compositor_FrameTiming struct in C# for compatibility with previous versions. ```csharp (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming)); ``` -------------------------------- ### Create Input Components and Set Profile Path Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/README.md In the Activate method, retrieve the property container, set the input profile path, and create various input components like boolean, scalar, and haptic. Ensure the profile path is correctly formatted. ```c++ void ControllerDevice::Activate(uint32_t unObjectId) { ... // Properties are stored in containers, usually one container per device index. We need to get this container to set // The properties we want, so we call this to retrieve a handle to it. vr::PropertyContainerHandle_t container = vr::VRProperties()->TrackedDeviceToPropertyContainer( my_controller_index_ ); // Tell the runtime where our input profile is located vr::VRProperties()->SetStringProperty(container, vr::Prop_InputProfilePath_String, "{}/resources/input/_profile.json"); vr::VRDriverInput()->CreateBooleanComponent(container, "/input/a/click", &my_input_handles_[kInputHandle_A_click]); vr::VRDriverInput()->CreateBooleanComponent(container, "/input/a/touch", &my_input_handles_[kInputHandle_A_touch]); vr::VRDriverInput()->CreateScalarComponent(container, "/input/trigger/value", &my_input_handles_[kInputHandle_trigger_value], vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedOneSided); vr::VRDriverInput()->CreateBooleanComponent(container, "/input/trigger/click", &my_input_handles_[kInputHandle_trigger_click]); vr::VRDriverInput()->CreateScalarComponent(container, "/input/joystick/x", &my_input_handles_[kInputHandle_joystick_x], vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateScalarComponent(container, "/input/joystick/y", &my_input_handles_[kInputHandle_joystick_y], vr::VRScalarType_Absolute, vr::VRScalarUnits_NormalizedTwoSided); vr::VRDriverInput()->CreateBooleanComponent(container, "/input/joystick/click", &my_input_handles_[kInputHandle_joystick_click]); vr::VRDriverInput()->CreateHapticComponent(container, "/output/haptic", &my_input_handles_[kInputHandle_haptic]); } ``` -------------------------------- ### Build OpenVR on Windows Source: https://github.com/valvesoftware/openvr/blob/master/samples/thirdparty/glew/glew-1.11.0/README.txt Instructions for building on Windows using Visual Studio. ```bash use the project file in build/vc6/ ``` -------------------------------- ### Get Overlay Width Source: https://github.com/valvesoftware/openvr/wiki/IVROverlay::SetOverlayWidthInMeters Gets the current width of the overlay quad in meters. The height is a function of the width and the overlay's texture aspect ratio. ```APIDOC ## GET /GetOverlayWidthInMeters ### Description Gets the width of the overlay quad in meters. ### Method GET ### Endpoint /GetOverlayWidthInMeters ### Parameters #### Path Parameters - **ulOverlayHandle** (VROverlayHandle_t) - Required - Handle of the overlay to get width for #### Query Parameters - **pfWidthInMeters** (float*) - Required - Receives width of the overlay in meters ### Request Example ```json { "ulOverlayHandle": "overlay_handle_value" } ``` ### Response #### Success Response (200) - **result** (VROverlayError) - Indicates success or failure of the operation. - **pfWidthInMeters** (float) - The current width of the overlay in meters. #### Response Example ```json { "result": "Success", "pfWidthInMeters": 1.2 } ``` ``` -------------------------------- ### Example driver.vrdrivermanifest Configuration Source: https://github.com/valvesoftware/openvr/blob/master/docs/Driver_API_Documentation.md This is a sample driver.vrdrivermanifest file. Ensure all JSON is valid, as trailing commas will cause runtime failures. The 'name' field must match the driver's root folder name and the driver DLL name. ```json { "alwaysActivate": false, "name": "barebones", "directory": "", "resourceOnly": false, "hmd_presence": [ "*.*" ] } ``` -------------------------------- ### Get Overlay Auto Curve Distance Range Source: https://github.com/valvesoftware/openvr/wiki/IVROverlay::SetOverlayAutoCurveDistanceRangeInMeters Gets the distance range in meters used to curve the overlay around the viewer. This is only used by the high-quality overlay. ```APIDOC ## GET /overlay/GetOverlayAutoCurveDistanceRangeInMeters ### Description Gets the distance range in meters used to curve the overlay around the viewer. This is only used by the high-quality overlay. ### Method GET ### Endpoint /overlay/GetOverlayAutoCurveDistanceRangeInMeters ### Parameters #### Path Parameters - **ulOverlayHandle** (VROverlayHandle_t) - Required - Handle of the overlay to get the ranges for ### Request Example { "ulOverlayHandle": "overlay_handle_value" } ### Response #### Success Response (200) - **pfMinDistanceInMeters** (float *) - Receives distance where the overlay will be the most curved - **pfMaxDistanceInMeters** (float *) - Receives distance where the overlay will be the least curved - **result** (VROverlayError) - Indicates success or failure of the operation. #### Response Example { "pfMinDistanceInMeters": 0.5, "pfMaxDistanceInMeters": 2.0, "result": "VROverlayError_None" } ``` -------------------------------- ### Build OpenVR on Unix Source: https://github.com/valvesoftware/openvr/blob/master/samples/thirdparty/glew/glew-1.11.0/README.txt Standard build process for Unix-like systems. Assumes a downloaded tarball. ```bash make ``` ```bash sudo -s ``` ```bash make install ``` ```bash make clean ``` -------------------------------- ### Get Overlay Input Method Source: https://github.com/valvesoftware/openvr/wiki/IVROverlay::SetOverlayInputMethod Gets the current input method settings for the specified overlay. Dashboard overlays are always VROverlayInputMethod_Mouse. Other overlays default to VROverlayInputMethod_None, but can be set to use automatic mouse interaction. ```APIDOC ## GET /overlay/inputMethod/{ulOverlayHandle} ### Description Gets the current input method settings for the specified overlay. Dashboard overlays are always VROverlayInputMethod_Mouse. Other overlays default to VROverlayInputMethod_None, but can be set to use automatic mouse interaction. ### Method GET ### Endpoint /overlay/inputMethod/{ulOverlayHandle} ### Parameters #### Path Parameters - **ulOverlayHandle** (VROverlayHandle_t) - Required - Handle of the overlay to get input settings for ### Response #### Success Response (200) - **VROverlayError** (integer) - Indicates success or failure of the operation. A value of 0 typically means success. - **peInputMethod** (VROverlayInputMethod) - Receives the overlay's input method. #### Response Example ```json { "VROverlayError": 0, "peInputMethod": "VROverlayInputMethod_Mouse" } ``` ``` -------------------------------- ### Initialize and Add Devices in DeviceProvider::Init Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/README.md Instantiate `ControllerDevice` objects for left and right hands and register them with the OpenVR runtime using `TrackedDeviceAdded`. Ensure each device has a unique serial number and is correctly classified. ```c++ void DeviceProvider::Init() { my_left_device_ = std::make_unique(vr::TrackedControllerRole_LeftHand); vr::VRServerDriverHost()->TrackedDeviceAdded("", vr::TrackedDeviceClass_Controller, my_left_device_.get()); my_right_device_ = std::make_unique(vr::TrackedControllerRole_RightHand); vr::VRServerDriverHost()->TrackedDeviceAdded("", vr::TrackedDeviceClass_Controller, my_right_device_.get()); } ``` -------------------------------- ### GetOverlayTextureBounds Source: https://github.com/valvesoftware/openvr/wiki/IVROverlay::SetOverlayTextureBounds Gets the part of the texture to use for the overlay. ```APIDOC ## GET /GetOverlayTextureBounds ### Description Gets the part of the texture to use for the overlay. ### Method GET ### Endpoint /GetOverlayTextureBounds ### Parameters #### Path Parameters - **ulOverlayHandle** (VROverlayHandle_t) - Required - Handle of the overlay to get texture bounds for #### Query Parameters - **pOverlayTextureBounds** (VRTextureBounds_t) - Output - Bounds to get ### Response #### Success Response (200) - **VROverlayError** (integer) - Indicates success or failure of the operation. ``` -------------------------------- ### OpenVR CMake Project Setup Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/CMakeLists.txt Initializes the CMake build system for the OpenVR project. Sets the minimum required CMake version and project name. ```cmake cmake_minimum_required(VERSION 3.7.1) project(openvr_samples) ``` -------------------------------- ### Enable Experimental Drivers Source: https://github.com/valvesoftware/openvr/blob/master/samples/thirdparty/glew/glew-1.11.0/doc/basic.html Set the glewExperimental global switch to GL_TRUE before calling glewInit() to expose all extensions with valid entry points, useful for experimental drivers. ```c glewExperimental = GL_TRUE; glewInit(); ``` -------------------------------- ### Get IPD Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Retrieves the current Interpupillary Distance (IPD) in meters. ```cpp float GetIPD() ``` -------------------------------- ### Basic DirectX12 Frame Timing (Simplified) Source: https://github.com/valvesoftware/openvr/wiki/DirectX12 This simplified example demonstrates a basic frame timing sequence using DirectX12 with SteamVR. It does not utilize explicit timing and is suitable for understanding the fundamental flow of presenting frames and updating poses. ```cpp IVRCompositor::WaitGetPoses // Application builds command list for left/right eye and companion window ExecuteCommandLists IVRCompositor::Submit (left eye) IVRCompositor::Submit (right eye) Swapchain Present // Repeat ``` -------------------------------- ### Implement IServerTrackedDeviceProvider Methods in OpenVR Source: https://github.com/valvesoftware/openvr/blob/master/samples/drivers/drivers/tutorial/README.md Implement the methods of the DeviceProvider class in device_provider.cpp. The Init method initializes the driver context and logs a message, while Cleanup cleans it up. Other methods are stubbed or return default values. ```cpp #include "device_provider.h" vr::EVRInitError DeviceProvider::Init(vr::IVRDriverContext* pDriverContext) { VR_INIT_SERVER_DRIVER_CONTEXT(pDriverContext); vr::VRDriverLog()->Log("Hello world!"); return vr::VRInitError_None; } void DeviceProvider::Cleanup() { VR_CLEANUP_SERVER_DRIVER_CONTEXT(); } const char* const* DeviceProvider::GetInterfaceVersions() { return vr::k_InterfaceVersions; } void DeviceProvider::RunFrame() { } bool DeviceProvider::ShouldBlockStandbyMode() { return false; } void DeviceProvider::EnterStandby() { } void DeviceProvider::LeaveStandby() { } ``` -------------------------------- ### Get Serial Number Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Returns the serial number of the tracked device. ```cpp const char *GetSerialNumber() ``` -------------------------------- ### Sample Driver Manifest JSON Source: https://github.com/valvesoftware/openvr/wiki/DriverManifest This is an example of a driver manifest file. It defines basic properties like the driver's name, activation behavior, and HMD presence. ```json { "alwaysActivate": false, "name" : "sample", "directory" : "", "resourceOnly" : false, "hmd_presence" : [ "*.*" ] } ``` -------------------------------- ### Get Model Number Source: https://github.com/valvesoftware/openvr/wiki/vr::ITrackedDeviceServerDriver-Overview Returns the model number of the tracked device. ```cpp const char *GetModelNumber() ``` -------------------------------- ### Explicit Timing Frame Loop (Advanced) Source: https://github.com/valvesoftware/openvr/wiki/DirectX12 This advanced example illustrates a frame timing loop for real-world applications using explicit timing with SteamVR. It involves pre-building command lists and using IVRCompositor::SubmitExplicitTimingData to manage GPU work timing. ```cpp Build rendering command lists for the next frame prior to calling IVRCompositor::WaitGetPoses // After IVRCompositor::WaitGetPoses returns, update transforms in command lists // Submit CB update command list(s) ExecuteCommandLists IVRCompositor::SubmitExplicitTimingData ExecuteCommandLists (rendering work) IVRCompositor::Submit (left eye) IVRCompositor::Submit (right eye) Swapchain Present IVRCompositor::PostPresentHandoff (optional) // Repeat ``` -------------------------------- ### Get Controller State Source: https://github.com/valvesoftware/openvr/wiki/IVRSystem::GetControllerState Retrieves the current state of a specified controller. ```APIDOC ## GET /api/controller/state ### Description Retrieves the current state of the controller identified by `unControllerDeviceIndex`. ### Method GET ### Endpoint `/api/controller/state ### Parameters #### Query Parameters - **unControllerDeviceIndex** (vr::TrackedDeviceIndex_t) - Required - The tracked device index of the controller to get the state of. - **pControllerState** (vr::VRControllerState_t *) - Required - A pointer to a struct that will be filled with the controller state. ### Response #### Success Response (200) - **bool** - Returns true if the state was successfully retrieved, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Get Action Origins Source: https://github.com/valvesoftware/openvr/wiki/SteamVR-Input Retrieves the action sources (origins) for a given action. ```APIDOC ## Get Action Origins ### Description Retrieves the action sources for an action. If the action has more origins than will fit in the array, only the number that will fit are returned. If the action has fewer origins, the extra array entries will be set to k_ulInvalidInputValueHandle. ### Method `EVRInputError GetActionOrigins( VRActionSetHandle_t actionSetHandle, VRActionHandle_t digitalActionHandle, VRInputValueHandle_t *originsOut, uint32_t originOutCount )` ### Parameters #### Path Parameters - **actionSetHandle** (VRActionSetHandle_t) - Required - Handle of the action set. - **digitalActionHandle** (VRActionHandle_t) - Required - Handle of the digital action. - **originsOut** (VRInputValueHandle_t *) - Required - Pointer to an array to store the origin handles. - **originOutCount** (uint32_t) - Required - The maximum number of origins to retrieve. ### Request Example ```json { "actionSetHandle": "handle_to_action_set", "digitalActionHandle": "handle_to_digital_action", "originsOut": null, "originOutCount": 16 } ``` ### Response #### Success Response (0 - VRInputError_None) - **originsOut** (VRInputValueHandle_t[]) - An array of handles representing the input sources for the action. #### Response Example ```json [ "handle_to_origin_1", "handle_to_origin_2" ] ``` ``` -------------------------------- ### Initialize GLEW Source: https://github.com/valvesoftware/openvr/blob/master/samples/thirdparty/glew/glew-1.11.0/doc/basic.html Initialize GLEW after creating a valid OpenGL rendering context. GLEW_OK indicates successful initialization. ```c #include #include ... glutInit(&argc, argv); glutCreateWindow("GLEW Test"); GLenum err = glewInit(); if (GLEW_OK != err) { /* Problem: glewInit failed, something is seriously wrong. */ fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); ... } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); ```