# myDriver
**Repository Path**: BabyXin/myDriver
## Basic Information
- **Project Name**: myDriver
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: GPL-3.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-04-23
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# myDriver 使用指南
参考[OpenVR Github Wiki](https://github.com/ValveSoftware/openvr/wiki/Driver-Documentation), 对原流程进行了一定程度简化。源代码可见[github](https://github.com/r57zone/OpenVR-driver-for-DIY/releases),使用指南如下:
## 环境需求
```
Windows 10
Cmake 3.17.0-rc3
VS2019 16.5.4
SteamVR 1.13.10
```
## Step 1: 下载
下载driver项目文件
```bash
git clone https://gitee.com/BabyXin/OpenVR-driver-for-DIY.git
```
## Step 2: 修改配置变量
`driver_sample.cpp`文件第32行记录了可能需要修改的变量,在编译前需要进行自定义。
```cpp
const char* logPath = "C:/Users/16356/steamVR/driver.log"; // 日志文件地址
const int Port = 12348; // 服务器端口
```
## Step 3: 编译
1. 使用vs2019打开项目`{the_project_path}\OpenVR\samples\driver_sample\driver_sample.vcxproj`
2. 打开后,将**解决方案配置**改为`Release`,将**解决方案平台**改为`x64`。
3. 使用快捷键`ctrl+shift+B`生成解决方案。(直接运行本地调试器会报错,是因为本项目只生成ddl动态链接库,不是可运行的程序,忽视即可)
## Step 4: SteamVR配置
#### 移动ddl文件至null文件夹
1. 打开openvr生成的动态链接库路径`{the_project_path}\OpenVR\samples\driver_sample\bin\drivers\sample\bin\win64`,复制文件夹中的`driver_sample.ddl`
2. 打开steamvr的安装位置
我的路径是在`D:\Happy\Game\Steam\steamapps\common\SteamVR`。
3. 粘贴文件` driver_sample.ddl`至`{SteamVR_path}\drivers\null\bin\win64`,并将文件名修改为`driver_null.dll`,替换原来的文件。
#### 修改配置文件
打开steam的SteamVR配置文件 `steamvr.vrsettings`
我的完整路径为`D:\Happy\Game\Steam\config\steamvr.vrsettings`, 其中`D:\Happy\Game\Steam`为Steam的安装位置。
将文件内容修改为如下内容:
```json
{
"driver_null" : {
"enable" : true,
"id" : "Null Driver",
"renderWidth" : 1920,
"renderHeight" : 1080,
"secondsFromVsyncToPhotons" : 0.10000000149011612,
"displayFrequency" : 60.0,
"serialNumber" : "Null 4711",
"windowHeight" : 1080,
"windowWidth" : 1920,
"windowX" : 0,
"windowY" : 0
},
"steamvr" : {
"activateMultipleDrivers" : true,
"enableHomeApp" : false,
"forcedDriver" : "null",
"mirrorViewGeometry" : "0 0 960 540"
}
}
```
## 控制方法
### udp包控制
默认端口为`12348`,接受的包为24个字节,字节格式如下表:
| | x | y | z | yaw | pitch | roll |
| ------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ |
| 格式 | 单精度
浮点数 | 单精度
浮点数 | 单精度
浮点数 | 单精度
浮点数 | 单精度
浮点数 | 单精度
浮点数 |
| 字节数 | 4 | 4 | 4 | 4 | 4 | 4 |
| 首位字节位置 | 0 | 4 | 8 | 12 | 16 | 20 |
可以在命令行运行`python controller.py`即可在steamvr中看见移动效果。
### 键盘控制
在没有接受的包的情况下,可以使用键盘进行控制。控制方法如下:
#### Buttons HMD
> NumPad 2 & 8 - turn up and down.
> NumPad 4 & 6 - turn left and right.
> NumPad 1 & 3 - rotation of the head left and right.
> NumPad 7 - resetting of turns and rotation.
> Up & Down - move forward and back.
> Left & Right - move left and right.
> PageUp & PageDown - move up and down. End - reset position.
#### Controller buttons 1
> W, A, S, D - move left, right, forward and back.
> Q, E - move up and down.
> R - reset the move.
> Z, X, C, V, 1 - сontroller buttons.
> T, G, F, H - rotation of both controllers.
> B - reset the rotation of both controllers.
#### Controller buttons 2
> I, K, J, L - move left, right, forward and back.
> U, O - move up and down.
> P - reset the move.
> N, M, <, >, 4 - сontroller buttons.
## 其他提示
如果不能正常运行,可以下载[Release](https://gitee.com/BabyXin/myDriver/releases)中的`driver_null.dll`,按照[Step 4](#Step 4: SteamVR配置)的步骤,如仍旧不能成功运行,可能是配置出现的问题。
## 参考
1. https://github.com/r57zone/OpenVR-driver-for-DIY/releases
键盘控制方法来源
2. https://github.com/ValveSoftware/openvr/wiki/Driver-Documentation
配置方法来源