Decompiled source of SimCruiser G25 v1.2.0

SimCruiser-G25.dll

Decompiled 18 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SimCruiser-G25")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0a3bad0d91362026ffd78079e8f9e25cfe0f0d46")]
[assembly: AssemblyProduct("SimCruiser-G25")]
[assembly: AssemblyTitle("SimCruiser-G25")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SimCruiser_G25
{
	[BepInPlugin("com.BigSaltyBeans.SimCruiser_G25", "Sim Cruiser G25", "1.2.0")]
	public class SimCruiser_G25 : BaseUnityPlugin
	{
		private const string GUID = "com.BigSaltyBeans.SimCruiser_G25";

		private const string NAME = "Sim Cruiser G25";

		private const string VERSION = "1.2.0";

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.BigSaltyBeans.SimCruiser_G25");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched Sim Cruiser G25");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SimCruiser-G25";

		public const string PLUGIN_NAME = "SimCruiser-G25";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SimCruiser_G25.Patches
{
	[HarmonyPatch(typeof(StartOfRound), "Update")]
	internal class AddWheelBindings
	{
		private static bool added;

		private static void Postfix()
		{
			if (added)
			{
				return;
			}
			PlayerControllerB val = StartOfRound.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			InputActionAsset asset = val.playerActions.asset;
			if ((Object)(object)asset == (Object)null)
			{
				Debug.LogError((object)"Fatal PlayerActions is null :(");
				return;
			}
			InputActionAsset actions = InputSystem.actions;
			if ((Object)(object)actions == (Object)null)
			{
				Debug.LogError((object)"Fatal PlayerActions is null :(");
				return;
			}
			ApplyBindings(asset);
			ApplyBindings(actions);
			added = true;
			Debug.Log((object)"Added G25's input bindings! :D");
		}

		private static void ApplyBindings(InputActionAsset actions)
		{
			//IL_00a2: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: 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_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			InputAction val = actions.FindAction("Move", false);
			if (val == null)
			{
				Debug.LogError((object)"Fatal Move Action in PlayerActions is null :(");
				return;
			}
			InputAction val2 = actions.FindAction("Jump", false);
			if (val2 == null)
			{
				Debug.LogError((object)"Fatal Jump Action in PlayerActions is null :(");
				return;
			}
			InputAction val3 = actions.FindAction("Interact", false);
			if (val3 == null)
			{
				Debug.LogError((object)"Fatal Interact Action in PlayerActions is null :(");
				return;
			}
			InputAction val4 = actions.FindAction("Look", false);
			if (val4 == null)
			{
				Debug.LogError((object)"Fatal Look Action in PlayerActions is null :(");
				return;
			}
			Enumerator<InputDevice> enumerator = InputSystem.devices.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					InputDevice current = enumerator.Current;
					Debug.Log((object)((InputControl)current).path);
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			Enumerator<InputDevice> enumerator2 = InputSystem.devices.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					InputDevice current2 = enumerator2.Current;
					if (!((InputControl)current2).displayName.ToLower().Contains("g25"))
					{
						continue;
					}
					Debug.Log((object)("Found g25: " + ((InputControl)current2).name));
					Enumerator<InputControl> enumerator3 = current2.allControls.GetEnumerator();
					try
					{
						while (enumerator3.MoveNext())
						{
							InputControl current3 = enumerator3.Current;
							Debug.Log((object)current3.path);
						}
					}
					finally
					{
						((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose();
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
			CompositeSyntax val5 = InputActionSetupExtensions.AddCompositeBinding(val, "2DVector", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Up", "<HID::G25 Racing Wheel>/stick/up", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Down", "<HID::G25 Racing Wheel>/stick/down", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Left", "<HID::G25 Racing Wheel>/stick/left", (string)null, (string)null);
			((CompositeSyntax)(ref val5)).With("Right", "<HID::G25 Racing Wheel>/stick/right", (string)null, (string)null);
			BindingSyntax val6 = InputActionSetupExtensions.AddBinding(val2, "<HID::G25 Racing Wheel>/button8", (string)null, (string)null, (string)null);
			((BindingSyntax)(ref val6)).WithInteraction("press");
			val5 = InputActionSetupExtensions.AddCompositeBinding(val, "2DVector", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Up", "<HID::G25 Racing Wheel>/button16", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Down", "<HID::G25 Racing Wheel>/button18", (string)null, (string)null);
			val5 = ((CompositeSyntax)(ref val5)).With("Left", "<HID::G25 Racing Wheel>/button17", (string)null, (string)null);
			((CompositeSyntax)(ref val5)).With("Right", "<HID::G25 Racing Wheel>/button19", (string)null, (string)null);
			val6 = InputActionSetupExtensions.AddBinding(val3, "<HID::G25 Racing Wheel>/button7", (string)null, (string)null, (string)null);
			((BindingSyntax)(ref val6)).WithInteraction("press");
			val6 = InputActionSetupExtensions.AddBinding(val4, "<HID::G25 Racing Wheel>/hat", (string)null, (string)null, (string)null);
			((BindingSyntax)(ref val6)).WithProcessor("scaleVector2(x=100,y=100)");
		}
	}
}