internal static bool LaunchSteamVRViaVRStartUp64(SteamVRInfo steamVRInfo) { var vrStartUp64Path = steamVRInfo?.VRStartUp64Path; if (!IsOn64BitSystem() || vrStartUp64Path == null || !vrStartUp64Path.Exists) { return(false); } var fullName = vrStartUp64Path.FullName; try { using (Process.Start(fullName)) { // Skip } return(true); } catch (Exception e) { Logger.GetInstance(typeof(DefaultOpenVRManager)).Error($"Can not launch SteamVR via vrstartup: \"{fullName}\". error: {e.Message}"); } return(false); }
internal static bool IsVRServerRunning(SteamVRInfo steamVRInfo) { if (steamVRInfo == null) { return(false); } var targetProcessName = steamVRInfo.VRServer32Path?.FullName; if (string.IsNullOrWhiteSpace(targetProcessName)) { targetProcessName = steamVRInfo.VRServer64Path?.FullName; } if (string.IsNullOrWhiteSpace(targetProcessName)) { return(false); } targetProcessName = Path.GetFileNameWithoutExtension(targetProcessName); var processList = Process.GetProcessesByName(targetProcessName); if (processList.Length <= 0) { return(false); } foreach (var process in processList) { string processPath = null; try { processPath = process.MainModule?.FileName; } catch (Win32Exception) { processPath = ProcessManager.GetProcessPathById(process.Id); } catch (Exception e) { Logger.GetInstance(typeof(Runtime)).Error($"Can not get process path: {e.Message}"); } if (processPath == null) { continue; } if (processPath.Equals(steamVRInfo.VRServer32Path?.FullName)) { return(true); } if (processPath.Equals(steamVRInfo.VRServer64Path?.FullName)) { return(true); } } return(false); }
internal static bool KillSteamVRViaVRMonitor64(SteamVRInfo steamVRInfo) { var vrMonitor64Path = steamVRInfo?.VRMonitor64Path; if (vrMonitor64Path == null || !vrMonitor64Path.Exists) { return(true); } return(KillProcessesByFullPath(vrMonitor64Path.FullName)); }
internal static List <SteamVRInfo> GetSteamVRListFromOpenVRPath() { var result = new List <SteamVRInfo>(); var openVRPathPath = GetOpenVRPathPath(); if (openVRPathPath == null || !openVRPathPath.Exists) { return(result); } try { using (var streamReader = File.OpenText(openVRPathPath.FullName)) { var data = streamReader.ReadToEnd(); var jsonObject = JsonFactory.GetInstance().GetJsonObject(data); var runtime = jsonObject.ParseJsonArray("runtime"); var size = runtime.Size(); for (var i = 0; i < size; i++) { var runtimePathString = runtime.ParseString(i); if (string.IsNullOrWhiteSpace(runtimePathString)) { continue; } var runtimePath = new DirectoryInfo(runtimePathString); if (!runtimePath.Exists) { continue; } var steamVrInfo = new SteamVRInfo { InstallPath = runtimePath, InstallVersion = ParseSteamVRVersion(GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "version.txt"))), VRMonitor32Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win32", VRMonitorFileName)), VRMonitor64Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win64", VRMonitorFileName)), VRPathReg32Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win32", VRPathRegFileName)), VRPathReg64Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win64", VRPathRegFileName)), VRServer32Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win32", VRServerFileName)), VRServer64Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win64", VRServerFileName)), VRStartUp32Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win32", VRStartUpFileName)), VRStartUp64Path = GetSteamVRComponentPath(runtimePath, Path.Combine("bin", "win64", VRStartUpFileName)) }; if (steamVrInfo.VRMonitor32Path == null && steamVrInfo.VRMonitor64Path == null) { continue; } if (steamVrInfo.VRServer32Path == null && steamVrInfo.VRServer64Path == null) { continue; } result.Add(steamVrInfo); } } } catch (Exception e) { Logger.GetInstance(typeof(Runtime)).Error($"Can not parse SteamVR package version: {e.Message}"); } return(result); }
internal static bool LaunchSteamVRViaVRStartUp(SteamVRInfo steamVRInfo) { return(LaunchSteamVRViaVRStartUp64(steamVRInfo) || LaunchSteamVRViaVRStartUp32(steamVRInfo)); }
internal static bool LaunchSteamVRViaVRMonitor(SteamVRInfo steamVRInfo) { return(LaunchSteamVRViaVRMonitor64(steamVRInfo) || LaunchSteamVRViaVRMonitor32(steamVRInfo)); }
internal static bool LaunchSteamVR(SteamVRInfo steamVRInfo) { return(LaunchSteamVRViaVRStartUp(steamVRInfo) || LaunchSteamVRViaVRMonitor(steamVRInfo)); }
internal static bool KillSteamVRViaVRMonitor(SteamVRInfo steamVRInfo) { return(KillSteamVRViaVRMonitor32(steamVRInfo) && KillSteamVRViaVRMonitor64(steamVRInfo)); }
internal static bool KillSteamVR(SteamVRInfo steamVRInfo) { return(KillSteamVRViaVRMonitor(steamVRInfo)); }