-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi, I came across an issue where it doesn't correctly select the steamvr openxr runtime if you have multiple library folders and steamvr is installed in the second folder.
here's a fixed version:
internal class SteamVRRuntimeJson : IOpenXRRuntimeJson
{
private const string SteamPathKey = @"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam";
private const string SteamPathValue = "SteamPath";
private const string LibraryFoldersVdf = "steamapps/libraryfolders.vdf";
private const string LibraryFoldersKey = "\"libraryfolders\"";
private const string JsonName = @"common/SteamVR/steamxr_win64.json";
private static readonly Regex RxLibraryPath = new Regex(@"^\s*""path""\s*""([^""]+)""", RegexOptions.Compiled);
public OpenXRRuntimeType Name => OpenXRRuntimeType.SteamVR;
public bool TryGetJsonPath(out string jsonPath)
{
jsonPath = default;
var steamPathValue = Registry.GetValue(SteamPathKey, SteamPathValue, string.Empty);
if (!(steamPathValue is string steamPath) || string.IsNullOrWhiteSpace(steamPath))
return false;
var libraryFolders = Path.Combine(steamPath, LibraryFoldersVdf);
if (!File.Exists(libraryFolders))
return false;
var folders = new List<string> { Path.Combine(steamPath, "steamapps") };
foreach (var line in File.ReadLines(libraryFolders))
{
var match = RxLibraryPath.Match(line.Trim());
if (match.Success)
{
var path = match.Groups[1].Value.Replace(@"\\", @"\");
folders.Add(Path.Combine(path, "steamapps"));
}
}
foreach (var folder in folders)
{
var path = Path.Combine(folder, JsonName);
if (File.Exists(path))
{
jsonPath = Path.GetFullPath(path);
return true;
}
}
return false;
}
}
Metadata
Metadata
Assignees
Labels
No labels