Decompiled source of SBGVR v1.4.2

patchers/Uuvr.Patcher.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
internal static class GameFolderRedirect
{
	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate IntPtr CreateFileWFn(IntPtr name, uint access, uint share, IntPtr security, uint disposition, uint flags, IntPtr template);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate uint GetFileAttributesWFn(IntPtr name);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate int GetFileAttributesExWFn(IntPtr name, int level, IntPtr info);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate IntPtr FindFirstFileWFn(IntPtr name, IntPtr data);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate IntPtr FindFirstFileExWFn(IntPtr name, int level, IntPtr data, int op, IntPtr filter, uint flags);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate IntPtr LoadLibraryWFn(IntPtr name);

	[UnmanagedFunctionPointer(CallingConvention.Winapi, SetLastError = true)]
	private delegate IntPtr LoadLibraryExWFn(IntPtr name, IntPtr file, uint flags);

	private const int MaxLoggedRedirects = 60;

	private static readonly ManualLogSource Log = Logger.CreateLogSource("SBGVR Redirect");

	private static readonly string[] RuntimePlugins = new string[4] { "openvr_api.dll", "openxr_loader.dll", "UnityOpenXR.dll", "XRSDKOpenVR.dll" };

	private static string _dataPath = "";

	private static string _sourceData = "";

	private static string _sourcePlugins = "";

	private static readonly HashSet<string> PluginNames = new HashSet<string>(RuntimePlugins, StringComparer.OrdinalIgnoreCase);

	private static readonly HashSet<string> PluginsWithOwnLookups = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "UnityOpenXR.dll", "XRSDKOpenVR.dll" };

	private static readonly HashSet<IntPtr> PatchedModules = new HashSet<IntPtr>();

	private static readonly object Lock = new object();

	private static readonly HashSet<string> Logged = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

	private static readonly CreateFileWFn RealCreateFileW = Real<CreateFileWFn>("CreateFileW");

	private static readonly GetFileAttributesWFn RealGetFileAttributesW = Real<GetFileAttributesWFn>("GetFileAttributesW");

	private static readonly GetFileAttributesExWFn RealGetFileAttributesExW = Real<GetFileAttributesExWFn>("GetFileAttributesExW");

	private static readonly FindFirstFileWFn RealFindFirstFileW = Real<FindFirstFileWFn>("FindFirstFileW");

	private static readonly FindFirstFileExWFn RealFindFirstFileExW = Real<FindFirstFileExWFn>("FindFirstFileExW");

	private static readonly LoadLibraryExWFn RealLoadLibraryExW = Real<LoadLibraryExWFn>("LoadLibraryExW");

	private static readonly CreateFileWFn HookCreateFileW = (IntPtr n, uint a, uint s, IntPtr sec, uint d, uint f, IntPtr t) => WithPath(n, "CreateFileW", (IntPtr p) => RealCreateFileW(p, a, s, sec, d, f, t));

	private static readonly GetFileAttributesWFn HookGetFileAttributesW = (IntPtr n) => WithPath(n, "GetFileAttributesW", (IntPtr p) => RealGetFileAttributesW(p));

	private static readonly GetFileAttributesExWFn HookGetFileAttributesExW = (IntPtr n, int l, IntPtr i) => WithPath(n, "GetFileAttributesExW", (IntPtr p) => RealGetFileAttributesExW(p, l, i));

	private static readonly FindFirstFileWFn HookFindFirstFileW = (IntPtr n, IntPtr d) => WithPath(n, "FindFirstFileW", (IntPtr p) => RealFindFirstFileW(p, d));

	private static readonly FindFirstFileExWFn HookFindFirstFileExW = (IntPtr n, int l, IntPtr d, int o, IntPtr f, uint fl) => WithPath(n, "FindFirstFileExW", (IntPtr p) => RealFindFirstFileExW(p, l, d, o, f, fl));

	private static readonly LoadLibraryWFn HookLoadLibraryW = (IntPtr n) => LoadLibrary(n, 0u, "LoadLibraryW");

	private static readonly LoadLibraryExWFn HookLoadLibraryExW = (IntPtr n, IntPtr file, uint flags) => LoadLibrary(n, flags, "LoadLibraryExW");

	private static readonly Dictionary<string, Delegate> AllHooks = new Dictionary<string, Delegate>
	{
		["CreateFileW"] = HookCreateFileW,
		["GetFileAttributesW"] = HookGetFileAttributesW,
		["GetFileAttributesExW"] = HookGetFileAttributesExW,
		["FindFirstFileW"] = HookFindFirstFileW,
		["FindFirstFileExW"] = HookFindFirstFileExW,
		["LoadLibraryW"] = HookLoadLibraryW,
		["LoadLibraryExW"] = HookLoadLibraryExW
	};

	private static readonly Dictionary<string, Delegate> LibraryHooks = new Dictionary<string, Delegate>
	{
		["LoadLibraryW"] = HookLoadLibraryW,
		["LoadLibraryExW"] = HookLoadLibraryExW
	};

	public static void Install(string vrRuntimePath, string dataPath)
	{
		_dataPath = Path.GetFullPath(dataPath).TrimEnd('\\', '/');
		_sourceData = Path.Combine(vrRuntimePath, "Data");
		_sourcePlugins = Path.Combine(Path.Combine(vrRuntimePath, "Plugins"), (IntPtr.Size == 8) ? "x64" : "x86");
		Log.LogInfo((object)("Game data folder: " + _dataPath));
		Log.LogInfo((object)("VR runtime files are read from: " + vrRuntimePath));
		ReportGameFolderCopies();
		IntPtr moduleHandleW = GetModuleHandleW("UnityPlayer.dll");
		if (moduleHandleW == IntPtr.Zero)
		{
			Log.LogInfo((object)"[FAILED] UnityPlayer.dll isn't loaded; nothing redirected.");
			return;
		}
		int num = PatchImports(moduleHandleW, "UnityPlayer.dll", AllHooks);
		IntPtr intPtr = FindMono();
		if (intPtr != IntPtr.Zero)
		{
			num += PatchImports(intPtr, "Mono", LibraryHooks);
		}
		string[] array = new string[4] { "openxr_loader.dll", "openvr_api.dll", "UnityOpenXR.dll", "XRSDKOpenVR.dll" };
		foreach (string text in array)
		{
			string text2 = Path.Combine(_sourcePlugins, text);
			IntPtr intPtr2 = LoadLibraryExW(text2, IntPtr.Zero, 8u);
			if (intPtr2 == IntPtr.Zero)
			{
				Log.LogError((object)$"[FAILED] Loading {text2} failed with Windows error {Marshal.GetLastWin32Error()}.");
				continue;
			}
			Log.LogInfo((object)("Loaded " + text2));
			if (PluginsWithOwnLookups.Contains(text))
			{
				num += PatchImports(intPtr2, text, AllHooks);
			}
		}
		Log.LogInfo((object)($"{num} imports redirected. Each redirected path is logged below as it's used " + $"(the first {60})."));
	}

	private static void ReportGameFolderCopies()
	{
		List<string> list = new List<string>();
		string[] array = new string[2]
		{
			Path.Combine(_dataPath, "UnitySubsystems"),
			Path.Combine(Path.Combine(_dataPath, "StreamingAssets"), "SteamVR")
		};
		foreach (string text in array)
		{
			if (Directory.Exists(text))
			{
				list.Add(text);
			}
		}
		string path = Path.Combine(_dataPath, "Plugins");
		if (Directory.Exists(path))
		{
			string[] files = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories);
			foreach (string text2 in files)
			{
				if (PluginNames.Contains(Path.GetFileName(text2)))
				{
					list.Add(text2);
				}
			}
		}
		if (list.Count == 0)
		{
			Log.LogInfo((object)"The game folder has no copies of the VR runtime: everything VR loads comes from the mod's folder.");
		}
		else
		{
			Log.LogInfo((object)("WARNING: the game folder still has VR runtime files copied by SBGVR 1.3.2 or earlier. They aren't used (the mod's own copies are) and can be deleted:\n  " + string.Join("\n  ", list.ToArray())));
		}
	}

	internal static string? Redirect(string path)
	{
		if (string.IsNullOrEmpty(path))
		{
			return null;
		}
		string text = "";
		string text2 = path.Replace('/', '\\');
		if (text2.StartsWith("\\\\?\\", StringComparison.Ordinal))
		{
			text = "\\\\?\\";
			text2 = text2.Substring(4);
		}
		if (text2.Length < _dataPath.Length || !text2.StartsWith(_dataPath, StringComparison.OrdinalIgnoreCase))
		{
			return SteamVrFolderElsewhere(text2, text);
		}
		string text3 = text2.Substring(_dataPath.Length);
		if (text3.Length > 0 && text3[0] != '\\')
		{
			return SteamVrFolderElsewhere(text2, text);
		}
		string text4 = null;
		if (Under(text3, "\\UnitySubsystems") || Under(text3, "\\StreamingAssets\\SteamVR"))
		{
			text4 = _sourceData + text3;
		}
		else if (Under(text3, "\\Plugins"))
		{
			string text5 = text3.Substring(text3.LastIndexOf('\\') + 1);
			if (!text5.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
			{
				text5 += ".dll";
			}
			if (PluginNames.Contains(text5))
			{
				text4 = _sourcePlugins + "\\" + text5;
			}
		}
		return (text4 == null) ? null : (text + text4);
	}

	internal static string? RedirectLibrary(string path)
	{
		string text = Redirect(path);
		if (text != null || string.IsNullOrEmpty(path) || Path.IsPathRooted(path))
		{
			return text;
		}
		string text2 = path.Replace('/', '\\');
		text2 = text2.Substring(text2.LastIndexOf('\\') + 1);
		if (!text2.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
		{
			text2 += ".dll";
		}
		return PluginNames.Contains(text2) ? (_sourcePlugins + "\\" + text2) : null;
	}

	private static string? SteamVrFolderElsewhere(string p, string prefix)
	{
		int num = p.IndexOf("StreamingAssets\\SteamVR", StringComparison.OrdinalIgnoreCase);
		if (num < 0 || (num > 0 && p[num - 1] != '\\'))
		{
			return null;
		}
		int num2 = num + "StreamingAssets\\SteamVR".Length;
		if (num2 < p.Length && p[num2] != '\\')
		{
			return null;
		}
		if (p.StartsWith(_sourceData + "\\", StringComparison.OrdinalIgnoreCase))
		{
			return null;
		}
		return prefix + _sourceData + "\\" + p.Substring(num);
	}

	private static bool Under(string rest, string folder)
	{
		return rest.Equals(folder, StringComparison.OrdinalIgnoreCase) || rest.StartsWith(folder + "\\", StringComparison.OrdinalIgnoreCase);
	}

	private static T WithPath<T>(IntPtr name, string function, Func<IntPtr, T> call)
	{
		IntPtr intPtr = IntPtr.Zero;
		try
		{
			string text = ((name == IntPtr.Zero) ? null : Redirect(Marshal.PtrToStringUni(name)));
			if (text != null)
			{
				intPtr = Marshal.StringToHGlobalUni(text);
				LogRedirect(function, Marshal.PtrToStringUni(name), text);
			}
		}
		catch
		{
		}
		try
		{
			T result = call((intPtr != IntPtr.Zero) ? intPtr : name);
			SetLastError(Marshal.GetLastWin32Error());
			return result;
		}
		finally
		{
			if (intPtr != IntPtr.Zero)
			{
				int lastWin32Error = Marshal.GetLastWin32Error();
				Marshal.FreeHGlobal(intPtr);
				SetLastError(lastWin32Error);
			}
		}
	}

	private static IntPtr LoadLibrary(IntPtr name, uint flags, string function)
	{
		string text = null;
		try
		{
			if (name != IntPtr.Zero)
			{
				text = RedirectLibrary(Marshal.PtrToStringUni(name));
			}
		}
		catch
		{
			text = null;
		}
		if (text == null)
		{
			IntPtr result = RealLoadLibraryExW(name, IntPtr.Zero, flags);
			SetLastError(Marshal.GetLastWin32Error());
			return result;
		}
		LogRedirect(function, Marshal.PtrToStringUni(name), text);
		if ((flags & 0x1F00) == 0)
		{
			flags |= 8;
		}
		IntPtr intPtr = Marshal.StringToHGlobalUni(text);
		IntPtr intPtr2;
		int lastWin32Error;
		try
		{
			intPtr2 = RealLoadLibraryExW(intPtr, IntPtr.Zero, flags);
			lastWin32Error = Marshal.GetLastWin32Error();
		}
		finally
		{
			Marshal.FreeHGlobal(intPtr);
		}
		if (intPtr2 != IntPtr.Zero && PluginsWithOwnLookups.Contains(Path.GetFileName(text)))
		{
			try
			{
				PatchImports(intPtr2, Path.GetFileName(text), AllHooks);
			}
			catch (Exception ex)
			{
				Log.LogInfo((object)("Couldn't redirect " + Path.GetFileName(text) + "'s own file lookups: " + ex.Message));
			}
		}
		if (intPtr2 == IntPtr.Zero)
		{
			Log.LogInfo((object)$"[FAILED] Loading {text} failed with Windows error {lastWin32Error}.");
		}
		SetLastError(lastWin32Error);
		return intPtr2;
	}

	private static void LogRedirect(string function, string from, string to)
	{
		lock (Lock)
		{
			if (Logged.Count < 60 && Logged.Add(function + "|" + from))
			{
				Log.LogInfo((object)(function + ": " + from + " -> " + to));
			}
		}
	}

	private static int PatchImports(IntPtr module, string moduleName, Dictionary<string, Delegate> hooks)
	{
		lock (Lock)
		{
			if (!PatchedModules.Add(module))
			{
				return 0;
			}
		}
		IntPtr ptr = Add(module, Marshal.ReadInt32(module, 60));
		if (Marshal.ReadInt32(ptr) != 17744 || Marshal.ReadInt16(ptr, 24) != 523)
		{
			throw new BadImageFormatException(moduleName + " isn't a 64-bit Windows module");
		}
		int num = Marshal.ReadInt32(ptr, 144);
		if (num == 0)
		{
			return 0;
		}
		List<string> list = new List<string>();
		IntPtr intPtr = Add(module, num);
		while (true)
		{
			int num2 = Marshal.ReadInt32(intPtr, 0);
			int num3 = Marshal.ReadInt32(intPtr, 12);
			int num4 = Marshal.ReadInt32(intPtr, 16);
			if (num3 == 0 && num4 == 0)
			{
				break;
			}
			string a = Marshal.PtrToStringAnsi(Add(module, num3));
			if (string.Equals(a, "KERNEL32.dll", StringComparison.OrdinalIgnoreCase))
			{
				IntPtr ptr2 = Add(module, (num2 != 0) ? num2 : num4);
				int num5 = 0;
				while (true)
				{
					long num6 = Marshal.ReadInt64(ptr2, num5 * 8);
					if (num6 == 0)
					{
						break;
					}
					if (num6 >= 0)
					{
						string text = Marshal.PtrToStringAnsi(Add(module, (int)(num6 & 0x7FFFFFFF) + 2));
						if (text != null && hooks.TryGetValue(text, out Delegate value))
						{
							IntPtr intPtr2 = Add(module, num4 + num5 * 8);
							if (VirtualProtect(intPtr2, (UIntPtr)8uL, 4u, out var oldProtect))
							{
								Marshal.WriteIntPtr(intPtr2, Marshal.GetFunctionPointerForDelegate(value));
								VirtualProtect(intPtr2, (UIntPtr)8uL, oldProtect, out var _);
								list.Add(text);
							}
						}
					}
					num5++;
				}
			}
			intPtr = Add(intPtr, 20);
		}
		Log.LogInfo((object)(moduleName + ": " + ((list.Count == 0) ? "no file imports to redirect" : string.Join(", ", list.ToArray()))));
		return list.Count;
	}

	private static IntPtr FindMono()
	{
		string[] array = new string[3] { "mono-2.0-bdwgc.dll", "mono-2.0-sgen.dll", "mono.dll" };
		foreach (string name in array)
		{
			IntPtr moduleHandleW = GetModuleHandleW(name);
			if (moduleHandleW != IntPtr.Zero)
			{
				return moduleHandleW;
			}
		}
		Log.LogInfo((object)"Mono's module wasn't found; [DllImport] loads aren't redirected.");
		return IntPtr.Zero;
	}

	private static T Real<T>(string function) where T : Delegate
	{
		return (T)Marshal.GetDelegateForFunctionPointer(GetProcAddress(GetModuleHandleW("kernel32.dll"), function), typeof(T));
	}

	private static IntPtr Add(IntPtr pointer, int offset)
	{
		return new IntPtr(pointer.ToInt64() + offset);
	}

	[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
	private static extern IntPtr GetModuleHandleW(string name);

	[DllImport("kernel32.dll", BestFitMapping = false, CharSet = CharSet.Ansi)]
	private static extern IntPtr GetProcAddress(IntPtr module, string name);

	[DllImport("kernel32.dll")]
	private static extern bool VirtualProtect(IntPtr address, UIntPtr size, uint protect, out uint oldProtect);

	[DllImport("kernel32.dll")]
	private static extern void SetLastError(int error);

	[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
	private static extern IntPtr LoadLibraryExW(string path, IntPtr file, uint flags);
}
public class Patcher
{
	public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };

	public static void Patch(AssemblyDefinition assembly)
	{
	}

	public static void Initialize()
	{
		string location = Assembly.GetExecutingAssembly().Location;
		string fileName = Process.GetCurrentProcess().MainModule.FileName;
		string directoryName = Path.GetDirectoryName(fileName);
		string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
		string dataPath = Path.Combine(directoryName, fileNameWithoutExtension + "_Data/");
		string directoryName2 = Path.GetDirectoryName(location);
		GameFolderRedirect.Install(Path.Combine(directoryName2, "VrRuntime"), dataPath);
	}
}

plugins/Uuvr.XR.Management.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using UnityEngine.Rendering;
using UnityEngine.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: InternalsVisibleTo("Unity.XR.Management.Tests")]
[assembly: InternalsVisibleTo("Unity.XR.Management.EditorTests")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace UnityEngine.XR.Management
{
	[AttributeUsage(AttributeTargets.Class)]
	public sealed class XRConfigurationDataAttribute : Attribute
	{
		public string displayName { get; set; }

		public string buildSettingsKey { get; set; }

		private XRConfigurationDataAttribute()
		{
		}

		public XRConfigurationDataAttribute(string displayName, string buildSettingsKey)
		{
			this.displayName = displayName;
			this.buildSettingsKey = buildSettingsKey;
		}
	}
	public class XRGeneralSettings : ScriptableObject
	{
		public static string k_SettingsKey = "com.unity.xr.management.loader_settings";

		internal static XRGeneralSettings s_RuntimeSettingsInstance = null;

		[SerializeField]
		internal XRManagerSettings m_LoaderManagerInstance = null;

		[SerializeField]
		[Tooltip("Toggling this on/off will enable/disable the automatic startup of XR at run time.")]
		internal bool m_InitManagerOnStart = true;

		private XRManagerSettings m_XRManager = null;

		private bool m_ProviderIntialized = false;

		private bool m_ProviderStarted = false;

		public XRManagerSettings Manager
		{
			get
			{
				return m_LoaderManagerInstance;
			}
			set
			{
				m_LoaderManagerInstance = value;
			}
		}

		public static XRGeneralSettings Instance => s_RuntimeSettingsInstance;

		public XRManagerSettings AssignedSettings => m_LoaderManagerInstance;

		public bool InitManagerOnStart => m_InitManagerOnStart;

		private void Awake()
		{
			Debug.Log((object)"XRGeneral Settings awakening...");
			s_RuntimeSettingsInstance = this;
			Application.quitting += Quit;
			Object.DontDestroyOnLoad((Object)(object)s_RuntimeSettingsInstance);
		}

		private static void Quit()
		{
			XRGeneralSettings instance = Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.DeInitXRSDK();
			}
		}

		private void Start()
		{
			StartXRSDK();
		}

		private void OnDestroy()
		{
			DeInitXRSDK();
		}

		[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
		internal static void AttemptInitializeXRSDKOnLoad()
		{
			XRGeneralSettings instance = Instance;
			if (!((Object)(object)instance == (Object)null) && instance.InitManagerOnStart)
			{
				instance.InitXRSDK();
			}
		}

		[RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)]
		internal static void AttemptStartXRSDKOnBeforeSplashScreen()
		{
			XRGeneralSettings instance = Instance;
			if (!((Object)(object)instance == (Object)null) && instance.InitManagerOnStart)
			{
				instance.StartXRSDK();
			}
		}

		private void InitXRSDK()
		{
			if (!((Object)(object)Instance == (Object)null) && !((Object)(object)Instance.m_LoaderManagerInstance == (Object)null) && Instance.m_InitManagerOnStart)
			{
				m_XRManager = Instance.m_LoaderManagerInstance;
				if ((Object)(object)m_XRManager == (Object)null)
				{
					Debug.LogError((object)"Assigned GameObject for XR Management loading is invalid. No XR Providers will be automatically loaded.");
					return;
				}
				m_XRManager.automaticLoading = false;
				m_XRManager.automaticRunning = false;
				m_XRManager.InitializeLoaderSync();
				m_ProviderIntialized = true;
			}
		}

		private void StartXRSDK()
		{
			if ((Object)(object)m_XRManager != (Object)null && (Object)(object)m_XRManager.activeLoader != (Object)null)
			{
				m_XRManager.StartSubsystems();
				m_ProviderStarted = true;
			}
		}

		private void StopXRSDK()
		{
			if ((Object)(object)m_XRManager != (Object)null && (Object)(object)m_XRManager.activeLoader != (Object)null)
			{
				m_XRManager.StopSubsystems();
				m_ProviderStarted = false;
			}
		}

		private void DeInitXRSDK()
		{
			if ((Object)(object)m_XRManager != (Object)null && (Object)(object)m_XRManager.activeLoader != (Object)null)
			{
				m_XRManager.DeinitializeLoader();
				m_XRManager = null;
				m_ProviderIntialized = false;
			}
		}
	}
	public abstract class XRLoader : ScriptableObject
	{
		public virtual bool Initialize()
		{
			return true;
		}

		public virtual bool Start()
		{
			return true;
		}

		public virtual bool Stop()
		{
			return true;
		}

		public virtual bool Deinitialize()
		{
			return true;
		}

		public abstract T GetLoadedSubsystem<T>() where T : class, ISubsystem;

		public virtual List<GraphicsDeviceType> GetSupportedGraphicsDeviceTypes(bool buildingPlayer)
		{
			return new List<GraphicsDeviceType>();
		}
	}
	public abstract class XRLoaderHelper : XRLoader
	{
		protected Dictionary<Type, ISubsystem> m_SubsystemInstanceMap = new Dictionary<Type, ISubsystem>();

		public override T GetLoadedSubsystem<T>()
		{
			Type typeFromHandle = typeof(T);
			m_SubsystemInstanceMap.TryGetValue(typeFromHandle, out ISubsystem value);
			return value as T;
		}

		protected void StartSubsystem<T>() where T : class, ISubsystem
		{
			T loadedSubsystem = GetLoadedSubsystem<T>();
			if (loadedSubsystem != null)
			{
				((ISubsystem)loadedSubsystem).Start();
			}
		}

		protected void StopSubsystem<T>() where T : class, ISubsystem
		{
			T loadedSubsystem = GetLoadedSubsystem<T>();
			if (loadedSubsystem != null)
			{
				((ISubsystem)loadedSubsystem).Stop();
			}
		}

		protected void DestroySubsystem<T>() where T : class, ISubsystem
		{
			T loadedSubsystem = GetLoadedSubsystem<T>();
			if (loadedSubsystem != null)
			{
				Type typeFromHandle = typeof(T);
				if (m_SubsystemInstanceMap.ContainsKey(typeFromHandle))
				{
					m_SubsystemInstanceMap.Remove(typeFromHandle);
				}
				((ISubsystem)loadedSubsystem).Destroy();
			}
		}

		protected void CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id) where TDescriptor : ISubsystemDescriptor where TSubsystem : ISubsystem
		{
			if (descriptors == null)
			{
				throw new ArgumentNullException("descriptors");
			}
			SubsystemManager.GetSubsystemDescriptors<TDescriptor>(descriptors);
			if (descriptors.Count <= 0)
			{
				return;
			}
			foreach (TDescriptor descriptor in descriptors)
			{
				ISubsystem val = null;
				if (string.Compare(((ISubsystemDescriptor)descriptor).id, id, ignoreCase: true) == 0)
				{
					val = ((ISubsystemDescriptor)descriptor/*cast due to .constrained prefix*/).Create();
				}
				if (val != null)
				{
					m_SubsystemInstanceMap[typeof(TSubsystem)] = val;
					break;
				}
			}
		}

		[Obsolete("This method is obsolete. Please use the geenric CreateSubsystem method.", false)]
		protected void CreateIntegratedSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id) where TDescriptor : IntegratedSubsystemDescriptor where TSubsystem : IntegratedSubsystem
		{
			CreateSubsystem<TDescriptor, TSubsystem>(descriptors, id);
		}

		[Obsolete("This method is obsolete. Please use the generic CreateSubsystem method.", false)]
		protected void CreateStandaloneSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id) where TDescriptor : SubsystemDescriptor where TSubsystem : Subsystem
		{
			CreateSubsystem<TDescriptor, TSubsystem>(descriptors, id);
		}

		public override bool Deinitialize()
		{
			m_SubsystemInstanceMap.Clear();
			return base.Deinitialize();
		}
	}
	public sealed class XRManagerSettings : ScriptableObject
	{
		[HideInInspector]
		private bool m_InitializationComplete = false;

		[HideInInspector]
		[SerializeField]
		private bool m_RequiresSettingsUpdate = false;

		[SerializeField]
		[Tooltip("Determines if the XR Manager instance is responsible for creating and destroying the appropriate loader instance.")]
		[FormerlySerializedAs("AutomaticLoading")]
		private bool m_AutomaticLoading = false;

		[SerializeField]
		[Tooltip("Determines if the XR Manager instance is responsible for starting and stopping subsystems for the active loader instance.")]
		[FormerlySerializedAs("AutomaticRunning")]
		private bool m_AutomaticRunning = false;

		[SerializeField]
		[Tooltip("List of XR Loader instances arranged in desired load order.")]
		[FormerlySerializedAs("Loaders")]
		private List<XRLoader> m_Loaders = new List<XRLoader>();

		[SerializeField]
		[HideInInspector]
		private HashSet<XRLoader> m_RegisteredLoaders = new HashSet<XRLoader>();

		public bool automaticLoading
		{
			get
			{
				return m_AutomaticLoading;
			}
			set
			{
				m_AutomaticLoading = value;
			}
		}

		public bool automaticRunning
		{
			get
			{
				return m_AutomaticRunning;
			}
			set
			{
				m_AutomaticRunning = value;
			}
		}

		[Obsolete("'XRManagerSettings.loaders' property is obsolete. Use 'XRManagerSettings.activeLoaders' instead to get a list of the current loaders.")]
		public List<XRLoader> loaders => m_Loaders;

		public IReadOnlyList<XRLoader> activeLoaders => m_Loaders;

		public bool isInitializationComplete => m_InitializationComplete;

		[HideInInspector]
		public XRLoader activeLoader { get; private set; }

		internal List<XRLoader> currentLoaders
		{
			get
			{
				return m_Loaders;
			}
			set
			{
				m_Loaders = value;
			}
		}

		internal HashSet<XRLoader> registeredLoaders => m_RegisteredLoaders;

		public T ActiveLoaderAs<T>() where T : XRLoader
		{
			return activeLoader as T;
		}

		public void InitializeLoaderSync()
		{
			if ((Object)(object)activeLoader != (Object)null)
			{
				Debug.LogWarning((object)"XR Management has already initialized an active loader in this scene. Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.");
				return;
			}
			foreach (XRLoader currentLoader in currentLoaders)
			{
				if ((Object)(object)currentLoader != (Object)null && CheckGraphicsAPICompatibility(currentLoader) && currentLoader.Initialize())
				{
					activeLoader = currentLoader;
					m_InitializationComplete = true;
					return;
				}
			}
			activeLoader = null;
		}

		public IEnumerator InitializeLoader()
		{
			if ((Object)(object)activeLoader != (Object)null)
			{
				Debug.LogWarning((object)"XR Management has already initialized an active loader in this scene. Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.");
				yield break;
			}
			foreach (XRLoader loader in currentLoaders)
			{
				if ((Object)(object)loader != (Object)null && CheckGraphicsAPICompatibility(loader) && loader.Initialize())
				{
					activeLoader = loader;
					m_InitializationComplete = true;
					yield break;
				}
				yield return null;
			}
			activeLoader = null;
		}

		public bool TryAddLoader(XRLoader loader, int index = -1)
		{
			if ((Object)(object)loader == (Object)null || currentLoaders.Contains(loader))
			{
				return false;
			}
			if (!m_RegisteredLoaders.Contains(loader))
			{
				return false;
			}
			if (index < 0 || index >= currentLoaders.Count)
			{
				currentLoaders.Add(loader);
			}
			else
			{
				currentLoaders.Insert(index, loader);
			}
			return true;
		}

		public bool TryRemoveLoader(XRLoader loader)
		{
			bool result = true;
			if (currentLoaders.Contains(loader))
			{
				result = currentLoaders.Remove(loader);
			}
			return result;
		}

		public bool TrySetLoaders(List<XRLoader> reorderedLoaders)
		{
			List<XRLoader> list = new List<XRLoader>(activeLoaders);
			currentLoaders.Clear();
			foreach (XRLoader reorderedLoader in reorderedLoaders)
			{
				if (!TryAddLoader(reorderedLoader))
				{
					currentLoaders = list;
					return false;
				}
			}
			return true;
		}

		private void Awake()
		{
			foreach (XRLoader currentLoader in currentLoaders)
			{
				if (!m_RegisteredLoaders.Contains(currentLoader))
				{
					m_RegisteredLoaders.Add(currentLoader);
				}
			}
		}

		private unsafe bool CheckGraphicsAPICompatibility(XRLoader loader)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			GraphicsDeviceType graphicsDeviceType = SystemInfo.graphicsDeviceType;
			List<GraphicsDeviceType> supportedGraphicsDeviceTypes = loader.GetSupportedGraphicsDeviceTypes(buildingPlayer: false);
			if (supportedGraphicsDeviceTypes.Count > 0 && !supportedGraphicsDeviceTypes.Contains(graphicsDeviceType))
			{
				Debug.LogWarning((object)$"The {((Object)loader).name} does not support the initialized graphics device, {((object)(*(GraphicsDeviceType*)(&graphicsDeviceType))/*cast due to .constrained prefix*/).ToString()}. Please change the preffered Graphics API in PlayerSettings. Attempting to start the next XR loader.");
				return false;
			}
			return true;
		}

		public void StartSubsystems()
		{
			if (!m_InitializationComplete)
			{
				Debug.LogWarning((object)"Call to StartSubsystems without an initialized manager.Please make sure wait for initialization to complete before calling this API.");
			}
			else if ((Object)(object)activeLoader != (Object)null)
			{
				activeLoader.Start();
			}
		}

		public void StopSubsystems()
		{
			if (!m_InitializationComplete)
			{
				Debug.LogWarning((object)"Call to StopSubsystems without an initialized manager.Please make sure wait for initialization to complete before calling this API.");
			}
			else if ((Object)(object)activeLoader != (Object)null)
			{
				activeLoader.Stop();
			}
		}

		public void DeinitializeLoader()
		{
			if (!m_InitializationComplete)
			{
				Debug.LogWarning((object)"Call to DeinitializeLoader without an initialized manager.Please make sure wait for initialization to complete before calling this API.");
				return;
			}
			StopSubsystems();
			if ((Object)(object)activeLoader != (Object)null)
			{
				activeLoader.Deinitialize();
				activeLoader = null;
			}
			m_InitializationComplete = false;
		}

		private void Start()
		{
			if (automaticLoading && automaticRunning)
			{
				StartSubsystems();
			}
		}

		private void OnDisable()
		{
			if (automaticLoading && automaticRunning)
			{
				StopSubsystems();
			}
		}

		private void OnDestroy()
		{
			if (automaticLoading)
			{
				DeinitializeLoader();
			}
		}
	}
}

