Skip to content

Commit e125113

Browse files
committed
Rename driver from "example" to "websocket_trackers"
1 parent 8bef044 commit e125113

40 files changed

+253
-232
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/.vs
22
/build
33
/CMakeFiles
4-
/driver_example.dir/
4+
/driver_websocket_trackers.dir/
55
/Release
66
/x64
77
ALL_BUILD.vcxproj
88
ALL_BUILD.vcxproj.filters
99
cmake_install.cmake
1010
CMakeCache.txt
11-
driver_example.vcxproj
12-
driver_example.vcxproj.filters
11+
driver_websocket_trackers.vcxproj
12+
driver_websocket_trackers.vcxproj.filters
1313
Simple_SteamVR_Driver_Tutorial.sln
1414
ZERO_CHECK.vcxproj
1515
ZERO_CHECK.vcxproj.filters

CMakeLists.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,44 @@ endif()
2424

2525
find_library(OPENVR_LIB openvr_api HINTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/openvr/lib/${PLATFORM_NAME}${PROCESSOR_ARCH}/" NO_DEFAULT_PATH )
2626

27-
# Example Driver
28-
set(DRIVER_NAME "example")
29-
set(EXAMPLE_PROJECT "driver_${DRIVER_NAME}")
27+
# websocket_trackers Driver
28+
set(DRIVER_NAME "websocket_trackers")
29+
set(websocket_trackers_PROJECT "driver_${DRIVER_NAME}")
3030
file(GLOB_RECURSE HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src/*.hpp")
3131
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src/*.cpp")
32-
add_library("${EXAMPLE_PROJECT}" SHARED "${HEADERS}" "${SOURCES}")
33-
34-
target_include_directories("${EXAMPLE_PROJECT}" PUBLIC "${OPENVR_INCLUDE_DIR}")
35-
target_include_directories("${EXAMPLE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/linalg")
36-
target_include_directories("${EXAMPLE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src/")
37-
target_include_directories("${EXAMPLE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
38-
target_include_directories("${EXAMPLE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/boost_1_69_0")
39-
target_link_directories("${EXAMPLE_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/boost_1_69_0")
40-
target_link_libraries("${EXAMPLE_PROJECT}" PUBLIC "${OPENVR_LIB}")
32+
add_library("${websocket_trackers_PROJECT}" SHARED "${HEADERS}" "${SOURCES}")
33+
34+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "${OPENVR_INCLUDE_DIR}")
35+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/linalg")
36+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src/")
37+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
38+
target_include_directories("${websocket_trackers_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/boost_1_69_0")
39+
target_link_directories("${websocket_trackers_PROJECT}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libraries/boost_1_69_0")
40+
target_link_libraries("${websocket_trackers_PROJECT}" PUBLIC "${OPENVR_LIB}")
4141
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src" PREFIX "Header Files" FILES ${HEADERS})
4242
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/driver_files/src" PREFIX "Source Files" FILES ${SOURCES})
43-
set_property(TARGET "${EXAMPLE_PROJECT}" PROPERTY CXX_STANDARD 17)
43+
set_property(TARGET "${websocket_trackers_PROJECT}" PROPERTY CXX_STANDARD 17)
4444

4545

4646

4747

4848

4949
# Copy driver assets to output folder
5050
add_custom_command(
51-
TARGET ${EXAMPLE_PROJECT}
51+
TARGET ${websocket_trackers_PROJECT}
5252
PRE_BUILD
5353
COMMAND ${CMAKE_COMMAND} -E copy_directory
5454
${CMAKE_SOURCE_DIR}/driver_files/driver/
55-
$<TARGET_FILE_DIR:${EXAMPLE_PROJECT}>
55+
$<TARGET_FILE_DIR:${websocket_trackers_PROJECT}>
5656
)
5757

5858
# Copy dll to output folder
5959
add_custom_command(
60-
TARGET ${EXAMPLE_PROJECT}
60+
TARGET ${websocket_trackers_PROJECT}
6161
POST_BUILD
6262
COMMAND ${CMAKE_COMMAND} -E copy
63-
$<TARGET_FILE:${EXAMPLE_PROJECT}>
64-
$<TARGET_FILE_DIR:${EXAMPLE_PROJECT}>/${DRIVER_NAME}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}/$<TARGET_FILE_NAME:${EXAMPLE_PROJECT}>
63+
$<TARGET_FILE:${websocket_trackers_PROJECT}>
64+
$<TARGET_FILE_DIR:${websocket_trackers_PROJECT}>/${DRIVER_NAME}/bin/${PLATFORM_NAME}${PROCESSOR_ARCH}/$<TARGET_FILE_NAME:${websocket_trackers_PROJECT}>
6565
)
6666

6767

README.md

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
# Websocket OpenVR Driver Tutorial
1+
# Websocket OpenVR Driver
2+
The aim of this repository is to give the end user a driver that hosts a local websocket server on their computer which they can connect to and spawn trackers in VR.
3+
It also echoes back the position of all currently active VR devices, allowing you to use the driver to find the position of a HMD using local websockets.
24

3-
This is an adaptation of the repository authored by terminal29, "Simple-OpenVR-Driver-Tutorial"
5+
This is desirable as it allows simple applications (such as web based applications) to interface with SteamVR without the hassle of setting up their own driver.
46

5-
The aim of this repository is to give the end user a driver that hosts a local websocket server on their computer which they can connect to and spawn trackers in VR using simple JSON.
7+
Finally, the driver also has the ability to host a simple webserver, which serves the files in `/resources/webserver` on port 8088.
8+
This can be accessed from: [http://localhost:8088](http://localhost:8088), which serves `/resources/webserver/index.html`.
69

7-
This is desirable as it allows simple Python or JavaScript applications to interface with SteamVR and create trackers.
8-
This means you can write simple Python code to, for example, emulate a hip tracker using neural networks and a webcam and easily add it to SteamVR.
10+
This is built upon the work of [terminal29's](https://github.com/terminal29) ["Simple-OpenVR-Driver-Tutorial"](https://github.com/terminal29/Simple-OpenVR-Driver-Tutorial), the license for which is found at the bottom of this document.
11+
12+
---
13+
14+
# Quick setup
15+
A release file for this driver can be downloaded [here](https://github.com/John-Dean/OpenVR-Tracker-Websocket-Driver/releases/latest/download/driver.zip).
16+
17+
## Installation
18+
Find your SteamVR driver directory, which should be at:
19+
`C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers`
20+
and copy the `websocket_trackers` directory into the SteamVR drivers directory.
21+
22+
---
923

1024
# Websocket server
11-
The websocket server can be connected to at:
25+
The websocket server is hosted on port 8082, and can be connected to at:
1226
`ws://127.0.0.1:8082`
1327

14-
And commands are sent using JSON in the format:
28+
## Creating/updating trackers
29+
Commands are sent using a JSON object in the format:
1530
`{"id":"tracker_0","x":0,"y":1,"z":2}`
1631

17-
Where the following are valid keys:
32+
Where the following are valid keys:
1833
- id (String - Required)
1934
- Unique name of the tracker, if no tracker exists with the id a new tracker is created. For all intents and purposes there is no limit on the number that can be spawned.
2035
- x,y,z (Numeric - Optional - default 0)
@@ -23,21 +38,23 @@ Where the following are valid keys:
2338
- Rotation in 3D space
2439
- connected (Boolean - Optional - default true)
2540
- Set to true/false to enable/disable the tracker
26-
41+
42+
2743
If a key is omitted the value will not be changed from the previous update.
2844

29-
Commands can be stacked in a JSON array as follows (there should be no limit on how many can be added):
45+
## Updating multiple trackers in a single request
46+
Commands can be stacked in a JSON array as follows (there should be no limit on how many can be added):
3047
`[{"id":"tracker_0","x":0,"y":1,"z":2}, {"id":"tracker_1","x":0,"y":1,"z":2}]`
3148

32-
If a command contains invalid JSON the whole command is ignored.
33-
34-
## Testing
49+
## Invalid commands
50+
If any part of a command contains invalid JSON the whole request is ignored.
3551

52+
## Example code
3653
If you would like to test this out, please do the following.
3754

3855
- Install the driver (from the releases or build it yourself using below instructions)
39-
- Start SteamVR and connect a headset
40-
- Start a local webserver
56+
- Start SteamVR
57+
- Navigate to [http://localhost:8088](http://localhost:8088)
4158
- Open a console and paste and run the following:
4259
```js
4360
// Create WebSocket connection.
@@ -50,60 +67,51 @@ socket.addEventListener('open', function (event) {
5067

5168
// Listen for messages
5269
socket.addEventListener('message', function (event) {
53-
console.log('Message from server ', event.data);
70+
console.log('Message from server ', JSON.parse(event.data));
5471
});
5572
```
5673

57-
## Building
74+
---
75+
76+
# Building
77+
To build the project do the following (tested with CMake 3.20.1 and Visual Studio 2019):
5878
- Clone the project and submodules
5979
- `git clone --recursive https://github.com/John-Dean/OpenVR-Tracker-Websocket-Driver.git`
6080
- Build project with CMake
6181
- `cd OpenVR-Tracker-Websocket-Driver && cmake .`
62-
- Open project with Visual Studio and hit build
63-
- Driver folder structure and files will be copied to the output folder as `example`.
64-
65-
## Installation
82+
- Open project with Visual Studio, select release and build
83+
- Driver folder structure and files will be copied to the output folder as `websocket_trackers`.
6684

67-
There are two ways to "install" your plugin (The first one is recommended):
68-
69-
- Find your SteamVR driver directory, which should be at:
70-
`C:\Program Files (x86)\Steam\steamapps\common\SteamVR\drivers`
71-
and copy the `example` directory from the project's build directory into the SteamVR drivers directory. Your folder structure should look something like this:
72-
73-
![Drivers folder structure](https://i.imgur.com/hOsDk1H.png)
74-
or
75-
76-
- 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:
77-
78-
```json
79-
{
80-
"config" :
81-
[
82-
"C:\\Program Files (x86)\\Steam\\config",
83-
"c:\\program files (x86)\\steam\\config"
84-
],
85-
"external_drivers" :
86-
[
87-
"C:\\Users\\<Username>\\Documents\\Programming\\c++\\Simple-OpenVR-Driver-Tutorial\\build\\Debug\\example"
88-
],
89-
"jsonid" : "vrpathreg",
90-
"log" :
91-
[
92-
"C:\\Program Files (x86)\\Steam\\logs",
93-
"c:\\program files (x86)\\steam\\logs"
94-
],
95-
"runtime" :
96-
[
97-
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\SteamVR"
98-
],
99-
"version" : 1
100-
}
101-
```
85+
---
86+
87+
# Licenses
88+
## Websocket OpenVR Driver license
89+
MIT License
90+
91+
Copyright (c) 2022 John Dean
92+
93+
Permission is hereby granted, free of charge, to any person obtaining a copy
94+
of this software and associated documentation files (the "Software"), to deal
95+
in the Software without restriction, including without limitation the rights
96+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97+
copies of the Software, and to permit persons to whom the Software is
98+
furnished to do so, subject to the following conditions:
99+
100+
The above copyright notice and this permission notice shall be included in all
101+
copies or substantial portions of the Software.
102+
103+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
109+
SOFTWARE.
102110

103-
## License
111+
## Original license (for [terminal29's](https://github.com/terminal29) ["Simple-OpenVR-Driver-Tutorial"](https://github.com/terminal29/Simple-OpenVR-Driver-Tutorial))
104112
MIT License
105113

106-
Copyright (c) 2020 Jacob Hilton (Terminal29)
114+
Copyright (c) 2020 Jacob Hilton [Terminal29](https://github.com/terminal29)
107115

108116
Permission is hereby granted, free of charge, to any person obtaining a copy
109117
of this software and associated documentation files (the "Software"), to deal

driver_files/driver/example/resources/webserver/index.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

driver_files/driver/example/driver.vrdrivermanifest renamed to driver_files/driver/websocket_trackers/driver.vrdrivermanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"alwaysActivate": true,
3-
"name" : "example",
3+
"name" : "websocket_trackers",
44
"directory" : "",
55
"resourceOnly" : false,
66
"prefersUpperDeviceIndices" : true,

driver_files/driver/example/resources/input/example_controller_bindings.json renamed to driver_files/driver/websocket_trackers/resources/input/example_controller_bindings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"jsonid": "input_profile",
3-
"controller_type": "example_controller",
3+
"controller_type": "websocket_trackers_controller",
44
"device_class": "TrackedDeviceClass_Controller",
5-
"resource_root": "example",
6-
"driver_name": "example",
5+
"resource_root": "websocket_trackers",
6+
"driver_name": "websocket_trackers",
77
"input_bindingui_mode": "controller_handed",
88
"should_show_binding_errors": true,
99
"input_bindingui_left": {
10-
"image": "{example}/icons/example_controller_left.svg"
10+
"image": "{websocket_trackers}/icons/websocket_trackers_controller_left.svg"
1111
},
1212
"input_bindingui_right": {
13-
"image": "{example}/icons/example_controller_right.svg"
13+
"image": "{websocket_trackers}/icons/websocket_trackers_controller_right.svg"
1414
},
1515
"input_source": {
1616
"/pose/raw" : {

driver_files/driver/example/resources/input/example_tracker_bindings.json renamed to driver_files/driver/websocket_trackers/resources/input/example_tracker_bindings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"jsonid": "input_profile",
3-
"controller_type": "example_tracker",
3+
"controller_type": "websocket_trackers_tracker",
44
"device_class": "TrackedDeviceClass_GenericTracker",
5-
"resource_root": "example",
6-
"driver_name": "example",
5+
"resource_root": "websocket_trackers",
6+
"driver_name": "websocket_trackers",
77
"input_bindingui_mode": "single_device",
88
"should_show_binding_errors": true,
99
"input_bindingui_left": {
1010
"transform": "scale(-1,1)",
11-
"image": "{example}/icons/example_tracker.svg"
11+
"image": "{websocket_trackers}/icons/websocket_trackers_tracker.svg"
1212
},
1313
"input_bindingui_right": {
14-
"image": "{example}/icons/example_tracker.svg"
14+
"image": "{websocket_trackers}/icons/websocket_trackers_tracker.svg"
1515
},
1616
"input_source": {
1717
"/pose/raw" : {

driver_files/driver/example/resources/localization/localization.json renamed to driver_files/driver/websocket_trackers/resources/localization/localization.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[
22
{
33
"language_tag": "en_US",
4-
"example_controller": "Example Controller",
5-
"example_tracker": "Example Tracker",
6-
"example_basestation": "Example BaseStation",
4+
"websocket_trackers_controller": "websocket_trackers Controller",
5+
"websocket_trackers_tracker": "websocket_trackers Tracker",
6+
"websocket_trackers_basestation": "websocket_trackers BaseStation",
77
"/input/a": "A Button",
88
"/input/b": "B Button",
99
"/input/system": "System Button",

driver_files/driver/example/resources/rendermodels/example_controller/example_controller.mtl renamed to driver_files/driver/websocket_trackers/resources/rendermodels/example_controller/example_controller.mtl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Ke 0.000000 0.000000 0.000000
1010
Ni 1.450000
1111
d 1.000000
1212
illum 3
13-
map_Kd example_controller.png
13+
map_Kd websocket_trackers_controller.png

driver_files/driver/example/resources/rendermodels/example_controller/example_controller.obj renamed to driver_files/driver/websocket_trackers/resources/rendermodels/example_controller/example_controller.obj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Blender v2.81 (sub 16) OBJ File: ''
22
# www.blender.org
3-
mtllib example_controller.mtl
3+
mtllib websocket_trackers_controller.mtl
44
usemtl Material_75
55
v -0.032265 -0.032265 0.032265
66
v -0.032265 0.032265 0.032265
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h1>TEST</h1>
2+
3+
<!--
4+
5+
Message from server:
6+
{
7+
"vr_trackers": [],
8+
"echo": "",
9+
"ip": [
10+
"192.168.0.0"
11+
]
12+
}
13+
14+
-->

0 commit comments

Comments
 (0)