|
| 1 | +# Simple OpenVR Driver Tutorial |
| 2 | +I created this driver as a demonstration for how to write some of the most common things a SteamVR/OpenVR driver would want to do. You will need to understand C++11 and some C++17 features at least to make the most use of this repo. It features: |
| 3 | + |
| 4 | +- [Reading and writing configuration files]() |
| 5 | +- [Tracked HMD]() |
| 6 | +- [Tracked Controllers]() (todo) |
| 7 | +- [Tracked Trackers]() (todo) |
| 8 | +- [Tracking References (base stations)]() (todo) |
| 9 | + |
| 10 | +## Building |
| 11 | +- Clone the project and submodules |
| 12 | + - `git clone --recursive https://github.com/terminal29/Simple-OpenVR-Driver-Tutorial.git` |
| 13 | +- Build project with CMake |
| 14 | + - `cd Simple-OpenVR-Driver-Tutorial && cmake .` |
| 15 | +- Open project with Visual Studio and hit build |
| 16 | + - Driver folder structure and files will be copied to the output folder as `example`. |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +There are two ways to "install" this plugin: |
| 21 | + |
| 22 | +- Find your SteamVR driver directory, which should be at: |
| 23 | + `C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers` |
| 24 | + and copy the `example` directory from the project's build directory into the SteamVR drivers directory. Your folder structure should look something like this: |
| 25 | + |
| 26 | + |
| 27 | +or |
| 28 | + |
| 29 | +- Navigate to `C:\Users\<Username>\AppData\Local\openvr` and find the `openvrpaths.vrpath` file. Open this file with your text editor of choice, and under `"external_drivers"`, add another entry with the location of the `example` folder. For example mine looks like this after adding the entry: |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "config" : |
| 34 | + [ |
| 35 | + "C:\\Program Files (x86)\\Steam\\config", |
| 36 | + "c:\\program files (x86)\\steam\\config" |
| 37 | + ], |
| 38 | + "external_drivers" : |
| 39 | + [ |
| 40 | + "C:\\Users\\<Username>\\Documents\\Programming\\c++\\Simple-OpenVR-Driver-Tutorial\\build\\Debug\\example" |
| 41 | + ], |
| 42 | + "jsonid" : "vrpathreg", |
| 43 | + "log" : |
| 44 | + [ |
| 45 | + "C:\\Program Files (x86)\\Steam\\logs", |
| 46 | + "c:\\program files (x86)\\steam\\logs" |
| 47 | + ], |
| 48 | + "runtime" : |
| 49 | + [ |
| 50 | + "C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR" |
| 51 | + ], |
| 52 | + "version" : 1 |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +## Debugging |
| 57 | +Debugging SteamVR is not as simple as it seems because of the startup procedure it uses. The SteamVR ecosystem consists of a couple programs: |
| 58 | + |
| 59 | + - **vrserver**: the driver host |
| 60 | + - **vrcompositor**: the render engine |
| 61 | + - **vrmonitor**: the popup that displays status information |
| 62 | + - **vrdashboard**: the VR menu/overlay |
| 63 | + - **vrstartup**: a program to start everything up |
| 64 | + |
| 65 | + To debug effectively in Visual Studio, you can use an extension called [Microsoft Child Process Debugging Power Tool](https://marketplace.visualstudio.com/items?itemName=vsdbgplat.MicrosoftChildProcessDebuggingPowerTool) and enable debugging child processes, disable debugging for all other child processes, and add `vrserver.exe` as a child process to debug as below: |
| 66 | + |
| 67 | + |
| 68 | +Set the program the project should run in debug mode to **vrstartup** (Usually located `C:\Program Files (x86)\Steam\steamapps\common\SteamVR\bin\win64\vrstartup.exe`). Now we can start up SteamVR without needing to go through Steam, and can properly startup all the other programs vrserver needs. |
| 69 | + |
| 70 | + |
| 71 | +## License |
| 72 | +MIT License |
| 73 | + |
| 74 | +Copyright (c) 2020 Jacob Hilton (Terminal29) |
| 75 | + |
| 76 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 77 | +of this software and associated documentation files (the "Software"), to deal |
| 78 | +in the Software without restriction, including without limitation the rights |
| 79 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 80 | +copies of the Software, and to permit persons to whom the Software is |
| 81 | +furnished to do so, subject to the following conditions: |
| 82 | + |
| 83 | +The above copyright notice and this permission notice shall be included in all |
| 84 | +copies or substantial portions of the Software. |
| 85 | + |
| 86 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 87 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 88 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 89 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 90 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 91 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 92 | +SOFTWARE. |
0 commit comments