plugins/SBGVR.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Game.Rendering.Blur;
using Game.Rendering.CRT;
using Game.Rendering.FlashFrame;
using Game.Rendering.StealthFrame;
using HTraceAO.Rendering.URP.Infrastructure;
using HarmonyLib;
using SBGVR.Comfort;
using SBGVR.Controls;
using SBGVR.Diagnostics;
using SBGVR.Fades;
using SBGVR.Hud;
using SBGVR.Rendering;
using SBGVR.View;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.TextCore;
using UnityEngine.UI;
using UnityEngine.XR;
using UnityEngine.XR.OpenXR.Features.Interactions;
using Uuvr;
using Uuvr.VrCamera;
using Uuvr.VrUi;
using Uuvr.VrUi.PatchModes;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("lmkHenlo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 lmkHenlo")]
[assembly: AssemblyDescription("Super Battle Golf fixes for the UUVR VR mod.")]
[assembly: AssemblyFileVersion("1.4.2.0")]
[assembly: AssemblyInformationalVersion("1.4.2+3a9401c739943f22f40c41fe15431ddf533a5675")]
[assembly: AssemblyProduct("SBGVR")]
[assembly: AssemblyTitle("SBGVR")]
[assembly: AssemblyVersion("1.4.2.0")]
namespace SBGVR
{
	internal static class EmbeddedImage
	{
		internal static Texture2D Load(string resource, string textureName)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			byte[] array;
			using (Stream stream = typeof(EmbeddedImage).Assembly.GetManifestResourceStream(resource))
			{
				if (stream == null)
				{
					throw new FileNotFoundException(resource + " is missing from SBGVR.dll");
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				array = memoryStream.ToArray();
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, false)
			{
				name = textureName,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)2,
				hideFlags = (HideFlags)61
			};
			if (ImageConversion.LoadImage(val, array, true))
			{
				return val;
			}
			Object.Destroy((Object)(object)val);
			throw new InvalidDataException(resource + " couldn't be read");
		}
	}
	[BepInPlugin("com.sbgvr", "SBGVR", "1.4.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.sbgvr";

		public const string Name = "SBGVR";

		public const string Version = "1.4.2";

		internal const string UuvrGuid = "raicuparta.uuvr-modern";

		internal static ManualLogSource Log;

		internal static Harmony Harmony;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Settings.Bind(((BaseUnityPlugin)this).Config);
			Harmony = new Harmony("com.sbgvr");
			GameObject val = new GameObject("SBGVR");
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<VrStateTracker>();
			Patch("Screen shake", typeof(ScreenShakePatches));
			Patch("Impact and flash frames, CRT effect, menu blur", typeof(ScreenEffectPatches));
			Patch("Camera transitions", typeof(CameraTransitionPatches));
			Patch("Smoke bomb frame kept off the floating screen", typeof(StealthFramePatches));
			RailgunScopeZoom.ZoomAvailable = Patch("Railgun scope zoom", typeof(RailgunScopeZoomPatches));
			Add(val, "Railgun scope view lock, HUD and floating screen", typeof(RailgunScopeZoom));
			if (Patch("Ambient occlusion for each eye", typeof(AmbientOcclusionEyePatches)))
			{
				AmbientOcclusionEyePatches.Verify();
			}
			Patch("Ambient occlusion", typeof(AmbientOcclusionPatches));
			if (Patch("Full-view fades", typeof(FullViewFadePatches)))
			{
				val.AddComponent<FullViewFade>();
			}
			if (Patch("World-space markers", typeof(MarkerPatches)))
			{
				WorldMarker.Initialize();
				MarkerOcclusion.Initialize();
				Patch("World-space markers: icons up to MarkerViewAngle", typeof(MarkerViewAnglePatches));
				Add(val, "World-space reticles", typeof(WorldReticles));
				Add(val, "Aim line", typeof(AimLine));
				Patch("World-space lock-on reticles, airhorn targets, timers and popups", typeof(MoreMarkerPatches));
			}
			Add(val, "Main menu background", typeof(MenuBackground));
			Add(val, "Controller layout in the main menu", typeof(MenuControlsPanel));
			Add(val, "Recenter key", typeof(Recenter));
			if (Settings.MotionControls.Value)
			{
				EnableOpenXrControllers();
				Add(val, "Motion controls", typeof(MotionControls));
				Patch("Meta Quest button prompts: on device switch", typeof(MetaButtonPromptPatches));
				Add(val, "Meta Quest button prompts", typeof(MetaButtonPrompts));
				if (Settings.MotionCamera.Value)
				{
					Add(val, "Motion camera", typeof(MotionCamera));
					Add(val, "Motion camera for weapons", typeof(WeaponMotionCamera));
				}
			}
			if (Patch("Aiming with the controller or head", typeof(ControllerAimPatches)) && Patch("Aiming with the controller or head: rocket launcher lock-on", typeof(ControllerAimLockOnPatches)))
			{
				Patch("Aiming with the controller or head: rocket launcher lock-on (scope)", typeof(ControllerAimLockOnPatches.RocketLauncherScope));
			}
			if (Patch("First person", typeof(FirstPersonPatches)))
			{
				Patch("First person: walking and aiming where you look", typeof(FirstPersonMovementPatches));
				Add(val, "First person toggle", typeof(FirstPersonView));
			}
			if (Settings.DiagnosticsEnabled.Value)
			{
				Add(val, "Diagnostics", typeof(VrDiagnostics));
			}
			Log.LogInfo((object)(Settings.DiagnosticsEnabled.Value ? "SBGVR 1.4.2 loaded. Diagnostics are on: VR, camera and renderer details go to this log." : "SBGVR 1.4.2 loaded."));
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void EnableOpenXrControllers()
		{
			try
			{
				string[] value = ControllerProfiles.Enable();
				Log.LogInfo((object)("[ok] OpenXR controller profiles: " + string.Join(", ", value)));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[FAILED] OpenXR controller profiles: " + ex.GetBaseException().Message + ". Controllers won't work with OpenXR; OpenVR and the rest of SBGVR work as before."));
			}
		}

		private static bool Patch(string feature, Type patchClass)
		{
			try
			{
				Harmony.CreateClassProcessor(patchClass).Patch();
				Log.LogInfo((object)("[ok] " + feature));
				return true;
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[FAILED] " + feature + ": " + ex.GetBaseException().Message + ". This feature is off; the rest of SBGVR works as before."));
				try
				{
					UnpatchClass(patchClass);
				}
				catch (Exception ex2)
				{
					Log.LogWarning((object)("Couldn't fully remove the patches for " + feature + ": " + ex2.Message));
				}
				return false;
			}
		}

		private static void UnpatchClass(Type patchClass)
		{
			foreach (MethodBase patchedMethod in Harmony.GetPatchedMethods())
			{
				Patches patchInfo = Harmony.GetPatchInfo(patchedMethod);
				foreach (Patch prefix in patchInfo.Prefixes)
				{
					Remove(patchedMethod, prefix);
				}
				foreach (Patch postfix in patchInfo.Postfixes)
				{
					Remove(patchedMethod, postfix);
				}
				foreach (Patch transpiler in patchInfo.Transpilers)
				{
					Remove(patchedMethod, transpiler);
				}
			}
			void Remove(MethodBase original, Patch patch)
			{
				if (patch.owner == "com.sbgvr" && patch.PatchMethod.DeclaringType == patchClass)
				{
					Harmony.Unpatch(original, patch.PatchMethod);
				}
			}
		}

		private static void Add(GameObject host, string feature, Type component)
		{
			try
			{
				host.AddComponent(component);
				Log.LogInfo((object)("[ok] " + feature));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[FAILED] " + feature + ": " + ex.GetBaseException().Message));
			}
		}
	}
	internal enum CameraTransitionMode
	{
		Game,
		Fast,
		Instant
	}
	internal enum MenuBackgroundMode
	{
		Moving,
		Still
	}
	internal static class Settings
	{
		internal static ConfigEntry<float> ScreenShake;

		internal static ConfigEntry<bool> ImpactFrames;

		internal static ConfigEntry<bool> FlashFrames;

		internal static ConfigEntry<CameraTransitionMode> CameraTransitions;

		internal static ConfigEntry<MenuBackgroundMode> MenuBackground;

		internal static ConfigEntry<bool> FullViewFades;

		internal static ConfigEntry<Key> RecenterKey;

		internal static ConfigEntry<bool> WorldSpaceMarkers;

		internal static ConfigEntry<bool> MarkersOnTop;

		internal static ConfigEntry<float> MarkerScale;

		internal static ConfigEntry<float> MarkerViewAngle;

		internal static ConfigEntry<bool> PlayersCoverMarkers;

		internal static ConfigEntry<bool> WorldSpaceReticles;

		internal static ConfigEntry<bool> AimLine;

		internal static ConfigEntry<bool> MenuControls;

		internal static ConfigEntry<MenuControlsSide> MenuControlsSide;

		internal static ConfigEntry<bool> AmbientOcclusion;

		internal static ConfigEntry<bool> MotionControls;

		internal static ConfigEntry<bool> ControllerAiming;

		internal static ConfigEntry<ControllerHand> DominantHand;

		internal static ConfigEntry<float> ControllerAimPitch;

		internal static ConfigEntry<bool> MirrorButtons;

		internal static ConfigEntry<bool> MotionCamera;

		internal static ConfigEntry<float> MotionCameraStrength;

		internal static ConfigEntry<float> MotionCameraMovement;

		internal static ConfigEntry<float> MotionCameraMaxYaw;

		internal static ConfigEntry<float> MotionCameraMaxPitch;

		internal static ConfigEntry<bool> FirstPerson;

		internal static ConfigEntry<Key> FirstPersonKey;

		internal static ConfigEntry<bool> FirstPersonControllerToggle;

		internal static ConfigEntry<TurnMode> FirstPersonTurn;

		internal static ConfigEntry<float> SnapTurnAngle;

		internal static ConfigEntry<float> FirstPersonEyeOffset;

		internal static ConfigEntry<bool> DiagnosticsEnabled;

		internal static ConfigEntry<float> PerformanceLogInterval;

		internal static void Bind(ConfigFile config)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Expected O, but got Unknown
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Expected O, but got Unknown
			ScreenShake = config.Bind<float>("VR Comfort", "ScreenShake", 0.25f, new ConfigDescription("Camera shake in VR, as a share of the shake the game would use with your Screen shake setting. 0 = no shake, 1 = the game's shake.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ImpactFrames = config.Bind<bool>("VR Comfort", "ImpactFrames", false, "Show the game's impact frames (the brief distorted, recoloured frame when an explosion goes off near you) in VR. They fill your whole view and are centred for a flat screen.");
			FlashFrames = config.Bind<bool>("VR Comfort", "FlashFrames", true, "Show the game's flash frames in VR: the full-view flash with a doubled picture that blinds you when another player's flash camera catches you. Off = you aren't blinded in VR.");
			CameraTransitions = config.Bind<CameraTransitionMode>("VR Comfort", "CameraTransitions", CameraTransitionMode.Game, "How the camera moves when the game switches views, for example to the hole overview and back. Game = the game's own sweep, Fast = the same sweep in about a third of the time, Instant = a cut.");
			MenuBackground = config.Bind<MenuBackgroundMode>("VR Comfort", "MenuBackground", MenuBackgroundMode.Still, "The main menu's background scenes. Moving = the game's slow camera pans, Still = each scene holds still. The game still fades between scenes either way.");
			FullViewFades = config.Bind<bool>("VR Comfort", "FullViewFades", true, "Fade your whole view when the game fades the screen (scene changes, the main menu's background), instead of only the floating screen.");
			RecenterKey = config.Bind<Key>("VR Comfort", "RecenterKey", (Key)97, "Key that turns the view so the direction you're facing becomes straight ahead. None = no key.");
			WorldSpaceMarkers = config.Bind<bool>("VR HUD", "WorldSpaceMarkers", true, "Draw markers (ball, hole and other icons, name tags, the target reticle) in the world at their target, so each eye sees them at the right depth. Off = UUVR's floating screen, where markers on nearby targets look doubled.");
			MarkersOnTop = config.Bind<bool>("VR HUD", "MarkersOnTop", true, "Draw world-space markers over scenery, like the game does. Menus on the floating screen still cover them. Off = scenery in front of a target hides its marker. Weapon reticles are always drawn on top.");
			MarkerScale = config.Bind<float>("VR HUD", "MarkerScale", 1f, new ConfigDescription("Size of world-space markers. 1 = the size they have on UUVR's floating screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>()));
			MarkerViewAngle = config.Bind<float>("VR HUD", "MarkerViewAngle", 70f, new ConfigDescription("Icons for targets within this many degrees of straight ahead are drawn in the world; targets further round get the game's arrow at the edge of the floating screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 120f), Array.Empty<object>()));
			WorldSpaceReticles = config.Bind<bool>("VR HUD", "WorldSpaceReticles", true, "Draw weapon reticles in the world at the point you're aiming at, so both eyes see them on the target, always on top of scenery and characters. Off = on UUVR's floating screen, where they look doubled against a distant target.");
			AimLine = config.Bind<bool>("VR HUD", "AimLine", false, "With WorldSpaceReticles, draw a thin white line from your character's hand to the weapon reticle while you aim, so you can see where the shot goes from where it leaves. Not for the railgun, thunderstorm or flash camera.");
			MenuControls = config.Bind<bool>("VR HUD", "MenuControls", true, "With MotionControls, show the VR controller layout on a panel next to the floating screen while you're in the main menu (from the moment the game starts) and while the pause menu is open. It never covers the menu: look down (or to the side, see MenuControlsSide) to read it.");
			MenuControlsSide = config.Bind<MenuControlsSide>("VR HUD", "MenuControlsSide", SBGVR.Hud.MenuControlsSide.Below, "Where the menus' controller layout is: Below the floating screen, tilted towards you, or to its Left or Right.");
			PlayersCoverMarkers = config.Bind<bool>("VR HUD", "PlayersCoverMarkers", false, "With MarkersOnTop, a player character (yours or anyone else's) in front of a marker covers it, while scenery still doesn't. A name tag or teammate icon isn't covered by the player it belongs to, and weapon reticles aren't covered at all.");
			AmbientOcclusion = config.Bind<bool>("VR Graphics", "AmbientOcclusion", true, "The game's ambient occlusion (soft shading where surfaces meet) in VR. It costs more than on a flat screen: each eye is drawn separately, at the headset's resolution. Off = none in VR; the game's own setting still applies on a flat screen.");
			MotionControls = config.Bind<bool>("VR Controls", "MotionControls", true, "Play with your VR controllers: while VR runs, their thumbsticks, trigger buttons and buttons work like a gamepad, including your gamepad rebinds. Left thumbstick moves, right thumbstick turns the camera, left trigger button aims, right trigger button swings, A jumps, B dives, X interacts, Y changes the swing angle, the right grip button and a tap of the left grip button cycle items, and the Menu button pauses (through SteamVR it opens SteamVR's menu instead). Hold the left grip button for more: right thumbstick = D-pad (emotes, push to talk, votes), A = pause, B = scoreboard. A real gamepad, keyboard and mouse still work. Restart the game after changing this.");
			ControllerAiming = config.Bind<bool>("VR Controls", "ControllerAiming", true, "With MotionControls, weapons aim where your DominantHand controller points while you aim or use them (dueling pistol, elephant gun, rocket launcher and its lock-on, railgun, freeze bomb, thunderstorm), and your character turns to face that way when you use them. Golf swings still follow the camera. Only while you're playing with the controllers: after you use a gamepad, keyboard or mouse, weapons aim along the camera (or your head, in first person) until you use a controller again. Off = weapons always aim along the camera (or your head, in first person).");
			DominantHand = config.Bind<ControllerHand>("VR Controls", "DominantHand", ControllerHand.Right, "The controller weapons aim with: Right or Left. Buttons stay where they are; see MirrorButtons.");
			ControllerAimPitch = config.Bind<float>("VR Controls", "ControllerAimPitch", 0f, new ConfigDescription("Degrees to tilt the aim from where the controller points: positive tilts it down, negative up. For controllers that aim too high or low in your hand.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-45f, 45f), Array.Empty<object>()));
			MirrorButtons = config.Bind<bool>("VR Controls", "MirrorButtons", false, "With MotionControls, mirror the button layout left to right, for example for left-handed play with DominantHand = Left: the right controller moves and aims items, the left one turns the camera and swings or fires, X and Y act as A and B, and the right grip button opens the D-pad layer. The Menu button stays on the left controller.");
			MotionCamera = config.Bind<bool>("VR Controls", "MotionCamera", true, "With MotionControls, small movements of your DominantHand controller turn the camera, only while you're playing with the controllers (not a gamepad, keyboard or mouse). Swings: while you aim and charge a golf club or rocket club swing, turn the controller or move it sideways to turn the camera left or right, like the right thumbstick (and, with MotionCameraMaxPitch above 0, tilt it to look up or down). Your character faces the camera while aiming, so this fine-tunes where the swing goes. It starts from how you hold the controller when you start aiming and stops when you swing; the thumbstick still works. In first person it turns left and right only. The MotionCamera settings below tune swings only. Items (with ControllerAiming): while you aim an item, in third or first person, turning or tilting the controller turns the camera by the same angle (1:1), and weapons aim along the camera. The aim starts where the controller points and goes back there after each shot; when you stop aiming, the camera's tilt eases back to where it was.");
			MotionCameraStrength = config.Bind<float>("VR Controls", "MotionCameraStrength", 0.25f, new ConfigDescription("How much of the controller's turn and tilt goes into the camera: 0.25 = turning it 8 degrees turns the camera about 2 degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			MotionCameraMovement = config.Bind<float>("VR Controls", "MotionCameraMovement", 2f, new ConfigDescription("Degrees the camera turns for every 10 cm you move the controller sideways. 0 = only turning and tilting count.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			MotionCameraMaxYaw = config.Bind<float>("VR Controls", "MotionCameraMaxYaw", 30f, new ConfigDescription("The furthest the controller turns the camera left or right while aiming, in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 45f), Array.Empty<object>()));
			MotionCameraMaxPitch = config.Bind<float>("VR Controls", "MotionCameraMaxPitch", 0f, new ConfigDescription("The furthest the controller tilts the camera up or down while aiming, in degrees. 0 = left and right only.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			FirstPerson = config.Bind<bool>("VR First Person", "FirstPerson", false, "See through your character's eyes in VR instead of from the third-person camera behind them. FirstPersonKey and the controller toggle switch this, and it's remembered. You look around and up and down with your head, and walking goes where you look. The game switches back to the third-person camera on its own while you're knocked out, respawning or spectating, and returns to first person afterwards. VR only: a flat screen always uses the third-person camera.");
			FirstPersonKey = config.Bind<Key>("VR First Person", "FirstPersonKey", (Key)98, "Key that switches between first person and third person in VR. None = no key.");
			FirstPersonControllerToggle = config.Bind<bool>("VR First Person", "FirstPersonControllerToggle", true, "With MotionControls, hold the left grip button and press the right thumbstick to switch between first person and third person (the right grip button and left thumbstick with MirrorButtons). Pressing the thumbstick without the grip button still drops your item.");
			FirstPersonTurn = config.Bind<TurnMode>("VR First Person", "FirstPersonTurn", TurnMode.Smooth, "How the right thumbstick turns you in first person. Snap = turns in steps of SnapTurnAngle, Smooth = turns continuously, like the third-person camera. A mouse always turns smoothly.");
			SnapTurnAngle = config.Bind<float>("VR First Person", "SnapTurnAngle", 30f, new ConfigDescription("Degrees each snap turn turns you, with FirstPersonTurn = Snap.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 90f), Array.Empty<object>()));
			FirstPersonEyeOffset = config.Bind<float>("VR First Person", "FirstPersonEyeOffset", 0f, new ConfigDescription("Raises (positive) or lowers (negative) your eyes in first person, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>()));
			DiagnosticsEnabled = config.Bind<bool>("Diagnostics", "Enabled", true, "Write VR, camera and renderer details to the BepInEx log (LogOutput.log), so problems in the headset can be tracked down from the log. Only changes are logged, not every frame.");
			PerformanceLogInterval = config.Bind<float>("Diagnostics", "PerformanceLogInterval", 30f, new ConfigDescription("Seconds between frame rate lines in the log while VR is running. 0 = never.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>()));
		}
	}
	internal static class VrState
	{
		private static readonly List<XRDisplaySubsystem> Displays = new List<XRDisplaySubsystem>();

		internal static bool IsRunning { get; private set; }

		internal static event Action<bool> Changed;

		internal static Camera ViewCamera()
		{
			VrCamera highestDepthVrCamera = VrCamera.HighestDepthVrCamera;
			if ((Object)(object)highestDepthVrCamera != (Object)null && ((Behaviour)highestDepthVrCamera).isActiveAndEnabled && (Object)(object)highestDepthVrCamera.ParentCamera != (Object)null)
			{
				return highestDepthVrCamera.ParentCamera;
			}
			return Camera.main;
		}

		internal static void Refresh()
		{
			SubsystemManager.GetSubsystems<XRDisplaySubsystem>(Displays);
			bool flag = false;
			foreach (XRDisplaySubsystem display in Displays)
			{
				if (((IntegratedSubsystem)display).running)
				{
					flag = true;
					break;
				}
			}
			if (flag == IsRunning)
			{
				return;
			}
			IsRunning = flag;
			Plugin.Log.LogInfo((object)(flag ? "VR started: VR settings are on." : "VR stopped: the game is back to normal."));
			Action<bool> changed = VrState.Changed;
			if (changed == null)
			{
				return;
			}
			Delegate[] invocationList = changed.GetInvocationList();
			for (int i = 0; i < invocationList.Length; i++)
			{
				Action<bool> action = (Action<bool>)invocationList[i];
				try
				{
					action(flag);
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)("VR " + (flag ? "start" : "stop") + ": " + (action.Method.DeclaringType?.Name ?? "a feature") + " " + $"failed; the other features carry on. {arg}"));
				}
			}
		}
	}
	[DefaultExecutionOrder(-30000)]
	internal sealed class VrStateTracker : MonoBehaviour
	{
		private void Update()
		{
			VrState.Refresh();
		}
	}
}
namespace SBGVR.View
{
	[HarmonyPatch]
	internal static class FirstPersonPatches
	{
		[HarmonyPatch(typeof(CameraModuleController), "TransitionToInternal")]
		[HarmonyPrefix]
		private static void KeepFirstPerson(ref CameraModuleType cameraType)
		{
			if ((int)cameraType == 1 && FirstPersonView.ShouldRedirectToFirstPerson())
			{
				cameraType = (CameraModuleType)2;
			}
		}

		[HarmonyPatch(typeof(FirstPersonCameraModule), "UpdateModule")]
		[HarmonyPrefix]
		private static void BeforeUpdateModule(FirstPersonCameraModule __instance)
		{
			FirstPersonView.BeforeModuleUpdate(__instance);
		}

		[HarmonyPatch(typeof(FirstPersonCameraModule), "Rotate")]
		[HarmonyPrefix]
		private static bool Turn(FirstPersonCameraModule __instance, ref Vector2 axis)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!FirstPersonView.Shows(__instance))
			{
				return true;
			}
			if (FirstPersonView.InGolfCart())
			{
				__instance.InformNoRotation();
				return false;
			}
			axis.y = 0f;
			if (Settings.FirstPersonTurn.Value != TurnMode.Snap || !PlayerInput.UsingGamepad || FirstPersonView.IsAimingShot())
			{
				return true;
			}
			CameraActions camera = PlayerInput.Controls.Camera;
			Vector2 val = ((CameraActions)(ref camera)).Look.ReadValue<Vector2>();
			FirstPersonView.SnapTurn(__instance, val.x);
			__instance.InformNoRotation();
			return false;
		}

		[HarmonyPatch(typeof(PlayerInventory), "UpdateIsInFirstPersonAim")]
		[HarmonyPrefix]
		private static void BeforeRailgunScope(out float __state)
		{
			__state = float.NaN;
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (FirstPersonView.Owns && CameraModuleController.TryGetFirstPersonModule(ref val) && (Object)(object)val != (Object)null)
			{
				__state = val.Yaw;
			}
		}

		[HarmonyPatch(typeof(PlayerInventory), "UpdateIsInFirstPersonAim")]
		[HarmonyPostfix]
		private static void AfterRailgunScope(PlayerInventory __instance, float __state)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (!float.IsNaN(__state) && FirstPersonView.Owns && CameraModuleController.TryGetFirstPersonModule(ref val) && !((Object)(object)val == (Object)null))
			{
				val.SetYaw(__state);
				val.SetPitch(0f);
				val.SetLocalPosition(Vector3.zero);
				if (!__instance.IsInFirstPersonAim)
				{
					val.CancelFovOverrideInstantly();
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class FirstPersonMovementPatches
	{
		private static readonly MethodInfo GetYaw = AccessTools.PropertyGetter(typeof(FirstPersonCameraModule), "Yaw");

		private static readonly MethodInfo YawOf = AccessTools.Method(typeof(FirstPersonView), "YawOf", (Type[])null, (Type[])null);

		private static IEnumerable<MethodBase> TargetMethods()
		{
			yield return Method("ProcessMovementInput");
			yield return Method("UpdateTargetYaw");
		}

		private static MethodBase Method(string name)
		{
			return AccessTools.Method(typeof(PlayerMovement), name, (Type[])null, (Type[])null) ?? throw new MissingMethodException("PlayerMovement", name);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original)
		{
			List<CodeInstruction> list = instructions.ToList();
			int num = 0;
			foreach (CodeInstruction item in list)
			{
				if (CodeInstructionExtensions.Calls(item, GetYaw))
				{
					item.opcode = OpCodes.Call;
					item.operand = YawOf;
					num++;
				}
			}
			if (num == 0)
			{
				throw new InvalidOperationException("PlayerMovement." + original.Name + " no longer reads the first-person camera's yaw.");
			}
			return list;
		}
	}
	internal enum TurnMode
	{
		Snap,
		Smooth
	}
	internal sealed class FirstPersonView : MonoBehaviour
	{
		private const float EyeHeightSmoothing = 0.2f;

		private const float EyeHeight = 1.5f;

		private const float SnapThreshold = 0.7f;

		private const float SnapReset = 0.3f;

		private static Transform _anchor;

		private static FirstPersonCameraModule _anchoredModule;

		private static bool _owns;

		private static float _eyeHeight;

		private static bool _snapArmed = true;

		private static string _lastStatus;

		private static bool _loggedEyeHeight;

		private static bool _wasAimingShot;

		internal static bool Owns => _owns;

		internal static bool Shows(FirstPersonCameraModule module)
		{
			if (_owns && (Object)(object)module != (Object)null)
			{
				return module == _anchoredModule;
			}
			return false;
		}

		internal static void Toggle()
		{
			if (VrState.IsRunning)
			{
				Settings.FirstPerson.Value = !Settings.FirstPerson.Value;
				Plugin.Log.LogInfo((object)(Settings.FirstPerson.Value ? "First person: on." : "First person: off."));
			}
		}

		private void OnEnable()
		{
			VrState.Changed += OnVrChanged;
		}

		private void OnDisable()
		{
			VrState.Changed -= OnVrChanged;
		}

		private static void OnVrChanged(bool running)
		{
			_snapArmed = true;
		}

		private void Update()
		{
			HandleKey();
			Refresh();
			StartShotAimWhereLooking();
		}

		private static void StartShotAimWhereLooking()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = _owns && IsAimingShot();
			bool num = flag && !_wasAimingShot;
			_wasAimingShot = flag;
			if (!num)
			{
				return;
			}
			FirstPersonCameraModule anchoredModule = _anchoredModule;
			if (!Shows(anchoredModule) || !ControllerAim.TryGetHeadPose(out var _, out var rotation))
			{
				return;
			}
			float num2 = Mathf.DeltaAngle(anchoredModule.Yaw, HorizontalYaw(rotation));
			if (!(Mathf.Abs(num2) < 0.1f))
			{
				anchoredModule.SetYaw(anchoredModule.Yaw + num2);
				VrCameraOffset.RecenterRotation = Quaternion.Euler(0f, 0f - num2, 0f) * VrCameraOffset.RecenterRotation;
				if (Settings.DiagnosticsEnabled.Value)
				{
					Plugin.Log.LogInfo((object)$"First person: shot aim starts where you're looking ({num2:+0;-0;0}° from the view's forward).");
				}
			}
		}

		private static void HandleKey()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!VrState.IsRunning)
			{
				return;
			}
			Key value = Settings.FirstPersonKey.Value;
			if ((int)value == 0)
			{
				return;
			}
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				KeyControl val = current[value];
				if (val != null && ((ButtonControl)val).wasPressedThisFrame)
				{
					Toggle();
				}
			}
		}

		private static void Refresh()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			CameraModuleType currentModuleType = CameraModuleController.CurrentModuleType;
			if (_owns && (int)currentModuleType != 2)
			{
				_owns = false;
			}
			bool value = Settings.FirstPerson.Value;
			string reason;
			bool flag = IsAllowed(out reason);
			LogStatus(value, flag, reason);
			if (value && flag)
			{
				if (!_owns && !CameraModuleController.IsTransitioning)
				{
					if ((int)currentModuleType == 1)
					{
						Enter();
					}
					else if ((int)currentModuleType == 2)
					{
						Adopt();
					}
				}
			}
			else if (_owns && !InRailgunScope())
			{
				Exit();
			}
			if (!_owns && (Object)(object)_anchoredModule != (Object)null && !CameraModuleController.IsTransitioning)
			{
				ReleaseViewer();
			}
			if (!_owns)
			{
				_snapArmed = true;
			}
		}

		private static bool IsAllowed(out string reason)
		{
			reason = null;
			if (!VrState.IsRunning)
			{
				return false;
			}
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			PlayerMovement localPlayerMovement = GameManager.LocalPlayerMovement;
			if ((Object)(object)localPlayerInfo == (Object)null || (Object)(object)localPlayerMovement == (Object)null)
			{
				return false;
			}
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (!CameraModuleController.TryGetFirstPersonModule(ref val) || (Object)(object)val == (Object)null)
			{
				return false;
			}
			PlayerSpectator localPlayerAsSpectator = GameManager.LocalPlayerAsSpectator;
			if ((Object)(object)localPlayerAsSpectator != (Object)null && localPlayerAsSpectator.IsSpectating)
			{
				reason = "spectating";
				return false;
			}
			if (localPlayerMovement.IsKnockedOutOrRecovering)
			{
				reason = "knocked out";
				return false;
			}
			if (localPlayerMovement.IsRespawningOrDrowning)
			{
				reason = "respawning";
				return false;
			}
			return true;
		}

		private static void LogStatus(bool wanted, bool allowed, string reason)
		{
			string text = ((wanted && !allowed && reason != null) ? reason : null);
			if (!(text == _lastStatus))
			{
				string lastStatus = _lastStatus;
				_lastStatus = text;
				if (text != null)
				{
					Plugin.Log.LogInfo((object)("First person: third person while " + text + "."));
				}
				else if (wanted && lastStatus != null)
				{
					Plugin.Log.LogInfo((object)"First person: back in first person.");
				}
			}
		}

		private static bool InRailgunScope()
		{
			PlayerInventory localPlayerInventory = GameManager.LocalPlayerInventory;
			if ((Object)(object)localPlayerInventory != (Object)null)
			{
				return localPlayerInventory.IsInFirstPersonAim;
			}
			return false;
		}

		private static void Enter()
		{
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (CameraModuleController.TryGetFirstPersonModule(ref val) && !((Object)(object)val == (Object)null))
			{
				Prepare(val, fromOrbit: true);
				_owns = true;
				GameplayCameraManager.TransitionTo((CameraModuleType)2);
			}
		}

		private static void Adopt()
		{
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (CameraModuleController.TryGetFirstPersonModule(ref val) && !((Object)(object)val == (Object)null))
			{
				Prepare(val, fromOrbit: false);
				_owns = true;
			}
		}

		private static void Exit()
		{
			_owns = false;
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			OrbitCameraModule val2 = default(OrbitCameraModule);
			if (CameraModuleController.TryGetFirstPersonModule(ref val) && (Object)(object)val != (Object)null && CameraModuleController.TryGetOrbitModule(ref val2) && (Object)(object)val2 != (Object)null)
			{
				val2.SetYaw(val.Yaw);
				val2.ForceUpdateModule();
			}
			GameplayCameraManager.TransitionTo((CameraModuleType)1);
		}

		internal static bool ShouldRedirectToFirstPerson()
		{
			if (!Settings.FirstPerson.Value || !IsAllowed(out var _))
			{
				return false;
			}
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (!CameraModuleController.TryGetFirstPersonModule(ref val) || (Object)(object)val == (Object)null)
			{
				return false;
			}
			if (!_owns)
			{
				Prepare(val, fromOrbit: true);
			}
			_owns = true;
			return true;
		}

		private static void Prepare(FirstPersonCameraModule module, bool fromOrbit)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (fromOrbit)
			{
				OrbitCameraModule val = default(OrbitCameraModule);
				if (CameraModuleController.TryGetOrbitModule(ref val) && (Object)(object)val != (Object)null)
				{
					module.SetYaw(val.Yaw);
				}
				module.CancelFovOverrideInstantly();
			}
			module.SetPitch(0f);
			module.SetRoll(0f);
			UpdateAnchor(snap: true);
			module.SetViewer(Anchor());
			module.SetLocalPosition(Vector3.zero);
			_anchoredModule = module;
			_snapArmed = true;
		}

		private static void ReleaseViewer()
		{
			FirstPersonCameraModule anchoredModule = _anchoredModule;
			_anchoredModule = null;
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if ((Object)(object)anchoredModule != (Object)null && (Object)(object)localPlayerInfo != (Object)null)
			{
				anchoredModule.SetViewer(((Component)localPlayerInfo).transform);
			}
		}

		internal static void BeforeModuleUpdate(FirstPersonCameraModule module)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)module == (Object)null || module != _anchoredModule)
			{
				return;
			}
			UpdateAnchor(snap: false);
			module.SetViewer(_anchor);
			module.SetLocalPosition(Vector3.zero);
			if (_owns)
			{
				module.SetPitch(WeaponMotionCamera.FirstPersonPitch);
				module.SetRoll(0f);
				if (TryGetCart(out var cart))
				{
					module.SetYaw(HorizontalYaw(cart.rotation));
				}
			}
		}

		private static bool TryGetCart(out Transform cart)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			cart = null;
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if ((Object)(object)localPlayerInfo == (Object)null)
			{
				return false;
			}
			GolfCartSeat activeGolfCartSeat = localPlayerInfo.ActiveGolfCartSeat;
			if (!((GolfCartSeat)(ref activeGolfCartSeat)).IsValid() || (Object)(object)activeGolfCartSeat.golfCart == (Object)null)
			{
				return false;
			}
			GolfCartMovement movement = activeGolfCartSeat.golfCart.Movement;
			cart = (((Object)(object)movement != (Object)null) ? ((Component)movement).transform : ((Component)activeGolfCartSeat.golfCart).transform);
			return true;
		}

		internal static bool InGolfCart()
		{
			Transform cart;
			if (_owns)
			{
				return TryGetCart(out cart);
			}
			return false;
		}

		private static void UpdateAnchor(bool snap)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if (!((Object)(object)localPlayerInfo == (Object)null))
			{
				Transform transform = ((Component)localPlayerInfo).transform;
				PlayerMovement movement = localPlayerInfo.Movement;
				float num = (((Object)(object)movement != (Object)null) ? movement.CharacterScale : 1f);
				float num2 = 1.5f * num * transform.lossyScale.y + Settings.FirstPersonEyeOffset.Value;
				_eyeHeight = (snap ? num2 : Mathf.Lerp(_eyeHeight, num2, 1f - Mathf.Exp((0f - Time.unscaledDeltaTime) / 0.2f)));
				Transform cart;
				Vector3 val = (TryGetCart(out cart) ? cart.position : transform.position);
				Anchor().SetPositionAndRotation(val + Vector3.up * _eyeHeight, Quaternion.identity);
				if (snap)
				{
					LogEyeHeight(localPlayerInfo, num);
				}
			}
		}

		private static void LogEyeHeight(PlayerInfo player, float scale)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!_loggedEyeHeight && Settings.DiagnosticsEnabled.Value)
			{
				_loggedEyeHeight = true;
				Transform headBone = player.HeadBone;
				string text = (((Object)(object)headBone != (Object)null) ? $"{headBone.position.y - ((Component)player).transform.position.y:0.00} m" : "unknown");
				Plugin.Log.LogInfo((object)($"First person: eyes {_eyeHeight:0.00} m above the feet ({1.5f:0.00} m × scale {scale:0.##}, offset {Settings.FirstPersonEyeOffset.Value:0.00} m); " + "head bone " + text + " above the feet."));
			}
		}

		private static Transform Anchor()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			if ((Object)(object)_anchor != (Object)null)
			{
				return _anchor;
			}
			GameObject val = new GameObject("SBGVR First Person Eyes")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			_anchor = val.transform;
			return _anchor;
		}

		internal static bool IsAimingShot()
		{
			PlayerGolfer localPlayerAsGolfer = GameManager.LocalPlayerAsGolfer;
			if ((Object)(object)localPlayerAsGolfer != (Object)null)
			{
				if (!localPlayerAsGolfer.IsAimingSwing && !localPlayerAsGolfer.IsChargingSwing)
				{
					return localPlayerAsGolfer.IsSwinging;
				}
				return true;
			}
			return false;
		}

		internal static float YawOf(FirstPersonCameraModule module)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (Shows(module) && !IsAimingShot() && !WeaponMotionCamera.SteersFirstPerson && ControllerAim.TryGetHeadPose(out var _, out var rotation))
			{
				return HorizontalYaw(rotation);
			}
			return module.Yaw;
		}

		internal static bool TryGetHeadAimRay(out Vector3 origin, out Vector3 direction)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			direction = default(Vector3);
			if (!Shows(_anchoredModule) || IsAimingShot() || !ControllerAim.TryGetHeadPose(out origin, out var rotation))
			{
				origin = default(Vector3);
				return false;
			}
			direction = rotation * Vector3.forward;
			return true;
		}

		private static float HorizontalYaw(Quaternion rotation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = rotation * Vector3.forward;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.x, 0f, val.z);
			if (((Vector3)(ref val2)).sqrMagnitude < 0.04f)
			{
				Vector3 val3 = rotation * Vector3.up;
				val2 = ((val.y < 0f) ? new Vector3(val3.x, 0f, val3.z) : new Vector3(0f - val3.x, 0f, 0f - val3.z));
			}
			return Mathf.Atan2(val2.x, val2.z) * 57.29578f;
		}

		internal static void SnapTurn(FirstPersonCameraModule module, float stickX)
		{
			float num = Mathf.Abs(stickX);
			if (num < 0.3f)
			{
				_snapArmed = true;
			}
			else if (_snapArmed && !(num < 0.7f))
			{
				_snapArmed = false;
				module.SetYaw(module.Yaw + Mathf.Sign(stickX) * Settings.SnapTurnAngle.Value);
			}
		}
	}
	internal sealed class RailgunScopeZoom : MonoBehaviour
	{
		private const float MaxFactor = 20f;

		private static int _factorFrame = -1;

		private static float _factor = 1f;

		private static bool _wasZoomed;

		private Transform _screen;

		private Renderer _screenRenderer;

		private Material _screenMaterial;

		private Material _onTopMaterial;

		private Vector3 _screenPosition;

		private bool _screenMoved;

		private bool _loggedLock;

		internal static bool ZoomAvailable;

		private static int _lockFrame = -1;

		private static bool _locked;

		internal static bool ViewLocked
		{
			get
			{
				if (_lockFrame == Time.frameCount)
				{
					return _locked;
				}
				_lockFrame = Time.frameCount;
				_locked = IsAimingRailgun() && CameraIsTheAim();
				return _locked;
			}
		}

		internal static float Factor
		{
			get
			{
				if (_factorFrame == Time.frameCount)
				{
					return _factor;
				}
				_factorFrame = Time.frameCount;
				_factor = ComputeFactor();
				return _factor;
			}
		}

		internal static float HudScale => 1f / Factor;

		private static float ComputeFactor()
		{
			float setting = 0f;
			float scope = 0f;
			bool flag = ZoomAvailable && ViewLocked && TryGetScopeFov(out setting, out scope);
			float result = (flag ? Mathf.Clamp(Mathf.Tan(setting * 0.5f * ((float)Math.PI / 180f)) / Mathf.Tan(scope * 0.5f * ((float)Math.PI / 180f)), 1f, 20f) : 1f);
			if (flag != _wasZoomed && flag)
			{
				LogZoom(setting);
			}
			_wasZoomed = flag;
			return result;
		}

		private static bool TryGetScopeFov(out float setting, out float scope)
		{
			setting = (scope = 0f);
			if (!VrState.IsRunning)
			{
				return false;
			}
			PlayerInventory localPlayerInventory = GameManager.LocalPlayerInventory;
			if ((Object)(object)localPlayerInventory == (Object)null || !localPlayerInventory.IsInFirstPersonAim)
			{
				return false;
			}
			FirstPersonCameraModule val = default(FirstPersonCameraModule);
			if (!CameraModuleController.TryGetFirstPersonModule(ref val) || (Object)(object)val == (Object)null)
			{
				return false;
			}
			AllSettings all = GameSettings.All;
			if (((all != null) ? all.Graphics : null) == null)
			{
				return false;
			}
			setting = all.Graphics.FieldOfView;
			scope = ((CameraModule)val).FieldOfView;
			if (setting > 1f && setting < 179f && scope > 0.1f)
			{
				return scope < 179f;
			}
			return false;
		}

		private static void LogZoom(float setting)
		{
			if (Settings.DiagnosticsEnabled.Value)
			{
				ItemSettings itemSettings = GameManager.ItemSettings;
				if (!((Object)(object)itemSettings == (Object)null))
				{
					Plugin.Log.LogInfo((object)($"[diag] Railgun scope: field of view {setting:0.#} (setting), {itemSettings.RailgunZoomInitialFov:0.#} " + $"to {itemSettings.RailgunZoomFinalFov:0.#} over {itemSettings.RailgunZoomFovChangeDuration:0.##} s (scope): " + $"magnifies {Magnification(itemSettings.RailgunZoomInitialFov):0.00}x to {Magnification(itemSettings.RailgunZoomFinalFov):0.00}x."));
				}
			}
			float Magnification(float fov)
			{
				return Mathf.Tan(setting * 0.5f * ((float)Math.PI / 180f)) / Mathf.Tan(fov * 0.5f * ((float)Math.PI / 180f));
			}
		}

		internal static bool IsAimingRailgun()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			if (!VrState.IsRunning)
			{
				return false;
			}
			PlayerInventory localPlayerInventory = GameManager.LocalPlayerInventory;
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if ((Object)(object)localPlayerInventory != (Object)null && (Object)(object)localPlayerInfo != (Object)null && (int)localPlayerInfo.NetworkedEquippedItem == 16)
			{
				if (!localPlayerInventory.IsInFirstPersonAim && !localPlayerInventory.IsAimingItem)
				{
					return localPlayerInventory.IsUsingItemAtAll;
				}
				return true;
			}
			return false;
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.onBeforeRender += new UnityAction(UpdateViewLock);
		}

		private static bool CameraIsTheAim()
		{
			if (!Settings.MotionControls.Value || !Settings.ControllerAiming.Value || !MotionControls.InUse)
			{
				return !FirstPersonView.Owns;
			}
			Quaternion rotation;
			return WeaponMotionCamera.TryGetCameraAim(out rotation);
		}

		private void UpdateViewLock()
		{
			bool flag = (VrCamera.LookWhereGameCameraLooks = ViewLocked);
			if (flag != _loggedLock && Settings.DiagnosticsEnabled.Value)
			{
				_loggedLock = flag;
				Plugin.Log.LogInfo((object)(flag ? "Railgun: view and aim locked to the camera; the headset's rotation and position don't move them." : "Railgun: aiming ended; head tracking is back."));
			}
		}

		private void LateUpdate()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			float factor = Factor;
			if (factor > 1f && FindScreen())
			{
				if (!_screenMoved)
				{
					_screenPosition = _screen.localPosition;
					_screenMoved = true;
				}
				_screen.localPosition = new Vector3(_screenPosition.x, _screenPosition.y, _screenPosition.z * factor);
				DrawScreenOnTop(onTop: true);
			}
			else
			{
				RestoreScreen();
			}
		}

		private void OnDisable()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			RestoreScreen();
			Application.onBeforeRender -= new UnityAction(UpdateViewLock);
			VrCamera.LookWhereGameCameraLooks = false;
		}

		private void RestoreScreen()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (_screenMoved)
			{
				_screenMoved = false;
				if ((Object)(object)_screen != (Object)null)
				{
					_screen.localPosition = _screenPosition;
				}
				DrawScreenOnTop(onTop: false);
			}
		}

		private bool FindScreen()
		{
			if ((Object)(object)_screen != (Object)null)
			{
				return true;
			}
			VrUiManager val = Object.FindAnyObjectByType<VrUiManager>();
			_screen = (((Object)(object)val != (Object)null) ? ((Component)val).transform.Find("VrUiContainer/VrUiQuad") : null);
			_screenRenderer = (((Object)(object)_screen != (Object)null) ? ((Component)_screen).GetComponent<Renderer>() : null);
			if ((Object)(object)_screen != (Object)null && (Object)(object)_screenRenderer != (Object)null)
			{
				return true;
			}
			_screen = null;
			return false;
		}

		private void DrawScreenOnTop(bool onTop)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			if ((Object)(object)_screenRenderer == (Object)null)
			{
				return;
			}
			if (onTop)
			{
				Material sharedMaterial = _screenRenderer.sharedMaterial;
				if (!((Object)(object)sharedMaterial == (Object)null) && !((Object)(object)sharedMaterial == (Object)(object)_onTopMaterial))
				{
					if ((Object)(object)_onTopMaterial != (Object)null)
					{
						Object.Destroy((Object)(object)_onTopMaterial);
					}
					_screenMaterial = sharedMaterial;
					_onTopMaterial = new Material(sharedMaterial)
					{
						name = ((Object)sharedMaterial).name + " (SBGVR scope zoom)"
					};
					_onTopMaterial.SetInt(GuiZTest.Id, 8);
					_screenRenderer.sharedMaterial = _onTopMaterial;
				}
			}
			else if ((Object)(object)_screenMaterial != (Object)null && (Object)(object)_screenRenderer.sharedMaterial == (Object)(object)_onTopMaterial)
			{
				_screenRenderer.sharedMaterial = _screenMaterial;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_onTopMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_onTopMaterial);
			}
		}
	}
	[HarmonyPatch]
	internal static class RailgunScopeZoomPatches
	{
		private static readonly FieldInfo Projection = AccessTools.Field(typeof(XRRenderParameter), "projection");

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(XRSystem), "BuildView", (Type[])null, (Type[])null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			int found = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				yield return instruction;
				if (CodeInstructionExtensions.LoadsField(instruction, Projection, false))
				{
					found++;
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RailgunScopeZoomPatches), "Zoom", (Type[])null, (Type[])null));
				}
			}
			if (found != 1)
			{
				throw new InvalidOperationException($"XRSystem.BuildView reads the eye's projection {found} times, expected once");
			}
		}

		private static Matrix4x4 Zoom(Matrix4x4 projection)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			float factor = RailgunScopeZoom.Factor;
			if (factor <= 1f)
			{
				return projection;
			}
			projection.m00 *= factor;
			projection.m11 *= factor;
			return projection;
		}
	}
}
namespace SBGVR.Rendering
{
	[HarmonyPatch]
	internal static class AmbientOcclusionPatches
	{
		private const string OcclusionKeyword = "_SCREEN_SPACE_OCCLUSION";

