Browse Source

Merge a30f709ae6 into a81bad951f

pull/105/merge
Pink 1 week ago
committed by GitHub
parent
commit
da3d0473e3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
1 changed files with 56 additions and 0 deletions
  1. +56
    -0
      IPA.Injector/Injector.cs

+ 56
- 0
IPA.Injector/Injector.cs View File

@ -5,6 +5,7 @@ using IPA.Injector.Backups;
using IPA.Loader; using IPA.Loader;
using IPA.Logging; using IPA.Logging;
using IPA.Utilities; using IPA.Utilities;
using Microsoft.Win32;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
using System; using System;
@ -84,6 +85,8 @@ namespace IPA.Injector
GameVersionEarly.Load(); GameVersionEarly.Load();
SelfConfig.Instance.CheckVersionBoundary(); SelfConfig.Instance.CheckVersionBoundary();
SetOpenXRRuntime(arguments);
// updates backup // updates backup
InstallBootstrapPatch(); InstallBootstrapPatch();
@ -102,6 +105,59 @@ namespace IPA.Injector
} }
} }
public static void SetOpenXRRuntime(string[] arguments)
{
if (arguments == null)
return;
string targetRuntime = string.Empty;
for (int i = 0; i < arguments.Length; i++)
{
if (arguments[i] == "-vrmode" && i + 1 < arguments.Length)
{
targetRuntime = arguments[i + 1];
break;
}
}
if (string.IsNullOrEmpty(targetRuntime))
return;
targetRuntime = targetRuntime.ToLower(System.Globalization.CultureInfo.CurrentCulture);
//This forces the OpenXRLoader to error as there is no OpenXR Runtime found, which is intentional as a mod can then select it
switch (targetRuntime)
{
case "none":
case "fpfc":
case "controllable":
Environment.SetEnvironmentVariable("XR_RUNTIME_JSON", targetRuntime); //By checking the env variable you can see what caused the override while still causing the fail
return;
}
string registryPath = @"SOFTWARE\Khronos\OpenXR\1\AvailableRuntimes";
RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(registryPath);
string foundRuntime = string.Empty;
if (baseKey != null)
{
foreach (string valueName in baseKey.GetValueNames())
{
if (Path.GetFileNameWithoutExtension(valueName).ToLower().Contains(targetRuntime))
{
foundRuntime = valueName;
break;
}
}
baseKey.Close();
}
if(!string.IsNullOrEmpty(foundRuntime))
Environment.SetEnvironmentVariable("XR_RUNTIME_JSON", foundRuntime);
//This is not stored within CommandLineValues.Debug as you can check the environment variable
}
private static void MaybeInitializeConsole(string[] arguments) private static void MaybeInitializeConsole(string[] arguments)
{ {
var i = 0; var i = 0;


Loading…
Cancel
Save