-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathViveVRDiagnostics.cs
More file actions
56 lines (45 loc) · 2.27 KB
/
ViveVRDiagnostics.cs
File metadata and controls
56 lines (45 loc) · 2.27 KB
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
using Microsoft.Win32;
using Newtonsoft.Json;
namespace SLZ.XRDoctor;
public static class ViveVRDiagnostics {
private static readonly Serilog.ILogger Log = Serilog.Log.ForContext(typeof(ViveVRDiagnostics));
private const string LogTag = "ViveVR";
public static void CheckDirectly(out bool hasViveVR) {
Log.Information("[{LogTag}] Checking directly for Vive OpenXR runtime at {ViveVRRegistryKey}.",
LogTag, @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\HtcVive\Updater");
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\HtcVive\Updater");
do {
try {
var o = key?.GetValue("AppPath");
if (o is not string viveLocation || string.IsNullOrWhiteSpace(viveLocation)) {
Log.Information("[{LogTag}] Vive Updater not found.", LogTag);
break;
}
var runtimePath = Path.Combine(viveLocation, "App", "ViveVRRuntime", "ViveVR_openxr",
"ViveOpenXR.json");
if (!File.Exists(runtimePath)) {
Log.Warning("[{LogTag}] Runtime JSON not found at expected path \"{runtimePath}\".", LogTag,
runtimePath);
break;
}
var runtimeJsonStr = File.ReadAllText(runtimePath);
if (string.IsNullOrWhiteSpace(runtimeJsonStr)) {
Log.Error("[{LogTag}] Runtime JSON was empty at \"{runtimePath}\".", LogTag, runtimePath);
break;
}
RuntimeManifest manifest;
try {
manifest = JsonConvert.DeserializeObject<RuntimeManifest>(runtimeJsonStr);
} catch (JsonException e) {
Log.Error(e, "[{LogTag}] Runtime JSON did not parse correctly at {runtimePath}.", LogTag,
runtimePath);
break;
}
Log.Information("[{LogTag}] Runtime found at path \"{location}\".", LogTag, runtimePath);
hasViveVR = true;
return;
} catch (Exception e) { Log.Error(e, "[{LogTag}] Error while determining install state.", LogTag); }
} while (false);
hasViveVR = false;
}
}