		internal static bool EyePatchesApplied;

		[HarmonyPatch(typeof(HTraceAORendererFeature), "AddRenderPasses")]
		[HarmonyPrefix]
		private static bool AddRenderPasses(ref RenderingData renderingData)
		{
			if (VrState.IsRunning && (!EyePatchesApplied || !Settings.AmbientOcclusion.Value))
			{
				Shader.DisableKeyword("_SCREEN_SPACE_OCCLUSION");
				return false;
			}
			if (EyePatchesApplied)
			{
				EyeView.Capture(ref renderingData);
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class AmbientOcclusionEyePatches
	{
		private static readonly Dictionary<MethodInfo, MethodInfo> CameraGetters = new Dictionary<MethodInfo, MethodInfo>
		{
			[Getter("scaledPixelWidth")] = Hook("ScaledPixelWidth"),
			[Getter("scaledPixelHeight")] = Hook("ScaledPixelHeight"),
			[Getter("pixelHeight")] = Hook("PixelHeight"),
			[Getter("fieldOfView")] = Hook("FieldOfView"),
			[Getter("projectionMatrix")] = Hook("ProjectionMatrix"),
			[Getter("nonJitteredProjectionMatrix")] = Hook("NonJitteredProjectionMatrix"),
			[Getter("worldToCameraMatrix")] = Hook("WorldToCameraMatrix")
		};

		private static readonly MethodInfo GetHashCodeMethod = AccessTools.Method(typeof(object), "GetHashCode", (Type[])null, (Type[])null);

		private static readonly MethodInfo FrameCountGetter = AccessTools.PropertyGetter(typeof(Time), "frameCount");

		private static readonly MethodInfo SetGlobalVector = AccessTools.Method(typeof(CommandBuffer), "SetGlobalVector", new Type[2]
		{
			typeof(int),
			typeof(Vector4)
		}, (Type[])null);

		private const string DepthToViewParamsField = "g_HDepthToViewParamsAO";

		private static int _getterCount;

		private static int _historyKeyCount;

		private static int _depthToViewCount;

		private static MethodInfo Getter(string property)
		{
			return AccessTools.PropertyGetter(typeof(Camera), property);
		}

		private static MethodInfo Hook(string name)
		{
			return AccessTools.Method(typeof(EyeView), name, (Type[])null, (Type[])null);
		}

		private static IEnumerable<MethodBase> TargetMethods()
		{
			Assembly assembly = typeof(HTraceAORendererFeature).Assembly;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (type.ContainsGenericParameters)
				{
					continue;
				}
				foreach (MethodBase item in type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Cast<MethodBase>().Concat(type.GetConstructors(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)))
				{
					if (!item.IsAbstract && !item.ContainsGenericParameters && item.GetMethodBody() != null && ReadsCamera(item))
					{
						yield return item;
					}
				}
			}
		}

		private static bool ReadsCamera(MethodBase method)
		{
			try
			{
				List<KeyValuePair<OpCode, object>> list = PatchProcessor.ReadMethodBody(method).ToList();
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].Value is MethodInfo methodInfo)
					{
						if (CameraGetters.ContainsKey(methodInfo))
						{
							return true;
						}
						if (methodInfo == GetHashCodeMethod && i + 1 < list.Count && list[i + 1].Value as MethodInfo == FrameCountGetter)
						{
							return true;
						}
					}
				}
				return false;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			int num = CameraArgument(original);
			for (int i = 0; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.operand is MethodInfo key && CameraGetters.TryGetValue(key, out var value) && (val.opcode == OpCodes.Callvirt || val.opcode == OpCodes.Call))
				{
					list[i] = CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Call, (object)value), val), val);
					_getterCount++;
				}
				else if (val.operand is MethodInfo methodInfo && methodInfo == GetHashCodeMethod && i + 1 < list.Count && CodeInstructionExtensions.Calls(list[i + 1], FrameCountGetter) && (i == 0 || list[i - 1].opcode != OpCodes.Constrained))
				{
					list[i] = CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Call, (object)Hook("HistoryKey")), val), val);
					_historyKeyCount++;
				}
				else if (num >= 0 && val.opcode == OpCodes.Ldsfld && val.operand is FieldInfo { Name: "g_HDepthToViewParamsAO" } && i + 2 < list.Count && CodeInstructionExtensions.IsLdloc(list[i + 1], (LocalBuilder)null) && CodeInstructionExtensions.Calls(list[i + 2], SetGlobalVector))
				{
					list.Insert(i + 2, LoadArgument(num));
					list.Insert(i + 3, new CodeInstruction(OpCodes.Call, (object)Hook("DepthToViewParams")));
					_depthToViewCount++;
					i += 3;
				}
			}
			return list;
		}

		private static CodeInstruction LoadArgument(int index)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			return (CodeInstruction)(index switch
			{
				0 => (object)new CodeInstruction(OpCodes.Ldarg_0, (object)null), 
				1 => (object)new CodeInstruction(OpCodes.Ldarg_1, (object)null), 
				2 => (object)new CodeInstruction(OpCodes.Ldarg_2, (object)null), 
				3 => (object)new CodeInstruction(OpCodes.Ldarg_3, (object)null), 
				_ => (object)new CodeInstruction(OpCodes.Ldarg_S, (object)(byte)index), 
			});
		}

		private static int CameraArgument(MethodBase method)
		{
			ParameterInfo[] parameters = method.GetParameters();
			for (int i = 0; i < parameters.Length; i++)
			{
				if (parameters[i].ParameterType == typeof(Camera))
				{
					if (!method.IsStatic)
					{
						return i + 1;
					}
					return i;
				}
			}
			return -1;
		}

		internal static void Verify()
		{
			bool num = (AmbientOcclusionPatches.EyePatchesApplied = _getterCount > 0 && _historyKeyCount > 0 && _depthToViewCount > 0);
			string text = $"{_getterCount} camera reads, {_historyKeyCount} history keys, " + $"{_depthToViewCount} view factor(s)";
			if (num)
			{
				Plugin.Log.LogInfo((object)("Ambient occlusion: draws for each eye in VR (" + text + ")."));
			}
			else
			{
				Plugin.Log.LogWarning((object)("Ambient occlusion: HTrace AO isn't the code SBGVR expects (" + text + "), so it's off in VR."));
			}
		}
	}
	internal static class EyeView
	{
		private static Camera _camera;

		private static int _eye;

		private static int _width;

		private static int _height;

		private static Matrix4x4 _projection;

		private static Matrix4x4 _view;

		private static int _loggedWidth;

		private static int _loggedHeight;

		internal static void Capture(ref RenderingData renderingData)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			ref CameraData cameraData = ref renderingData.cameraData;
			XRPass xr = ((CameraData)(ref cameraData)).xr;
			if (xr == null || !xr.enabled || xr.singlePassEnabled)
			{
				_camera = null;
				return;
			}
			RenderTextureDescriptor cameraTargetDescriptor = ((CameraData)(ref cameraData)).cameraTargetDescriptor;
			_camera = ((CameraData)(ref cameraData)).camera;
			_eye = xr.multipassId;
			_width = ((RenderTextureDescriptor)(ref cameraTargetDescriptor)).width;
			_height = ((RenderTextureDescriptor)(ref cameraTargetDescriptor)).height;
			_projection = ((CameraData)(ref cameraData)).GetProjectionMatrix(0);
			_view = ((CameraData)(ref cameraData)).GetViewMatrix(0);
			if (_width != _loggedWidth || _height != _loggedHeight)
			{
				_loggedWidth = _width;
				_loggedHeight = _height;
				Plugin.Log.LogInfo((object)$"Ambient occlusion: drawn for each eye at {_width}x{_height}.");
			}
		}

		private static bool IsEye(Camera camera)
		{
			if ((Object)(object)_camera != (Object)null)
			{
				return camera == _camera;
			}
			return false;
		}

		internal static int ScaledPixelWidth(Camera camera)
		{
			if (!IsEye(camera))
			{
				return camera.scaledPixelWidth;
			}
			return _width;
		}

		internal static int ScaledPixelHeight(Camera camera)
		{
			if (!IsEye(camera))
			{
				return camera.scaledPixelHeight;
			}
			return _height;
		}

		internal static int PixelHeight(Camera camera)
		{
			if (!IsEye(camera))
			{
				return camera.pixelHeight;
			}
			return _height;
		}

		internal static float FieldOfView(Camera camera)
		{
			if (!IsEye(camera))
			{
				return camera.fieldOfView;
			}
			return 2f * Mathf.Atan(1f / _projection.m11) * 57.29578f;
		}

		internal static Matrix4x4 ProjectionMatrix(Camera camera)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEye(camera))
			{
				return camera.projectionMatrix;
			}
			return _projection;
		}

		internal static Matrix4x4 NonJitteredProjectionMatrix(Camera camera)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEye(camera))
			{
				return camera.nonJitteredProjectionMatrix;
			}
			return _projection;
		}

		internal static Matrix4x4 WorldToCameraMatrix(Camera camera)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEye(camera))
			{
				return camera.worldToCameraMatrix;
			}
			return _view;
		}

		internal static int HistoryKey(object camera)
		{
			Camera val = (Camera)((camera is Camera) ? camera : null);
			if (val != null && IsEye(val))
			{
				return (((object)val).GetHashCode() * 397) ^ (_eye + 1);
			}
			return camera.GetHashCode();
		}

		internal static Vector4 DepthToViewParams(Vector4 original, Camera camera)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEye(camera))
			{
				return original;
			}
			Matrix4x4 projection = _projection;
			return new Vector4(2f / projection.m00, 2f / projection.m11, (0f - (1f - projection.m02)) / projection.m00, (0f - (1f - projection.m12)) / projection.m11);
		}
	}
	internal static class GuiZTest
	{
		internal const string Name = "unity_GUIZTestMode";

		internal static readonly int Id = Shader.PropertyToID("unity_GUIZTestMode");
	}
	[HarmonyPatch]
	internal static class StealthFramePatches
	{
		[HarmonyPatch(typeof(StealthFrameFeature), "AddRenderPasses")]
		[HarmonyPrefix]
		private static bool AddRenderPasses(ref RenderingData renderingData)
		{
			if (!VrState.IsRunning || !StealthFrameFeature.Enabled)
			{
				return true;
			}
			return !DrawsFloatingScreen(((CameraData)(ref renderingData.cameraData)).camera);
		}

		private static bool DrawsFloatingScreen(Camera camera)
		{
			if ((Object)(object)camera == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)camera).GetComponent<ScreenMirrorPatchMode>() != (Object)null)
			{
				return true;
			}
			Transform parent = ((Component)camera).transform.parent;
			if ((Object)(object)parent != (Object)null)
			{
				return (Object)(object)((Component)parent).GetComponent<CanvasRedirectPatchMode>() != (Object)null;
			}
			return false;
		}
	}
}
namespace SBGVR.Hud
{
	[DefaultExecutionOrder(30001)]
	internal sealed class AimLine : MonoBehaviour
	{
		private const float WidthPerMetre = 0.0018f;

