Skip to content

Commit 9ae7a8f

Browse files
committed
Added Readme.
1 parent 78962da commit 9ae7a8f

File tree

1 file changed

+269
-0
lines changed

1 file changed

+269
-0
lines changed

Readme.md

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
![language](https://img.shields.io/badge/Language-C%2B%2B11-green.svg) ![dependencies](https://img.shields.io/badge/Dependencies-Boost%201.63-green.svg) ![license_gpl3](https://img.shields.io/badge/License-GPL%203.0-green.svg)
2+
3+
# OpenVR-InputEmulator
4+
5+
An OpenVR driver that allows to create virtual controllers, emulate controller input, manipulate poses of existing controllers and remap buttons. A client-side library which communicates with the driver via shared-memory is also included.
6+
7+
The OpenVR driver hooks into the HTC Vive lighthouse driver and allows to modify any pose updates or button/axis events coming from the Vive controllers. Due to the nature of this hack the driver may break when Valve decides to update the driver-side OpenVR API.
8+
9+
The motivation of this driver is that I want to make myself a tracked gun that is guaranteed to work in any SteamVR game regardless of whether the original dev wants to support tracked guns or not. To accomplish this I need some way to add translation and rotation offsets to the poses of the motion controllers so that I can line up my tracked gun and the gun in the game. Additionally I need a way to easily switch between the tracking puck on my gun and my motion controller with the game thinking it's still the same controller (Throwing grenades with a tracked gun is not fun). But this driver should also support other use cases.
10+
11+
There is also a client-side API which other programs can use to communicate with the driver. This API should be powerful enough to also support the development of full-fledged motion-controller drivers.
12+
13+
# Features
14+
15+
- Create virtual controllers and control their positions and rotations.
16+
- Emulate controller input.
17+
- Remap controller buttons.
18+
- Add translation and rotation offsets to the pose of existing controllers.
19+
- Mirror the pose from one controller to another.
20+
- ...
21+
22+
# Notes:
23+
24+
This is a work-in-progress.
25+
26+
# Usage
27+
28+
## Driver
29+
30+
Download the newest driver archive from the [release section](https://github.com/matzman666/OpenVR-InputEmulator/releases) and copy the contained directory into "<Your SteamVR directory>\drivers".
31+
32+
The **activateMultipleDrivers** setting must be set to true, otherwise SteamVR will not load the driver.
33+
34+
## Client
35+
36+
Currently there is only a command line client available. Download the newest client archive from the [release section](https://github.com/matzman666/OpenVR-InputEmulator/releases) and unpack it. Enter client_commandline.exe help on the command line for usage instructions.
37+
38+
39+
# Documentation
40+
41+
## client_commandline commands:
42+
43+
### listdevices
44+
45+
Lists all openvr devices.
46+
47+
### buttonevent
48+
49+
```
50+
buttonevent [press|pressandhold|unpress|touch|touchandhold|untouch] <openvrId> <buttonId>
51+
```
52+
53+
Emulates a button event on the given device. See [openvr.h](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L600-L626) for available button ids.
54+
55+
### axisevent
56+
57+
```
58+
axisevent <openvrId> <axisId> <x> <y>
59+
```
60+
61+
Emulates an axisevent on the given device. Valid axis ids are 0-4.
62+
63+
### proximitysensor
64+
65+
```
66+
proximitysensor <openvrId> [0|1]
67+
```
68+
69+
Emulates a proximity sensor event on the given device.
70+
71+
### getdeviceproperty
72+
73+
```
74+
getdeviceproperty <openvrId> scan
75+
```
76+
77+
Scans the given device for all available device properties.
78+
79+
```
80+
getdeviceproperty <openvrId> <property> [int32|uint64|float|bool|string]
81+
```
82+
83+
Returns the given device property. See [openvr.h](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L235-L363) for valid property ids.
84+
85+
### listvirtual
86+
87+
Lists all virtual devices managed by this driver.
88+
89+
### addcontroller
90+
91+
```
92+
addcontroller <serialnumber>
93+
```
94+
95+
Creates a new virtual controller. Serialnumber needs to be unique. When the command is successful the id of the virtual controller is written to stdout.
96+
97+
### publishdevice
98+
99+
```
100+
publishdevice <virtualId>
101+
```
102+
103+
Tells OpenVR that there is a new device. Before this command is called all device properties should have been set.
104+
105+
### setdeviceproperty
106+
107+
```
108+
setdeviceproperty <virtualId> <property> [int32|uint64|float|bool|string] <value>
109+
```
110+
111+
Sets the given device property. See [openvr.h](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L235-L363) for valid property ids.
112+
113+
### removedeviceproperty
114+
115+
```
116+
removedeviceproperty <virtualId> <property>
117+
```
118+
119+
Removes the given device property. See [openvr.h](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L235-L363) for valid property ids.
120+
121+
### setdeviceconnection
122+
123+
```
124+
setdeviceconnection <virtualId> [0|1]
125+
```
126+
127+
Sets the connection state of the given virtual device. Default value is disconnected.
128+
129+
### setdeviceposition
130+
131+
```
132+
setdeviceposition <virtualId> <x> <y> <z>
133+
```
134+
135+
Sets the position of the given virtual device.
136+
137+
### setdevicerotation
138+
139+
```
140+
setdeviceposition <virtualId> <x> <y> <z>
141+
```
142+
143+
setdevicerotation <virtualId> <yaw> <pitch> <roll>.
144+
145+
### devicebuttonmapping
146+
147+
```
148+
devicebuttonmapping <openvrId> [enable|disable]
149+
```
150+
151+
Enables/disables device button mapping on the given device.
152+
153+
```
154+
devicebuttonmapping <openvrId> add <buttonId> <mappedButtonId>
155+
```
156+
157+
Adds a new button mapping to the given device. See [openvr.h](https://github.com/ValveSoftware/openvr/blob/master/headers/openvr.h#L600-L626) for available button ids.
158+
159+
```
160+
devicebuttonmapping <openvrId> remove [<buttonId>|all]
161+
```
162+
163+
Removes a button mapping from the given device.
164+
165+
### devicetranslationoffset
166+
167+
```
168+
devicetranslationoffset <openvrId> [enable|disable]
169+
```
170+
171+
Enables/disables pose translation offset on the given device.
172+
173+
```
174+
devicetranslationoffset <openvrId> set <x> <y> <z>
175+
```
176+
177+
Sets the pose translation offset on the given device.
178+
179+
### devicerotationoffset
180+
181+
```
182+
devicerotationoffset <openvrId> [enable|disable]
183+
```
184+
185+
Enables/disables pose rotation offset on the given device.
186+
187+
```
188+
devicerotationoffset <openvrId> set <yaw> <pitch> <roll>
189+
```
190+
191+
Sets the pose rotation offset on the given device.
192+
193+
### devicemirrormode
194+
195+
```
196+
devicemirrormode <openvrId> off
197+
```
198+
199+
Turns mirror mode off on the given device.
200+
201+
```
202+
devicemirrormode <openvrId> [mirror|redirect] <targetOpenvrId>
203+
```
204+
205+
Mirrors/Redirects the pose of the given device to another device.
206+
207+
## Client API
208+
209+
ToDo. See [vrinputemulator.h](https://github.com/matzman666/OpenVR-InputEmulator/blob/master/lib_vrinputemulator/include/vrinputemulator.h).
210+
211+
# Examples
212+
213+
## Create virtual controller
214+
215+
```
216+
# Create virtual controller
217+
client_commandline.exe addcontroller controller01 # Writes virtual device id to stdout (Let's assume it is 0)
218+
# Set device properties
219+
client_commandline.exe setdeviceproperty 0 1000 string lighthouse
220+
client_commandline.exe setdeviceproperty 0 1001 string "Vive Controller MV"
221+
client_commandline.exe setdeviceproperty 0 1003 string vr_controller_vive_1_5
222+
client_commandline.exe setdeviceproperty 0 1004 bool 0
223+
client_commandline.exe setdeviceproperty 0 1005 string HTC
224+
client_commandline.exe setdeviceproperty 0 1006 string "1465809478 htcvrsoftware@firmware-win32 2016-06-13 FPGA 1.6/0/0 VRC 1465809477 Radio 1466630404"
225+
client_commandline.exe setdeviceproperty 0 1007 string "product 129 rev 1.5.0 lot 2000/0/0 0"
226+
client_commandline.exe setdeviceproperty 0 1010 bool 1
227+
client_commandline.exe setdeviceproperty 0 1017 uint64 2164327680
228+
client_commandline.exe setdeviceproperty 0 1018 uint64 1465809478
229+
client_commandline.exe setdeviceproperty 0 1029 int32 2
230+
client_commandline.exe setdeviceproperty 0 3001 uint64 12884901895
231+
client_commandline.exe setdeviceproperty 0 3002 int32 1
232+
client_commandline.exe setdeviceproperty 0 3003 int32 3
233+
client_commandline.exe setdeviceproperty 0 3004 int32 0
234+
client_commandline.exe setdeviceproperty 0 3005 int32 0
235+
client_commandline.exe setdeviceproperty 0 3006 int32 0
236+
client_commandline.exe setdeviceproperty 0 3007 int32 0
237+
client_commandline.exe setdeviceproperty 0 5000 string icons
238+
client_commandline.exe setdeviceproperty 0 5001 string {htc}controller_status_off.png
239+
client_commandline.exe setdeviceproperty 0 5002 string {htc}controller_status_searching.gif
240+
client_commandline.exe setdeviceproperty 0 5003 string {htc}controller_status_searching_alert.gif
241+
client_commandline.exe setdeviceproperty 0 5004 string {htc}controller_status_ready.png
242+
client_commandline.exe setdeviceproperty 0 5005 string {htc}controller_status_ready_alert.png
243+
client_commandline.exe setdeviceproperty 0 5006 string {htc}controller_status_error.png
244+
client_commandline.exe setdeviceproperty 0 5007 string {htc}controller_status_standby.png
245+
client_commandline.exe setdeviceproperty 0 5008 string {htc}controller_status_ready_low.png
246+
# Let OpenVR know that there is a new device
247+
client_commandline.exe publishdevice 0
248+
# Connect the device
249+
client_commandline.exe setdeviceconnection 0 1
250+
# Set the device position
251+
client_commandline.exe setdeviceposition 0 -1 -1 -1
252+
```
253+
254+
## Map the grip-button to the trigger-button and vice-versa on the controller with id 3
255+
256+
```
257+
client_commandline.exe devicebuttonmapping 3 add 2 33
258+
client_commandline.exe devicebuttonmapping 3 add 33 2
259+
client_commandline.exe devicebuttonmapping 3 enable
260+
```
261+
262+
263+
# Known Bugs
264+
265+
- The shared-memory message queue is prone to deadlock the driver when the client crashes or is exited ungracefully.
266+
267+
# License
268+
269+
This software is released under GPL 3.0.

0 commit comments

Comments
 (0)