-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-msfs-quest-vr.ps1
184 lines (174 loc) · 5.3 KB
/
setup-msfs-quest-vr.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Default config
$DEFAULT_OCULUS_TOOL = "C:\Program Files\Oculus\Support\oculus-diagnostics\OculusDebugToolCLI.exe"
$DEFAULT_LOG_FILE = ".\config\odt-config-default.txt"
$DEFAULT_QRES_TOOL = ".\bin\QRes.exe"
$DEFAULT_VR_RESOLUTION = "800x600"
$DEFAULT_DEFAULT_RESOLUTION = "3440x1440" # WQHD Ultrawide
# Help
function Show-Usage {
Write-Host "Usage: $($MyInvocation.MyCommand.Name) [options]"
Write-Host "Options:"
Write-Host " -o, --oculus-tool <path> Path to OculusDebugToolCLI.exe (default: $DEFAULT_OCULUS_TOOL)"
Write-Host " -l, --log-file <path> Path to log file (default: $DEFAULT_LOG_FILE)"
Write-Host " -q, --qres-tool <path> Path to QRes.exe (default: $DEFAULT_QRES_TOOL)"
Write-Host " -v, --vr-resolution <res> VR resolution (default: $DEFAULT_VR_RESOLUTION)"
Write-Host " -d, --default-resolution <res> Default resolution (default: $DEFAULT_DEFAULT_RESOLUTION)"
Write-Host " -h, --help Show this help message and exit"
exit 1
}
# Arguments
$OCULUS_TOOL = $DEFAULT_OCULUS_TOOL
$LOG_FILE = $DEFAULT_LOG_FILE
$QRES_TOOL = $DEFAULT_QRES_TOOL
$VR_RESOLUTION = $DEFAULT_VR_RESOLUTION
$DEFAULT_RESOLUTION = $DEFAULT_DEFAULT_RESOLUTION
$i = 0
while ($i -lt $args.Count) {
$arg = $args[$i]
switch ($arg) {
'-o' {
$i++
if ($i -lt $args.Count) {
$OCULUS_TOOL = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'--oculus-tool' {
$i++
if ($i -lt $args.Count) {
$OCULUS_TOOL = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'-l' {
$i++
if ($i -lt $args.Count) {
$LOG_FILE = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'--log-file' {
$i++
if ($i -lt $args.Count) {
$LOG_FILE = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'-q' {
$i++
if ($i -lt $args.Count) {
$QRES_TOOL = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'--qres-tool' {
$i++
if ($i -lt $args.Count) {
$QRES_TOOL = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'-v' {
$i++
if ($i -lt $args.Count) {
$VR_RESOLUTION = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'--vr-resolution' {
$i++
if ($i -lt $args.Count) {
$VR_RESOLUTION = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'-d' {
$i++
if ($i -lt $args.Count) {
$DEFAULT_RESOLUTION = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'--default-resolution' {
$i++
if ($i -lt $args.Count) {
$DEFAULT_RESOLUTION = $args[$i];
} else {
Write-Host "Option $arg requires an argument."
Show-Usage
}
}
'-h' {
Show-Usage
}
'--help' {
Show-Usage
}
default {
Write-Host "Unknown option: $arg"
Show-Usage
}
}
$i++
}
# Functions
function Set-Resolution {
param (
[string]$resolution
)
$width, $height = $resolution -split 'x'
Write-Host "[DEBUG] Command: $QRES_TOOL /x:$width /y:$height"
& $QRES_TOOL "/x:$width" "/y:$height"
$status = $LASTEXITCODE
if ($status -eq 0) {
Write-Host "Resolution successfully set to ${width}x${height}."
} else {
Write-Host "Failed to set resolution. QRes returned exit code $status."
Write-Host "Please ensure QRes is properly configured and the syntax is correct."
}
}
function Start-VRSession {
Write-Host "Starting VR session..."
Write-Host "[DEBUG] Command: `"$OCULUS_TOOL`" -f `"$LOG_FILE`""
& $OCULUS_TOOL "-f" $LOG_FILE
Set-Resolution $VR_RESOLUTION
}
function End-VRSession {
Write-Host "Ending VR session..."
Set-Resolution $DEFAULT_RESOLUTION
}
# Main
Clear-Host
Write-Host "VR Session Manager"
Write-Host "Press any key to end the VR session and restore the resolution."
Start-VRSession
while ($true) {
Start-Sleep -Milliseconds 1000
if ($Host.UI.RawUI.KeyAvailable) {
$key = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host
Write-Host "Key pressed. Exiting VR session..."
End-VRSession
break
}
}
Write-Host "Resolution restored to $DEFAULT_RESOLUTION. Exiting..."
exit 0