		private LineRenderer _line;

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			GameObject val = new GameObject("SBGVR Aim Line");
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			_line = val.AddComponent<LineRenderer>();
			_line.useWorldSpace = true;
			_line.positionCount = 2;
			_line.alignment = (LineAlignment)0;
			_line.numCapVertices = 2;
			((Renderer)_line).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)_line).receiveShadows = false;
			((Renderer)_line).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)_line).reflectionProbeUsage = (ReflectionProbeUsage)0;
			((Renderer)_line).allowOcclusionWhenDynamic = false;
			_line.startColor = Color.white;
			_line.endColor = Color.white;
			Material val2 = new Material(Canvas.GetDefaultCanvasMaterial())
			{
				name = "SBGVR aim line",
				color = Color.white,
				renderQueue = 3000
			};
			val2.SetInt(GuiZTest.Id, 4);
			((Renderer)_line).sharedMaterial = val2;
			((Renderer)_line).enabled = false;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_line != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_line).gameObject);
			}
		}

		private void LateUpdate()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 start = Vector3.zero;
			Camera val = ((VrState.IsRunning && Settings.AimLine.Value && WorldReticles.AimShowing && TryGetStart(out start)) ? VrState.ViewCamera() : null);
			if ((Object)(object)val == (Object)null)
			{
				((Renderer)_line).enabled = false;
				return;
			}
			Vector3 aimPoint = WorldReticles.AimPoint;
			Vector3 position = ((Component)val).transform.position;
			_line.SetPosition(0, start);
			_line.SetPosition(1, aimPoint);
			float num = 0.0018f * RailgunScopeZoom.HudScale;
			_line.startWidth = num * Vector3.Distance(position, start);
			_line.endWidth = num * Vector3.Distance(position, aimPoint);
			((Renderer)_line).enabled = true;
		}

		private static bool TryGetStart(out Vector3 start)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			start = default(Vector3);
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			if ((Object)(object)localPlayerInfo == (Object)null)
			{
				return false;
			}
			EquipmentSwitcher rightHandEquipmentSwitcher = localPlayerInfo.RightHandEquipmentSwitcher;
			start = (((Object)(object)rightHandEquipmentSwitcher != (Object)null) ? ((Component)rightHandEquipmentSwitcher).transform.position : (((Component)localPlayerInfo).transform.position + Vector3.up));
			return true;
		}
	}
	internal static class GameAimPoint
	{
		private const float MaxLocalYaw = 45f;

		private const float CrossCheckInterval = 1f;

		private const float CrossCheckTolerance = 0.01f;

		private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[100];

		private static readonly HashSet<ItemType> LoggedWeapons = new HashSet<ItemType>();

		private static readonly HashSet<ItemType> LoggedMismatches = new HashSet<ItemType>();

		private static readonly HashSet<string> LoggedErrors = new HashSet<string>();

		private static float _nextCrossCheck;

		private static bool _unavailable;

		internal static bool TryGet(out Vector3 point, out float range)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			point = default(Vector3);
			range = 0f;
			if (_unavailable)
			{
				return false;
			}
			try
			{
				return TryGetFromGame(out point, out range);
			}
			catch (Exception ex) when (ex is MissingMemberException || ex is TypeLoadException)
			{
				_unavailable = true;
				Plugin.Log.LogError((object)("Gun crosshairs: the game's aiming code has changed (" + ex.GetBaseException().Message + "). Gun crosshairs use SBGVR's own raycast instead."));
				return false;
			}
			catch (Exception ex2)
			{
				if (LoggedErrors.Add(ex2.GetType().FullName + ex2.Message))
				{
					Plugin.Log.LogWarning((object)$"Gun crosshairs: couldn't get the game's aim point: {ex2}");
				}
				return false;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static bool TryGetFromGame(out Vector3 point, out float range)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			point = default(Vector3);
			range = 0f;
			PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
			ItemSettings itemSettings = GameManager.ItemSettings;
			LayerSettings layerSettings = GameManager.LayerSettings;
			if ((Object)(object)localPlayerInfo == (Object)null || (Object)(object)itemSettings == (Object)null || (Object)(object)layerSettings == (Object)null)
			{
				return false;
			}
			PlayerInventory inventory = localPlayerInfo.Inventory;
			if ((Object)(object)inventory == (Object)null)
			{
				return false;
			}
			ItemType networkedEquippedItem = localPlayerInfo.NetworkedEquippedItem;
			Vector3 val;
			Vector3 val2;
			int num;
			int num2;
			if ((int)networkedEquippedItem <= 3)
			{
				if ((int)networkedEquippedItem != 2)
				{
					if ((int)networkedEquippedItem != 3)
					{
						goto IL_0133;
					}
					val = inventory.GetElephantGunBarrelEndPosition();
					val2 = inventory.GetElephantGunBarrelForward();
					range = itemSettings.ElephantGunMaxAimingDistance;
					num = (num2 = LayerMask.op_Implicit(layerSettings.GunHittablesMask));
				}
				else
				{
					val = inventory.GetDuelingPistolBarrelEndPosition();
					val2 = inventory.GetDuelingPistolBarrelForward();
					range = itemSettings.DuelingPistolMaxAimingDistance;
					num = (num2 = LayerMask.op_Implicit(layerSettings.GunHittablesMask));
				}
			}
			else if ((int)networkedEquippedItem != 7)
			{
				if ((int)networkedEquippedItem != 16)
				{
					goto IL_0133;
				}
				val = inventory.GetRailgunBeamOriginPosition();
				val2 = inventory.GetRailgunBarrelForward();
				range = itemSettings.RailgunMaxAimingDistance;
				num = (num2 = LayerMask.op_Implicit(layerSettings.RailgunAimablesMask));
			}
			else
			{
				val = inventory.GetRocketLauncherBarrelFrontEndPosition();
				val2 = inventory.GetRocketLauncherBarrelForward();
				range = itemSettings.RocketLauncherMaxAimingDistance;
				num = LayerMask.op_Implicit(layerSettings.RocketHittablesMask);
				num2 = LayerMask.op_Implicit(layerSettings.GunHittablesMask);
			}
			LogWeapon(networkedEquippedItem, range, num, num2);
			float num3 = default(float);
			point = inventory.GetFirearmAimPoint(val, val2, range, num, ref num3);
			if (Mathf.Abs(num3) <= 45f)
			{
				CrossCheck(networkedEquippedItem, inventory, point, val, val2, range, num);
				return true;
			}
			point = AimWithoutTurnLimit(inventory, val, val2, range, num2);
			return true;
			IL_0133:
			return false;
		}

		private static Vector3 AimWithoutTurnLimit(PlayerInventory inventory, Vector3 backmost, Vector3 forward, float range, int layerMask)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = ControllerAim.TransformOf((Component)(object)GameManager.Camera);
			Vector3 position = obj.position;
			Vector3 forward2 = obj.forward;
			int num = Physics.RaycastNonAlloc(new Ray(position, forward2), Hits, range, layerMask, (QueryTriggerInteraction)1);
			float num2 = float.MaxValue;
			Vector3 result = position + forward2 * range;
			for (int i = 0; i < num; i++)
			{
				RaycastHit val = Hits[i];
				if (!(((RaycastHit)(ref val)).distance >= num2) && !((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(Vector3.Dot(((RaycastHit)(ref val)).point - backmost, forward) <= 0f) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerInventory>(true) == (Object)(object)inventory))
				{
					num2 = ((RaycastHit)(ref val)).distance;
					result = ((RaycastHit)(ref val)).point;
				}
			}
			return result;
		}

		private static void CrossCheck(ItemType weapon, PlayerInventory inventory, Vector3 gamePoint, Vector3 backmost, Vector3 forward, float range, int layerMask)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.DiagnosticsEnabled.Value && !(Time.unscaledTime < _nextCrossCheck) && !LoggedMismatches.Contains(weapon))
			{
				_nextCrossCheck = Time.unscaledTime + 1f;
				float num = Vector3.Distance(AimWithoutTurnLimit(inventory, backmost, forward, range, layerMask), gamePoint);
				if (!(num <= 0.01f))
				{
					LoggedMismatches.Add(weapon);
					Plugin.Log.LogWarning((object)($"[diag] Gun crosshairs: SBGVR's copy of the game's aim for the {weapon} is {num:0.00} m off " + "the game's own; while aiming more than 45 degrees to the side, its crosshair may not be exact."));
				}
			}
		}

		private static void LogWeapon(ItemType weapon, float range, int layerMask, int layerMaskAfterTurning)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.DiagnosticsEnabled.Value && LoggedWeapons.Add(weapon))
			{
				Plugin.Log.LogInfo((object)($"[diag] Gun crosshairs: the {weapon} aims up to {range:0.#} m, layers 0x{layerMask:X8}" + ((layerMaskAfterTurning != layerMask) ? $" (0x{layerMaskAfterTurning:X8} after turning)" : "") + "."));
			}
		}
	}
	internal static class MarkerOcclusion
	{
		private struct MarkerInView
		{
			internal WorldMarker Marker;

			internal Rect Area;

			internal float Distance;
		}

		private const int StencilBits = 8;

		private static readonly Dictionary<PlayerInfo, PlayerOccluder> Occluders = new Dictionary<PlayerInfo, PlayerOccluder>();

		private static readonly List<MarkerInView> Markers = new List<MarkerInView>();

		private static readonly List<PlayerOverlap.PlayerView> Covering = new List<PlayerOverlap.PlayerView>();

		private static readonly Dictionary<WorldMarker, int> Masks = new Dictionary<WorldMarker, int>();

		private static readonly Dictionary<PlayerOverlap.PlayerView, int> Bits = new Dictionary<PlayerOverlap.PlayerView, int>();

		private static readonly HashSet<PlayerInfo> Drawn = new HashSet<PlayerInfo>();

		private static readonly List<PlayerInfo> Gone = new List<PlayerInfo>();

		internal static void Initialize()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			_ = CanvasUpdateRegistry.instance;
			Canvas.willRenderCanvases += new WillRenderCanvases(OnWillRenderCanvases);
		}

		private static void OnWillRenderCanvases()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			Camera val = ((WorldMarker.Enabled && Settings.MarkersOnTop.Value && Settings.PlayersCoverMarkers.Value) ? VrState.ViewCamera() : null);
			Markers.Clear();
			Covering.Clear();
			Masks.Clear();
			Bits.Clear();
			Drawn.Clear();
			Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null);
			foreach (WorldMarker item in WorldMarker.InWorld)
			{
				if (!((Object)(object)item == (Object)null) && !((Object)(object)val == (Object)null) && !item.AlwaysOnTop && item.DrawnOnTop && item.TryGetArea(val2, out var area))
				{
					Markers.Add(new MarkerInView
					{
						Marker = item,
						Area = area,
						Distance = Vector3.Distance(val2.position, item.Position)
					});
				}
			}
			if (Markers.Count > 0)
			{
				foreach (PlayerOverlap.PlayerView item2 in PlayerOverlap.Update(val))
				{
					foreach (MarkerInView marker in Markers)
					{
						if (IsCovering(item2, marker))
						{
							Covering.Add(item2);
							break;
						}
					}
				}
				Covering.Sort((PlayerOverlap.PlayerView a, PlayerOverlap.PlayerView b) => a.Distance.CompareTo(b.Distance));
				for (int num = 0; num < Covering.Count; num++)
				{
					PlayerOverlap.PlayerView playerView = Covering[num];
					int num2 = 1 << Mathf.Min(num, 7);
					Bits[playerView] = num2;
					if (!Occluders.TryGetValue(playerView.Player, out var value))
					{
						value = new PlayerOccluder();
						Occluders[playerView.Player] = value;
					}
					value.Draw(playerView, num2);
					Drawn.Add(playerView.Player);
				}
				foreach (MarkerInView marker2 in Markers)
				{
					int num3 = 0;
					foreach (PlayerOverlap.PlayerView item3 in Covering)
					{
						if (IsCovering(item3, marker2))
						{
							num3 |= Bits[item3];
						}
					}
					if (num3 != 0)
					{
						Masks[marker2.Marker] = num3;
					}
				}
			}
			foreach (WorldMarker item4 in WorldMarker.InWorld)
			{
				if (!((Object)(object)item4 == (Object)null))
				{
					item4.SetCoveringMask(Masks.TryGetValue(item4, out var value2) ? value2 : 0);
					item4.EnforceDrawnMaterials();
				}
			}
			foreach (KeyValuePair<PlayerInfo, PlayerOccluder> occluder in Occluders)
			{
				if ((Object)(object)occluder.Key == (Object)null)
				{
					Gone.Add(occluder.Key);
				}
				else if (!Drawn.Contains(occluder.Key))
				{
					occluder.Value.Hide();
				}
			}
			foreach (PlayerInfo item5 in Gone)
			{
				Occluders[item5].Dispose();
				Occluders.Remove(item5);
			}
			Gone.Clear();
		}

		private static bool IsCovering(PlayerOverlap.PlayerView player, MarkerInView marker)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player.Player != (Object)(object)marker.Marker.Owner && player.Distance < marker.Distance)
			{
				return player.Overlaps(marker.Area);
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class MarkerPatches
	{
		[HarmonyPatch(typeof(WorldspaceIconUi), "LateUpdate")]
		[HarmonyPostfix]
		private static void IconLateUpdate(WorldspaceIconUi __instance, Vector3 ___worldPosition, bool ___isOffscreen, Transform ___parent, WorldspaceIconUiSettings ___settings)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			bool flag = WorldMarker.Enabled && !___isOffscreen;
			PlayerInfo owner = ((flag && (Object)(object)___parent != (Object)null && (Object)(object)___settings == (Object)(object)WorldspaceIconManager.TeammateIconSettings) ? ((Component)___parent).GetComponentInParent<PlayerInfo>() : null);
			WorldMarker.Place((Component)(object)__instance, ___worldPosition, flag, owner);
		}

		[HarmonyPatch(typeof(NameTagUi), "LateUpdate")]
		[HarmonyPostfix]
		private static void NameTagLateUpdate(NameTagUi __instance, Vector3 ___worldPosition, PlayerInfo ___playerInfo, bool ___nameTagIsPlayer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			WorldMarker.Place((Component)(object)__instance, ___worldPosition, WorldMarker.Enabled, ___nameTagIsPlayer ? ___playerInfo : null);
		}

		[HarmonyPatch(typeof(TargetReticleUi), "LateUpdate")]
		[HarmonyPostfix]
		private static void ReticleLateUpdate(UiVisibilityController ___reticleVisibilityController, ButtonPrompt ___interactButtonPrompt, Vector3 ___lastInteractableReticleWorldPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			WorldMarker.Place((Component)(object)___reticleVisibilityController, ___lastInteractableReticleWorldPosition, WorldMarker.Enabled);
			WorldMarker.Place((Component)(object)___interactButtonPrompt, ___lastInteractableReticleWorldPosition, WorldMarker.Enabled);
		}
	}
	[HarmonyPatch]
	internal static class MarkerViewAnglePatches
	{
		private const string LocalFunctionPrefix = "<LateUpdate>g__IsOffscreen|";

		private static MethodBase TargetMethod()
		{
			return AccessTools.GetDeclaredMethods(typeof(WorldspaceIconUi)).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("<LateUpdate>g__IsOffscreen|", StringComparison.Ordinal) && m.ReturnType == typeof(bool)) ?? throw new MissingMethodException("WorldspaceIconUi", "<LateUpdate>g__IsOffscreen|...");
		}

		private static bool Prefix(Vector3 ___worldPosition, ref bool __result)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!WorldMarker.Enabled)
			{
				return true;
			}
			Camera camera = GameManager.Camera;
			if ((Object)(object)camera == (Object)null)
			{
				return true;
			}
			Vector3 val = ___worldPosition - ((Component)camera).transform.position;
			__result = Vector3.Angle(((Component)camera).transform.forward, val) > Settings.MarkerViewAngle.Value;
			return false;
		}
	}
	internal enum MenuControlsSide
	{
		Below,
		Left,
		Right
	}
	internal sealed class MenuControlsPanel : MonoBehaviour
	{
		private const string ImageResource = "SBGVR.controller-layout.png";

		private const string MirroredImageResource = "SBGVR.controller-layout-mirrored.png";

		private const int RenderQueue = 5000;

		private const int OrdersAfterScreen = 2;

		private const float WidthPerMetre = 0.95f;

		private const float GapDegrees = 4f;

		private GameObject _panel;

		private Material _material;

		private Texture2D _texture;

		private Texture2D _mirroredTexture;

		private bool _showingMirrored;

		private bool _mirroredFailed;

		private float _aspect = 55f / 72f;

		private bool _failed;

		private string _loggedWhere;

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.onBeforeRender += new UnityAction(Place);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Application.onBeforeRender -= new UnityAction(Place);
			if ((Object)(object)_panel != (Object)null)
			{
				_panel.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_panel != (Object)null)
			{
				Object.Destroy((Object)(object)_panel);
			}
			if ((Object)(object)_material != (Object)null)
			{
				Object.Destroy((Object)(object)_material);
			}
			if ((Object)(object)_texture != (Object)null)
			{
				Object.Destroy((Object)(object)_texture);
			}
			if ((Object)(object)_mirroredTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_mirroredTexture);
			}
		}

		private void LateUpdate()
		{
			Place();
		}

		private static string ShowingFor()
		{
			if (!VrState.IsRunning || !Settings.MenuControls.Value || !Settings.MotionControls.Value)
			{
				return null;
			}
			if (SingletonBehaviour<MainMenu>.HasInstance)
			{
				return "the main menu";
			}
			if (PauseMenu.IsPaused)
			{
				return "the pause menu";
			}
			return null;
		}

		private void Place()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			if (_failed)
			{
				return;
			}
			string text = ShowingFor();
			Camera val = ((text != null) ? VrState.ViewCamera() : null);
			if ((Object)(object)val == (Object)null)
			{
				if ((Object)(object)_panel != (Object)null && _panel.activeSelf)
				{
					_panel.SetActive(false);
				}
			}
			else if (!((Object)(object)_panel == (Object)null) || Create())
			{
				ShowLayout(Settings.MirrorButtons.Value);
				ModConfiguration instance = ModConfiguration.Instance;
				Vector3 value = instance.VrUiPosition.Value;
				float num = Mathf.Max(0.3f, Mathf.Abs(value.z));
				float num2 = 1.8f * instance.VrUiScale.Value / 2f;
				float num3 = num2 * (float)Screen.height / (float)Mathf.Max(1, Screen.width);
				float num4 = 0.95f * num;
				MenuControlsSide value2 = Settings.MenuControlsSide.Value;
				float num7;
				Quaternion val2;
				Vector3 val3 = default(Vector3);
				if (value2 == MenuControlsSide.Below)
				{
					float num5 = Mathf.Atan2(value.y - num3, n

plugins/Uuvr.XR.OpenVR.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using AOT;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.XR;
using UnityEngine.XR.Management;
using Valve.VR;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Valve.VR
{
	public struct IVRSystem
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetRecommendedRenderTargetSize(ref uint pnWidth, ref uint pnHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdMatrix44_t _GetProjectionMatrix(EVREye eEye, float fNearZ, float fFarZ);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetProjectionRaw(EVREye eEye, ref float pfLeft, ref float pfRight, ref float pfTop, ref float pfBottom);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ComputeDistortion(EVREye eEye, float fU, float fV, ref DistortionCoordinates_t pDistortionCoordinates);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdMatrix34_t _GetEyeToHeadTransform(EVREye eEye);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetTimeSinceLastVsync(ref float pfSecondsSinceLastVsync, ref ulong pulFrameCounter);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate int _GetD3D9AdapterIndex();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetDXGIOutputInfo(ref int pnAdapterIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetOutputDevice(ref ulong pnDevice, ETextureType textureType, IntPtr pInstance);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsDisplayOnDesktop();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _SetDisplayVisibility(bool bIsVisibleOnDesktop);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetDeviceToAbsoluteTrackingPose(ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, [In][Out] TrackedDevicePose_t[] pTrackedDevicePoseArray, uint unTrackedDevicePoseArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdMatrix34_t _GetSeatedZeroPoseToStandingAbsoluteTrackingPose();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdMatrix34_t _GetRawZeroPoseToStandingAbsoluteTrackingPose();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetSortedTrackedDeviceIndicesOfClass(ETrackedDeviceClass eTrackedDeviceClass, [In][Out] uint[] punTrackedDeviceIndexArray, uint unTrackedDeviceIndexArrayCount, uint unRelativeToTrackedDeviceIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EDeviceActivityLevel _GetTrackedDeviceActivityLevel(uint unDeviceId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ApplyTransform(ref TrackedDevicePose_t pOutputPose, ref TrackedDevicePose_t pTrackedDevicePose, ref HmdMatrix34_t pTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole unDeviceType);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedControllerRole _GetControllerRoleForTrackedDeviceIndex(uint unDeviceIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedDeviceClass _GetTrackedDeviceClass(uint unDeviceIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsTrackedDeviceConnected(uint unDeviceIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetBoolTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate float _GetFloatTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate int _GetInt32TrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _GetUint64TrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdMatrix34_t _GetMatrix34TrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetArrayTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, uint propType, IntPtr pBuffer, uint unBufferSize, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetStringTrackedDeviceProperty(uint unDeviceIndex, ETrackedDeviceProperty prop, StringBuilder pchValue, uint unBufferSize, ref ETrackedPropertyError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetPropErrorNameFromEnum(ETrackedPropertyError error);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _PollNextEvent(ref VREvent_t pEvent, uint uncbVREvent);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _PollNextEventWithPose(ETrackingUniverseOrigin eOrigin, ref VREvent_t pEvent, uint uncbVREvent, ref TrackedDevicePose_t pTrackedDevicePose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetEventTypeNameFromEnum(EVREventType eType);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HiddenAreaMesh_t _GetHiddenAreaMesh(EVREye eEye, EHiddenAreaMeshType type);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetControllerState(uint unControllerDeviceIndex, ref VRControllerState_t pControllerState, uint unControllerStateSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetControllerStateWithPose(ETrackingUniverseOrigin eOrigin, uint unControllerDeviceIndex, ref VRControllerState_t pControllerState, uint unControllerStateSize, ref TrackedDevicePose_t pTrackedDevicePose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _TriggerHapticPulse(uint unControllerDeviceIndex, uint unAxisId, ushort usDurationMicroSec);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetButtonIdNameFromEnum(EVRButtonId eButtonId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetControllerAxisTypeNameFromEnum(EVRControllerAxisType eAxisType);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsInputAvailable();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsSteamVRDrawingControllers();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ShouldApplicationPause();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ShouldApplicationReduceRenderingWork();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRFirmwareError _PerformFirmwareUpdate(uint unDeviceIndex);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _AcknowledgeQuit_Exiting();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetAppContainerFilePaths(StringBuilder pchBuffer, uint unBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetRuntimeVersion();

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRecommendedRenderTargetSize GetRecommendedRenderTargetSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetProjectionMatrix GetProjectionMatrix;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetProjectionRaw GetProjectionRaw;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ComputeDistortion ComputeDistortion;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetEyeToHeadTransform GetEyeToHeadTransform;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTimeSinceLastVsync GetTimeSinceLastVsync;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetD3D9AdapterIndex GetD3D9AdapterIndex;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDXGIOutputInfo GetDXGIOutputInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOutputDevice GetOutputDevice;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsDisplayOnDesktop IsDisplayOnDesktop;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetDisplayVisibility SetDisplayVisibility;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDeviceToAbsoluteTrackingPose GetDeviceToAbsoluteTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSeatedZeroPoseToStandingAbsoluteTrackingPose GetSeatedZeroPoseToStandingAbsoluteTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRawZeroPoseToStandingAbsoluteTrackingPose GetRawZeroPoseToStandingAbsoluteTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSortedTrackedDeviceIndicesOfClass GetSortedTrackedDeviceIndicesOfClass;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTrackedDeviceActivityLevel GetTrackedDeviceActivityLevel;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ApplyTransform ApplyTransform;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTrackedDeviceIndexForControllerRole GetTrackedDeviceIndexForControllerRole;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetControllerRoleForTrackedDeviceIndex GetControllerRoleForTrackedDeviceIndex;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTrackedDeviceClass GetTrackedDeviceClass;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsTrackedDeviceConnected IsTrackedDeviceConnected;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBoolTrackedDeviceProperty GetBoolTrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetFloatTrackedDeviceProperty GetFloatTrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetInt32TrackedDeviceProperty GetInt32TrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetUint64TrackedDeviceProperty GetUint64TrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetMatrix34TrackedDeviceProperty GetMatrix34TrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetArrayTrackedDeviceProperty GetArrayTrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetStringTrackedDeviceProperty GetStringTrackedDeviceProperty;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPropErrorNameFromEnum GetPropErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PollNextEvent PollNextEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PollNextEventWithPose PollNextEventWithPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetEventTypeNameFromEnum GetEventTypeNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHiddenAreaMesh GetHiddenAreaMesh;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetControllerState GetControllerState;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetControllerStateWithPose GetControllerStateWithPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _TriggerHapticPulse TriggerHapticPulse;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetButtonIdNameFromEnum GetButtonIdNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetControllerAxisTypeNameFromEnum GetControllerAxisTypeNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsInputAvailable IsInputAvailable;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsSteamVRDrawingControllers IsSteamVRDrawingControllers;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShouldApplicationPause ShouldApplicationPause;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShouldApplicationReduceRenderingWork ShouldApplicationReduceRenderingWork;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PerformFirmwareUpdate PerformFirmwareUpdate;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _AcknowledgeQuit_Exiting AcknowledgeQuit_Exiting;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetAppContainerFilePaths GetAppContainerFilePaths;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRuntimeVersion GetRuntimeVersion;
	}
	public struct IVRExtendedDisplay
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetWindowBounds(ref int pnX, ref int pnY, ref uint pnWidth, ref uint pnHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetEyeOutputViewport(EVREye eEye, ref uint pnX, ref uint pnY, ref uint pnWidth, ref uint pnHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetDXGIOutputInfo(ref int pnAdapterIndex, ref int pnAdapterOutputIndex);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWindowBounds GetWindowBounds;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetEyeOutputViewport GetEyeOutputViewport;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDXGIOutputInfo GetDXGIOutputInfo;
	}
	public struct IVRTrackedCamera
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetCameraErrorNameFromEnum(EVRTrackedCameraError eCameraError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _HasCamera(uint nDeviceIndex, ref bool pHasCamera);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetCameraFrameSize(uint nDeviceIndex, EVRTrackedCameraFrameType eFrameType, ref uint pnWidth, ref uint pnHeight, ref uint pnFrameBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetCameraIntrinsics(uint nDeviceIndex, uint nCameraIndex, EVRTrackedCameraFrameType eFrameType, ref HmdVector2_t pFocalLength, ref HmdVector2_t pCenter);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetCameraProjection(uint nDeviceIndex, uint nCameraIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, ref HmdMatrix44_t pProjection);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _AcquireVideoStreamingService(uint nDeviceIndex, ref ulong pHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _ReleaseVideoStreamingService(ulong hTrackedCamera);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetVideoStreamFrameBuffer(ulong hTrackedCamera, EVRTrackedCameraFrameType eFrameType, IntPtr pFrameBuffer, uint nFrameBufferSize, ref CameraVideoStreamFrameHeader_t pFrameHeader, uint nFrameHeaderSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetVideoStreamTextureSize(uint nDeviceIndex, EVRTrackedCameraFrameType eFrameType, ref VRTextureBounds_t pTextureBounds, ref uint pnWidth, ref uint pnHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetVideoStreamTextureD3D11(ulong hTrackedCamera, EVRTrackedCameraFrameType eFrameType, IntPtr pD3D11DeviceOrResource, ref IntPtr ppD3D11ShaderResourceView, ref CameraVideoStreamFrameHeader_t pFrameHeader, uint nFrameHeaderSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _GetVideoStreamTextureGL(ulong hTrackedCamera, EVRTrackedCameraFrameType eFrameType, ref uint pglTextureId, ref CameraVideoStreamFrameHeader_t pFrameHeader, uint nFrameHeaderSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRTrackedCameraError _ReleaseVideoStreamTextureGL(ulong hTrackedCamera, uint glTextureId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetCameraTrackingSpace(ETrackingUniverseOrigin eUniverse);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackingUniverseOrigin _GetCameraTrackingSpace();

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCameraErrorNameFromEnum GetCameraErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HasCamera HasCamera;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCameraFrameSize GetCameraFrameSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCameraIntrinsics GetCameraIntrinsics;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCameraProjection GetCameraProjection;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _AcquireVideoStreamingService AcquireVideoStreamingService;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseVideoStreamingService ReleaseVideoStreamingService;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVideoStreamFrameBuffer GetVideoStreamFrameBuffer;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVideoStreamTextureSize GetVideoStreamTextureSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVideoStreamTextureD3D11 GetVideoStreamTextureD3D11;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVideoStreamTextureGL GetVideoStreamTextureGL;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseVideoStreamTextureGL ReleaseVideoStreamTextureGL;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetCameraTrackingSpace SetCameraTrackingSpace;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCameraTrackingSpace GetCameraTrackingSpace;
	}
	public struct IVRApplications
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _AddApplicationManifest(IntPtr pchApplicationManifestFullPath, bool bTemporary);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _RemoveApplicationManifest(IntPtr pchApplicationManifestFullPath);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsApplicationInstalled(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetApplicationCount();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _GetApplicationKeyByIndex(uint unApplicationIndex, StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _GetApplicationKeyByProcessId(uint unProcessId, StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _LaunchApplication(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _LaunchTemplateApplication(IntPtr pchTemplateAppKey, IntPtr pchNewAppKey, [In][Out] AppOverrideKeys_t[] pKeys, uint unKeys);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _LaunchApplicationFromMimeType(IntPtr pchMimeType, IntPtr pchArgs);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _LaunchDashboardOverlay(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _CancelApplicationLaunch(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _IdentifyApplication(uint unProcessId, IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetApplicationProcessId(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetApplicationsErrorNameFromEnum(EVRApplicationError error);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetApplicationPropertyString(IntPtr pchAppKey, EVRApplicationProperty eProperty, StringBuilder pchPropertyValueBuffer, uint unPropertyValueBufferLen, ref EVRApplicationError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetApplicationPropertyBool(IntPtr pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _GetApplicationPropertyUint64(IntPtr pchAppKey, EVRApplicationProperty eProperty, ref EVRApplicationError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _SetApplicationAutoLaunch(IntPtr pchAppKey, bool bAutoLaunch);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetApplicationAutoLaunch(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _SetDefaultApplicationForMimeType(IntPtr pchAppKey, IntPtr pchMimeType);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetDefaultApplicationForMimeType(IntPtr pchMimeType, StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetApplicationSupportedMimeTypes(IntPtr pchAppKey, StringBuilder pchMimeTypesBuffer, uint unMimeTypesBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetApplicationsThatSupportMimeType(IntPtr pchMimeType, StringBuilder pchAppKeysThatSupportBuffer, uint unAppKeysThatSupportBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetApplicationLaunchArguments(uint unHandle, StringBuilder pchArgs, uint unArgs);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _GetStartingApplication(StringBuilder pchAppKeyBuffer, uint unAppKeyBufferLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRSceneApplicationState _GetSceneApplicationState();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _PerformApplicationPrelaunchCheck(IntPtr pchAppKey);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetSceneApplicationStateNameFromEnum(EVRSceneApplicationState state);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRApplicationError _LaunchInternalProcess(IntPtr pchBinaryPath, IntPtr pchArguments, IntPtr pchWorkingDirectory);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetCurrentSceneProcessId();

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _AddApplicationManifest AddApplicationManifest;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RemoveApplicationManifest RemoveApplicationManifest;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsApplicationInstalled IsApplicationInstalled;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationCount GetApplicationCount;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationKeyByIndex GetApplicationKeyByIndex;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationKeyByProcessId GetApplicationKeyByProcessId;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LaunchApplication LaunchApplication;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LaunchTemplateApplication LaunchTemplateApplication;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LaunchApplicationFromMimeType LaunchApplicationFromMimeType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LaunchDashboardOverlay LaunchDashboardOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CancelApplicationLaunch CancelApplicationLaunch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IdentifyApplication IdentifyApplication;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationProcessId GetApplicationProcessId;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationsErrorNameFromEnum GetApplicationsErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationPropertyString GetApplicationPropertyString;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationPropertyBool GetApplicationPropertyBool;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationPropertyUint64 GetApplicationPropertyUint64;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetApplicationAutoLaunch SetApplicationAutoLaunch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationAutoLaunch GetApplicationAutoLaunch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetDefaultApplicationForMimeType SetDefaultApplicationForMimeType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDefaultApplicationForMimeType GetDefaultApplicationForMimeType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationSupportedMimeTypes GetApplicationSupportedMimeTypes;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationsThatSupportMimeType GetApplicationsThatSupportMimeType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetApplicationLaunchArguments GetApplicationLaunchArguments;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetStartingApplication GetStartingApplication;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSceneApplicationState GetSceneApplicationState;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PerformApplicationPrelaunchCheck PerformApplicationPrelaunchCheck;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSceneApplicationStateNameFromEnum GetSceneApplicationStateNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LaunchInternalProcess LaunchInternalProcess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCurrentSceneProcessId GetCurrentSceneProcessId;
	}
	public struct IVRChaperone
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ChaperoneCalibrationState _GetCalibrationState();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetPlayAreaSize(ref float pSizeX, ref float pSizeZ);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetPlayAreaRect(ref HmdQuad_t rect);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ReloadInfo();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetSceneColor(HmdColor_t color);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetBoundsColor(ref HmdColor_t pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, ref HmdColor_t pOutputCameraColor);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _AreBoundsVisible();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ForceBoundsVisible(bool bForce);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ResetZeroPose(ETrackingUniverseOrigin eTrackingUniverseOrigin);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCalibrationState GetCalibrationState;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPlayAreaSize GetPlayAreaSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPlayAreaRect GetPlayAreaRect;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReloadInfo ReloadInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetSceneColor SetSceneColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBoundsColor GetBoundsColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _AreBoundsVisible AreBoundsVisible;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ForceBoundsVisible ForceBoundsVisible;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ResetZeroPose ResetZeroPose;
	}
	public struct IVRChaperoneSetup
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _CommitWorkingCopy(EChaperoneConfigFile configFile);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _RevertWorkingCopy();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetWorkingPlayAreaSize(ref float pSizeX, ref float pSizeZ);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetWorkingPlayAreaRect(ref HmdQuad_t rect);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetWorkingCollisionBoundsInfo([In][Out] HmdQuad_t[] pQuadsBuffer, ref uint punQuadsCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetLiveCollisionBoundsInfo([In][Out] HmdQuad_t[] pQuadsBuffer, ref uint punQuadsCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatStandingZeroPoseToRawTrackingPose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetWorkingPlayAreaSize(float sizeX, float sizeZ);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetWorkingCollisionBoundsInfo([In][Out] HmdQuad_t[] pQuadsBuffer, uint unQuadsCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetWorkingPerimeter([In][Out] HmdVector2_t[] pPointBuffer, uint unPointCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetWorkingSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatSeatedZeroPoseToRawTrackingPose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetWorkingStandingZeroPoseToRawTrackingPose(ref HmdMatrix34_t pMatStandingZeroPoseToRawTrackingPose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ReloadFromDisk(EChaperoneConfigFile configFile);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetLiveSeatedZeroPoseToRawTrackingPose(ref HmdMatrix34_t pmatSeatedZeroPoseToRawTrackingPose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ExportLiveToBuffer(StringBuilder pBuffer, ref uint pnBufferLength);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ImportFromBufferToWorking(IntPtr pBuffer, uint nImportFlags);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ShowWorkingSetPreview();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _HideWorkingSetPreview();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _RoomSetupStarting();

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CommitWorkingCopy CommitWorkingCopy;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RevertWorkingCopy RevertWorkingCopy;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWorkingPlayAreaSize GetWorkingPlayAreaSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWorkingPlayAreaRect GetWorkingPlayAreaRect;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWorkingCollisionBoundsInfo GetWorkingCollisionBoundsInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLiveCollisionBoundsInfo GetLiveCollisionBoundsInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWorkingSeatedZeroPoseToRawTrackingPose GetWorkingSeatedZeroPoseToRawTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetWorkingStandingZeroPoseToRawTrackingPose GetWorkingStandingZeroPoseToRawTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetWorkingPlayAreaSize SetWorkingPlayAreaSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetWorkingCollisionBoundsInfo SetWorkingCollisionBoundsInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetWorkingPerimeter SetWorkingPerimeter;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetWorkingSeatedZeroPoseToRawTrackingPose SetWorkingSeatedZeroPoseToRawTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetWorkingStandingZeroPoseToRawTrackingPose SetWorkingStandingZeroPoseToRawTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReloadFromDisk ReloadFromDisk;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLiveSeatedZeroPoseToRawTrackingPose GetLiveSeatedZeroPoseToRawTrackingPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ExportLiveToBuffer ExportLiveToBuffer;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ImportFromBufferToWorking ImportFromBufferToWorking;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowWorkingSetPreview ShowWorkingSetPreview;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HideWorkingSetPreview HideWorkingSetPreview;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RoomSetupStarting RoomSetupStarting;
	}
	public struct IVRCompositor
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetTrackingSpace(ETrackingUniverseOrigin eOrigin);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackingUniverseOrigin _GetTrackingSpace();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _WaitGetPoses([In][Out] TrackedDevicePose_t[] pRenderPoseArray, uint unRenderPoseArrayCount, [In][Out] TrackedDevicePose_t[] pGamePoseArray, uint unGamePoseArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetLastPoses([In][Out] TrackedDevicePose_t[] pRenderPoseArray, uint unRenderPoseArrayCount, [In][Out] TrackedDevicePose_t[] pGamePoseArray, uint unGamePoseArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetLastPoseForTrackedDeviceIndex(uint unDeviceIndex, ref TrackedDevicePose_t pOutputPose, ref TrackedDevicePose_t pOutputGamePose);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _Submit(EVREye eEye, ref Texture_t pTexture, ref VRTextureBounds_t pBounds, EVRSubmitFlags nSubmitFlags);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ClearLastSubmittedFrame();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _PostPresentHandoff();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetFrameTimings([In][Out] Compositor_FrameTiming[] pTiming, uint nFrames);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate float _GetFrameTimeRemaining();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetCumulativeStats(ref Compositor_CumulativeStats pStats, uint nStatsSizeInBytes);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _FadeToColor(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate HmdColor_t _GetCurrentFadeColor(bool bBackground);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _FadeGrid(float fSeconds, bool bFadeGridIn);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate float _GetCurrentGridAlpha();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _SetSkyboxOverride([In][Out] Texture_t[] pTextures, uint unTextureCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ClearSkyboxOverride();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _CompositorBringToFront();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _CompositorGoToBack();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _CompositorQuit();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsFullscreen();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetCurrentSceneFocusProcess();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetLastFrameRenderer();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _CanRenderScene();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ShowMirrorWindow();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _HideMirrorWindow();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsMirrorWindowVisible();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _CompositorDumpImages();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ShouldAppRenderWithLowResources();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ForceInterleavedReprojectionOn(bool bOverride);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ForceReconnectProcess();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SuspendRendering(bool bSuspend);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetMirrorTextureD3D11(EVREye eEye, IntPtr pD3D11DeviceOrResource, ref IntPtr ppD3D11ShaderResourceView);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ReleaseMirrorTextureD3D11(IntPtr pD3D11ShaderResourceView);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetMirrorTextureGL(EVREye eEye, ref uint pglTextureId, IntPtr pglSharedTextureHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ReleaseSharedGLTexture(uint glTextureId, IntPtr glSharedTextureHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _LockGLSharedTextureForAccess(IntPtr glSharedTextureHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _UnlockGLSharedTextureForAccess(IntPtr glSharedTextureHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetVulkanInstanceExtensionsRequired(StringBuilder pchValue, uint unBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetVulkanDeviceExtensionsRequired(IntPtr pPhysicalDevice, StringBuilder pchValue, uint unBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetExplicitTimingMode(EVRCompositorTimingMode eTimingMode);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _SubmitExplicitTimingData();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsMotionSmoothingEnabled();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsMotionSmoothingSupported();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsCurrentSceneFocusAppLoading();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _SetStageOverride_Async(IntPtr pchRenderModelPath, ref HmdMatrix34_t pTransform, ref Compositor_StageRenderSettings pRenderSettings, uint nSizeOfRenderSettings);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ClearStageOverride();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetCompositorBenchmarkResults(ref Compositor_BenchmarkResults pBenchmarkResults, uint nSizeOfBenchmarkResults);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetLastPosePredictionIDs(ref uint pRenderPosePredictionID, ref uint pGamePosePredictionID);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRCompositorError _GetPosesForFrame(uint unPosePredictionID, [In][Out] TrackedDevicePose_t[] pPoseArray, uint unPoseArrayCount);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetTrackingSpace SetTrackingSpace;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTrackingSpace GetTrackingSpace;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _WaitGetPoses WaitGetPoses;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLastPoses GetLastPoses;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLastPoseForTrackedDeviceIndex GetLastPoseForTrackedDeviceIndex;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _Submit Submit;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ClearLastSubmittedFrame ClearLastSubmittedFrame;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PostPresentHandoff PostPresentHandoff;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetFrameTiming GetFrameTiming;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetFrameTimings GetFrameTimings;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetFrameTimeRemaining GetFrameTimeRemaining;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCumulativeStats GetCumulativeStats;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FadeToColor FadeToColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCurrentFadeColor GetCurrentFadeColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FadeGrid FadeGrid;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCurrentGridAlpha GetCurrentGridAlpha;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetSkyboxOverride SetSkyboxOverride;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ClearSkyboxOverride ClearSkyboxOverride;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CompositorBringToFront CompositorBringToFront;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CompositorGoToBack CompositorGoToBack;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CompositorQuit CompositorQuit;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsFullscreen IsFullscreen;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCurrentSceneFocusProcess GetCurrentSceneFocusProcess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLastFrameRenderer GetLastFrameRenderer;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CanRenderScene CanRenderScene;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowMirrorWindow ShowMirrorWindow;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HideMirrorWindow HideMirrorWindow;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsMirrorWindowVisible IsMirrorWindowVisible;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CompositorDumpImages CompositorDumpImages;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShouldAppRenderWithLowResources ShouldAppRenderWithLowResources;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ForceInterleavedReprojectionOn ForceInterleavedReprojectionOn;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ForceReconnectProcess ForceReconnectProcess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SuspendRendering SuspendRendering;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetMirrorTextureD3D11 GetMirrorTextureD3D11;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseMirrorTextureD3D11 ReleaseMirrorTextureD3D11;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetMirrorTextureGL GetMirrorTextureGL;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseSharedGLTexture ReleaseSharedGLTexture;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LockGLSharedTextureForAccess LockGLSharedTextureForAccess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _UnlockGLSharedTextureForAccess UnlockGLSharedTextureForAccess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVulkanInstanceExtensionsRequired GetVulkanInstanceExtensionsRequired;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetVulkanDeviceExtensionsRequired GetVulkanDeviceExtensionsRequired;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetExplicitTimingMode SetExplicitTimingMode;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SubmitExplicitTimingData SubmitExplicitTimingData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsMotionSmoothingEnabled IsMotionSmoothingEnabled;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsMotionSmoothingSupported IsMotionSmoothingSupported;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsCurrentSceneFocusAppLoading IsCurrentSceneFocusAppLoading;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetStageOverride_Async SetStageOverride_Async;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ClearStageOverride ClearStageOverride;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetCompositorBenchmarkResults GetCompositorBenchmarkResults;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetLastPosePredictionIDs GetLastPosePredictionIDs;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPosesForFrame GetPosesForFrame;
	}
	public struct IVROverlay
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _FindOverlay(IntPtr pchOverlayKey, ref ulong pOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _CreateOverlay(IntPtr pchOverlayKey, IntPtr pchOverlayName, ref ulong pOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _DestroyOverlay(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetOverlayKey(ulong ulOverlayHandle, StringBuilder pchValue, uint unBufferSize, ref EVROverlayError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetOverlayName(ulong ulOverlayHandle, StringBuilder pchValue, uint unBufferSize, ref EVROverlayError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayName(ulong ulOverlayHandle, IntPtr pchName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayImageData(ulong ulOverlayHandle, IntPtr pvBuffer, uint unBufferSize, ref uint punWidth, ref uint punHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetOverlayErrorNameFromEnum(EVROverlayError error);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayRenderingPid(ulong ulOverlayHandle, uint unPID);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetOverlayRenderingPid(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayFlag(ulong ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayFlag(ulong ulOverlayHandle, VROverlayFlags eOverlayFlag, ref bool pbEnabled);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayFlags(ulong ulOverlayHandle, ref uint pFlags);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayColor(ulong ulOverlayHandle, float fRed, float fGreen, float fBlue);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayColor(ulong ulOverlayHandle, ref float pfRed, ref float pfGreen, ref float pfBlue);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayAlpha(ulong ulOverlayHandle, float fAlpha);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayAlpha(ulong ulOverlayHandle, ref float pfAlpha);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTexelAspect(ulong ulOverlayHandle, float fTexelAspect);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTexelAspect(ulong ulOverlayHandle, ref float pfTexelAspect);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlaySortOrder(ulong ulOverlayHandle, uint unSortOrder);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlaySortOrder(ulong ulOverlayHandle, ref uint punSortOrder);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayWidthInMeters(ulong ulOverlayHandle, float fWidthInMeters);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayWidthInMeters(ulong ulOverlayHandle, ref float pfWidthInMeters);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayCurvature(ulong ulOverlayHandle, float fCurvature);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayCurvature(ulong ulOverlayHandle, ref float pfCurvature);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayPreCurvePitch(ulong ulOverlayHandle, float fRadians);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayPreCurvePitch(ulong ulOverlayHandle, ref float pfRadians);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTextureColorSpace(ulong ulOverlayHandle, EColorSpace eTextureColorSpace);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTextureColorSpace(ulong ulOverlayHandle, ref EColorSpace peTextureColorSpace);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTextureBounds(ulong ulOverlayHandle, ref VRTextureBounds_t pOverlayTextureBounds);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTextureBounds(ulong ulOverlayHandle, ref VRTextureBounds_t pOverlayTextureBounds);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTransformType(ulong ulOverlayHandle, ref VROverlayTransformType peTransformType);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTransformAbsolute(ulong ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTransformAbsolute(ulong ulOverlayHandle, ref ETrackingUniverseOrigin peTrackingOrigin, ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle, uint unTrackedDevice, ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTransformTrackedDeviceRelative(ulong ulOverlayHandle, ref uint punTrackedDevice, ref HmdMatrix34_t pmatTrackedDeviceToOverlayTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, uint unDeviceIndex, IntPtr pchComponentName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTransformTrackedDeviceComponent(ulong ulOverlayHandle, ref uint punDeviceIndex, StringBuilder pchComponentName, uint unComponentNameSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTransformCursor(ulong ulCursorOverlayHandle, ref HmdVector2_t pvHotspot);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTransformCursor(ulong ulOverlayHandle, ref HmdVector2_t pvHotspot);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTransformProjection(ulong ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, ref HmdMatrix34_t pmatTrackingOriginToOverlayTransform, ref VROverlayProjection_t pProjection, EVREye eEye);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ShowOverlay(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _HideOverlay(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsOverlayVisible(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetTransformForOverlayCoordinates(ulong ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, HmdVector2_t coordinatesInOverlay, ref HmdMatrix34_t pmatTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _WaitFrameSync(uint nTimeoutMs);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _PollNextOverlayEvent(ulong ulOverlayHandle, ref VREvent_t pEvent, uint uncbVREvent);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayInputMethod(ulong ulOverlayHandle, ref VROverlayInputMethod peInputMethod);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayInputMethod(ulong ulOverlayHandle, VROverlayInputMethod eInputMethod);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayMouseScale(ulong ulOverlayHandle, ref HmdVector2_t pvecMouseScale);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayMouseScale(ulong ulOverlayHandle, ref HmdVector2_t pvecMouseScale);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _ComputeOverlayIntersection(ulong ulOverlayHandle, ref VROverlayIntersectionParams_t pParams, ref VROverlayIntersectionResults_t pResults);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsHoverTargetOverlay(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayIntersectionMask(ulong ulOverlayHandle, ref VROverlayIntersectionMaskPrimitive_t pMaskPrimitives, uint unNumMaskPrimitives, uint unPrimitiveSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _TriggerLaserMouseHapticVibration(ulong ulOverlayHandle, float fDurationSeconds, float fFrequency, float fAmplitude);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayCursor(ulong ulOverlayHandle, ulong ulCursorHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayCursorPositionOverride(ulong ulOverlayHandle, ref HmdVector2_t pvCursor);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ClearOverlayCursorPositionOverride(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayTexture(ulong ulOverlayHandle, ref Texture_t pTexture);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ClearOverlayTexture(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayRaw(ulong ulOverlayHandle, IntPtr pvBuffer, uint unWidth, uint unHeight, uint unBytesPerPixel);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetOverlayFromFile(ulong ulOverlayHandle, IntPtr pchFilePath);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTexture(ulong ulOverlayHandle, ref IntPtr pNativeTextureHandle, IntPtr pNativeTextureRef, ref uint pWidth, ref uint pHeight, ref uint pNativeFormat, ref ETextureType pAPIType, ref EColorSpace pColorSpace, ref VRTextureBounds_t pTextureBounds);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ReleaseNativeOverlayHandle(ulong ulOverlayHandle, IntPtr pNativeTextureHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetOverlayTextureSize(ulong ulOverlayHandle, ref uint pWidth, ref uint pHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _CreateDashboardOverlay(IntPtr pchOverlayKey, IntPtr pchOverlayFriendlyName, ref ulong pMainHandle, ref ulong pThumbnailHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsDashboardVisible();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsActiveDashboardOverlay(ulong ulOverlayHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _SetDashboardOverlaySceneProcess(ulong ulOverlayHandle, uint unProcessId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _GetDashboardOverlaySceneProcess(ulong ulOverlayHandle, ref uint punProcessId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _ShowDashboard(IntPtr pchOverlayToShow);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetPrimaryDashboardDevice();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ShowKeyboard(int eInputMode, int eLineInputMode, uint unFlags, IntPtr pchDescription, uint unCharMax, IntPtr pchExistingText, ulong uUserValue);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ShowKeyboardForOverlay(ulong ulOverlayHandle, int eInputMode, int eLineInputMode, uint unFlags, IntPtr pchDescription, uint unCharMax, IntPtr pchExistingText, ulong uUserValue);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetKeyboardText(StringBuilder pchText, uint cchText);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _HideKeyboard();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetKeyboardTransformAbsolute(ETrackingUniverseOrigin eTrackingOrigin, ref HmdMatrix34_t pmatTrackingOriginToKeyboardTransform);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetKeyboardPositionForOverlay(ulong ulOverlayHandle, HmdRect2_t avoidRect);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate VRMessageOverlayResponse _ShowMessageOverlay(IntPtr pchText, IntPtr pchCaption, IntPtr pchButton0Text, IntPtr pchButton1Text, IntPtr pchButton2Text, IntPtr pchButton3Text);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _CloseMessageOverlay();

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FindOverlay FindOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CreateOverlay CreateOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _DestroyOverlay DestroyOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayKey GetOverlayKey;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayName GetOverlayName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayName SetOverlayName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayImageData GetOverlayImageData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayErrorNameFromEnum GetOverlayErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayRenderingPid SetOverlayRenderingPid;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayRenderingPid GetOverlayRenderingPid;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayFlag SetOverlayFlag;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayFlag GetOverlayFlag;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayFlags GetOverlayFlags;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayColor SetOverlayColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayColor GetOverlayColor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayAlpha SetOverlayAlpha;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayAlpha GetOverlayAlpha;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTexelAspect SetOverlayTexelAspect;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTexelAspect GetOverlayTexelAspect;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlaySortOrder SetOverlaySortOrder;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlaySortOrder GetOverlaySortOrder;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayWidthInMeters SetOverlayWidthInMeters;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayWidthInMeters GetOverlayWidthInMeters;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayCurvature SetOverlayCurvature;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayCurvature GetOverlayCurvature;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayPreCurvePitch SetOverlayPreCurvePitch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayPreCurvePitch GetOverlayPreCurvePitch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTextureColorSpace SetOverlayTextureColorSpace;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTextureColorSpace GetOverlayTextureColorSpace;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTextureBounds SetOverlayTextureBounds;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTextureBounds GetOverlayTextureBounds;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTransformType GetOverlayTransformType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTransformAbsolute SetOverlayTransformAbsolute;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTransformAbsolute GetOverlayTransformAbsolute;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTransformTrackedDeviceRelative SetOverlayTransformTrackedDeviceRelative;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTransformTrackedDeviceRelative GetOverlayTransformTrackedDeviceRelative;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTransformTrackedDeviceComponent SetOverlayTransformTrackedDeviceComponent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTransformTrackedDeviceComponent GetOverlayTransformTrackedDeviceComponent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTransformCursor SetOverlayTransformCursor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTransformCursor GetOverlayTransformCursor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTransformProjection SetOverlayTransformProjection;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowOverlay ShowOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HideOverlay HideOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsOverlayVisible IsOverlayVisible;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetTransformForOverlayCoordinates GetTransformForOverlayCoordinates;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _WaitFrameSync WaitFrameSync;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PollNextOverlayEvent PollNextOverlayEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayInputMethod GetOverlayInputMethod;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayInputMethod SetOverlayInputMethod;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayMouseScale GetOverlayMouseScale;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayMouseScale SetOverlayMouseScale;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ComputeOverlayIntersection ComputeOverlayIntersection;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsHoverTargetOverlay IsHoverTargetOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayIntersectionMask SetOverlayIntersectionMask;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _TriggerLaserMouseHapticVibration TriggerLaserMouseHapticVibration;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayCursor SetOverlayCursor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayCursorPositionOverride SetOverlayCursorPositionOverride;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ClearOverlayCursorPositionOverride ClearOverlayCursorPositionOverride;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayTexture SetOverlayTexture;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ClearOverlayTexture ClearOverlayTexture;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayRaw SetOverlayRaw;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetOverlayFromFile SetOverlayFromFile;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTexture GetOverlayTexture;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseNativeOverlayHandle ReleaseNativeOverlayHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOverlayTextureSize GetOverlayTextureSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CreateDashboardOverlay CreateDashboardOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsDashboardVisible IsDashboardVisible;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsActiveDashboardOverlay IsActiveDashboardOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetDashboardOverlaySceneProcess SetDashboardOverlaySceneProcess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDashboardOverlaySceneProcess GetDashboardOverlaySceneProcess;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowDashboard ShowDashboard;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPrimaryDashboardDevice GetPrimaryDashboardDevice;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowKeyboard ShowKeyboard;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowKeyboardForOverlay ShowKeyboardForOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetKeyboardText GetKeyboardText;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HideKeyboard HideKeyboard;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetKeyboardTransformAbsolute SetKeyboardTransformAbsolute;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetKeyboardPositionForOverlay SetKeyboardPositionForOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowMessageOverlay ShowMessageOverlay;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CloseMessageOverlay CloseMessageOverlay;
	}
	public struct IVROverlayView
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _AcquireOverlayView(ulong ulOverlayHandle, ref VRNativeDevice_t pNativeDevice, ref VROverlayView_t pOverlayView, uint unOverlayViewSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVROverlayError _ReleaseOverlayView(ref VROverlayView_t pOverlayView);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _PostOverlayEvent(ulong ulOverlayHandle, ref VREvent_t pvrEvent);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsViewingPermitted(ulong ulOverlayHandle);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _AcquireOverlayView AcquireOverlayView;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReleaseOverlayView ReleaseOverlayView;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PostOverlayEvent PostOverlayEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsViewingPermitted IsViewingPermitted;
	}
	public struct IVRHeadsetView
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetHeadsetViewSize(uint nWidth, uint nHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetHeadsetViewSize(ref uint pnWidth, ref uint pnHeight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetHeadsetViewMode(uint eHeadsetViewMode);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetHeadsetViewMode();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetHeadsetViewCropped(bool bCropped);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetHeadsetViewCropped();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate float _GetHeadsetViewAspectRatio();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetHeadsetViewBlendRange(float flStartPct, float flEndPct);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetHeadsetViewBlendRange(ref float pStartPct, ref float pEndPct);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetHeadsetViewSize SetHeadsetViewSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHeadsetViewSize GetHeadsetViewSize;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetHeadsetViewMode SetHeadsetViewMode;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHeadsetViewMode GetHeadsetViewMode;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetHeadsetViewCropped SetHeadsetViewCropped;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHeadsetViewCropped GetHeadsetViewCropped;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHeadsetViewAspectRatio GetHeadsetViewAspectRatio;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetHeadsetViewBlendRange SetHeadsetViewBlendRange;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetHeadsetViewBlendRange GetHeadsetViewBlendRange;
	}
	public struct IVRRenderModels
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRRenderModelError _LoadRenderModel_Async(IntPtr pchRenderModelName, ref IntPtr ppRenderModel);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _FreeRenderModel(IntPtr pRenderModel);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRRenderModelError _LoadTexture_Async(int textureId, ref IntPtr ppTexture);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _FreeTexture(IntPtr pTexture);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRRenderModelError _LoadTextureD3D11_Async(int textureId, IntPtr pD3D11Device, ref IntPtr ppD3D11Texture2D);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRRenderModelError _LoadIntoTextureD3D11_Async(int textureId, IntPtr pDstTexture);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _FreeTextureD3D11(IntPtr pD3D11Texture2D);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetRenderModelName(uint unRenderModelIndex, StringBuilder pchRenderModelName, uint unRenderModelNameLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetRenderModelCount();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetComponentCount(IntPtr pchRenderModelName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetComponentName(IntPtr pchRenderModelName, uint unComponentIndex, StringBuilder pchComponentName, uint unComponentNameLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _GetComponentButtonMask(IntPtr pchRenderModelName, IntPtr pchComponentName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetComponentRenderModelName(IntPtr pchRenderModelName, IntPtr pchComponentName, StringBuilder pchComponentRenderModelName, uint unComponentRenderModelNameLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetComponentStateForDevicePath(IntPtr pchRenderModelName, IntPtr pchComponentName, ulong devicePath, ref RenderModel_ControllerMode_State_t pState, ref RenderModel_ComponentState_t pComponentState);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetComponentState(IntPtr pchRenderModelName, IntPtr pchComponentName, ref VRControllerState_t pControllerState, ref RenderModel_ControllerMode_State_t pState, ref RenderModel_ComponentState_t pComponentState);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _RenderModelHasComponent(IntPtr pchRenderModelName, IntPtr pchComponentName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetRenderModelThumbnailURL(IntPtr pchRenderModelName, StringBuilder pchThumbnailURL, uint unThumbnailURLLen, ref EVRRenderModelError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetRenderModelOriginalPath(IntPtr pchRenderModelName, StringBuilder pchOriginalPath, uint unOriginalPathLen, ref EVRRenderModelError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetRenderModelErrorNameFromEnum(EVRRenderModelError error);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LoadRenderModel_Async LoadRenderModel_Async;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FreeRenderModel FreeRenderModel;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LoadTexture_Async LoadTexture_Async;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FreeTexture FreeTexture;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LoadTextureD3D11_Async LoadTextureD3D11_Async;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LoadIntoTextureD3D11_Async LoadIntoTextureD3D11_Async;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FreeTextureD3D11 FreeTextureD3D11;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRenderModelName GetRenderModelName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRenderModelCount GetRenderModelCount;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentCount GetComponentCount;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentName GetComponentName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentButtonMask GetComponentButtonMask;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentRenderModelName GetComponentRenderModelName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentStateForDevicePath GetComponentStateForDevicePath;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentState GetComponentState;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RenderModelHasComponent RenderModelHasComponent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRenderModelThumbnailURL GetRenderModelThumbnailURL;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRenderModelOriginalPath GetRenderModelOriginalPath;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetRenderModelErrorNameFromEnum GetRenderModelErrorNameFromEnum;
	}
	public struct IVRNotifications
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRNotificationError _CreateNotification(ulong ulOverlayHandle, ulong ulUserValue, EVRNotificationType type, IntPtr pchText, EVRNotificationStyle style, ref NotificationBitmap_t pImage, ref uint pNotificationId);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRNotificationError _RemoveNotification(uint notificationId);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CreateNotification CreateNotification;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RemoveNotification RemoveNotification;
	}
	public struct IVRSettings
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetSettingsErrorNameFromEnum(EVRSettingsError eError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetBool(IntPtr pchSection, IntPtr pchSettingsKey, bool bValue, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetInt32(IntPtr pchSection, IntPtr pchSettingsKey, int nValue, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetFloat(IntPtr pchSection, IntPtr pchSettingsKey, float flValue, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _SetString(IntPtr pchSection, IntPtr pchSettingsKey, IntPtr pchValue, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _GetBool(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate int _GetInt32(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate float _GetFloat(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _GetString(IntPtr pchSection, IntPtr pchSettingsKey, StringBuilder pchValue, uint unValueLen, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _RemoveSection(IntPtr pchSection, ref EVRSettingsError peError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate void _RemoveKeyInSection(IntPtr pchSection, IntPtr pchSettingsKey, ref EVRSettingsError peError);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSettingsErrorNameFromEnum GetSettingsErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetBool SetBool;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetInt32 SetInt32;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetFloat SetFloat;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetString SetString;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBool GetBool;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetInt32 GetInt32;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetFloat GetFloat;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetString GetString;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RemoveSection RemoveSection;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RemoveKeyInSection RemoveKeyInSection;
	}
	public struct IVRScreenshots
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotError _RequestScreenshot(ref uint pOutScreenshotHandle, EVRScreenshotType type, IntPtr pchPreviewFilename, IntPtr pchVRFilename);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotError _HookScreenshot([In][Out] EVRScreenshotType[] pSupportedTypes, int numTypes);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotType _GetScreenshotPropertyType(uint screenshotHandle, ref EVRScreenshotError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetScreenshotPropertyFilename(uint screenshotHandle, EVRScreenshotPropertyFilenames filenameType, StringBuilder pchFilename, uint cchFilename, ref EVRScreenshotError pError);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotError _UpdateScreenshotProgress(uint screenshotHandle, float flProgress);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotError _TakeStereoScreenshot(ref uint pOutScreenshotHandle, IntPtr pchPreviewFilename, IntPtr pchVRFilename);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRScreenshotError _SubmitScreenshot(uint screenshotHandle, EVRScreenshotType type, IntPtr pchSourcePreviewFilename, IntPtr pchSourceVRFilename);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _RequestScreenshot RequestScreenshot;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HookScreenshot HookScreenshot;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetScreenshotPropertyType GetScreenshotPropertyType;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetScreenshotPropertyFilename GetScreenshotPropertyFilename;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _UpdateScreenshotProgress UpdateScreenshotProgress;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _TakeStereoScreenshot TakeStereoScreenshot;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SubmitScreenshot SubmitScreenshot;
	}
	public struct IVRResources
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _LoadSharedResource(IntPtr pchResourceName, string pchBuffer, uint unBufferLen);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetResourceFullPath(IntPtr pchResourceName, IntPtr pchResourceTypeDirectory, StringBuilder pchPathBuffer, uint unBufferLen);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _LoadSharedResource LoadSharedResource;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetResourceFullPath GetResourceFullPath;
	}
	public struct IVRDriverManager
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetDriverCount();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _GetDriverName(uint nDriver, StringBuilder pchValue, uint unBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _GetDriverHandle(IntPtr pchDriverName);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsEnabled(uint nDriver);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDriverCount GetDriverCount;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDriverName GetDriverName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDriverHandle GetDriverHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsEnabled IsEnabled;
	}
	public struct IVRInput
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _SetActionManifestPath(IntPtr pchActionManifestPath);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetActionSetHandle(IntPtr pchActionSetName, ref ulong pHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetActionHandle(IntPtr pchActionName, ref ulong pHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetInputSourceHandle(IntPtr pchInputSourcePath, ref ulong pHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _UpdateActionState([In][Out] VRActiveActionSet_t[] pSets, uint unSizeOfVRSelectedActionSet_t, uint unSetCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetDigitalActionData(ulong action, ref InputDigitalActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetAnalogActionData(ulong action, ref InputAnalogActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetPoseActionDataRelativeToNow(ulong action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, ref InputPoseActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetPoseActionDataForNextFrame(ulong action, ETrackingUniverseOrigin eOrigin, ref InputPoseActionData_t pActionData, uint unActionDataSize, ulong ulRestrictToDevice);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalActionData(ulong action, ref InputSkeletalActionData_t pActionData, uint unActionDataSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetDominantHand(ref ETrackedControllerRole peDominantHand);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _SetDominantHand(ETrackedControllerRole eDominantHand);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetBoneCount(ulong action, ref uint pBoneCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetBoneHierarchy(ulong action, [In][Out] int[] pParentIndices, uint unIndexArayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetBoneName(ulong action, int nBoneIndex, StringBuilder pchBoneName, uint unNameBufferSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalReferenceTransforms(ulong action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, [In][Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalTrackingLevel(ulong action, ref EVRSkeletalTrackingLevel pSkeletalTrackingLevel);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalBoneData(ulong action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, [In][Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalSummaryData(ulong action, EVRSummaryType eSummaryType, ref VRSkeletalSummaryData_t pSkeletalSummaryData);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetSkeletalBoneDataCompressed(ulong action, EVRSkeletalMotionRange eMotionRange, IntPtr pvCompressedData, uint unCompressedSize, ref uint punRequiredCompressedSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _DecompressSkeletalBoneData(IntPtr pvCompressedBuffer, uint unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, [In][Out] VRBoneTransform_t[] pTransformArray, uint unTransformArrayCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _TriggerHapticVibrationAction(ulong action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, ulong ulRestrictToDevice);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetActionOrigins(ulong actionSetHandle, ulong digitalActionHandle, [In][Out] ulong[] originsOut, uint originOutCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetOriginLocalizedName(ulong origin, StringBuilder pchNameArray, uint unNameArraySize, int unStringSectionsToInclude);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetOriginTrackedDeviceInfo(ulong origin, ref InputOriginInfo_t pOriginInfo, uint unOriginInfoSize);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetActionBindingInfo(ulong action, ref InputBindingInfo_t pOriginInfo, uint unBindingInfoSize, uint unBindingInfoCount, ref uint punReturnedBindingInfoCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _ShowActionOrigins(ulong actionSetHandle, ulong ulActionHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _ShowBindingsForActionSet([In][Out] VRActiveActionSet_t[] pSets, uint unSizeOfVRSelectedActionSet_t, uint unSetCount, ulong originToHighlight);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetComponentStateForBinding(IntPtr pchRenderModelName, IntPtr pchComponentName, ref InputBindingInfo_t pOriginInfo, uint unBindingInfoSize, uint unBindingInfoCount, ref RenderModel_ComponentState_t pComponentState);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _IsUsingLegacyInput();

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _OpenBindingUI(IntPtr pchAppKey, ulong ulActionSetHandle, ulong ulDeviceHandle, bool bShowOnDesktop);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRInputError _GetBindingVariant(ulong ulDevicePath, StringBuilder pchVariantArray, uint unVariantArraySize);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetActionManifestPath SetActionManifestPath;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetActionSetHandle GetActionSetHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetActionHandle GetActionHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetInputSourceHandle GetInputSourceHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _UpdateActionState UpdateActionState;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDigitalActionData GetDigitalActionData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetAnalogActionData GetAnalogActionData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPoseActionDataRelativeToNow GetPoseActionDataRelativeToNow;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPoseActionDataForNextFrame GetPoseActionDataForNextFrame;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalActionData GetSkeletalActionData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetDominantHand GetDominantHand;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _SetDominantHand SetDominantHand;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBoneCount GetBoneCount;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBoneHierarchy GetBoneHierarchy;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBoneName GetBoneName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalReferenceTransforms GetSkeletalReferenceTransforms;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalTrackingLevel GetSkeletalTrackingLevel;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalBoneData GetSkeletalBoneData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalSummaryData GetSkeletalSummaryData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSkeletalBoneDataCompressed GetSkeletalBoneDataCompressed;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _DecompressSkeletalBoneData DecompressSkeletalBoneData;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _TriggerHapticVibrationAction TriggerHapticVibrationAction;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetActionOrigins GetActionOrigins;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOriginLocalizedName GetOriginLocalizedName;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetOriginTrackedDeviceInfo GetOriginTrackedDeviceInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetActionBindingInfo GetActionBindingInfo;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowActionOrigins ShowActionOrigins;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ShowBindingsForActionSet ShowBindingsForActionSet;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetComponentStateForBinding GetComponentStateForBinding;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _IsUsingLegacyInput IsUsingLegacyInput;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _OpenBindingUI OpenBindingUI;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetBindingVariant GetBindingVariant;
	}
	public struct IVRIOBuffer
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EIOBufferError _Open(IntPtr pchPath, EIOBufferMode mode, uint unElementSize, uint unElements, ref ulong pulBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EIOBufferError _Close(ulong ulBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EIOBufferError _Read(ulong ulBuffer, IntPtr pDst, uint unBytes, ref uint punRead);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EIOBufferError _Write(ulong ulBuffer, IntPtr pSrc, uint unBytes);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _PropertyContainer(ulong ulBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate bool _HasReaders(ulong ulBuffer);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _Open Open;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _Close Close;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _Read Read;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _Write Write;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _PropertyContainer PropertyContainer;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HasReaders HasReaders;
	}
	public struct IVRSpatialAnchors
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRSpatialAnchorError _CreateSpatialAnchorFromDescriptor(IntPtr pchDescriptor, ref uint pHandleOut);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRSpatialAnchorError _CreateSpatialAnchorFromPose(uint unDeviceIndex, ETrackingUniverseOrigin eOrigin, ref SpatialAnchorPose_t pPose, ref uint pHandleOut);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRSpatialAnchorError _GetSpatialAnchorPose(uint unHandle, ETrackingUniverseOrigin eOrigin, ref SpatialAnchorPose_t pPoseOut);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRSpatialAnchorError _GetSpatialAnchorDescriptor(uint unHandle, StringBuilder pchDescriptorOut, ref uint punDescriptorBufferLenInOut);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CreateSpatialAnchorFromDescriptor CreateSpatialAnchorFromDescriptor;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _CreateSpatialAnchorFromPose CreateSpatialAnchorFromPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSpatialAnchorPose GetSpatialAnchorPose;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetSpatialAnchorDescriptor GetSpatialAnchorDescriptor;
	}
	public struct IVRDebug
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRDebugError _EmitVrProfilerEvent(IntPtr pchMessage);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRDebugError _BeginVrProfilerEvent(ref ulong pHandleOut);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EVRDebugError _FinishVrProfilerEvent(ulong hHandle, IntPtr pchMessage);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate uint _DriverDebugRequest(uint unDeviceIndex, IntPtr pchRequest, StringBuilder pchResponseBuffer, uint unResponseBufferSize);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _EmitVrProfilerEvent EmitVrProfilerEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _BeginVrProfilerEvent BeginVrProfilerEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _FinishVrProfilerEvent FinishVrProfilerEvent;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _DriverDebugRequest DriverDebugRequest;
	}
	public struct IVRProperties
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _ReadPropertyBatch(ulong ulContainerHandle, ref PropertyRead_t pBatch, uint unBatchEntryCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _WritePropertyBatch(ulong ulContainerHandle, ref PropertyWrite_t pBatch, uint unBatchEntryCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate IntPtr _GetPropErrorNameFromEnum(ETrackedPropertyError error);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ulong _TrackedDeviceToPropertyContainer(uint nDevice);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReadPropertyBatch ReadPropertyBatch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _WritePropertyBatch WritePropertyBatch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _GetPropErrorNameFromEnum GetPropErrorNameFromEnum;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _TrackedDeviceToPropertyContainer TrackedDeviceToPropertyContainer;
	}
	public struct IVRPaths
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _ReadPathBatch(ulong ulRootHandle, ref PathRead_t pBatch, uint unBatchEntryCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _WritePathBatch(ulong ulRootHandle, ref PathWrite_t pBatch, uint unBatchEntryCount);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _StringToHandle(ref ulong pHandle, IntPtr pchPath);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate ETrackedPropertyError _HandleToString(ulong pHandle, string pchBuffer, uint unBufferSize, ref uint punBufferSizeUsed);

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _ReadPathBatch ReadPathBatch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _WritePathBatch WritePathBatch;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _StringToHandle StringToHandle;

		[MarshalAs(UnmanagedType.FunctionPtr)]
		internal _HandleToString HandleToString;
	}
	public struct IVRBlockQueue
	{
		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _Create(ref ulong pulQueueHandle, IntPtr pchPath, uint unBlockDataSize, uint unBlockHeaderSize, uint unBlockCount, uint unFlags);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _Connect(ref ulong pulQueueHandle, IntPtr pchPath);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _Destroy(ulong ulQueueHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _AcquireWriteOnlyBlock(ulong ulQueueHandle, ref ulong pulBlockHandle, ref IntPtr ppvBuffer);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _ReleaseWriteOnlyBlock(ulong ulQueueHandle, ulong ulBlockHandle);

		[UnmanagedFunctionPointer(CallingConvention.StdCall)]
		internal delegate EBlockQueueError _WaitAndAcquireReadOnlyBlock(ulong ulQueueHandle, ref ulong pulBlockHandle, ref IntPtr ppvBuffer, EBlockQueueReadType eReadType, uint unTimeoutMs);

		[UnmanagedFunctionPointer(Calling

plugins/Uuvr.XR.OpenXR.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using AOT;
using Microsoft.CodeAnalysis;
using UnityEngine.Events;
using UnityEngine.Scripting;
using UnityEngine.Serialization;
using UnityEngine.XR.Management;
using UnityEngine.XR.OpenXR.Features;
using UnityEngine.XR.OpenXR.Input;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.Editor")]
[assembly: InternalsVisibleTo("UnityEditor.XR.OpenXR.Tests")]
[assembly: Preserve]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.TestHelpers")]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.Tests")]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.Tests.Editor")]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.Features.MockRuntime")]
[assembly: InternalsVisibleTo("Unity.XR.OpenXR.Features.ConformanceAutomation")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace UnityEngine.XR.OpenXR
{
	[Serializable]
	public class OpenXRSettings : ScriptableObject
	{
		public enum RenderMode
		{
			MultiPass,
			SinglePassInstanced
		}

		public enum DepthSubmissionMode
		{
			None,
			Depth16Bit,
			Depth24Bit
		}

		[FormerlySerializedAs("extensions")]
		[HideInInspector]
		[SerializeField]
		internal OpenXRFeature[] features = new OpenXRFeature[0];

		[SerializeField]
		private RenderMode m_renderMode = RenderMode.SinglePassInstanced;

		[SerializeField]
		private DepthSubmissionMode m_depthSubmissionMode = DepthSubmissionMode.None;

		private const string LibraryName = "UnityOpenXR";

		private static OpenXRSettings s_RuntimeInstance;

		public int featureCount => features.Length;

		public RenderMode renderMode
		{
			get
			{
				if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
				{
					return Internal_GetRenderMode();
				}
				return m_renderMode;
			}
			set
			{
				if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
				{
					Internal_SetRenderMode(value);
				}
				else
				{
					m_renderMode = value;
				}
			}
		}

		public DepthSubmissionMode depthSubmissionMode
		{
			get
			{
				if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
				{
					return Internal_GetDepthSubmissionMode();
				}
				return m_depthSubmissionMode;
			}
			set
			{
				if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
				{
					Internal_SetDepthSubmissionMode(value);
				}
				else
				{
					m_depthSubmissionMode = value;
				}
			}
		}

		public static OpenXRSettings ActiveBuildTargetInstance => GetInstance(useActiveBuildTarget: true);

		public static OpenXRSettings Instance => GetInstance(useActiveBuildTarget: false);

		public TFeature GetFeature<TFeature>() where TFeature : OpenXRFeature
		{
			return (TFeature)GetFeature(typeof(TFeature));
		}

		public OpenXRFeature GetFeature(Type featureType)
		{
			OpenXRFeature[] array = features;
			foreach (OpenXRFeature openXRFeature in array)
			{
				if (featureType.IsInstanceOfType(openXRFeature))
				{
					return openXRFeature;
				}
			}
			return null;
		}

		public OpenXRFeature[] GetFeatures<TFeature>()
		{
			return GetFeatures(typeof(TFeature));
		}

		public OpenXRFeature[] GetFeatures(Type featureType)
		{
			List<OpenXRFeature> list = new List<OpenXRFeature>();
			OpenXRFeature[] array = features;
			foreach (OpenXRFeature openXRFeature in array)
			{
				if (featureType.IsInstanceOfType(openXRFeature))
				{
					list.Add(openXRFeature);
				}
			}
			return list.ToArray();
		}

		public int GetFeatures<TFeature>(List<TFeature> featuresOut) where TFeature : OpenXRFeature
		{
			featuresOut.Clear();
			OpenXRFeature[] array = features;
			foreach (OpenXRFeature openXRFeature in array)
			{
				if (openXRFeature is TFeature item)
				{
					featuresOut.Add(item);
				}
			}
			return featuresOut.Count;
		}

		public int GetFeatures(Type featureType, List<OpenXRFeature> featuresOut)
		{
			featuresOut.Clear();
			OpenXRFeature[] array = features;
			foreach (OpenXRFeature openXRFeature in array)
			{
				if (featureType.IsInstanceOfType(openXRFeature))
				{
					featuresOut.Add(openXRFeature);
				}
			}
			return featuresOut.Count;
		}

		public OpenXRFeature[] GetFeatures()
		{
			return ((OpenXRFeature[])features?.Clone()) ?? new OpenXRFeature[0];
		}

		public int GetFeatures(List<OpenXRFeature> featuresOut)
		{
			featuresOut.Clear();
			featuresOut.AddRange(features);
			return featuresOut.Count;
		}

		private void ApplyRenderSettings()
		{
			Internal_SetRenderMode(m_renderMode);
			Internal_SetDepthSubmissionMode(m_depthSubmissionMode);
		}

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_SetRenderMode")]
		private static extern void Internal_SetRenderMode(RenderMode renderMode);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetRenderMode")]
		private static extern RenderMode Internal_GetRenderMode();

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_SetDepthSubmissionMode")]
		private static extern void Internal_SetDepthSubmissionMode(DepthSubmissionMode depthSubmissionMode);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetDepthSubmissionMode")]
		private static extern DepthSubmissionMode Internal_GetDepthSubmissionMode();

		private void Awake()
		{
			s_RuntimeInstance = this;
		}

		internal void ApplySettings()
		{
			ApplyRenderSettings();
		}

		private static OpenXRSettings GetInstance(bool useActiveBuildTarget)
		{
			OpenXRSettings openXRSettings = s_RuntimeInstance;
			if ((Object)(object)openXRSettings == (Object)null)
			{
				openXRSettings = ScriptableObject.CreateInstance<OpenXRSettings>();
			}
			return openXRSettings;
		}
	}
	public static class Constants
	{
		public const string k_SettingsKey = "com.unity.xr.openxr.settings4";
	}
	public class OpenXRLoader : OpenXRLoaderBase
	{
	}
	public class OpenXRLoaderBase : XRLoaderHelper
	{
		internal enum LoaderState
		{
			Uninitialized,
			InitializeAttempted,
			Initialized,
			StartAttempted,
			Started,
			StopAttempted,
			Stopped,
			DeinitializeAttempted
		}

		internal delegate void ReceiveNativeEventDelegate(OpenXRFeature.NativeEvent e, ulong payload);

		private const double k_IdlePollingWaitTimeInSeconds = 0.1;

		private static List<XRDisplaySubsystemDescriptor> s_DisplaySubsystemDescriptors = new List<XRDisplaySubsystemDescriptor>();

		private static List<XRInputSubsystemDescriptor> s_InputSubsystemDescriptors = new List<XRInputSubsystemDescriptor>();

		private List<LoaderState> validLoaderInitStates = new List<LoaderState>
		{
			LoaderState.Uninitialized,
			LoaderState.InitializeAttempted
		};

		private List<LoaderState> validLoaderStartStates = new List<LoaderState>
		{
			LoaderState.Initialized,
			LoaderState.StartAttempted,
			LoaderState.Stopped
		};

		private List<LoaderState> validLoaderStopStates = new List<LoaderState>
		{
			LoaderState.StartAttempted,
			LoaderState.Started,
			LoaderState.StopAttempted
		};

		private List<LoaderState> validLoaderDeinitStates = new List<LoaderState>
		{
			LoaderState.InitializeAttempted,
			LoaderState.Initialized,
			LoaderState.Stopped,
			LoaderState.DeinitializeAttempted
		};

		private List<LoaderState> runningStates = new List<LoaderState>
		{
			LoaderState.Initialized,
			LoaderState.StartAttempted,
			LoaderState.Started
		};

		private OpenXRFeature.NativeEvent currentOpenXRState;

		private bool actionSetsAttached;

		private UnhandledExceptionEventHandler unhandledExceptionHandler = null;

		internal bool DisableValidationChecksOnEnteringPlaymode = false;

		private double lastPollCheckTime = 0.0;

		private const string LibraryName = "UnityOpenXR";

		internal static OpenXRLoaderBase Instance { get; private set; }

		internal LoaderState currentLoaderState { get; private set; } = LoaderState.Uninitialized;

		internal XRDisplaySubsystem displaySubsystem => ((XRLoaderHelper)this).GetLoadedSubsystem<XRDisplaySubsystem>();

		internal XRInputSubsystem inputSubsystem
		{
			get
			{
				OpenXRLoaderBase instance = Instance;
				return (instance != null) ? ((XRLoaderHelper)instance).GetLoadedSubsystem<XRInputSubsystem>() : null;
			}
		}

		public bool IsInitialized => currentLoaderState != LoaderState.Uninitialized && currentLoaderState != LoaderState.DeinitializeAttempted;

		private bool isStarted => runningStates.Contains(currentLoaderState);

		public override bool Initialize()
		{
			if (currentLoaderState == LoaderState.Initialized)
			{
				return true;
			}
			if (!validLoaderInitStates.Contains(currentLoaderState))
			{
				return false;
			}
			if ((Object)(object)Instance != (Object)null)
			{
				Debug.LogError((object)"Only one OpenXRLoader can be initialized at any given time");
				return false;
			}
			try
			{
				if (InitializeInternal())
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
			((XRLoader)this).Deinitialize();
			Instance = null;
			return false;
		}

		private bool InitializeInternal()
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			Instance = this;
			currentLoaderState = LoaderState.InitializeAttempted;
			OpenXRFeature.Initialize();
			if (!LoadOpenXRSymbols())
			{
				Debug.LogError((object)"Failed to load openxr runtime loader.");
				return false;
			}
			OpenXRSettings.Instance.features = (from f in OpenXRSettings.Instance.features
				where (Object)(object)f != (Object)null
				orderby f.priority descending, f.nameUi
				select f).ToArray();
			OpenXRFeature.HookGetInstanceProcAddr();
			if (!Internal_InitializeSession())
			{
				return false;
			}
			SetApplicationInfo();
			RequestOpenXRFeatures();
			RegisterOpenXRCallbacks();
			if ((Object)null != (Object)(object)OpenXRSettings.Instance)
			{
				OpenXRSettings.Instance.ApplySettings();
			}
			if (!CreateSubsystems())
			{
				return false;
			}
			if (OpenXRFeature.requiredFeatureFailed)
			{
				return false;
			}
			OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemCreate);
			DebugLogEnabledSpecExtensions();
			Application.onBeforeRender += new UnityAction(ProcessOpenXRMessageLoop);
			currentLoaderState = LoaderState.Initialized;
			return true;
		}

		private bool CreateSubsystems()
		{
			if (displaySubsystem == null)
			{
				this.CreateSubsystem<XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "OpenXR Display");
				if (displaySubsystem == null)
				{
					return false;
				}
			}
			if (inputSubsystem == null)
			{
				this.CreateSubsystem<XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "OpenXR Input");
				if (inputSubsystem == null)
				{
					return false;
				}
			}
			return true;
		}

		internal void ProcessOpenXRMessageLoop()
		{
			if (currentOpenXRState == OpenXRFeature.NativeEvent.XrIdle || currentOpenXRState == OpenXRFeature.NativeEvent.XrStopping || currentOpenXRState == OpenXRFeature.NativeEvent.XrExiting || currentOpenXRState == OpenXRFeature.NativeEvent.XrLossPending || currentOpenXRState == OpenXRFeature.NativeEvent.XrInstanceLossPending)
			{
				float realtimeSinceStartup = Time.realtimeSinceStartup;
				if ((double)realtimeSinceStartup - lastPollCheckTime < 0.1)
				{
					return;
				}
				lastPollCheckTime = realtimeSinceStartup;
			}
			Internal_PumpMessageLoop();
		}

		public override bool Start()
		{
			if (currentLoaderState == LoaderState.Started)
			{
				return true;
			}
			if (!validLoaderStartStates.Contains(currentLoaderState))
			{
				return false;
			}
			currentLoaderState = LoaderState.StartAttempted;
			if (!StartInternal())
			{
				((XRLoader)this).Stop();
				return false;
			}
			currentLoaderState = LoaderState.Started;
			return true;
		}

		private bool StartInternal()
		{
			if (!Internal_CreateSessionIfNeeded())
			{
				return false;
			}
			if (currentOpenXRState != OpenXRFeature.NativeEvent.XrReady || (currentLoaderState != LoaderState.StartAttempted && currentLoaderState != LoaderState.Started))
			{
				return true;
			}
			Internal_BeginSession();
			if (!actionSetsAttached)
			{
				try
				{
					OpenXRInput.AttachActionSets();
				}
				catch (Exception ex)
				{
					Debug.LogError((object)"SBGVR: couldn't set up OpenXR controller input; VR runs without controllers.");
					Debug.LogException(ex);
				}
				actionSetsAttached = true;
			}
			this.StartSubsystem<XRDisplaySubsystem>();
			XRDisplaySubsystem obj = displaySubsystem;
			if (obj != null && !((IntegratedSubsystem)obj).running)
			{
				return false;
			}
			this.StartSubsystem<XRInputSubsystem>();
			XRInputSubsystem obj2 = inputSubsystem;
			if (obj2 != null && !((IntegratedSubsystem)obj2).running)
			{
				return false;
			}
			OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemStart);
			return true;
		}

		public override bool Stop()
		{
			if (currentLoaderState == LoaderState.Stopped)
			{
				return true;
			}
			if (!validLoaderStopStates.Contains(currentLoaderState))
			{
				return false;
			}
			currentLoaderState = LoaderState.StopAttempted;
			StopInternal();
			currentLoaderState = LoaderState.Stopped;
			return true;
		}

		private void StopInternal()
		{
			XRInputSubsystem obj = inputSubsystem;
			bool flag = obj != null && ((IntegratedSubsystem)obj).running;
			XRDisplaySubsystem obj2 = displaySubsystem;
			bool flag2 = obj2 != null && ((IntegratedSubsystem)obj2).running;
			if (flag || flag2)
			{
				OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemStop);
			}
			if (flag)
			{
				this.StopSubsystem<XRInputSubsystem>();
			}
			if (flag2)
			{
				this.StopSubsystem<XRDisplaySubsystem>();
			}
			Internal_EndSession();
			ProcessOpenXRMessageLoop();
		}

		public override bool Deinitialize()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			if (currentLoaderState == LoaderState.Uninitialized)
			{
				return true;
			}
			if (!validLoaderDeinitStates.Contains(currentLoaderState))
			{
				return false;
			}
			currentLoaderState = LoaderState.DeinitializeAttempted;
			try
			{
				Internal_RequestExitSession();
				Application.onBeforeRender -= new UnityAction(ProcessOpenXRMessageLoop);
				ProcessOpenXRMessageLoop();
				OpenXRFeature.ReceiveLoaderEvent(this, OpenXRFeature.LoaderEvent.SubsystemDestroy);
				this.DestroySubsystem<XRInputSubsystem>();
				this.DestroySubsystem<XRDisplaySubsystem>();
				Internal_DestroySession();
				ProcessOpenXRMessageLoop();
				Internal_UnloadOpenXRLibrary();
				currentLoaderState = LoaderState.Uninitialized;
				actionSetsAttached = false;
				if (unhandledExceptionHandler != null)
				{
					AppDomain currentDomain = AppDomain.CurrentDomain;
					currentDomain.UnhandledException -= unhandledExceptionHandler;
					unhandledExceptionHandler = null;
				}
				return ((XRLoaderHelper)this).Deinitialize();
			}
			finally
			{
				Instance = null;
			}
		}

		internal void CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id) where TDescriptor : ISubsystemDescriptor where TSubsystem : ISubsystem
		{
			((XRLoaderHelper)this).CreateSubsystem<TDescriptor, TSubsystem>(descriptors, id);
		}

		internal void StartSubsystem<T>() where T : class, ISubsystem
		{
			((XRLoaderHelper)this).StartSubsystem<T>();
		}

		internal void StopSubsystem<T>() where T : class, ISubsystem
		{
			((XRLoaderHelper)this).StopSubsystem<T>();
		}

		internal void DestroySubsystem<T>() where T : class, ISubsystem
		{
			((XRLoaderHelper)this).DestroySubsystem<T>();
		}

		private void SetApplicationInfo()
		{
			MD5 mD = MD5.Create();
			byte[] array = mD.ComputeHash(Encoding.UTF8.GetBytes(Application.version));
			if (BitConverter.IsLittleEndian)
			{
				Array.Reverse(array);
			}
			uint applicationVersionHash = BitConverter.ToUInt32(array, 0);
			Internal_SetApplicationInfo(Application.productName, Application.version, applicationVersionHash, Application.unityVersion);
		}

		private byte[] StringToWCHAR_T(string s)
		{
			Encoding encoding = ((Environment.OSVersion.Platform == PlatformID.Unix) ? Encoding.UTF32 : Encoding.Unicode);
			return encoding.GetBytes(s + "\0");
		}

		private bool LoadOpenXRSymbols()
		{
			string s = "openxr_loader";
			if (!Internal_LoadOpenXRLibrary(StringToWCHAR_T(s)))
			{
				return false;
			}
			return true;
		}

		private void RequestOpenXRFeatures()
		{
			OpenXRSettings instance = OpenXRSettings.Instance;
			if ((Object)(object)instance == (Object)null || instance.features == null)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder("");
			StringBuilder stringBuilder2 = new StringBuilder("");
			uint num = 0u;
			uint num2 = 0u;
			OpenXRFeature[] features = instance.features;
			foreach (OpenXRFeature openXRFeature in features)
			{
				if ((Object)(object)openXRFeature == (Object)null || !openXRFeature.enabled)
				{
					continue;
				}
				num++;
				stringBuilder.Append("  " + openXRFeature.nameUi + ": Version=" + openXRFeature.version + ", Company=\"" + openXRFeature.company + "\"");
				if (!string.IsNullOrEmpty(openXRFeature.openxrExtensionStrings))
				{
					stringBuilder.Append(", Extensions=\"" + openXRFeature.openxrExtensionStrings + "\"");
					string[] array = openXRFeature.openxrExtensionStrings.Split(' ');
					foreach (string text in array)
					{
						if (!string.IsNullOrWhiteSpace(text) && !Internal_RequestEnableExtensionString(text))
						{
							num2++;
							stringBuilder2.Append("  " + text + ": Feature=\"" + openXRFeature.nameUi + "\": Version=" + openXRFeature.version + ", Company=\"" + openXRFeature.company + "\"\n");
						}
					}
				}
				stringBuilder.Append("\n");
			}
		}

		private static void DebugLogEnabledSpecExtensions()
		{
			string[] enabledExtensions = OpenXRRuntime.GetEnabledExtensions();
			StringBuilder stringBuilder = new StringBuilder($"({enabledExtensions.Length})\n");
			string[] array = enabledExtensions;
			foreach (string text in array)
			{
				stringBuilder.Append($"  {text}: Version={OpenXRRuntime.GetExtensionVersion(text)}\n");
			}
		}

		[MonoPInvokeCallback(typeof(ReceiveNativeEventDelegate))]
		private static void ReceiveNativeEvent(OpenXRFeature.NativeEvent e, ulong payload)
		{
			OpenXRLoaderBase instance = Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.currentOpenXRState = e;
			}
			switch (e)
			{
			case OpenXRFeature.NativeEvent.XrRestartRequested:
				OpenXRRestarter.Instance.ShutdownAndRestart();
				break;
			case OpenXRFeature.NativeEvent.XrReady:
				instance.StartInternal();
				break;
			case OpenXRFeature.NativeEvent.XrStopping:
				instance.StopInternal();
				break;
			}
			OpenXRFeature.ReceiveNativeEvent(e, payload);
			if ((!((Object)(object)instance == (Object)null) && instance.isStarted) || e == OpenXRFeature.NativeEvent.XrInstanceChanged)
			{
				switch (e)
				{
				case OpenXRFeature.NativeEvent.XrExiting:
					OpenXRRestarter.Instance.Shutdown();
					break;
				case OpenXRFeature.NativeEvent.XrLossPending:
					OpenXRRestarter.Instance.ShutdownAndRestart();
					break;
				case OpenXRFeature.NativeEvent.XrInstanceLossPending:
					OpenXRRestarter.Instance.Shutdown();
					break;
				}
			}
		}

		internal static void RegisterOpenXRCallbacks()
		{
			Internal_SetCallbacks(ReceiveNativeEvent);
		}

		[DllImport("UnityOpenXR", EntryPoint = "main_LoadOpenXRLibrary")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_LoadOpenXRLibrary(byte[] loaderPath);

		[DllImport("UnityOpenXR", EntryPoint = "main_UnloadOpenXRLibrary")]
		internal static extern void Internal_UnloadOpenXRLibrary();

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_SetCallbacks")]
		private static extern void Internal_SetCallbacks(ReceiveNativeEventDelegate callback);

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "NativeConfig_SetApplicationInfo")]
		private static extern void Internal_SetApplicationInfo(string applicationName, string applicationVersion, uint applicationVersionHash, string engineVersion);

		[DllImport("UnityOpenXR", EntryPoint = "session_RequestExitSession")]
		internal static extern void Internal_RequestExitSession();

		[DllImport("UnityOpenXR", EntryPoint = "session_InitializeSession")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_InitializeSession();

		[DllImport("UnityOpenXR", EntryPoint = "session_CreateSessionIfNeeded")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_CreateSessionIfNeeded();

		[DllImport("UnityOpenXR", EntryPoint = "session_BeginSession")]
		internal static extern void Internal_BeginSession();

		[DllImport("UnityOpenXR", EntryPoint = "session_EndSession")]
		internal static extern void Internal_EndSession();

		[DllImport("UnityOpenXR", EntryPoint = "session_DestroySession")]
		internal static extern void Internal_DestroySession();

		[DllImport("UnityOpenXR", EntryPoint = "messagepump_PumpMessageLoop")]
		private static extern void Internal_PumpMessageLoop();

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "unity_ext_RequestEnableExtensionString")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_RequestEnableExtensionString(string extensionString);
	}
	internal class OpenXRRestarter : MonoBehaviour
	{
		internal Action onAfterRestart;

		internal Action onAfterShutdown;

		internal Action onQuit;

		internal Action onAfterCoroutine;

		private static OpenXRRestarter s_Instance;

		private Coroutine m_Coroutine;

		public bool isRunning => m_Coroutine != null;

		public static OpenXRRestarter Instance
		{
			get
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				if ((Object)(object)s_Instance == (Object)null)
				{
					GameObject val = GameObject.Find("~oxrestarter");
					if ((Object)(object)val == (Object)null)
					{
						val = new GameObject("~oxrestarter");
						((Object)val).hideFlags = (HideFlags)61;
						val.AddComponent<OpenXRRestarter>();
					}
					s_Instance = val.GetComponent<OpenXRRestarter>();
				}
				return s_Instance;
			}
		}

		public void ResetCallbacks()
		{
			onAfterRestart = null;
			onAfterShutdown = null;
			onAfterCoroutine = null;
			onQuit = null;
		}

		public void Shutdown()
		{
			if (!((Object)(object)OpenXRLoaderBase.Instance == (Object)null))
			{
				if (m_Coroutine != null)
				{
					Debug.LogError((object)"Only one shutdown or restart can be executed at a time");
				}
				else
				{
					m_Coroutine = ((MonoBehaviour)this).StartCoroutine(RestartCoroutine(shouldRestart: false));
				}
			}
		}

		public void ShutdownAndRestart()
		{
			if (!((Object)(object)OpenXRLoaderBase.Instance == (Object)null))
			{
				if (m_Coroutine != null)
				{
					Debug.LogError((object)"Only one shutdown or restart can be executed at a time");
				}
				else
				{
					m_Coroutine = ((MonoBehaviour)this).StartCoroutine(RestartCoroutine(shouldRestart: true));
				}
			}
		}

		private IEnumerator RestartCoroutine(bool shouldRestart)
		{
			try
			{
				yield return null;
				XRGeneralSettings.Instance.Manager.DeinitializeLoader();
				yield return null;
				onAfterShutdown?.Invoke();
				if (shouldRestart && OpenXRRuntime.ShouldRestart())
				{
					yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
					XRGeneralSettings.Instance.Manager.StartSubsystems();
					if ((Object)(object)XRGeneralSettings.Instance.Manager.activeLoader == (Object)null)
					{
						Debug.LogError((object)"Failure to restart OpenXRLoader after shutdown.");
					}
					onAfterRestart?.Invoke();
				}
				else if (OpenXRRuntime.ShouldQuit())
				{
					onQuit?.Invoke();
					Application.Quit();
				}
			}
			finally
			{
				m_Coroutine = null;
				onAfterCoroutine?.Invoke();
			}
		}
	}
	public static class OpenXRRuntime
	{
		private const string LibraryName = "UnityOpenXR";

		public static string name
		{
			get
			{
				IntPtr runtimeNamePtr;
				return Internal_GetRuntimeName(out runtimeNamePtr) ? Marshal.PtrToStringAnsi(runtimeNamePtr) : "";
			}
		}

		public static string version
		{
			get
			{
				ushort major;
				ushort minor;
				uint patch;
				return Internal_GetRuntimeVersion(out major, out minor, out patch) ? $"{major}.{minor}.{patch}" : "";
			}
		}

		public static string apiVersion
		{
			get
			{
				ushort major;
				ushort minor;
				uint patch;
				return Internal_GetAPIVersion(out major, out minor, out patch) ? $"{major}.{minor}.{patch}" : "";
			}
		}

		public static string pluginVersion
		{
			get
			{
				IntPtr pluginVersionPtr;
				return Internal_GetPluginVersion(out pluginVersionPtr) ? Marshal.PtrToStringAnsi(pluginVersionPtr) : "";
			}
		}

		public static event Func<bool> wantsToQuit;

		public static event Func<bool> wantsToRestart;

		public static bool IsExtensionEnabled(string extensionName)
		{
			return Internal_IsExtensionEnabled(extensionName);
		}

		public static uint GetExtensionVersion(string extensionName)
		{
			return Internal_GetExtensionVersion(extensionName);
		}

		public static string[] GetEnabledExtensions()
		{
			string[] array = new string[Internal_GetEnabledExtensionCount()];
			for (int i = 0; i < array.Length; i++)
			{
				Internal_GetEnabledExtensionName((uint)i, out string extensionName);
				array[i] = extensionName ?? "";
			}
			return array;
		}

		public static string[] GetAvailableExtensions()
		{
			string[] array = new string[Internal_GetAvailableExtensionCount()];
			for (int i = 0; i < array.Length; i++)
			{
				Internal_GetAvailableExtensionName((uint)i, out string extensionName);
				array[i] = extensionName ?? "";
			}
			return array;
		}

		private static bool InvokeEvent(Func<bool> func)
		{
			if (func == null)
			{
				return true;
			}
			Delegate[] invocationList = func.GetInvocationList();
			for (int i = 0; i < invocationList.Length; i++)
			{
				Func<bool> func2 = (Func<bool>)invocationList[i];
				try
				{
					if (!func2())
					{
						return false;
					}
				}
				catch (Exception ex)
				{
					Debug.LogException(ex);
				}
			}
			return true;
		}

		internal static bool ShouldQuit()
		{
			return InvokeEvent(OpenXRRuntime.wantsToQuit);
		}

		internal static bool ShouldRestart()
		{
			return InvokeEvent(OpenXRRuntime.wantsToRestart);
		}

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetRuntimeName")]
		private static extern bool Internal_GetRuntimeName(out IntPtr runtimeNamePtr);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetRuntimeVersion")]
		private static extern bool Internal_GetRuntimeVersion(out ushort major, out ushort minor, out uint patch);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetAPIVersion")]
		private static extern bool Internal_GetAPIVersion(out ushort major, out ushort minor, out uint patch);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetPluginVersion")]
		private static extern bool Internal_GetPluginVersion(out IntPtr pluginVersionPtr);

		[DllImport("UnityOpenXR", EntryPoint = "unity_ext_IsExtensionEnabled")]
		private static extern bool Internal_IsExtensionEnabled(string extensionName);

		[DllImport("UnityOpenXR", EntryPoint = "unity_ext_GetExtensionVersion")]
		private static extern uint Internal_GetExtensionVersion(string extensionName);

		[DllImport("UnityOpenXR", EntryPoint = "unity_ext_GetEnabledExtensionCount")]
		private static extern uint Internal_GetEnabledExtensionCount();

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "unity_ext_GetEnabledExtensionName")]
		private static extern bool Internal_GetEnabledExtensionNamePtr(uint index, out IntPtr outName);

		private static bool Internal_GetEnabledExtensionName(uint index, out string extensionName)
		{
			if (!Internal_GetEnabledExtensionNamePtr(index, out var outName))
			{
				extensionName = "";
				return false;
			}
			extensionName = Marshal.PtrToStringAnsi(outName);
			return true;
		}

		[DllImport("UnityOpenXR", EntryPoint = "unity_ext_GetAvailableExtensionCount")]
		private static extern uint Internal_GetAvailableExtensionCount();

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "unity_ext_GetAvailableExtensionName")]
		private static extern bool Internal_GetAvailableExtensionNamePtr(uint index, out IntPtr extensionName);

		private static bool Internal_GetAvailableExtensionName(uint index, out string extensionName)
		{
			if (!Internal_GetAvailableExtensionNamePtr(index, out var extensionName2))
			{
				extensionName = "";
				return false;
			}
			extensionName = Marshal.PtrToStringAnsi(extensionName2);
			return true;
		}

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "session_GetLastError")]
		private static extern bool Internal_GetLastError(out IntPtr error);

		internal static bool GetLastError(out string error)
		{
			if (!Internal_GetLastError(out var error2))
			{
				error = "";
				return false;
			}
			error = Marshal.PtrToStringAnsi(error2);
			return true;
		}

		internal static void LogLastError()
		{
			if (GetLastError(out string error))
			{
				Debug.LogError((object)error);
			}
		}
	}
}
namespace UnityEngine.XR.OpenXR.NativeTypes
{
	internal enum XrEnvironmentBlendMode
	{
		Opaque = 1,
		Additive,
		AlphaBlend
	}
	internal enum XrResult
	{
		Success = 0,
		TimeoutExpored = 1,
		LossPending = 3,
		EventUnavailable = 4,
		SpaceBoundsUnavailable = 7,
		SessionNotFocused = 8,
		FrameDiscarded = 9,
		ValidationFailure = -1,
		RuntimeFailure = -2,
		OutOfMemory = -3,
		ApiVersionUnsupported = -4,
		InitializationFailed = -6,
		FunctionUnsupported = -7,
		FeatureUnsupported = -8,
		ExtensionNotPresent = -9,
		LimitReached = -10,
		SizeInsufficient = -11,
		HandleInvalid = -12,
		InstanceLOst = -13,
		SessionRunning = -14,
		SessionNotRunning = -16,
		SessionLost = -17,
		SystemInvalid = -18,
		PathInvalid = -19,
		PathCountExceeded = -20,
		PathFormatInvalid = -21,
		PathUnsupported = -22,
		LayerInvalid = -23,
		LayerLimitExceeded = -24,
		SpwachainRectInvalid = -25,
		SwapchainFormatUnsupported = -26,
		ActionTypeMismatch = -27,
		SessionNotReady = -28,
		SessionNotStopping = -29,
		TimeInvalid = -30,
		ReferenceSpaceUnsupported = -31,
		FileAccessError = -32,
		FileContentsInvalid = -33,
		FormFactorUnsupported = -34,
		FormFactorUnavailable = -35,
		ApiLayerNotPresent = -36,
		CallOrderInvalid = -37,
		GraphicsDeviceInvalid = -38,
		PoseInvalid = -39,
		IndexOutOfRange = -40,
		ViewConfigurationTypeUnsupported = -41,
		EnvironmentBlendModeUnsupported = -42,
		NameDuplicated = -44,
		NameInvalid = -45,
		ActionsetNotAttached = -46,
		ActionsetsAlreadyAttached = -47,
		LocalizedNameDuplicated = -48,
		LocalizedNameInvalid = -49,
		AndroidThreadSettingsIdInvalidKHR = -1000003000,
		AndroidThreadSettingsdFailureKHR = -1000003001,
		CreateSpatialAnchorFailedMSFT = -1000039001,
		SecondaryViewConfigurationTypeNotEnabledMSFT = -1000053000,
		MaxResult = int.MaxValue
	}
	internal enum XrViewConfigurationType
	{
		PrimaryMono = 1,
		PrimaryStereo = 2,
		PrimaryQuadVarjo = 1000037000,
		SecondaryMonoFirstPersonObserver = 1000054000,
		SecondaryMonoThirdPersonObserver = 1000145000
	}
	[Flags]
	internal enum XrSpaceLocationFlags
	{
		None = 0,
		OrientationValid = 1,
		PositionValid = 2,
		OrientationTracked = 4,
		PositionTracked = 8
	}
	[Flags]
	internal enum XrViewStateFlags
	{
		None = 0,
		OrientationValid = 1,
		PositionValid = 2,
		OrientationTracked = 4,
		PositionTracked = 8
	}
	[Flags]
	internal enum XrReferenceSpaceType
	{
		View = 1,
		Local = 2,
		Stage = 3,
		UnboundedMsft = 0x3B9B5E70,
		CombinedEyeVarjo = 0x3B9CA2A8
	}
	internal enum XrSessionState
	{
		Unknown,
		Idle,
		Ready,
		Synchronized,
		Visible,
		Focused,
		Stopping,
		LossPending,
		Exiting
	}
	internal struct XrVector2f
	{
		private float x;

		private float y;

		public XrVector2f(float x, float y)
		{
			this.x = x;
			this.y = y;
		}

		public XrVector2f(Vector2 value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			x = value.x;
			y = value.y;
		}
	}
	internal struct XrVector3f
	{
		private float x;

		private float y;

		private float z;

		public XrVector3f(float x, float y, float z)
		{
			this.x = x;
			this.y = y;
			this.z = 0f - z;
		}

		public XrVector3f(Vector3 value)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			x = value.x;
			y = value.y;
			z = 0f - value.z;
		}
	}
	internal struct XrQuaternionf
	{
		private float x;

		private float y;

		private float z;

		private float w;

		public XrQuaternionf(float x, float y, float z, float w)
		{
			this.x = 0f - x;
			this.y = 0f - y;
			this.z = z;
			this.w = w;
		}

		public XrQuaternionf(Quaternion quaternion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			x = 0f - quaternion.x;
			y = 0f - quaternion.y;
			z = quaternion.z;
			w = quaternion.w;
		}
	}
	internal struct XrPosef
	{
		private XrQuaternionf orientation;

		private XrVector3f position;

		public XrPosef(Vector3 vec3, Quaternion quaternion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			position = new XrVector3f(vec3);
			orientation = new XrQuaternionf(quaternion);
		}
	}
}
namespace UnityEngine.XR.OpenXR.Input
{
	public static class OpenXRInput
	{
		[StructLayout(LayoutKind.Explicit)]
		private struct SerializedGuid
		{
			[FieldOffset(0)]
			public Guid guid;

			[FieldOffset(0)]
			public ulong ulong1;

			[FieldOffset(8)]
			public ulong ulong2;
		}

		internal struct SerializedBinding
		{
			public ulong actionId;

			public string path;
		}

		private const string Library = "UnityOpenXR";

		private static bool ValidateActionMapConfig(OpenXRInteractionFeature interactionFeature, OpenXRInteractionFeature.ActionMapConfig actionMapConfig)
		{
			bool result = true;
			if (actionMapConfig.deviceInfos == null || actionMapConfig.deviceInfos.Count == 0)
			{
				Debug.LogError((object)$"ActionMapConfig contains no `deviceInfos` in InteractionFeature '{((object)interactionFeature).GetType()}'");
				result = false;
			}
			if (actionMapConfig.actions == null || actionMapConfig.actions.Count == 0)
			{
				Debug.LogError((object)$"ActionMapConfig contains no `actions` in InteractionFeature '{((object)interactionFeature).GetType()}'");
				result = false;
			}
			return result;
		}

		internal static void AttachActionSets()
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected I4, but got Unknown
			List<OpenXRInteractionFeature.ActionMapConfig> list = new List<OpenXRInteractionFeature.ActionMapConfig>();
			foreach (OpenXRInteractionFeature item in from f in OpenXRSettings.Instance.features.OfType<OpenXRInteractionFeature>()
				where f.enabled
				select f)
			{
				int count = list.Count;
				item.CreateActionMaps(list);
				for (int num = list.Count - 1; num >= count; num--)
				{
					if (!ValidateActionMapConfig(item, list[num]))
					{
						list.RemoveAt(num);
					}
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			foreach (OpenXRInteractionFeature.ActionMapConfig item2 in list)
			{
				foreach (OpenXRInteractionFeature.DeviceConfig deviceInfo in item2.deviceInfos)
				{
					string name = ((item2.desiredInteractionProfile == null) ? UserPathToDeviceName(deviceInfo.userPath) : item2.localizedName);
					if (Internal_RegisterDeviceDefinition(deviceInfo.userPath, item2.desiredInteractionProfile, (uint)(int)deviceInfo.characteristics, name, item2.manufacturer, item2.serialNumber) == 0)
					{
						OpenXRRuntime.LogLastError();
						return;
					}
				}
			}
			Dictionary<string, List<SerializedBinding>> dictionary = new Dictionary<string, List<SerializedBinding>>();
			foreach (OpenXRInteractionFeature.ActionMapConfig item3 in list)
			{
				string localizedName = SanitizeStringForOpenXRPath(item3.localizedName);
				ulong num2 = Internal_CreateActionSet(SanitizeStringForOpenXRPath(item3.name), localizedName, default(SerializedGuid));
				if (num2 == 0)
				{
					OpenXRRuntime.LogLastError();
					return;
				}
				List<string> list2 = item3.deviceInfos.Select((OpenXRInteractionFeature.DeviceConfig d) => d.userPath).ToList();
				foreach (OpenXRInteractionFeature.ActionConfig action in item3.actions)
				{
					List<string> first = action.bindings.Where((OpenXRInteractionFeature.ActionBinding b) => b.userPaths != null).SelectMany((OpenXRInteractionFeature.ActionBinding b) => b.userPaths).Distinct()
						.ToList();
					string[] array = first.Union(list2).ToArray();
					ulong num3 = Internal_CreateAction(num2, SanitizeStringForOpenXRPath(action.name), action.localizedName, (uint)action.type, default(SerializedGuid), array, (uint)array.Length, action.usages?.ToArray(), (uint)(action.usages?.Count ?? 0));
					if (num3 == 0)
					{
						OpenXRRuntime.LogLastError();
						return;
					}
					foreach (OpenXRInteractionFeature.ActionBinding binding in action.bindings)
					{
						foreach (string item4 in binding.userPaths ?? list2)
						{
							string key = binding.interactionProfileName ?? item3.desiredInteractionProfile;
							if (!dictionary.TryGetValue(key, out var value))
							{
								value = (dictionary[key] = new List<SerializedBinding>());
							}
							value.Add(new SerializedBinding
							{
								actionId = num3,
								path = item4 + binding.interactionPath
							});
						}
					}
				}
			}
			foreach (KeyValuePair<string, List<SerializedBinding>> item5 in dictionary)
			{
				if (!Internal_SuggestBindings(item5.Key, item5.Value.ToArray(), (uint)item5.Value.Count))
				{
					OpenXRRuntime.LogLastError();
				}
			}
			if (!Internal_AttachActionSets())
			{
				OpenXRRuntime.LogLastError();
			}
		}

		private static char SanitizeCharForOpenXRPath(char c)
		{
			if (char.IsLower(c) || char.IsDigit(c))
			{
				return c;
			}
			if (char.IsUpper(c))
			{
				return char.ToLower(c);
			}
			if (c == '-' || c == '.' || c == '_' || c == '/')
			{
				return c;
			}
			return '\0';
		}

		private static string SanitizeStringForOpenXRPath(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return "";
			}
			int i;
			for (i = 0; i < input.Length && SanitizeCharForOpenXRPath(input[i]) == input[i]; i++)
			{
			}
			if (i == input.Length)
			{
				return input;
			}
			StringBuilder stringBuilder = new StringBuilder(input, 0, i, input.Length);
			for (; i < input.Length; i++)
			{
				char c = SanitizeCharForOpenXRPath(input[i]);
				if (c != 0)
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString();
		}

		private static string UserPathToDeviceName(string userPath)
		{
			string[] array = userPath.Split('/', '_');
			StringBuilder stringBuilder = new StringBuilder("OXR");
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (text.Length != 0)
				{
					string text2 = SanitizeStringForOpenXRPath(text);
					stringBuilder.Append(char.ToUpper(text2[0]));
					stringBuilder.Append(text2.Substring(1));
				}
			}
			return stringBuilder.ToString();
		}

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "OpenXRInputProvider_RegisterDeviceDefinition")]
		private static extern ulong Internal_RegisterDeviceDefinition(string userPath, string interactionProfile, uint characteristics, string name, string manufacturer, string serialNumber);

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "OpenXRInputProvider_CreateActionSet")]
		private static extern ulong Internal_CreateActionSet(string name, string localizedName, SerializedGuid guid);

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "OpenXRInputProvider_CreateAction")]
		private static extern ulong Internal_CreateAction(ulong actionSetId, string name, string localizedName, uint actionType, SerializedGuid guid, string[] userPaths, uint userPathCount, string[] usages, uint usageCount);

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "OpenXRInputProvider_SuggestBindings")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_SuggestBindings(string interactionProfile, SerializedBinding[] serializedBindings, uint serializedBindingCount);

		[DllImport("UnityOpenXR", CharSet = CharSet.Ansi, EntryPoint = "OpenXRInputProvider_AttachActionSets")]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool Internal_AttachActionSets();
	}
}
namespace UnityEngine.XR.OpenXR.Features
{
	[Serializable]
	public abstract class OpenXRFeature : ScriptableObject
	{
		internal enum LoaderEvent
		{
			SubsystemCreate,
			SubsystemDestroy,
			SubsystemStart,
			SubsystemStop
		}

		internal enum NativeEvent
		{
			XrSetupConfigValues,
			XrSystemIdChanged,
			XrInstanceChanged,
			XrSessionChanged,
			XrBeginSession,
			XrSessionStateChanged,
			XrChangedSpaceApp,
			XrEndSession,
			XrDestroySession,
			XrDestroyInstance,
			XrIdle,
			XrReady,
			XrSynchronized,
			XrVisible,
			XrFocused,
			XrStopping,
			XrExiting,
			XrLossPending,
			XrInstanceLossPending,
			XrRestartRequested
		}

		[FormerlySerializedAs("enabled")]
		[HideInInspector]
		[SerializeField]
		private bool m_enabled = false;

		[HideInInspector]
		[SerializeField]
		internal string nameUi = null;

		[HideInInspector]
		[SerializeField]
		internal string version = null;

		[HideInInspector]
		[SerializeField]
		internal string featureIdInternal = null;

		[HideInInspector]
		[SerializeField]
		internal string openxrExtensionStrings = null;

		[HideInInspector]
		[SerializeField]
		internal string company = null;

		[HideInInspector]
		[SerializeField]
		internal int priority = 0;

		[HideInInspector]
		[SerializeField]
		internal bool required = false;

		[NonSerialized]
		internal bool internalFieldsUpdated = false;

		private const string Library = "UnityOpenXR";

		internal bool failedInitialization { get; private set; } = false;

		internal static bool requiredFeatureFailed { get; private set; }

		public bool enabled
		{
			get
			{
				return m_enabled && ((Object)(object)OpenXRLoaderBase.Instance == (Object)null || !failedInitialization);
			}
			set
			{
				if (enabled != value)
				{
					if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
					{
						Debug.LogError((object)"OpenXRFeature.enabled cannot be changed while OpenXR is running");
						return;
					}
					m_enabled = value;
					OnEnabledChange();
				}
			}
		}

		protected static IntPtr xrGetInstanceProcAddr => Internal_GetProcAddressPtr(loaderDefault: false);

		protected internal virtual IntPtr HookGetInstanceProcAddr(IntPtr func)
		{
			return func;
		}

		protected internal virtual void OnSubsystemCreate()
		{
		}

		protected internal virtual void OnSubsystemStart()
		{
		}

		protected internal virtual void OnSubsystemStop()
		{
		}

		protected internal virtual void OnSubsystemDestroy()
		{
		}

		protected internal virtual bool OnInstanceCreate(ulong xrInstance)
		{
			return true;
		}

		protected internal virtual void OnSystemChange(ulong xrSystem)
		{
		}

		protected internal virtual void OnSessionCreate(ulong xrSession)
		{
		}

		protected internal virtual void OnAppSpaceChange(ulong xrSpace)
		{
		}

		protected internal virtual void OnSessionStateChange(int oldState, int newState)
		{
		}

		protected internal virtual void OnSessionBegin(ulong xrSession)
		{
		}

		protected internal virtual void OnSessionEnd(ulong xrSession)
		{
		}

		protected internal virtual void OnSessionExiting(ulong xrSession)
		{
		}

		protected internal virtual void OnSessionDestroy(ulong xrSession)
		{
		}

		protected internal virtual void OnInstanceDestroy(ulong xrInstance)
		{
		}

		protected internal virtual void OnSessionLossPending(ulong xrSession)
		{
		}

		protected internal virtual void OnInstanceLossPending(ulong xrInstance)
		{
		}

		protected internal virtual void OnFormFactorChange(int xrFormFactor)
		{
		}

		protected internal virtual void OnViewConfigurationTypeChange(int xrViewConfigurationType)
		{
		}

		protected internal virtual void OnEnvironmentBlendModeChange(int xrEnvironmentBlendMode)
		{
		}

		protected internal virtual void OnEnabledChange()
		{
		}

		protected static string PathToString(ulong path)
		{
			IntPtr path2;
			return Internal_PathToStringPtr(path, out path2) ? Marshal.PtrToStringAnsi(path2) : null;
		}

		protected static ulong StringToPath(string str)
		{
			ulong pathId;
			return Internal_StringToPath(str, out pathId) ? pathId : 0;
		}

		protected static ulong GetCurrentInteractionProfile(ulong userPath)
		{
			ulong interactionProfile;
			return Internal_GetCurrentInteractionProfile(userPath, out interactionProfile) ? interactionProfile : 0;
		}

		protected static ulong GetCurrentInteractionProfile(string userPath)
		{
			return GetCurrentInteractionProfile(StringToPath(userPath));
		}

		protected static ulong GetCurrentAppSpace()
		{
			ulong appSpace;
			return Internal_GetAppSpace(out appSpace) ? appSpace : 0;
		}

		protected static int GetViewConfigurationTypeForRenderPass(int renderPassIndex)
		{
			return Internal_GetViewTypeFromRenderIndex(renderPassIndex);
		}

		protected void CreateSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id) where TDescriptor : ISubsystemDescriptor where TSubsystem : ISubsystem
		{
			if ((Object)(object)OpenXRLoaderBase.Instance == (Object)null)
			{
				Debug.LogError((object)"CreateSubsystem called before loader was initialized");
			}
			else
			{
				OpenXRLoaderBase.Instance.CreateSubsystem<TDescriptor, TSubsystem>(descriptors, id);
			}
		}

		protected void StartSubsystem<T>() where T : class, ISubsystem
		{
			if ((Object)(object)OpenXRLoaderBase.Instance == (Object)null)
			{
				Debug.LogError((object)"StartSubsystem called before loader was initialized");
			}
			else
			{
				OpenXRLoaderBase.Instance.StartSubsystem<T>();
			}
		}

		protected void StopSubsystem<T>() where T : class, ISubsystem
		{
			if ((Object)(object)OpenXRLoaderBase.Instance == (Object)null)
			{
				Debug.LogError((object)"StopSubsystem called before loader was initialized");
			}
			else
			{
				OpenXRLoaderBase.Instance.StopSubsystem<T>();
			}
		}

		protected void DestroySubsystem<T>() where T : class, ISubsystem
		{
			if ((Object)(object)OpenXRLoaderBase.Instance == (Object)null)
			{
				Debug.LogError((object)"DestroySubsystem called before loader was initialized");
			}
			else
			{
				OpenXRLoaderBase.Instance.DestroySubsystem<T>();
			}
		}

		protected virtual void OnEnable()
		{
		}

		protected virtual void OnDisable()
		{
		}

		internal static bool ReceiveLoaderEvent(OpenXRLoaderBase loader, LoaderEvent e)
		{
			OpenXRSettings instance = OpenXRSettings.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return true;
			}
			OpenXRFeature[] features = instance.features;
			foreach (OpenXRFeature openXRFeature in features)
			{
				if (!((Object)(object)openXRFeature == (Object)null) && openXRFeature.enabled)
				{
					switch (e)
					{
					case LoaderEvent.SubsystemCreate:
						openXRFeature.OnSubsystemCreate();
						break;
					case LoaderEvent.SubsystemDestroy:
						openXRFeature.OnSubsystemDestroy();
						break;
					case LoaderEvent.SubsystemStart:
						openXRFeature.OnSubsystemStart();
						break;
					case LoaderEvent.SubsystemStop:
						openXRFeature.OnSubsystemStop();
						break;
					default:
						throw new ArgumentOutOfRangeException("e", e, null);
					}
				}
			}
			return true;
		}

		internal static void ReceiveNativeEvent(NativeEvent e, ulong payload)
		{
			if ((Object)null == (Object)(object)OpenXRSettings.Instance)
			{
				return;
			}
			OpenXRFeature[] features = OpenXRSettings.Instance.features;
			foreach (OpenXRFeature openXRFeature in features)
			{
				if (!((Object)(object)openXRFeature == (Object)null) && openXRFeature.enabled)
				{
					switch (e)
					{
					case NativeEvent.XrSetupConfigValues:
						openXRFeature.OnFormFactorChange(Internal_GetFormFactor());
						openXRFeature.OnEnvironmentBlendModeChange(Internal_GetEnvironmentBlendMode());
						openXRFeature.OnViewConfigurationTypeChange(Internal_GetViewConfigurationType());
						break;
					case NativeEvent.XrSystemIdChanged:
						openXRFeature.OnSystemChange(payload);
						break;
					case NativeEvent.XrInstanceChanged:
						openXRFeature.failedInitialization = !openXRFeature.OnInstanceCreate(payload);
						requiredFeatureFailed |= openXRFeature.required && openXRFeature.failedInitialization;
						break;
					case NativeEvent.XrSessionChanged:
						openXRFeature.OnSessionCreate(payload);
						break;
					case NativeEvent.XrBeginSession:
						openXRFeature.OnSessionBegin(payload);
						break;
					case NativeEvent.XrChangedSpaceApp:
						openXRFeature.OnAppSpaceChange(payload);
						break;
					case NativeEvent.XrSessionStateChanged:
					{
						Internal_GetSessionState(out var oldState, out var newState);
						openXRFeature.OnSessionStateChange(oldState, newState);
						break;
					}
					case NativeEvent.XrEndSession:
						openXRFeature.OnSessionEnd(payload);
						break;
					case NativeEvent.XrExiting:
						openXRFeature.OnSessionExiting(payload);
						break;
					case NativeEvent.XrDestroySession:
						openXRFeature.OnSessionDestroy(payload);
						break;
					case NativeEvent.XrDestroyInstance:
						openXRFeature.OnInstanceDestroy(payload);
						break;
					case NativeEvent.XrLossPending:
						openXRFeature.OnSessionLossPending(payload);
						break;
					case NativeEvent.XrInstanceLossPending:
						openXRFeature.OnInstanceLossPending(payload);
						break;
					}
				}
			}
		}

		internal static void Initialize()
		{
			requiredFeatureFailed = false;
			OpenXRSettings instance = OpenXRSettings.Instance;
			if ((Object)(object)instance == (Object)null || instance.features == null)
			{
				return;
			}
			OpenXRFeature[] features = instance.features;
			foreach (OpenXRFeature openXRFeature in features)
			{
				if ((Object)(object)openXRFeature != (Object)null)
				{
					openXRFeature.failedInitialization = false;
				}
			}
		}

		internal static void HookGetInstanceProcAddr()
		{
			IntPtr func = Internal_GetProcAddressPtr(loaderDefault: true);
			OpenXRSettings instance = OpenXRSettings.Instance;
			if ((Object)(object)instance != (Object)null && instance.features != null)
			{
				for (int num = instance.features.Length - 1; num >= 0; num--)
				{
					OpenXRFeature openXRFeature = instance.features[num];
					if (!((Object)(object)openXRFeature == (Object)null) && openXRFeature.enabled)
					{
						func = openXRFeature.HookGetInstanceProcAddr(func);
					}
				}
			}
			Internal_SetProcAddressPtrAndLoadStage1(func);
		}

		[DllImport("UnityOpenXR", EntryPoint = "Internal_PathToString")]
		private static extern bool Internal_PathToStringPtr(ulong pathId, out IntPtr path);

		[DllImport("UnityOpenXR")]
		private static extern bool Internal_StringToPath([MarshalAs(UnmanagedType.LPStr)] string str, out ulong pathId);

		[DllImport("UnityOpenXR")]
		private static extern bool Internal_GetCurrentInteractionProfile(ulong pathId, out ulong interactionProfile);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetFormFactor")]
		private static extern int Internal_GetFormFactor();

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetViewConfigurationType")]
		private static extern int Internal_GetViewConfigurationType();

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetViewTypeFromRenderIndex")]
		private static extern int Internal_GetViewTypeFromRenderIndex(int renderPassIndex);

		[DllImport("UnityOpenXR", EntryPoint = "session_GetSessionState")]
		private static extern void Internal_GetSessionState(out int oldState, out int newState);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetEnvironmentBlendMode")]
		private static extern int Internal_GetEnvironmentBlendMode();

		[DllImport("UnityOpenXR", EntryPoint = "OpenXRInputProvider_GetAppSpace")]
		private static extern bool Internal_GetAppSpace(out ulong appSpace);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_GetProcAddressPtr")]
		internal static extern IntPtr Internal_GetProcAddressPtr(bool loaderDefault);

		[DllImport("UnityOpenXR", EntryPoint = "NativeConfig_SetProcAddressPtrAndLoadStage1")]
		internal static extern void Internal_SetProcAddressPtrAndLoadStage1(IntPtr func);
	}
	[Serializable]
	public abstract class OpenXRInteractionFeature : OpenXRFeature
	{
		[Serializable]
		protected internal enum ActionType
		{
			Binary,
			Axis1D,
			Axis2D,
			Pose,
			Vibrate,
			Count
		}

		[Serializable]
		protected internal class ActionBinding
		{
			public string interactionProfileName;

			public string interactionPath;

			public List<string> userPaths;
		}

		[Serializable]
		protected internal class ActionConfig
		{
			public string name;

			public ActionType type;

			public string localizedName;

			public List<ActionBinding> bindings;

			public List<string> usages;
		}

		protected internal class DeviceConfig
		{
			public InputDeviceCharacteristics characteristics;

			public string userPath;
		}

		[Serializable]
		protected internal class ActionMapConfig
		{
			public string name;

			public string localizedName;

			public List<DeviceConfig> deviceInfos;

			public List<ActionConfig> actions;

			public string desiredInteractionProfile;

			public string manufacturer;

			public string serialNumber;
		}

		public static class UserPaths
		{
			public const string leftHand = "/user/hand/left";

			public const string rightHand = "/user/hand/right";

			public const string head = "/user/head";

			public const string gamepad = "/user/gamepad";

			public const string treadmill = "/user/treadmill";
		}

		private static List<ActionMapConfig> m_CreatedActionMaps;

		protected virtual void RegisterDeviceLayout()
		{
		}

		protected virtual void UnregisterDeviceLayout()
		{
		}

		protected virtual void RegisterActionMapsWithRuntime()
		{
		}

		protected internal override bool OnInstanceCreate(ulong xrSession)
		{
			RegisterDeviceLayout();
			return true;
		}

		internal void CreateActionMaps(List<ActionMapConfig> configs)
		{
			m_CreatedActionMaps = configs;
			RegisterActionMapsWithRuntime();
			m_CreatedActionMaps = null;
		}

		protected void AddActionMap(ActionMapConfig map)
		{
			if (map == null)
			{
				throw new ArgumentNullException("map");
			}
			if (m_CreatedActionMaps == null)
			{
				throw new InvalidOperationException("ActionMap must be added from within the RegisterActionMapsWithRuntime method");
			}
			m_CreatedActionMaps.Add(map);
		}

		internal static void RegisterLayouts()
		{
			OpenXRFeature[] features = OpenXRSettings.Instance.GetFeatures<OpenXRInteractionFeature>();
			foreach (OpenXRFeature openXRFeature in features)
			{
				if (openXRFeature.enabled)
				{
					((OpenXRInteractionFeature)openXRFeature).RegisterDeviceLayout();
				}
			}
		}
	}
}
namespace UnityEngine.XR.OpenXR.Features.Interactions
{
	public static class ControllerProfiles
	{
		public static string[] Enable()
		{
			if ((Object)(object)OpenXRLoaderBase.Instance != (Object)null)
			{
				throw new InvalidOperationException("Controller profiles must be enabled before OpenXR starts.");
			}
			OpenXRSettings instance = OpenXRSettings.Instance;
			List<OpenXRFeature> list = (instance.features ?? new OpenXRFeature[0]).Where((OpenXRFeature f) => (Object)(object)f != (Object)null).ToList();
			Add<OculusTouchControllerProfile>(list, "Oculus Touch Controller Profile", "com.unity.openxr.feature.input.oculustouch");
			Add<ValveIndexControllerProfile>(list, "Valve Index Controller Profile", "com.unity.openxr.feature.input.valveindex");
			Add<HTCViveControllerProfile>(list, "HTC Vive Controller Profile", "com.unity.openxr.feature.input.htcvive");
			Add<MicrosoftMotionControllerProfile>(list, "Microsoft Motion Controller Profile", "com.unity.openxr.feature.input.microsoftmotioncontroller");
			Add<KHRSimpleControllerProfile>(list, "Khronos Simple Controller Profile", "com.unity.openxr.feature.input.khrsimpleprofile");
			instance.features = list.ToArray();
			return (from f in list.OfType<OpenXRInteractionFeature>()
				where f.enabled
				select f.nameUi).ToArray();
		}

		private static void Add<T>(List<OpenXRFeature> features, string name, string featureId) where T : OpenXRInteractionFeature
		{
			if (!features.Any((OpenXRFeature f) => f is T))
			{
				T val = ScriptableObject.CreateInstance<T>();
				((Object)val).hideFlags = (HideFlags)61;
				((Object)val).name = name;
				val.nameUi = name;
				val.version = "0.0.1";
				val.company = "Unity";
				val.featureIdInternal = featureId;
				val.openxrExtensionStrings = "";
				val.enabled = true;
				features.Add(val);
			}
		}
	}
	public class HTCViveControllerProfile : OpenXRInteractionFeature
	{
		public const string featureId = "com.unity.openxr.feature.input.htcvive";

		public const string profile = "/interaction_profiles/htc/vive_controller";

		public const string system = "/input/system/click";

		public const string squeeze = "/input/squeeze/click";

		public const string menu = "/input/menu/click";

		public const string trigger = "/input/trigger/value";

		public const string triggerClick = "/input/trigger/click";

		public const string trackpad = "/input/trackpad";

		public const string trackpadClick = "/input/trackpad/click";

		public const string trackpadTouch = "/input/trackpad/touch";

		public const string grip = "/input/grip/pose";

		public const string aim = "/input/aim/pose";

		public const string haptic = "/output/haptic";

		private const string kDeviceLocalizedName = "HTC Vive Controller OpenXR";

		protected override void RegisterActionMapsWithRuntime()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ActionMapConfig map = new ActionMapConfig
			{
				name = "htcvivecontroller",
				localizedName = "HTC Vive Controller OpenXR",
				desiredInteractionProfile = "/interaction_profiles/htc/vive_controller",
				manufacturer = "HTC",
				serialNumber = "",
				deviceInfos = new List<DeviceConfig>
				{
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)356,
						userPath = "/user/hand/left"
					},
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)612,
						userPath = "/user/hand/right"
					}
				},
				actions = new List<ActionConfig>
				{
					new ActionConfig
					{
						name = "grip",
						localizedName = "Grip",
						type = ActionType.Axis1D,
						usages = new List<string> { "Grip" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "gripPressed",
						localizedName = "Grip Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "GripButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "menu",
						localizedName = "Menu",
						type = ActionType.Binary,
						usages = new List<string> { "MenuButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/menu/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "select",
						localizedName = "Select",
						type = ActionType.Binary,
						usages = new List<string> { "SystemButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/system/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trigger",
						localizedName = "Trigger",
						type = ActionType.Axis1D,
						usages = new List<string> { "Trigger" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerPressed",
						localizedName = "Trigger Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpad",
						localizedName = "Trackpad",
						type = ActionType.Axis2D,
						usages = new List<string> { "Primary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpadTouched",
						localizedName = "Trackpad Touched",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/touch",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpadClicked",
						localizedName = "Trackpad Clicked",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisClick" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/click",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "devicePose",
						localizedName = "Device Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Device" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/grip/pose",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "pointer",
						localizedName = "Pointer Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Pointer" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/aim/pose",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "haptic",
						localizedName = "Haptic Output",
						type = ActionType.Vibrate,
						usages = new List<string> { "Haptic" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/output/haptic",
								interactionProfileName = "/interaction_profiles/htc/vive_controller"
							}
						}
					}
				}
			};
			AddActionMap(map);
		}
	}
	public class KHRSimpleControllerProfile : OpenXRInteractionFeature
	{
		public const string featureId = "com.unity.openxr.feature.input.khrsimpleprofile";

		public const string profile = "/interaction_profiles/khr/simple_controller";

		public const string select = "/input/select/click";

		public const string menu = "/input/menu/click";

		public const string grip = "/input/grip/pose";

		public const string aim = "/input/aim/pose";

		public const string haptic = "/output/haptic";

		private const string kDeviceLocalizedName = "KHR Simple Controller OpenXR";

		protected override void RegisterActionMapsWithRuntime()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ActionMapConfig map = new ActionMapConfig
			{
				name = "khrsimplecontroller",
				localizedName = "KHR Simple Controller OpenXR",
				desiredInteractionProfile = "/interaction_profiles/khr/simple_controller",
				manufacturer = "Khronos",
				serialNumber = "",
				deviceInfos = new List<DeviceConfig>
				{
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)356,
						userPath = "/user/hand/left"
					},
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)612,
						userPath = "/user/hand/right"
					}
				},
				actions = new List<ActionConfig>
				{
					new ActionConfig
					{
						name = "select",
						localizedName = "Select",
						type = ActionType.Binary,
						usages = new List<string> { "PrimaryButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/select/click",
								interactionProfileName = "/interaction_profiles/khr/simple_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "menu",
						localizedName = "Menu",
						type = ActionType.Binary,
						usages = new List<string> { "MenuButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/menu/click",
								interactionProfileName = "/interaction_profiles/khr/simple_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "devicePose",
						localizedName = "Device Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Device" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/grip/pose",
								interactionProfileName = "/interaction_profiles/khr/simple_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "pointer",
						localizedName = "Pointer Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Pointer" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/aim/pose",
								interactionProfileName = "/interaction_profiles/khr/simple_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "haptic",
						localizedName = "Haptic Output",
						type = ActionType.Vibrate,
						usages = new List<string> { "Haptic" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/output/haptic",
								interactionProfileName = "/interaction_profiles/khr/simple_controller"
							}
						}
					}
				}
			};
			AddActionMap(map);
		}
	}
	public class MicrosoftMotionControllerProfile : OpenXRInteractionFeature
	{
		public const string featureId = "com.unity.openxr.feature.input.microsoftmotioncontroller";

		public const string profile = "/interaction_profiles/microsoft/motion_controller";

		public const string menu = "/input/menu/click";

		public const string squeeze = "/input/squeeze/click";

		public const string trigger = "/input/trigger/value";

		public const string thumbstick = "/input/thumbstick";

		public const string thumbstickClick = "/input/thumbstick/click";

		public const string trackpad = "/input/trackpad";

		public const string trackpadClick = "/input/trackpad/click";

		public const string trackpadTouch = "/input/trackpad/touch";

		public const string grip = "/input/grip/pose";

		public const string aim = "/input/aim/pose";

		public const string haptic = "/output/haptic";

		private const string kDeviceLocalizedName = "Windows MR Controller OpenXR";

		protected override void RegisterActionMapsWithRuntime()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ActionMapConfig map = new ActionMapConfig
			{
				name = "microsoftmotioncontroller",
				localizedName = "Windows MR Controller OpenXR",
				desiredInteractionProfile = "/interaction_profiles/microsoft/motion_controller",
				manufacturer = "Microsoft",
				serialNumber = "",
				deviceInfos = new List<DeviceConfig>
				{
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)356,
						userPath = "/user/hand/left"
					},
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)612,
						userPath = "/user/hand/right"
					}
				},
				actions = new List<ActionConfig>
				{
					new ActionConfig
					{
						name = "joystick",
						localizedName = "Joystick",
						type = ActionType.Axis2D,
						usages = new List<string> { "Primary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "touchpad",
						localizedName = "Touchpad",
						type = ActionType.Axis2D,
						usages = new List<string> { "Secondary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "grip",
						localizedName = "Grip",
						type = ActionType.Axis1D,
						usages = new List<string> { "Grip" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/click",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "gripPressed",
						localizedName = "Grip Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "GripButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/click",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "menu",
						localizedName = "Menu",
						type = ActionType.Binary,
						usages = new List<string> { "MenuButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/menu/click",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trigger",
						localizedName = "Trigger",
						type = ActionType.Axis1D,
						usages = new List<string> { "Trigger" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerPressed",
						localizedName = "Trigger Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "joystickClicked",
						localizedName = "JoystickClicked",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisClick" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick/click",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "touchpadClicked",
						localizedName = "Touchpad Clicked",
						type = ActionType.Binary,
						usages = new List<string> { "Secondary2DAxisClick" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/click",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "touchpadTouched",
						localizedName = "Touchpad Touched",
						type = ActionType.Binary,
						usages = new List<string> { "Secondary2DAxisTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/touch",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "devicePose",
						localizedName = "Device Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Device" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/grip/pose",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "pointer",
						localizedName = "Pointer Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Pointer" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/aim/pose",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "haptic",
						localizedName = "Haptic Output",
						type = ActionType.Vibrate,
						usages = new List<string> { "Haptic" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/output/haptic",
								interactionProfileName = "/interaction_profiles/microsoft/motion_controller"
							}
						}
					}
				}
			};
			AddActionMap(map);
		}
	}
	public class OculusTouchControllerProfile : OpenXRInteractionFeature
	{
		public const string featureId = "com.unity.openxr.feature.input.oculustouch";

		public const string profile = "/interaction_profiles/oculus/touch_controller";

		public const string buttonX = "/input/x/click";

		public const string buttonXTouch = "/input/x/touch";

		public const string buttonY = "/input/y/click";

		public const string buttonYTouch = "/input/y/touch";

		public const string menu = "/input/menu/click";

		public const string buttonA = "/input/a/click";

		public const string buttonATouch = "/input/a/touch";

		public const string buttonB = "/input/b/click";

		public const string buttonBTouch = "/input/b/touch";

		public const string system = "/input/system/click";

		public const string squeeze = "/input/squeeze/value";

		public const string trigger = "/input/trigger/value";

		public const string triggerTouch = "/input/trigger/touch";

		public const string thumbstick = "/input/thumbstick";

		public const string thumbstickClick = "/input/thumbstick/click";

		public const string thumbstickTouch = "/input/thumbstick/touch";

		public const string thumbrest = "/input/thumbrest/touch";

		public const string grip = "/input/grip/pose";

		public const string aim = "/input/aim/pose";

		public const string haptic = "/output/haptic";

		private const string kDeviceLocalizedName = "Oculus Touch Controller OpenXR";

		protected override void RegisterActionMapsWithRuntime()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ActionMapConfig map = new ActionMapConfig
			{
				name = "oculustouchcontroller",
				localizedName = "Oculus Touch Controller OpenXR",
				desiredInteractionProfile = "/interaction_profiles/oculus/touch_controller",
				manufacturer = "Oculus",
				serialNumber = "",
				deviceInfos = new List<DeviceConfig>
				{
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)356,
						userPath = "/user/hand/left"
					},
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)612,
						userPath = "/user/hand/right"
					}
				},
				actions = new List<ActionConfig>
				{
					new ActionConfig
					{
						name = "thumbstick",
						localizedName = "Thumbstick",
						type = ActionType.Axis2D,
						usages = new List<string> { "Primary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "grip",
						localizedName = "Grip",
						type = ActionType.Axis1D,
						usages = new List<string> { "Grip" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/value",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "gripPressed",
						localizedName = "Grip Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "GripButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/value",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "menu",
						localizedName = "Menu",
						type = ActionType.Binary,
						usages = new List<string> { "MenuButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/menu/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/left" }
							},
							new ActionBinding
							{
								interactionPath = "/input/system/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/right" }
							}
						}
					},
					new ActionConfig
					{
						name = "primaryButton",
						localizedName = "Primary Button",
						type = ActionType.Binary,
						usages = new List<string> { "PrimaryButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/x/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/left" }
							},
							new ActionBinding
							{
								interactionPath = "/input/a/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/right" }
							}
						}
					},
					new ActionConfig
					{
						name = "primaryTouched",
						localizedName = "Primary Touched",
						type = ActionType.Binary,
						usages = new List<string> { "PrimaryTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/x/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/left" }
							},
							new ActionBinding
							{
								interactionPath = "/input/a/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/right" }
							}
						}
					},
					new ActionConfig
					{
						name = "secondaryButton",
						localizedName = "Secondary Button",
						type = ActionType.Binary,
						usages = new List<string> { "SecondaryButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/y/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/left" }
							},
							new ActionBinding
							{
								interactionPath = "/input/b/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/right" }
							}
						}
					},
					new ActionConfig
					{
						name = "secondaryTouched",
						localizedName = "Secondary Touched",
						type = ActionType.Binary,
						usages = new List<string> { "SecondaryTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/y/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/left" }
							},
							new ActionBinding
							{
								interactionPath = "/input/b/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller",
								userPaths = new List<string> { "/user/hand/right" }
							}
						}
					},
					new ActionConfig
					{
						name = "trigger",
						localizedName = "Trigger",
						type = ActionType.Axis1D,
						usages = new List<string> { "Trigger" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerPressed",
						localizedName = "Trigger Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerTouched",
						localizedName = "Trigger Touched",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "thumbstickClicked",
						localizedName = "Thumbstick Clicked",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisClick" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick/click",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "thumbstickTouched",
						localizedName = "Thumbstick Touched",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick/touch",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "devicePose",
						localizedName = "Device Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Device" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/grip/pose",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "pointer",
						localizedName = "Pointer Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Pointer" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/aim/pose",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "haptic",
						localizedName = "Haptic Output",
						type = ActionType.Vibrate,
						usages = new List<string> { "Haptic" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/output/haptic",
								interactionProfileName = "/interaction_profiles/oculus/touch_controller"
							}
						}
					}
				}
			};
			AddActionMap(map);
		}
	}
	public class ValveIndexControllerProfile : OpenXRInteractionFeature
	{
		public const string featureId = "com.unity.openxr.feature.input.valveindex";

		public const string profile = "/interaction_profiles/valve/index_controller";

		public const string system = "/input/system/click";

		public const string systemTouch = "/input/system/touch";

		public const string buttonA = "/input/a/click";

		public const string buttonATouch = "/input/a/touch";

		public const string buttonB = "/input/b/click";

		public const string buttonBTouch = "/input/b/touch";

		public const string squeeze = "/input/squeeze/value";

		public const string squeezeForce = "/input/squeeze/force";

		public const string triggerClick = "/input/trigger/click";

		public const string trigger = "/input/trigger/value";

		public const string triggerTouch = "/input/trigger/touch";

		public const string thumbstick = "/input/thumbstick";

		public const string thumbstickClick = "/input/thumbstick/click";

		public const string thumbstickTouch = "/input/thumbstick/touch";

		public const string trackpad = "/input/trackpad";

		public const string trackpadForce = "/input/trackpad/force";

		public const string trackpadTouch = "/input/trackpad/touch";

		public const string grip = "/input/grip/pose";

		public const string aim = "/input/aim/pose";

		public const string haptic = "/output/haptic";

		private const string kDeviceLocalizedName = "Index Controller OpenXR";

		protected override void RegisterActionMapsWithRuntime()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			ActionMapConfig map = new ActionMapConfig
			{
				name = "valveindexcontroller",
				localizedName = "Index Controller OpenXR",
				desiredInteractionProfile = "/interaction_profiles/valve/index_controller",
				manufacturer = "Valve",
				serialNumber = "",
				deviceInfos = new List<DeviceConfig>
				{
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)356,
						userPath = "/user/hand/left"
					},
					new DeviceConfig
					{
						characteristics = (InputDeviceCharacteristics)612,
						userPath = "/user/hand/right"
					}
				},
				actions = new List<ActionConfig>
				{
					new ActionConfig
					{
						name = "system",
						localizedName = "System",
						type = ActionType.Binary,
						usages = new List<string> { "MenuButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/system/click",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "systemTouched",
						localizedName = "System Touched",
						type = ActionType.Binary,
						usages = new List<string> { "MenuTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/system/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "primaryButton",
						localizedName = "Primary Button",
						type = ActionType.Binary,
						usages = new List<string> { "PrimaryButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/a/click",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "primaryTouched",
						localizedName = "Primary Touched",
						type = ActionType.Binary,
						usages = new List<string> { "PrimaryTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/a/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "secondaryButton",
						localizedName = "Secondary Button",
						type = ActionType.Binary,
						usages = new List<string> { "SecondaryButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/b/click",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "secondaryTouched",
						localizedName = "Secondary Touched",
						type = ActionType.Binary,
						usages = new List<string> { "SecondaryTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/b/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "grip",
						localizedName = "Grip",
						type = ActionType.Axis1D,
						usages = new List<string> { "Grip" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/value",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "gripPressed",
						localizedName = "Grip Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "GripButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/value",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "gripForce",
						localizedName = "Grip Force",
						type = ActionType.Axis1D,
						usages = new List<string> { "GripForce" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/squeeze/force",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trigger",
						localizedName = "Trigger",
						type = ActionType.Axis1D,
						usages = new List<string> { "Trigger" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/value",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerPressed",
						localizedName = "Triggger Pressed",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerButton" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/click",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "triggerTouched",
						localizedName = "Trigger Touched",
						type = ActionType.Binary,
						usages = new List<string> { "TriggerTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trigger/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "thumbstick",
						localizedName = "Thumbstick",
						type = ActionType.Axis2D,
						usages = new List<string> { "Primary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "thumbstickClicked",
						localizedName = "Thumbstick Clicked",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisClick" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick/click",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "thumbstickTouched",
						localizedName = "Thumbstick Touched",
						type = ActionType.Binary,
						usages = new List<string> { "Primary2DAxisTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/thumbstick/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpad",
						localizedName = "Trackpad",
						type = ActionType.Axis2D,
						usages = new List<string> { "Secondary2DAxis" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpadForce",
						localizedName = "Trackpad Force",
						type = ActionType.Axis1D,
						usages = new List<string> { "Secondary2DAxisForce" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/force",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "trackpadTouched",
						localizedName = "Trackpad Touched",
						type = ActionType.Binary,
						usages = new List<string> { "Secondary2DAxisTouch" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/trackpad/touch",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "devicePose",
						localizedName = "Device Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Device" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/grip/pose",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "pointer",
						localizedName = "Pointer Pose",
						type = ActionType.Pose,
						usages = new List<string> { "Pointer" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/input/aim/pose",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					},
					new ActionConfig
					{
						name = "haptic",
						localizedName = "Haptic Output",
						type = ActionType.Vibrate,
						usages = new List<string> { "Haptic" },
						bindings = new List<ActionBinding>
						{
							new ActionBinding
							{
								interactionPath = "/output/haptic",
								interactionProfileName = "/interaction_profiles/valve/index_controller"
							}
						}
					}
				}
			};
			AddActionMap(map);
		}
	}
}

plugins/Uuvr.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.XR.OpenVR;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.XR.Management;
using UnityEngine.XR.OpenXR;
using Uuvr.UnityTypesHelper;
using Uuvr.VrCamera;
using Uuvr.VrTogglers;
using Uuvr.VrUi;
using Uuvr.VrUi.PatchModes;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace Uuvr
{
	public class FollowTarget : UuvrBehaviour
	{
		public Transform? Target;

		public Vector3 LocalPosition = Vector3.zero;

		public Quaternion LocalRotation = Quaternion.identity;

		protected override void OnBeforeRender()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null))
			{
				((Component)this).transform.position = Target.TransformPoint(LocalPosition);
				((Component)this).transform.rotation = Target.rotation * LocalRotation;
			}
		}
	}
	public class KeyboardKey
	{
		public enum KeyCode
		{
			F2 = 113,
			F3,
			F4,
			F5
		}

		private bool _previousIsKeyPressed;

		private bool _isKeyPressed;

		private readonly KeyCode _keyCode;

		public KeyboardKey(KeyCode keyCode)
		{
			_keyCode = keyCode;
		}

		public bool UpdateIsDown()
		{
			_previousIsKeyPressed = _isKeyPressed;
			_isKeyPressed = ((ushort)GetKeyState((int)_keyCode) & 0x8000) != 0;
			return !_previousIsKeyPressed && _isKeyPressed;
		}

		[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
		private static extern short GetKeyState(int keyCode);
	}
	public static class LayerHelper
	{
		private static int _freeLayer = -1;

		private static int FindFreeLayer()
		{
			for (int num = 31; num >= 0; num--)
			{
				if (LayerMask.LayerToName(num).Length == 0)
				{
					Debug.Log((object)$"Found free layer: {num}");
					return num;
				}
			}
			Debug.LogWarning((object)"Failed to find a free layer to use for VR UI. Falling back to last layer.");
			return 31;
		}

		private static int GetFreeLayerCached()
		{
			if (_freeLayer == -1)
			{
				_freeLayer = FindFreeLayer();
			}
			return _freeLayer;
		}

		public static int GetVrUiLayer()
		{
			int value = ModConfiguration.Instance.VrUiLayerOverride.Value;
			return (value > -1) ? value : GetFreeLayerCached();
		}

		public static void SetLayerRecursive(Transform transform, int layer)
		{
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				SetLayerRecursive(child, layer);
				((Component)transform).gameObject.layer = layer;
			}
		}
	}
	public class ModConfiguration
	{
		public enum CameraTrackingMode
		{
			[Description("Absolute")]
			Absolute,
			[Description("Relative matrix")]
			RelativeMatrix,
			[Description("Relative Transform")]
			RelativeTransform,
			[Description("Child")]
			Child
		}

		public enum VrApi
		{
			[Description("OpenVR")]
			OpenVr,
			[Description("OpenXR")]
			OpenXr
		}

		public enum ScreenSpaceCanvasType
		{
			[Description("None")]
			None,
			[Description("Not rendering to texture")]
			NotToTexture,
			[Description("All")]
			All
		}

		public enum UiRenderMode
		{
			[Description("Overlay camera (draws on top of everything)")]
			OverlayCamera,
			[Description("In world (can be occluded)")]
			InWorld
		}

		public enum UiPatchMode
		{
			[Description("Don't touch UI")]
			None,
			[Description("Mirror flat screen (game not mirrored)")]
			Mirror,
			[Description("Patch Canvas objects")]
			CanvasRedirect
		}

		public static ModConfiguration Instance;

		public readonly ConfigFile Config;

		public readonly ConfigEntry<CameraTrackingMode> CameraTracking;

		public readonly ConfigEntry<bool> RelativeCameraSetStereoView;

		public readonly ConfigEntry<int> VrCameraDepth;

		public readonly ConfigEntry<int> VrUiLayerOverride;

		public readonly ConfigEntry<Vector3> VrUiPosition;

		public readonly ConfigEntry<float> VrUiScale;

		public readonly ConfigEntry<string> VrUiShader;

		public readonly ConfigEntry<int> VrUiRenderQueue;

		public readonly ConfigEntry<bool> AlignCameraToHorizon;

		public readonly ConfigEntry<float> CameraPositionOffsetX;

		public readonly ConfigEntry<float> CameraPositionOffsetY;

		public readonly ConfigEntry<float> CameraPositionOffsetZ;

		public readonly ConfigEntry<bool> OverrideDepth;

		public readonly ConfigEntry<bool> PhysicsMatchHeadsetRefreshRate;

		public readonly ConfigEntry<UiPatchMode> PreferredUiPatchMode;

		public readonly ConfigEntry<UiRenderMode> PreferredUiRenderMode;

		public readonly ConfigEntry<ScreenSpaceCanvasType> ScreenSpaceCanvasTypesToPatch;

		public readonly ConfigEntry<string> ObjectsToDeactivateByComponent;

		public readonly ConfigEntry<string> ComponentsToDisable;

		public readonly ConfigEntry<float> ComponentSearchInterval;

		public readonly ConfigEntry<VrApi> PreferredVrApi;

		public ModConfiguration(ConfigFile config)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Expected O, but got Unknown
			Instance = this;
			Config = config;
			PreferredVrApi = config.Bind<VrApi>("General", "Preferred VR APi", VrApi.OpenXr, "VR API to use. Depending on the game, some APIs might be unavailable, so UUVR will fall back to one that works.");
			CameraTracking = config.Bind<CameraTrackingMode>("Camera", "Camera Tracking Mode", CameraTrackingMode.RelativeTransform, "Defines how camera tracking is done. Relative is usually preferred, but not all games support it. Changing this might require restarting the level.");
			RelativeCameraSetStereoView = config.Bind<bool>("Relative Camera", "Use SetStereoView for Relative Camera", false, "Some games are better with this on, some are better with this off. Just try it and see which one is better. Changing this might require restarting the level.");
			AlignCameraToHorizon = config.Bind<bool>("Camera", "Align To Horizon", false, "Prevents pitch and roll changes on the camera, allowing only yaw changes.");
			CameraPositionOffsetX = config.Bind<float>("Camera", "Camera Position Offset X", 0f, "Changes position of tracked VR cameras");
			CameraPositionOffsetY = config.Bind<float>("Camera", "Camera Position Offset Y", 0f, "Changes position of tracked VR cameras");
			CameraPositionOffsetZ = config.Bind<float>("Camera", "Camera Position Offset Z", 0f, "Changes position of tracked VR cameras");
			OverrideDepth = config.Bind<bool>("Camera", "Override Depth", false, "In some games, the VR camera won't display anything unless we override the camera depth value.");
			VrCameraDepth = config.Bind<int>("Camera", "Depth Value", 1, new ConfigDescription("Requires enabling 'Override Depth'. Range is -100 to 100, but you should try to find the lowest value that fixes visibility.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-100, 100), Array.Empty<object>()));
			PhysicsMatchHeadsetRefreshRate = config.Bind<bool>("General", "Force physics rate to match headset refresh rate", false, "Can help fix jiterriness in games that rely a lot on physics. Might break a lot of games too.");
			PreferredUiPatchMode = config.Bind<UiPatchMode>("UI", "UI Patch Mode", UiPatchMode.Mirror, "Method to use for patching UI for VR.");
			VrUiLayerOverride = config.Bind<int>("UI", "VR UI Layer Override", -1, new ConfigDescription("Layer to use for VR UI. By default (value -1) UUVR falls back to an unused (unnamed) layer.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 31), Array.Empty<object>()));
			VrUiPosition = config.Bind<Vector3>("UI", "VR UI Position", Vector3.forward * 1f, "Position of the VR UI projection relative to the camera.");
			VrUiScale = config.Bind<float>("UI", "VR UI Scale", 1f, "Scale of the VR UI projection.");
			VrUiShader = config.Bind<string>("UI", "VR UI Shader", "", "Name of shader to use for the VR UI projection (passed to Unity's Shader.Find). Leave empty to let UUVR pick for you.");
			VrUiRenderQueue = config.Bind<int>("UI", "VR UI Render Queue", 5000, new ConfigDescription("Render queue to use for the VR UI projection. Default is 5000, which is the same as Unity's default canvas material.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5000), Array.Empty<object>()));
			ScreenSpaceCanvasTypesToPatch = config.Bind<ScreenSpaceCanvasType>("UI", "Screen-space UI Elements to Patch", ScreenSpaceCanvasType.NotToTexture, "Screen-space UI elements are already visible in VR with no patches. But in some games, they are difficult to see in VR. So you can choose to patch some (or all) of them to be rendered in the VR UI screen.");
			PreferredUiRenderMode = config.Bind<UiRenderMode>("UI", "Preferred UI Plane Render Mode", UiRenderMode.InWorld, "How to render the VR UI Plane. Overlay is usually better, but doesn't work in every game.");
			ObjectsToDeactivateByComponent = config.Bind<string>("Fixes", "Objects to Deactivate by Component", "", "Any objects that contains one of these components gets deactivated. List of fully qualified C# type names, separated by /. Example: 'Canvas, UnityEngine/HUD, Assembly-CSharp'");
			ComponentsToDisable = config.Bind<string>("Fixes", "Components to Disable.", "", "Names of components to disable. List of fully qualified C# type names, separated by /. Example: 'Canvas, UnityEngine/HUD, Assembly-CSharp'");
			ComponentSearchInterval = config.Bind<float>("Fixes", "Component Search Interval", 1f, new ConfigDescription("Value in seconds, the interval between searches for components to disable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
		}
	}
	[HarmonyPatch]
	public static class Patches
	{
		public static Vector3 hehe = Vector3.one * 0.5f;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Camera), "set_fieldOfView")]
		private static bool PreventChangingFov()
		{
			return false;
		}
	}
	public class ThingDisabler : UuvrBehaviour
	{
		private float _previousSearchTime;

		protected override void Awake()
		{
			base.Awake();
			OnSettingChanged();
		}

		private void Update()
		{
			if (!(Time.unscaledTime < _previousSearchTime + ModConfiguration.Instance.ComponentSearchInterval.Value))
			{
				_previousSearchTime = Time.unscaledTime;
				SearchAndDisableComponents();
			}
		}

		private static void SearchAndDisableComponents()
		{
			try
			{
				DeactivateObjectsByComponent();
				DisableComponents();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[ThingDisabler] Error during component search: " + ex.Message));
			}
		}

		private static IEnumerable<Object>? FindObjects(string componentNamesString)
		{
			if (Utility.IsNullOrWhiteSpace(componentNamesString))
			{
				return null;
			}
			return (from name in componentNamesString.Split('/')
				select name.Trim() into name
				where !string.IsNullOrEmpty(name)
				select name).SelectMany(delegate(string name)
			{
				Type type = Type.GetType(name);
				return Object.FindObjectsOfType(type);
			});
		}

		private static void DeactivateObjectsByComponent()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			IEnumerable<Object> enumerable = FindObjects(ModConfiguration.Instance.ObjectsToDeactivateByComponent.Value);
			if (enumerable == null)
			{
				return;
			}
			foreach (Object item in enumerable)
			{
				PropertyInfo property = ((object)item).GetType().GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public);
				if (!(property == null))
				{
					GameObject val = (GameObject)property.GetValue(item);
					if (!((Object)(object)val == (Object)null))
					{
						val.SetActive(false);
					}
				}
			}
		}

		private static void DisableComponents()
		{
			IEnumerable<Object> enumerable = FindObjects(ModConfiguration.Instance.ComponentsToDisable.Value);
			if (enumerable == null)
			{
				return;
			}
			foreach (Object item in enumerable)
			{
				Type type = ((object)item).GetType();
				PropertyInfo property = type.GetProperty("enabled", BindingFlags.Instance | BindingFlags.Public);
				if (property == null || !property.CanWrite || property.PropertyType != typeof(bool))
				{
					break;
				}
				property.SetValue(item, false);
			}
		}
	}
	public static class TypeExtensions
	{
		private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static MemberInfo? GetAnyMember(this Type type, string name)
		{
			return type.GetMember(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault() ?? type.BaseType?.GetMember(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault() ?? type.BaseType?.BaseType?.GetMember(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault();
		}

		public static T? GetValue<T>(this object obj, string name)
		{
			MemberInfo anyMember = obj.GetType().GetAnyMember(name);
			if (!(anyMember is FieldInfo fieldInfo))
			{
				if (anyMember is PropertyInfo propertyInfo)
				{
					return (T)propertyInfo.GetValue(obj, null);
				}
				return default(T);
			}
			return (T)fieldInfo.GetValue(obj);
		}

		public static void SetValue(this object obj, string name, object value)
		{
			MemberInfo anyMember = obj.GetType().GetAnyMember(name);
			MemberInfo memberInfo = anyMember;
			if (!(memberInfo is FieldInfo fieldInfo))
			{
				if (memberInfo is PropertyInfo propertyInfo)
				{
					propertyInfo.SetValue(obj, value, null);
				}
			}
			else
			{
				fieldInfo.SetValue(obj, value);
			}
		}
	}
	public class UuvrBehaviour : MonoBehaviour
	{
		public static T Create<T>(Transform parent) where T : UuvrBehaviour
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(typeof(T).Name);
			val.transform.parent = parent;
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			return val.AddComponent<T>();
		}

		protected virtual void Awake()
		{
		}

		protected virtual void OnEnable()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Application.onBeforeRender += new UnityAction(OnBeforeRender);
			RenderPipelineManager.beginFrameRendering += OnBeginFrameRendering;
			RenderPipelineManager.endFrameRendering += OnEndFrameRendering;
			ModConfiguration.Instance.Config.SettingChanged += ConfigOnSettingChanged;
		}

		protected virtual void OnDisable()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Application.onBeforeRender -= new UnityAction(OnBeforeRender);
			RenderPipelineManager.beginFrameRendering -= OnBeginFrameRendering;
			RenderPipelineManager.endFrameRendering -= OnEndFrameRendering;
			ModConfiguration.Instance.Config.SettingChanged -= ConfigOnSettingChanged;
		}

		private void ConfigOnSettingChanged(object sender, SettingChangedEventArgs e)
		{
			OnSettingChanged();
		}

		protected virtual void OnBeforeRender()
		{
		}

		protected virtual void OnSettingChanged()
		{
		}

		private void OnBeginFrameRendering(ScriptableRenderContext arg1, Camera[] arg2)
		{
			OnBeginFrameRendering();
		}

		private void OnEndFrameRendering(ScriptableRenderContext arg1, Camera[] arg2)
		{
			OnEndFrameRendering();
		}

		protected virtual void OnBeginFrameRendering()
		{
		}

		protected virtual void OnEndFrameRendering()
		{
		}
	}
	public class UuvrCore : MonoBehaviour
	{
		private float _originalFixedDeltaTime;

		private VrUiManager? _vrUi;

		private ThingDisabler? _thingDisabler;

		private PropertyInfo? _refreshRateProperty;

		private VrTogglerManager? _vrTogglerManager;

		private static bool _isQuitting;

		public static void Create()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new GameObject("UUVR").AddComponent<UuvrCore>();
		}

		private void Awake()
		{
			Application.quitting -= OnApplicationQuitting;
			Application.quitting += OnApplicationQuitting;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Component)this).gameObject.AddComponent<VrCameraManager>();
		}

		private static void OnApplicationQuitting()
		{
			_isQuitting = true;
		}

		private void OnDestroy()
		{
			if (!_isQuitting)
			{
				Debug.Log((object)"UUVR has been destroyed. This shouldn't have happened. Recreating...");
				Create();
			}
		}

		private void Start()
		{
			_refreshRateProperty = (Type.GetType("UnityEngine.XR.XRDevice, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.XRDevice, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRDevice, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRDevice, UnityEngine"))?.GetProperty("refreshRate");
			_vrUi = UuvrBehaviour.Create<VrUiManager>(((Component)this).transform);
			_thingDisabler = UuvrBehaviour.Create<ThingDisabler>(((Component)this).transform);
			_vrTogglerManager = new VrTogglerManager();
			SetPositionTrackingEnabled(positionTrackingEnabled: false);
		}

		private void Update()
		{
			UpdatePhysicsRate();
		}

		private void UpdatePhysicsRate()
		{
			if (_originalFixedDeltaTime == 0f)
			{
				_originalFixedDeltaTime = Time.fixedDeltaTime;
			}
			if (_refreshRateProperty == null)
			{
				return;
			}
			float num = (float)_refreshRateProperty.GetValue(null, null);
			if (!(num <= 0f))
			{
				if (ModConfiguration.Instance.PhysicsMatchHeadsetRefreshRate.Value)
				{
					Time.fixedDeltaTime = 1f / (float)_refreshRateProperty.GetValue(null, null);
				}
				else
				{
					Time.fixedDeltaTime = _originalFixedDeltaTime;
				}
			}
		}

		private static void SetPositionTrackingEnabled(bool positionTrackingEnabled)
		{
			Type type = Type.GetType("UnityEngine.XR.InputTracking, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.InputTracking, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.InputTracking, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.InputTracking, UnityEngine");
			if (type != null)
			{
				PropertyInfo property = type.GetProperty("disablePositionalTracking");
				if (property != null)
				{
					property.SetValue(null, !positionTrackingEnabled, null);
				}
				else
				{
					Debug.LogWarning((object)"Failed to get property disablePositionalTracking");
				}
			}
			else
			{
				Debug.LogWarning((object)"Failed to get type UnityEngine.XR.InputTracking");
			}
		}
	}
	[BepInPlugin("raicuparta.uuvr-modern", "UUVR", "0.4.0")]
	public class UuvrPlugin : BaseUnityPlugin
	{
		private static UuvrPlugin _instance;

		public static string ModFolderPath { get; private set; }

		private void Awake()
		{
			_instance = this;
			ModFolderPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(UuvrPlugin)).Location);
			new ModConfiguration(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			UuvrCore.Create();
		}
	}
	public class UuvrPoseDriver : UuvrBehaviour
	{
		private MethodInfo? _trackingRotationMethod;

		private readonly object[] _trackingRotationMethodArgs = new object[1] { 2 };

		protected override void Awake()
		{
			base.Awake();
			_trackingRotationMethod = (Type.GetType("UnityEngine.XR.InputTracking, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.InputTracking, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.InputTracking, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.InputTracking, UnityEngine"))?.GetMethod("GetLocalRotation");
			if (_trackingRotationMethod == null)
			{
				Debug.LogError((object)"Failed to find InputTracking.GetLocalRotation. Destroying UUVR Pose Driver.");
				Object.Destroy((Object)(object)this);
			}
			else
			{
				DisableCameraAutoTracking();
			}
		}

		protected override void OnBeforeRender()
		{
			base.OnBeforeRender();
			UpdateTransform();
		}

		private void Update()
		{
			UpdateTransform();
		}

		private void LateUpdate()
		{
			UpdateTransform();
		}

		private void UpdateTransform()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (_trackingRotationMethod != null)
			{
				((Component)this).transform.localRotation = (Quaternion)_trackingRotationMethod.Invoke(null, _trackingRotationMethodArgs);
			}
		}

		private void DisableCameraAutoTracking()
		{
			Camera component = ((Component)this).GetComponent<Camera>();
			if (Object.op_Implicit((Object)(object)component))
			{
				MethodInfo methodInfo = UuvrXrDevice.XrDeviceType?.GetMethod("DisableAutoXRCameraTracking");
				if (methodInfo != null)
				{
					methodInfo.Invoke(null, new object[2] { component, true });
				}
				else
				{
					Debug.LogWarning((object)"Failed to find DisableAutoXRCameraTracking method. Using SetStereoViewMatrix, which also prevents Unity from auto-tracking cameras, but can cause other issues.");
				}
			}
		}
	}
}
namespace Uuvr.VrUi
{
	public class UiOverlayRenderMode : UuvrBehaviour
	{
		private Camera? _uiSceneCamera;

		protected override void OnSettingChanged()
		{
			base.OnSettingChanged();
			_uiSceneCamera.cullingMask = 1 << LayerHelper.GetVrUiLayer();
		}

		private new void Awake()
		{
			_uiSceneCamera = ((Component)UuvrBehaviour.Create<UuvrPoseDriver>(((Component)this).transform)).gameObject.AddComponent<Camera>();
			Uuvr.VrCamera.VrCamera.IgnoredCameras.Add(_uiSceneCamera);
			_uiSceneCamera.clearFlags = (CameraClearFlags)3;
			_uiSceneCamera.depth = 100f;
			_uiSceneCamera.cullingMask = 1 << LayerHelper.GetVrUiLayer();
		}
	}
	public static class UiSorting
	{
		public const int ScreenOrder = 32765;

		private static int? _lastLayerId;

		public static int LastLayerId
		{
			get
			{
				if (!_lastLayerId.HasValue)
				{
					SortingLayer[] layers = SortingLayer.layers;
					_lastLayerId = ((layers.Length != 0) ? ((SortingLayer)(ref layers[^1])).id : 0);
				}
				return _lastLayerId.Value;
			}
		}

		public static void DrawLast(Renderer renderer, int ordersAfterScreen = 0)
		{
			renderer.sortingLayerID = LastLayerId;
			renderer.sortingOrder = 32765 + Mathf.Clamp(ordersAfterScreen, 0, 2);
		}
	}
	public class VrUiCursor : UuvrBehaviour
	{
		private Texture2D _texture;

		private Vector2 _offset = new Vector2(22f, 2f);

		private void Start()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = File.ReadAllBytes(Path.Combine(UuvrPlugin.ModFolderPath, "Assets\\cursor.bmp"));
			int num = array[18] + (array[19] << 8);
			int num2 = array[22] + (array[23] << 8);
			Color32[] array2 = (Color32[])(object)new Color32[num * num2];
			_texture = new Texture2D(num, num2, (TextureFormat)14, false);
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i] = new Color32(array[i * 4 + 54], array[i * 4 + 55], array[i * 4 + 56], array[i * 4 + 57]);
			}
			_texture.SetPixels32(array2);
			_texture.Apply();
		}

		private void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_texture == (Object)null))
			{
				Cursor.SetCursor(_texture, _offset, (CursorMode)1);
			}
		}
	}
	public class VrUiManager : UuvrBehaviour
	{
		public const float ScreenWidthPerScale = 1.8f;

		private RenderTexture? _uiTexture;

		private GameObject? _vrUiQuad;

		private Renderer? _vrUiRenderer;

		private GameObject? _uiContainer;

		private CanvasRedirectPatchMode? _canvasRedirectPatchMode;

		private ScreenMirrorPatchMode? _screenMirrorPatchMode;

		private FollowTarget? _worldRenderModeFollowTarget;

		private UiOverlayRenderMode? _uiOverlayRenderMode;

		private void Start()
		{
			SetUpUi();
			OnSettingChanged();
			UuvrBehaviour.Create<VrUiCursor>(((Component)this).transform);
		}

		protected override void OnSettingChanged()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			base.OnSettingChanged();
			int vrUiLayer = LayerHelper.GetVrUiLayer();
			_vrUiQuad.layer = vrUiLayer;
			((Component)_uiOverlayRenderMode).gameObject.SetActive(ModConfiguration.Instance.PreferredUiRenderMode.Value == ModConfiguration.UiRenderMode.OverlayCamera);
			((Behaviour)_worldRenderModeFollowTarget).enabled = ModConfiguration.Instance.PreferredUiRenderMode.Value == ModConfiguration.UiRenderMode.InWorld;
			if (ModConfiguration.Instance.PreferredUiRenderMode.Value != ModConfiguration.UiRenderMode.InWorld)
			{
				((Component)_worldRenderModeFollowTarget).transform.localPosition = Vector3.zero;
				((Component)_worldRenderModeFollowTarget).transform.localRotation = Quaternion.identity;
			}
			((Behaviour)_screenMirrorPatchMode).enabled = ModConfiguration.Instance.PreferredUiPatchMode.Value == ModConfiguration.UiPatchMode.Mirror;
			((Behaviour)_canvasRedirectPatchMode).enabled = ModConfiguration.Instance.PreferredUiPatchMode.Value == ModConfiguration.UiPatchMode.CanvasRedirect;
			float num = (float)((Texture)_uiTexture).height / (float)((Texture)_uiTexture).width;
			float num2 = 1.8f * ModConfiguration.Instance.VrUiScale.Value;
			float num3 = num2 * num;
			_vrUiQuad.transform.localScale = new Vector3(num2, num3, 1f);
			float num4 = Mathf.Abs(_vrUiQuad.transform.localScale.y);
			if (ModConfiguration.Instance.PreferredUiPatchMode.Value == ModConfiguration.UiPatchMode.Mirror)
			{
				num4 *= -1f;
			}
			_vrUiQuad.transform.localScale = new Vector3(_vrUiQuad.transform.localScale.x, num4, _vrUiQuad.transform.localScale.z);
			_vrUiQuad.transform.localPosition = ModConfiguration.Instance.VrUiPosition.Value;
			if ((Object)(object)_vrUiRenderer != (Object)null)
			{
				_vrUiRenderer.material.shader = GetVrUiShader();
				_vrUiRenderer.material.renderQueue = ModConfiguration.Instance.VrUiRenderQueue.Value;
				UiSorting.DrawLast(_vrUiRenderer);
			}
			UpdateFollowTarget();
		}

		private static Shader GetVrUiShader()
		{
			if (Utility.IsNullOrWhiteSpace(ModConfiguration.Instance.VrUiShader.Value))
			{
				return Canvas.GetDefaultCanvasMaterial().shader;
			}
			Shader val = Shader.Find(ModConfiguration.Instance.VrUiShader.Value);
			return ((Object)(object)val != (Object)null) ? val : Canvas.GetDefaultCanvasMaterial().shader;
		}

		private void SetUpUi()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			_uiTexture = new RenderTexture(Screen.width, Screen.height, 16, (RenderTextureFormat)0);
			GameObject val = new GameObject("VrUiContainer");
			val.transform.parent = ((Component)this).transform;
			_uiContainer = val;
			_vrUiQuad = GameObject.CreatePrimitive((PrimitiveType)5);
			Object.Destroy((Object)(object)_vrUiQuad.GetComponent("Collider"));
			((Object)_vrUiQuad).name = "VrUiQuad";
			_vrUiQuad.transform.parent = _uiContainer.transform;
			_vrUiRenderer = _vrUiQuad.GetComponent<Renderer>();
			_vrUiRenderer.material = new Material(Canvas.GetDefaultCanvasMaterial())
			{
				mainTexture = (Texture)(object)_uiTexture
			};
			_canvasRedirectPatchMode = ((Component)this).gameObject.AddComponent<CanvasRedirectPatchMode>();
			_canvasRedirectPatchMode.SetUpTargetTexture(_uiTexture);
			_screenMirrorPatchMode = ((Component)this).gameObject.AddComponent<ScreenMirrorPatchMode>();
			_screenMirrorPatchMode.SetUpTargetTexture(_uiTexture);
			_uiOverlayRenderMode = UuvrBehaviour.Create<UiOverlayRenderMode>(((Component)this).transform);
			_worldRenderModeFollowTarget = _uiContainer.AddComponent<FollowTarget>();
		}

		private void Update()
		{
			if ((Object)(object)_uiTexture == (Object)null)
			{
				SetUpUi();
			}
			if ((Object)(object)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera != (Object)null && (Object)(object)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera.ParentCamera != (Object)null && (Object)(object)_uiContainer != (Object)null && (Object)(object)_uiContainer.transform.parent != (Object)(object)((Component)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera.ParentCamera).transform && (Object)(object)_worldRenderModeFollowTarget != (Object)null)
			{
				UpdateFollowTarget();
			}
		}

		private void UpdateFollowTarget()
		{
			if (!((Object)(object)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera == (Object)null) && !((Object)(object)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera.ParentCamera == (Object)null))
			{
				_worldRenderModeFollowTarget.Target = ((ModConfiguration.Instance.PreferredUiRenderMode.Value == ModConfiguration.UiRenderMode.InWorld) ? ((Component)Uuvr.VrCamera.VrCamera.HighestDepthVrCamera.ParentCamera).transform : null);
			}
		}
	}
}
namespace Uuvr.VrUi.PatchModes
{
	public class CanvasRedirect : UuvrBehaviour
	{
		private Canvas _canvas;

		private Camera _uiCaptureCamera;

		private bool _isPatched;

		private RenderMode _originalRenderMode;

		private Camera _originalWorldCamera;

		private float _originalPlaneDistance;

		private int _originalLayer;

		public static void Create(Canvas _canvas, Camera uiCaptureCamera)
		{
			CanvasRedirect canvasRedirect = ((Component)_canvas).gameObject.AddComponent<CanvasRedirect>();
			canvasRedirect._canvas = _canvas;
			canvasRedirect._uiCaptureCamera = uiCaptureCamera;
		}

		private void Start()
		{
			OnSettingChanged();
		}

		protected override void OnSettingChanged()
		{
			bool flag = ShouldPatchCanvas();
			if (flag && !_isPatched)
			{
				Patch();
			}
			else if (!flag && _isPatched)
			{
				UndoPatch();
			}
		}

		private bool ShouldPatchCanvas()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			if (ModConfiguration.Instance.PreferredUiPatchMode.Value != ModConfiguration.UiPatchMode.CanvasRedirect)
			{
				return false;
			}
			bool flag = (int)_originalRenderMode == 1;
			bool result;
			switch (ModConfiguration.Instance.ScreenSpaceCanvasTypesToPatch.Value)
			{
			case ModConfiguration.ScreenSpaceCanvasType.None:
				result = !flag;
				break;
			case ModConfiguration.ScreenSpaceCanvasType.NotToTexture:
			{
				int num;
				if (flag)
				{
					if (flag)
					{
						Camera worldCamera = _canvas.worldCamera;
						num = (((Object)(object)((worldCamera != null) ? worldCamera.targetTexture : null) == (Object)null) ? 1 : 0);
					}
					else
					{
						num = 0;
					}
				}
				else
				{
					num = 1;
				}
				result = (byte)num != 0;
				break;
			}
			case ModConfiguration.ScreenSpaceCanvasType.All:
				result = true;
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			return result;
		}

		private void Patch()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			LayerHelper.SetLayerRecursive(((Component)this).transform, LayerHelper.GetVrUiLayer());
			_originalRenderMode = _canvas.renderMode;
			_originalWorldCamera = _canvas.worldCamera;
			_originalPlaneDistance = _canvas.planeDistance;
			_originalLayer = ((Component)_canvas).gameObject.layer;
			_canvas.renderMode = (RenderMode)1;
			_canvas.worldCamera = _uiCaptureCamera;
			if ((int)_originalRenderMode == 1)
			{
				if (_originalPlaneDistance < _uiCaptureCamera.nearClipPlane)
				{
					_uiCaptureCamera.nearClipPlane = Mathf.Max(0.01f, _originalPlaneDistance - 0.1f);
				}
				if (_originalPlaneDistance > _uiCaptureCamera.farClipPlane)
				{
					_uiCaptureCamera.farClipPlane = _originalPlaneDistance + 0.1f;
				}
			}
			else
			{
				_canvas.planeDistance = 1f;
			}
			_isPatched = true;
		}

		private void UndoPatch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			LayerHelper.SetLayerRecursive(((Component)this).transform, _originalLayer);
			_canvas.renderMode = _originalRenderMode;
			_canvas.worldCamera = _originalWorldCamera;
			_canvas.planeDistance = _originalPlaneDistance;
			_isPatched = false;
		}
	}
	public class CanvasRedirectPatchMode : UuvrBehaviour, VrUiPatchMode
	{
		private readonly List<string> _ignoredCanvases = new List<string> { "unityexplorer", "universelib" };

		private Camera? _uiCaptureCamera;

		private static readonly FieldInfo? GraphicsField = typeof(GraphicRegistry).GetField("m_Graphics", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		protected override void OnSettingChanged()
		{
			base.OnSettingChanged();
			_uiCaptureCamera.cullingMask = 1 << LayerHelper.GetVrUiLayer();
		}

		private void Start()
		{
			OnSettingChanged();
		}

		protected override void OnEnable()
		{
			base.OnEnable();
			((Behaviour)_uiCaptureCamera).enabled = true;
		}

		protected override void OnDisable()
		{
			base.OnEnable();
			((Behaviour)_uiCaptureCamera).enabled = false;
		}

		private new void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			_uiCaptureCamera = new GameObject("VrUiCaptureCamera").AddComponent<Camera>();
			Uuvr.VrCamera.VrCamera.IgnoredCameras.Add(_uiCaptureCamera);
			((Component)_uiCaptureCamera).transform.parent = ((Component)this).transform;
			_uiCaptureCamera.clearFlags = (CameraClearFlags)2;
			_uiCaptureCamera.backgroundColor = Color.clear;
			_uiCaptureCamera.depth = 100f;
		}

		public void SetUpTargetTexture(RenderTexture targetTexture)
		{
			_uiCaptureCamera.targetTexture = targetTexture;
		}

		private void Update()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (GraphicRegistry.instance == null || !(GraphicsField?.GetValue(GraphicRegistry.instance) is IDictionary dictionary))
			{
				return;
			}
			foreach (object key in dictionary.Keys)
			{
				PatchCanvas((Canvas)((key is Canvas) ? key : null));
			}
			((Component)_uiCaptureCamera).transform.localPosition = Vector3.right * 10f;
		}

		private void PatchCanvas(Canvas canvas)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			if (!((Object)(object)canvas == (Object)null) && !((Object)(object)_uiCaptureCamera == (Object)null) && (int)canvas.renderMode != 2)
			{
				if (!canvas.isRootCanvas)
				{
					PatchCanvas(canvas.rootCanvas);
				}
				else if (!_ignoredCanvases.Any((string ignoredCanvas) => ((Object)canvas).name.ToLower().Contains(ignoredCanvas.ToLower())) && !Object.op_Implicit((Object)(object)((Component)canvas).GetComponent<CanvasRedirect>()))
				{
					CanvasRedirect.Create(canvas, _uiCaptureCamera);
				}
			}
		}
	}
	public class ScreenMirrorPatchMode : UuvrBehaviour, VrUiPatchMode
	{
		private CommandBuffer? _commandBuffer;

		private Camera? _clearCamera;

		private float _scale = 2f;

		private RenderTexture _targetTexture;

		private Coroutine _endOfFrameCoroutine;

		protected override void OnEnable()
		{
			base.OnEnable();
			SetXrMirror(mirror: false);
			_endOfFrameCoroutine = ((MonoBehaviour)this).StartCoroutine(EndOfFrameCoroutine());
		}

		protected override void OnDisable()
		{
			base.OnDisable();
			SetXrMirror(mirror: true);
			((MonoBehaviour)this).StopCoroutine(_endOfFrameCoroutine);
			Reset();
		}

		private new void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"mirror mode Start");
			_clearCamera = ((Component)this).gameObject.AddComponent<Camera>();
			_clearCamera.stereoTargetEye = (StereoTargetEyeMask)0;
			_clearCamera.depth = -100f;
			_clearCamera.cullingMask = 0;
			_clearCamera.clearFlags = (CameraClearFlags)2;
			_clearCamera.backgroundColor = Color.clear;
			_clearCamera.allowHDR = false;
			_clearCamera.allowMSAA = false;
			AdditionalCameraData additionalCameraData = AdditionalCameraData.Create(_clearCamera);
			if ((Object)(object)additionalCameraData != (Object)null)
			{
				additionalCameraData.SetAllowXrRendering(allowXrRendering: false);
			}
		}

		public void SetUpTargetTexture(RenderTexture targetTexture)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			_targetTexture = targetTexture;
			if (((Behaviour)this).enabled)
			{
				_commandBuffer = CreateCommandBuffer();
				_commandBuffer.name = "UUVR UI";
				_commandBuffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit((Texture)(object)targetTexture));
			}
		}

		private static CommandBuffer CreateCommandBuffer()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			Type typeFromHandle = typeof(CommandBuffer);
			ConstructorInfo constructor = typeFromHandle.GetConstructor(Type.EmptyTypes);
			return (CommandBuffer)constructor.Invoke(null);
		}

		private void Reset()
		{
			if (_commandBuffer != null)
			{
				_commandBuffer.Dispose();
				_commandBuffer = null;
			}
		}

		private void SetXrMirror(bool mirror)
		{
			Type type = Type.GetType("UnityEngine.XR.XRSettings, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.XRSettings, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRSettings, UnityEngine");
			type.GetProperty("showDeviceView").SetValue(null, mirror, null);
		}

		private IEnumerator EndOfFrameCoroutine()
		{
			while (true)
			{
				if ((Object)(object)_targetTexture != (Object)null && (_commandBuffer == null || Screen.width != ((Texture)_targetTexture).width || Screen.height != ((Texture)_targetTexture).height))
				{
					SetUpTargetTexture(_targetTexture);
				}
				yield return (object)new WaitForEndOfFrame();
				if (_commandBuffer != null && (Object)(object)_targetTexture != (Object)null)
				{
					Graphics.ExecuteCommandBuffer(_commandBuffer);
				}
			}
		}
	}
	public interface VrUiPatchMode
	{
		void SetUpTargetTexture(RenderTexture targetTexture);
	}
}
namespace Uuvr.VrTogglers
{
	public class LegacyOpenVrToggler : VrToggler
	{
		private static Type? _xrSettingsType;

		private static PropertyInfo? _xrEnabledProperty;

		protected override bool SetUp()
		{
			_xrSettingsType = Type.GetType("UnityEngine.XR.XRSettings, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.XRSettings, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRSettings, UnityEngine");
			_xrEnabledProperty = _xrSettingsType.GetProperty("enabled");
			return true;
		}

		protected override bool EnableVr()
		{
			_xrEnabledProperty.SetValue(null, true, null);
			return true;
		}

		protected override bool DisableVr()
		{
			_xrEnabledProperty.SetValue(null, false, null);
			return true;
		}
	}
	public abstract class VrToggler
	{
		private bool _isSetUp;

		public bool IsVrEnabled { get; private set; }

		protected abstract bool SetUp();

		protected abstract bool EnableVr();

		protected abstract bool DisableVr();

		public void SetVrEnabled(bool nextVrEnabled)
		{
			if (!_isSetUp)
			{
				_isSetUp = SetUp();
			}
			if (nextVrEnabled)
			{
				IsVrEnabled = EnableVr();
			}
			else if (DisableVr())
			{
				IsVrEnabled = false;
			}
		}
	}
	public class VrTogglerManager
	{
		private VrToggler _toggler;

		public VrTogglerManager()
		{
			SetUpToggler();
			_toggler?.SetVrEnabled(nextVrEnabled: true);
		}

		private void SetUpToggler()
		{
			if (_toggler != null)
			{
				_toggler.SetVrEnabled(nextVrEnabled: false);
			}
			switch (ModConfiguration.Instance.PreferredVrApi.Value)
			{
			case ModConfiguration.VrApi.OpenVr:
				_toggler = new XrPluginOpenVrToggler();
				break;
			case ModConfiguration.VrApi.OpenXr:
				_toggler = new XrPluginOpenXrToggler();
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
		}

		public void ToggleVr()
		{
			_toggler.SetVrEnabled(!_toggler.IsVrEnabled);
		}
	}
	public class XrPluginOpenVrToggler : XrPluginToggler
	{
		protected override XRLoader CreateLoader()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			OpenVRLoader val = ScriptableObject.CreateInstance<OpenVRLoader>();
			((XRLoader)val).Initialize();
			OpenVRSettings settings = OpenVRSettings.GetSettings(true);
			if ((Object)(object)settings == (Object)null)
			{
				throw new Exception("OpenVRSettings instance is null");
			}
			settings.EditorAppKey = "uuvr";
			settings.InitializationType = (InitializationTypes)1;
			settings.StereoRenderingMode = (StereoRenderingModes)0;
			settings.SetMirrorViewMode((MirrorViewModes)2);
			return (XRLoader)(object)val;
		}
	}
	public class XrPluginOpenXrToggler : XrPluginToggler
	{
		protected override XRLoader CreateLoader()
		{
			OpenXRLoader result = ScriptableObject.CreateInstance<OpenXRLoader>();
			OpenXRSettings.Instance.renderMode = (RenderMode)0;
			return (XRLoader)(object)result;
		}
	}
	public abstract class XrPluginToggler : VrToggler
	{
		protected XRGeneralSettings _generalSettings;

		protected XRManagerSettings _managerSetings;

		protected override bool SetUp()
		{
			_generalSettings = ScriptableObject.CreateInstance<XRGeneralSettings>();
			_managerSetings = ScriptableObject.CreateInstance<XRManagerSettings>();
			_generalSettings.Manager = _managerSetings;
			_managerSetings.loaders.Add(CreateLoader());
			_managerSetings.InitializeLoaderSync();
			if ((Object)(object)_managerSetings.activeLoader == (Object)null)
			{
				throw new Exception("Cannot initialize OpenXR Loader. Maybe The VR headset wasn't ready?");
			}
			return true;
		}

		protected override bool EnableVr()
		{
			_managerSetings.StartSubsystems();
			bool flag = _managerSetings.activeLoader.Initialize();
			bool flag2 = _managerSetings.activeLoader.Start();
			return flag && flag2;
		}

		protected override bool DisableVr()
		{
			bool flag = _managerSetings.activeLoader.Stop();
			bool flag2 = _managerSetings.activeLoader.Deinitialize();
			return flag && flag2;
		}

		protected abstract XRLoader CreateLoader();
	}
}
namespace Uuvr.VrCamera
{
	public class AdditionalCameraData : MonoBehaviour
	{
		private const int RenderTypeBase = 0;

		private const int RenderTypeOverlay = 1;

		private static Type? _additionalCameraDataType;

		private static PropertyInfo? _renderTypeProperty;

		private static PropertyInfo? _cameraStackProperty;

		private static PropertyInfo? _allowXrRenderingProperty;

		private object? _additionalCameraData;

		public static AdditionalCameraData Create(Camera camera)
		{
			if (_additionalCameraDataType == null)
			{
				_additionalCameraDataType = Type.GetType("UnityEngine.Rendering.Universal.UniversalAdditionalCameraData, Unity.RenderPipelines.Universal.Runtime");
				_renderTypeProperty = _additionalCameraDataType?.GetProperty("renderType");
				_cameraStackProperty = _additionalCameraDataType?.GetProperty("cameraStack");
				_allowXrRenderingProperty = _additionalCameraDataType?.GetProperty("allowXRRendering");
			}
			if (_additionalCameraDataType == null)
			{
				return null;
			}
			return ((Component)camera).gameObject.GetComponent<AdditionalCameraData>() ?? ((Component)camera).gameObject.AddComponent<AdditionalCameraData>();
		}

		private void Awake()
		{
			_additionalCameraData = ((Component)this).gameObject.GetComponent(_additionalCameraDataType) ?? ((Component)this).gameObject.AddComponent(_additionalCameraDataType);
		}

		public void SetRenderTypeBase()
		{
			_renderTypeProperty?.SetValue(_additionalCameraData, 0);
		}

		public void SetRenderTypeOverlay()
		{
			_renderTypeProperty?.SetValue(_additionalCameraData, 1);
		}

		public bool IsOverlay()
		{
			return (int)_renderTypeProperty.GetValue(_additionalCameraData) == 1;
		}

		public List<Camera> GetCameraStack()
		{
			return (List<Camera>)_cameraStackProperty.GetValue(_additionalCameraData);
		}

		public void SetAllowXrRendering(bool allowXrRendering)
		{
			_allowXrRenderingProperty.SetValue(_additionalCameraData, allowXrRendering);
		}
	}
	public class VrCamera : UuvrBehaviour
	{
		public static readonly HashSet<Camera> VrCameras = new HashSet<Camera>();

		public static readonly HashSet<Camera> IgnoredCameras = new HashSet<Camera>();

		public static bool LookWhereGameCameraLooks;

		private Quaternion _rotationBeforeRender;

		private UuvrPoseDriver? _parentCameraPoseDriver;

		private Camera? _childCamera;

		private UuvrPoseDriver? _childCameraPoseDriver;

		private LineRenderer _forwardLine;

		public static VrCamera? HighestDepthVrCamera { get; private set; }

		public Camera? ParentCamera { get; private set; }

		public Camera? CameraInUse => (ModConfiguration.Instance.CameraTracking.Value == ModConfiguration.CameraTrackingMode.Child) ? _childCamera : ParentCamera;

		protected override void Awake()
		{
			base.Awake();
			ParentCamera = ((Component)this).GetComponent<Camera>();
			VrCameras.Add(ParentCamera);
		}

		protected override void OnBeginFrameRendering()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			base.OnBeginFrameRendering();
			if (ModConfiguration.Instance.CameraTracking.Value == ModConfiguration.CameraTrackingMode.RelativeTransform)
			{
				_rotationBeforeRender = ((Component)this).transform.rotation;
				((Component)this).transform.rotation = (LookWhereGameCameraLooks ? (_rotationBeforeRender * HeadRoll(((Component)_childCameraPoseDriver).transform.localRotation)) : ((Component)_childCamera).transform.rotation);
			}
		}

		private static Quaternion HeadRoll(Quaternion head)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = head * Vector3.forward;
			Vector3 val2 = Vector3.ProjectOnPlane(Vector3.up, val);
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				return Quaternion.identity;
			}
			float num = Vector3.SignedAngle(val2, head * Vector3.up, val);
			return Quaternion.AngleAxis(num, Vector3.forward);
		}

		protected override void OnEndFrameRendering()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (ModConfiguration.Instance.CameraTracking.Value == ModConfiguration.CameraTrackingMode.RelativeTransform)
			{
				((Component)this).transform.rotation = _rotationBeforeRender;
			}
		}

		private void OnDestroy()
		{
			VrCameras.Remove(ParentCamera);
		}

		private void Start()
		{
			VrCameraOffset vrCameraOffset = UuvrBehaviour.Create<VrCameraOffset>(((Component)this).transform);
			_parentCameraPoseDriver = ((Component)ParentCamera).gameObject.AddComponent<UuvrPoseDriver>();
			_childCameraPoseDriver = UuvrBehaviour.Create<UuvrPoseDriver>(((Component)vrCameraOffset).transform);
			((Object)_childCameraPoseDriver).name = "VrChildCamera";
			_childCamera = ((Component)_childCameraPoseDriver).gameObject.AddComponent<Camera>();
			IgnoredCameras.Add(_childCamera);
			_childCamera.CopyFrom(ParentCamera);
		}

		protected override void OnBeforeRender()
		{
			UpdateRelativeMatrix();
		}

		private void OnPreCull()
		{
			UpdateRelativeMatrix();
		}

		private void OnPreRender()
		{
			UpdateRelativeMatrix();
		}

		private void LateUpdate()
		{
			UpdateRelativeMatrix();
		}

		private void Update()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (ModConfiguration.Instance.OverrideDepth.Value)
			{
				ParentCamera.depth = ModConfiguration.Instance.VrCameraDepth.Value;
			}
			ModConfiguration.CameraTrackingMode value = ModConfiguration.Instance.CameraTracking.Value;
			((Behaviour)_parentCameraPoseDriver).enabled = value == ModConfiguration.CameraTrackingMode.Absolute;
			((Component)_childCameraPoseDriver).gameObject.SetActive(value != ModConfiguration.CameraTrackingMode.Absolute);
			if (value == ModConfiguration.CameraTrackingMode.Child)
			{
				_childCamera.cullingMask = ParentCamera.cullingMask;
				_childCamera.clearFlags = ParentCamera.clearFlags;
				_childCamera.depth = ParentCamera.depth;
			}
			else
			{
				_childCamera.cullingMask = 0;
				_childCamera.clearFlags = (CameraClearFlags)4;
				_childCamera.depth = -100f;
			}
			if (IsRendering(this) && (!IsRendering(HighestDepthVrCamera) || ParentCamera.depth > HighestDepthVrCamera.CameraInUse.depth))
			{
				HighestDepthVrCamera = this;
			}
		}

		private static bool IsRendering(VrCamera? vrCamera)
		{
			return (Object)(object)vrCamera != (Object)null && ((Behaviour)vrCamera).isActiveAndEnabled && (Object)(object)vrCamera.ParentCamera != (Object)null && ((Behaviour)vrCamera.ParentCamera).isActiveAndEnabled;
		}

		private void UpdateRelativeMatrix()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (ModConfiguration.Instance.CameraTracking.Value == ModConfiguration.CameraTrackingMode.RelativeMatrix)
			{
				StereoscopicEye val = (StereoscopicEye)(((int)ParentCamera.stereoActiveEye != 0) ? 1 : 0);
				ParentCamera.worldToCameraMatrix = _childCamera.GetStereoViewMatrix(val);
				if (ModConfiguration.Instance.RelativeCameraSetStereoView.Value)
				{
					ParentCamera.SetStereoViewMatrix(val, ParentCamera.worldToCameraMatrix);
				}
			}
		}
	}
	public class VrCameraManager : MonoBehaviour
	{
		private Camera[] _allCameras;

		private void Update()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			if (_allCameras == null || _allCameras.Length < Camera.allCamerasCount)
			{
				_allCameras = (Camera[])(object)new Camera[Camera.allCamerasCount];
			}
			Camera.GetAllCameras(_allCameras);
			for (int i = 0; i < Camera.allCamerasCount; i++)
			{
				Camera val = _allCameras[i];
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.targetTexture != (Object)null) && (int)val.stereoTargetEye != 0 && !VrCamera.VrCameras.Contains(val) && !VrCamera.IgnoredCameras.Contains(val))
				{
					Debug.Log((object)("creating vr camera " + ((Object)val).name));
					((Component)val).gameObject.AddComponent<VrCamera>();
				}
			}
		}
	}
	public class VrCameraOffset : UuvrBehaviour
	{
		public static Quaternion RecenterRotation = Quaternion.identity;

		protected override void OnBeforeRender()
		{
			base.OnBeforeRender();
			UpdateTransform();
		}

		protected override void OnSettingChanged()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			base.OnSettingChanged();
			ModConfiguration instance = ModConfiguration.Instance;
			((Component)this).transform.localPosition = new Vector3(instance.CameraPositionOffsetX.Value, instance.CameraPositionOffsetY.Value, instance.CameraPositionOffsetZ.Value);
		}

		private void Update()
		{
			UpdateTransform();
		}

		private void LateUpdate()
		{
			UpdateTransform();
		}

		private void UpdateTransform()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (ModConfiguration.Instance.AlignCameraToHorizon.Value)
			{
				Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.parent.forward, Vector3.up);
				((Component)this).transform.LookAt(((Component)this).transform.position + val, Vector3.up);
				Transform transform = ((Component)this).transform;
				transform.rotation *= RecenterRotation;
			}
			else
			{
				((Component)this).transform.localRotation = RecenterRotation;
			}
		}
	}
}
namespace Uuvr.UnityTypesHelper
{
	public static class UuvrXrDevice
	{
		public static readonly Type? XrDeviceType = Type.GetType("UnityEngine.XR.XRDevice, UnityEngine.XRModule") ?? Type.GetType("UnityEngine.XR.XRDevice, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRDevice, UnityEngine.VRModule") ?? Type.GetType("UnityEngine.VR.VRDevice, UnityEngine");

		public static readonly PropertyInfo? RefreshRateProperty = XrDeviceType?.GetProperty("refreshRate");
	}
}