using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SebCore; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SebBinds")] [assembly: AssemblyProduct("SebBinds")] [assembly: AssemblyFileVersion("1.1.4")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.1.4.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 SebBinds { public enum AxisAction { MoveX, MoveY, Steering, Throttle, Brake, Clutch, CameraLookX, CameraLookY } public static class AxisBindingStore { private static readonly Dictionary AxisCache = new Dictionary(64); private const int BindingPovOffset = 1000; private const int BindingKeyOffset = 2000; private const int BindingMouseOffset = 10000; private const int BindingGamepadButtonOffset = 11000; private const int BindingGamepadDpadOffset = 12000; private const int BindingGamepadAxisOffset = 14000; private const int BindingWheelAxisOffset = 15000; private const int BindingGamepadDpadAxisOffset = 16000; private const int BindingWheelDpadAxisOffset = 17000; private static int CacheKey(BindingScheme scheme, AxisAction action) { return ((int)scheme << 16) | (int)action; } internal static void ClearRuntimeCache() { AxisCache.Clear(); } private static string Key(BindingScheme scheme, AxisAction action) { switch (scheme) { case BindingScheme.Wheel: { int num = (int)action; return "SebBinds_Wheel_Axis_" + num; } case BindingScheme.Keyboard: { int num = (int)action; return "SebBinds_KB_Axis_" + num; } default: { int num = (int)action; return "SebBinds_Axis_" + num; } } } public static BindingInput GetAxisBinding(BindingScheme scheme, AxisAction action) { int key = CacheKey(scheme, action); if (AxisCache.TryGetValue(key, out var value)) { return value; } string text = Key(scheme, action); int num = PlayerPrefs.GetInt(text, -1); BindingInput bindingInput = Decode(num); if (num < 0 && scheme == BindingScheme.Wheel) { string text2 = Key(BindingScheme.Controller, action); int num2 = PlayerPrefs.GetInt(text2, -1); BindingInput bindingInput2 = Decode(num2); if (bindingInput2.Kind == BindingKind.WheelAxis || bindingInput2.Kind == BindingKind.WheelDpadAxis) { PlayerPrefs.SetInt(text, num2); PlayerPrefs.DeleteKey(text2); bindingInput = bindingInput2; } } if (scheme == BindingScheme.Controller && (bindingInput.Kind == BindingKind.WheelAxis || bindingInput.Kind == BindingKind.WheelDpadAxis)) { bindingInput = new BindingInput { Kind = BindingKind.None, Code = 0 }; } if (scheme == BindingScheme.Wheel && (bindingInput.Kind == BindingKind.GamepadAxis || bindingInput.Kind == BindingKind.GamepadDpadAxis || bindingInput.Kind == BindingKind.GamepadDpad)) { bindingInput = new BindingInput { Kind = BindingKind.None, Code = 0 }; } AxisCache[key] = bindingInput; return bindingInput; } public static void SetAxisBinding(BindingScheme scheme, AxisAction action, BindingInput input) { if (scheme == BindingScheme.Controller && (input.Kind == BindingKind.WheelAxis || input.Kind == BindingKind.WheelDpadAxis)) { input = new BindingInput { Kind = BindingKind.None, Code = 0 }; } if (scheme == BindingScheme.Wheel && (input.Kind == BindingKind.GamepadAxis || input.Kind == BindingKind.GamepadDpadAxis || input.Kind == BindingKind.GamepadDpad)) { input = new BindingInput { Kind = BindingKind.None, Code = 0 }; } PlayerPrefs.SetInt(Key(scheme, action), Encode(input)); AxisCache[CacheKey(scheme, action)] = input; } public static void ClearAxisBinding(BindingScheme scheme, AxisAction action) { PlayerPrefs.DeleteKey(Key(scheme, action)); AxisCache.Remove(CacheKey(scheme, action)); } public static BindingInput GetAxisBinding(AxisAction action) { return GetAxisBinding(BindingScheme.Controller, action); } public static void SetAxisBinding(AxisAction action, BindingInput input) { SetAxisBinding(BindingScheme.Controller, action, input); } public static void ClearAxisBinding(AxisAction action) { ClearAxisBinding(BindingScheme.Controller, action); } public static void ClearAll() { foreach (AxisAction value in Enum.GetValues(typeof(AxisAction))) { PlayerPrefs.DeleteKey(Key(BindingScheme.Controller, value)); PlayerPrefs.DeleteKey(Key(BindingScheme.Keyboard, value)); PlayerPrefs.DeleteKey(Key(BindingScheme.Wheel, value)); } ClearRuntimeCache(); } public static void ClearScheme(BindingScheme scheme) { foreach (AxisAction value in Enum.GetValues(typeof(AxisAction))) { PlayerPrefs.DeleteKey(Key(scheme, value)); } ClearRuntimeCache(); } private static int Encode(BindingInput input) { if (input.Kind == BindingKind.Button) { return Mathf.Clamp(input.Code, 0, 127); } if (input.Kind == BindingKind.Pov) { return 1000 + Mathf.Clamp(input.Code, 0, 3); } if (input.Kind == BindingKind.Key) { return 2000 + Mathf.Max(0, input.Code); } if (input.Kind == BindingKind.MouseButton) { return 10000 + Mathf.Clamp(input.Code, 0, 31); } if (input.Kind == BindingKind.GamepadButton) { return 11000 + Mathf.Clamp(input.Code, 0, 255); } if (input.Kind == BindingKind.GamepadAxis) { return 14000 + Mathf.Clamp(input.Code, 0, 15); } if (input.Kind == BindingKind.WheelAxis) { return 15000 + Mathf.Clamp(input.Code, 0, 31); } if (input.Kind == BindingKind.GamepadDpadAxis) { return 16000 + Mathf.Clamp(input.Code, 0, 1); } if (input.Kind == BindingKind.WheelDpadAxis) { return 17000 + Mathf.Clamp(input.Code, 0, 1); } if (input.Kind == BindingKind.GamepadDpad) { return 12000 + Mathf.Clamp(input.Code, 0, 3); } return -1; } private static BindingInput Decode(int raw) { if (raw < 0) { return new BindingInput { Kind = BindingKind.None, Code = 0 }; } if (raw >= 17000) { return new BindingInput { Kind = BindingKind.WheelDpadAxis, Code = Mathf.Clamp(raw - 17000, 0, 1) }; } if (raw >= 16000) { return new BindingInput { Kind = BindingKind.GamepadDpadAxis, Code = Mathf.Clamp(raw - 16000, 0, 1) }; } if (raw >= 15000) { return new BindingInput { Kind = BindingKind.WheelAxis, Code = Mathf.Clamp(raw - 15000, 0, 31) }; } if (raw >= 14000) { return new BindingInput { Kind = BindingKind.GamepadAxis, Code = Mathf.Clamp(raw - 14000, 0, 15) }; } if (raw >= 12000) { return new BindingInput { Kind = BindingKind.GamepadDpad, Code = Mathf.Clamp(raw - 12000, 0, 3) }; } if (raw >= 11000) { return new BindingInput { Kind = BindingKind.GamepadButton, Code = Mathf.Clamp(raw - 11000, 0, 255) }; } if (raw >= 10000) { return new BindingInput { Kind = BindingKind.MouseButton, Code = Mathf.Clamp(raw - 10000, 0, 31) }; } if (raw >= 2000) { return new BindingInput { Kind = BindingKind.Key, Code = Mathf.Max(0, raw - 2000) }; } if (raw >= 1000) { return new BindingInput { Kind = BindingKind.Pov, Code = Mathf.Clamp(raw - 1000, 0, 3) }; } return new BindingInput { Kind = BindingKind.Button, Code = Mathf.Clamp(raw, 0, 127) }; } } internal static class AxisCapture { private static bool _wheelBaselineValid; private static readonly float[] _wheelBaseline = new float[8]; private static Vector2 _wheelPovBaseline; internal static void BeginCaptureSession(BindingScheme scheme) { //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_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references) if (scheme != BindingScheme.Wheel) { _wheelBaselineValid = false; return; } for (int i = 0; i < _wheelBaseline.Length; i++) { _wheelBaseline[i] = WheelInterop.GetWheelRawAxisValue(i); } _wheelBaselineValid = true; if (WheelInterop.TryGetPov8Vector(out var v)) { _wheelPovBaseline = -v; } else { _wheelPovBaseline = Vector2.zero; } } internal static bool TryCaptureNextAxis(BindingScheme scheme, out BindingInput input) { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ff: Unknown result type (might be due to invalid IL or missing references) if (scheme == BindingScheme.Wheel) { float num = 0f; int num2 = -1; if (!_wheelBaselineValid) { BeginCaptureSession(BindingScheme.Wheel); } for (int i = 0; i <= 7; i++) { float wheelRawAxisValue = WheelInterop.GetWheelRawAxisValue(i); float num3 = _wheelBaseline[i]; float num4 = Mathf.Abs(wheelRawAxisValue - num3); if (num4 > num) { num = num4; num2 = i; } } if (num2 >= 0 && num > 0.35f) { input = new BindingInput { Kind = BindingKind.WheelAxis, Code = num2 }; return true; } if (WheelInterop.TryGetPov8Vector(out var v)) { Vector2 val = -v; if (Mathf.Abs(val.x - _wheelPovBaseline.x) > 0.5f && Mathf.Abs(val.x) > 0.5f) { input = new BindingInput { Kind = BindingKind.WheelDpadAxis, Code = 0 }; return true; } if (Mathf.Abs(val.y - _wheelPovBaseline.y) > 0.5f && Mathf.Abs(val.y) > 0.5f) { input = new BindingInput { Kind = BindingKind.WheelDpadAxis, Code = 1 }; return true; } } } if (scheme == BindingScheme.Controller) { BindingEvaluator.BeginFrame(); float num5 = 0f; int num6 = -1; for (int j = 0; j <= 5; j++) { BindingInput input2 = new BindingInput { Kind = BindingKind.GamepadAxis, Code = j }; float axisValue = BindingEvaluator.GetAxisValue(input2); float prevAxisValueForCapture = BindingEvaluator.GetPrevAxisValueForCapture(input2); float num7 = Mathf.Abs(axisValue - prevAxisValueForCapture); if (num7 > num5) { num5 = num7; num6 = j; } } if (num6 >= 0 && num5 > 0.35f) { input = new BindingInput { Kind = BindingKind.GamepadAxis, Code = num6 }; return true; } Gamepad current = Gamepad.current; if (current != null) { Vector2 val2 = ((InputControl)(object)current.dpad).ReadValue(); if (Mathf.Abs(val2.x) > 0.5f) { input = new BindingInput { Kind = BindingKind.GamepadDpadAxis, Code = 0 }; return true; } if (Mathf.Abs(val2.y) > 0.5f) { input = new BindingInput { Kind = BindingKind.GamepadDpadAxis, Code = 1 }; return true; } } } input = default(BindingInput); return false; } } internal static class AxisDefaults { internal static void EnsureControllerDefaults() { SetIfUnset(AxisAction.MoveY, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 3 }); SetIfUnset(AxisAction.MoveX, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 2 }); SetIfUnset(AxisAction.Steering, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 2 }); SetIfUnset(AxisAction.Throttle, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 1 }); SetIfUnset(AxisAction.Brake, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 0 }); SetIfUnset(AxisAction.CameraLookX, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 4 }); SetIfUnset(AxisAction.CameraLookY, new BindingInput { Kind = BindingKind.GamepadAxis, Code = 5 }); } private static void SetIfUnset(AxisAction action, BindingInput input) { if (AxisBindingStore.GetAxisBinding(action).Kind == BindingKind.None) { AxisBindingStore.SetAxisBinding(action, input); } } } public interface IAxisProvider { bool IsAvailable(); bool SupportsClutch(); bool TryGetAxisValue(BindingInput input, out float value); bool TryGetAxisLabel(BindingInput input, out string label); bool TryCaptureNextAxis(out BindingInput input); } public enum BindingScheme { Controller, Keyboard, Wheel } public static class BindingStore { private const int BindingPovOffset = 1000; private const int BindingKeyOffset = 2000; private const int BindingMouseOffset = 10000; private const int BindingGamepadButtonOffset = 11000; private const int BindingGamepadDpadOffset = 12000; private const int BindingGamepadAxisOffset = 14000; private const int BindingWheelAxisOffset = 15000; private const int BindingGamepadDpadAxisOffset = 16000; private const int BindingWheelDpadAxisOffset = 17000; private const string PrefKeyBindModifierController = "ELWS_Bind_Modifier"; private const string PrefKeyBindModifierKeyboard = "SebBinds_KB_Bind_Modifier"; private const string PrefKeyBindModifierWheel = "SebBinds_Wheel_Bind_Modifier"; private static readonly Dictionary BindingCache = new Dictionary(256); private static readonly Dictionary ModifierCache = new Dictionary(4); private static int Key(BindingScheme scheme, BindingLayer layer, BindAction action) { return ((int)scheme << 16) | ((int)layer << 8) | (int)action; } private static int ModKey(BindingScheme scheme) { return (int)scheme; } internal static void ClearRuntimeCache() { BindingCache.Clear(); ModifierCache.Clear(); } private static string GetModifierPrefKey(BindingScheme scheme) { return scheme switch { BindingScheme.Wheel => "SebBinds_Wheel_Bind_Modifier", BindingScheme.Keyboard => "SebBinds_KB_Bind_Modifier", _ => "ELWS_Bind_Modifier", }; } private static string GetBindPrefKey(BindingScheme scheme, BindingLayer layer, BindAction action) { switch (scheme) { case BindingScheme.Keyboard: { int num = (int)layer; string text3 = num.ToString(); num = (int)action; return "SebBinds_KB_Bind_" + text3 + "_" + num; } case BindingScheme.Wheel: { int num = (int)layer; string text2 = num.ToString(); num = (int)action; return "SebBinds_Wheel_Bind_" + text2 + "_" + num; } default: { int num = (int)layer; string text = num.ToString(); num = (int)action; return "ELWS_Bind_" + text + "_" + num; } } } private static string GetLegacyBindPrefKey(BindingScheme scheme, BindingLayer layer, BindAction action) { return scheme switch { BindingScheme.Keyboard => "SebBinds_KB_Bind_" + layer.ToString() + "_" + action, BindingScheme.Wheel => "SebBinds_Wheel_Bind_" + layer.ToString() + "_" + action, _ => "ELWS_Bind_" + layer.ToString() + "_" + action, }; } public static void ClearAll() { foreach (BindAction value in Enum.GetValues(typeof(BindAction))) { foreach (BindingLayer value2 in Enum.GetValues(typeof(BindingLayer))) { foreach (BindingScheme value3 in Enum.GetValues(typeof(BindingScheme))) { PlayerPrefs.DeleteKey(GetBindPrefKey(value3, value2, value)); PlayerPrefs.DeleteKey(GetLegacyBindPrefKey(value3, value2, value)); } } } PlayerPrefs.DeleteKey(GetModifierPrefKey(BindingScheme.Controller)); PlayerPrefs.DeleteKey(GetModifierPrefKey(BindingScheme.Keyboard)); PlayerPrefs.DeleteKey(GetModifierPrefKey(BindingScheme.Wheel)); ClearRuntimeCache(); } public static void ClearScheme(BindingScheme scheme) { foreach (BindAction value in Enum.GetValues(typeof(BindAction))) { foreach (BindingLayer value2 in Enum.GetValues(typeof(BindingLayer))) { PlayerPrefs.DeleteKey(GetBindPrefKey(scheme, value2, value)); PlayerPrefs.DeleteKey(GetLegacyBindPrefKey(scheme, value2, value)); } } PlayerPrefs.DeleteKey(GetModifierPrefKey(scheme)); ClearRuntimeCache(); } public static BindingInput GetBinding(BindingLayer layer, BindAction action) { return GetBinding(BindingScheme.Controller, layer, action); } public static BindingInput GetBinding(BindingScheme scheme, BindingLayer layer, BindAction action) { int key = Key(scheme, layer, action); if (BindingCache.TryGetValue(key, out var value)) { return value; } string bindPrefKey = GetBindPrefKey(scheme, layer, action); int num = PlayerPrefs.GetInt(bindPrefKey, -1); if (num < 0) { num = PlayerPrefs.GetInt(GetLegacyBindPrefKey(scheme, layer, action), -1); if (num >= 0) { PlayerPrefs.SetInt(bindPrefKey, num); } } BindingInput bindingInput = Decode(num); BindingCache[key] = bindingInput; return bindingInput; } public static void SetBinding(BindingLayer layer, BindAction action, BindingInput input) { SetBinding(BindingScheme.Controller, layer, action, input); } public static void SetBinding(BindingScheme scheme, BindingLayer layer, BindAction action, BindingInput input) { PlayerPrefs.SetInt(GetBindPrefKey(scheme, layer, action), Encode(input)); BindingCache[Key(scheme, layer, action)] = input; } public static BindingInput GetModifierBinding() { return GetModifierBinding(BindingScheme.Controller); } public static void SetModifierBinding(BindingInput input) { SetModifierBinding(BindingScheme.Controller, input); } public static BindingInput GetModifierBinding(BindingScheme scheme) { int key = ModKey(scheme); if (ModifierCache.TryGetValue(key, out var value)) { return value; } BindingInput bindingInput = Decode(PlayerPrefs.GetInt(GetModifierPrefKey(scheme), -1)); ModifierCache[key] = bindingInput; return bindingInput; } public static void SetModifierBinding(BindingScheme scheme, BindingInput input) { PlayerPrefs.SetInt(GetModifierPrefKey(scheme), Encode(input)); ModifierCache[ModKey(scheme)] = input; } public static string GetBindingLabel(BindingInput input) { if (input.Kind == BindingKind.Button) { return "But. " + (Mathf.Clamp(input.Code, 0, 127) + 1); } if (input.Kind == BindingKind.Pov) { return Mathf.Clamp(input.Code, 0, 3) switch { 0 => "DP-U", 1 => "DP-R", 2 => "DP-D", _ => "DP-L", }; } if (input.Kind == BindingKind.Key) { try { return GetKeyLabel((Key)Mathf.Max(0, input.Code)); } catch { return "Key"; } } if (input.Kind == BindingKind.MouseButton) { return input.Code switch { 0 => "Mouse L", 1 => "Mouse R", 2 => "Mouse M", _ => "Mouse", }; } if (input.Kind == BindingKind.GamepadButton) { return "Pad " + input.Code; } if (input.Kind == BindingKind.GamepadDpad) { return Mathf.Clamp(input.Code, 0, 3) switch { 0 => "DP-U", 1 => "DP-R", 2 => "DP-D", _ => "DP-L", }; } if (input.Kind == BindingKind.GamepadAxis) { return input.Code switch { 0 => "LT Axis", 1 => "RT Axis", 2 => "LS X", 3 => "LS Y", 4 => "RS X", 5 => "RS Y", _ => "Axis", }; } if (input.Kind == BindingKind.WheelAxis) { return Mathf.Clamp(input.Code, 0, 7) switch { 0 => "lX", 1 => "lY", 2 => "lZ", 3 => "lRx", 4 => "lRy", 5 => "lRz", 6 => "slider0", 7 => "slider1", _ => "lX", }; } if (input.Kind == BindingKind.GamepadDpadAxis) { if (input.Code != 0) { return "Dpad Y"; } return "Dpad X"; } if (input.Kind == BindingKind.WheelDpadAxis) { if (input.Code != 0) { return "Wheel Dpad Y"; } return "Wheel Dpad X"; } return "None"; } private unsafe static string GetKeyLabel(Key key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0082: 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_00b6: Expected I4, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_00b6: 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_00d3: Expected I4, but got Unknown if ((int)key >= 15 && (int)key <= 40) { return ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); } if ((int)key >= 50 && (int)key <= 49) { string text = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); if (!text.StartsWith("Digit", StringComparison.Ordinal)) { return text; } return text.Substring(5); } if ((int)key >= 84 && (int)key <= 93) { string text2 = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(); if (!text2.StartsWith("Numpad", StringComparison.Ordinal)) { return text2; } return "Num" + text2.Substring(6); } return (key - 4) switch { 2 => ";", 1 => "'", 3 => ",", 4 => ".", 5 => "/", 6 => "\\", 7 => "[", 8 => "]", 9 => "-", 10 => "=", 0 => "`", _ => (key - 78) switch { 0 => "Num/", 1 => "Num*", 2 => "Num+", 3 => "Num-", 4 => "Num.", _ => ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString(), }, }; } public static string GetChordLabel(BindingInput input, bool modified) { return GetBindingLabel(input); } public static string GetActionLabel(BindAction action) { return action switch { BindAction.InteractOk => "Interact", BindAction.Back => "Back/Handbrake", BindAction.MapItems => "Map/Items", BindAction.Pause => "Pause", BindAction.Drive => "Drive", BindAction.Brake => "Brake/Reverse", BindAction.Map => "Map", BindAction.Items => "Items", BindAction.Jobs => "Jobs", BindAction.SteerLeft => "Steer Left", BindAction.SteerRight => "Steer Right", BindAction.MoveUp => "Move Up", BindAction.MoveDown => "Move Down", BindAction.MoveLeft => "Move Left", BindAction.MoveRight => "Move Right", BindAction.LookUp => "Look Up", BindAction.LookDown => "Look Down", BindAction.LookLeft => "Look Left", BindAction.LookRight => "Look Right", BindAction.CameraLookX => "Cam Look X", BindAction.CameraLookY => "Cam Look Y", BindAction.SteerAxis => "Steer Axis", BindAction.Camera => "1P/3P Camera", BindAction.FreeCam => "Free Cam Toggle", BindAction.FreeCamSelect => "Free Cam Place", BindAction.IndicatorLeft => "L Indicator", BindAction.IndicatorRight => "R Indicator", BindAction.IndicatorHazards => "4Way Indicator", BindAction.ResetVehicle => "Reset", BindAction.Headlights => "Lights", BindAction.Horn => "Horn", BindAction.RadioPower => "Radio Pwr", BindAction.RadioScanToggle => "Scan", BindAction.RadioScanLeft => "Prev Ch", BindAction.RadioScanRight => "Next Ch", BindAction.ToggleGearbox => "Gearbox", BindAction.ShiftUp => "Shift Up", BindAction.ShiftDown => "Shift Down", BindAction.IgnitionToggle => "Ignition", BindAction.Clutch => "Clutch", BindAction.GearReverse => "Reverse", BindAction.GearNeutral => "Neutral", BindAction.Gear1 => "Gear 1", BindAction.Gear2 => "Gear 2", BindAction.Gear3 => "Gear 3", BindAction.Gear4 => "Gear 4", BindAction.Gear5 => "Gear 5", BindAction.Gear6 => "Gear 6", _ => action.ToString(), }; } private static int Encode(BindingInput input) { if (input.Kind == BindingKind.Button) { return Mathf.Clamp(input.Code, 0, 127); } if (input.Kind == BindingKind.Pov) { return 1000 + Mathf.Clamp(input.Code, 0, 3); } if (input.Kind == BindingKind.Key) { return 2000 + Mathf.Max(0, input.Code); } if (input.Kind == BindingKind.MouseButton) { return 10000 + Mathf.Clamp(input.Code, 0, 31); } if (input.Kind == BindingKind.GamepadButton) { return 11000 + Mathf.Clamp(input.Code, 0, 255); } if (input.Kind == BindingKind.GamepadDpad) { return 12000 + Mathf.Clamp(input.Code, 0, 3); } if (input.Kind == BindingKind.GamepadAxis) { return 14000 + Mathf.Clamp(input.Code, 0, 15); } if (input.Kind == BindingKind.WheelAxis) { return 15000 + Mathf.Clamp(input.Code, 0, 31); } if (input.Kind == BindingKind.GamepadDpadAxis) { return 16000 + Mathf.Clamp(input.Code, 0, 1); } if (input.Kind == BindingKind.WheelDpadAxis) { return 17000 + Mathf.Clamp(input.Code, 0, 1); } return -1; } private static BindingInput Decode(int raw) { if (raw < 0) { return new BindingInput { Kind = BindingKind.None, Code = 0 }; } if (raw >= 17000) { return new BindingInput { Kind = BindingKind.WheelDpadAxis, Code = Mathf.Clamp(raw - 17000, 0, 1) }; } if (raw >= 16000) { return new BindingInput { Kind = BindingKind.GamepadDpadAxis, Code = Mathf.Clamp(raw - 16000, 0, 1) }; } if (raw >= 15000) { return new BindingInput { Kind = BindingKind.WheelAxis, Code = Mathf.Clamp(raw - 15000, 0, 31) }; } if (raw >= 14000) { return new BindingInput { Kind = BindingKind.GamepadAxis, Code = Mathf.Clamp(raw - 14000, 0, 15) }; } if (raw >= 12000) { return new BindingInput { Kind = BindingKind.GamepadDpad, Code = Mathf.Clamp(raw - 12000, 0, 3) }; } if (raw >= 11000) { return new BindingInput { Kind = BindingKind.GamepadButton, Code = Mathf.Clamp(raw - 11000, 0, 255) }; } if (raw >= 10000) { return new BindingInput { Kind = BindingKind.MouseButton, Code = Mathf.Clamp(raw - 10000, 0, 31) }; } if (raw >= 2000) { return new BindingInput { Kind = BindingKind.Key, Code = Mathf.Max(0, raw - 2000) }; } if (raw >= 1000) { return new BindingInput { Kind = BindingKind.Pov, Code = Mathf.Clamp(raw - 1000, 0, 3) }; } return new BindingInput { Kind = BindingKind.Button, Code = Mathf.Clamp(raw, 0, 127) }; } } public enum BindAction { InteractOk = 0, Back = 1, MapItems = 2, Pause = 3, Camera = 5, ResetVehicle = 6, Headlights = 7, Horn = 8, RadioPower = 9, RadioScanToggle = 10, RadioScanLeft = 11, RadioScanRight = 12, ToggleGearbox = 13, ShiftUp = 14, ShiftDown = 15, IgnitionToggle = 16, FreeCamSelect = 17, Clutch = 18, GearReverse = 19, GearNeutral = 20, Gear1 = 21, Gear2 = 22, Gear3 = 23, Gear4 = 24, Gear5 = 25, Gear6 = 26, Drive = 100, Brake = 101, Map = 102, Items = 103, Jobs = 104, SteerLeft = 105, SteerRight = 106, MoveUp = 111, MoveDown = 112, MoveLeft = 113, MoveRight = 114, LookUp = 115, LookDown = 116, LookLeft = 117, LookRight = 118, FreeCam = 107, CameraLookX = 108, CameraLookY = 109, SteerAxis = 110, IndicatorLeft = 119, IndicatorRight = 120, IndicatorHazards = 121 } public enum BindingLayer { Normal, Modified } public enum BindingKind { None, Button, Pov, Key, MouseButton, GamepadButton, GamepadDpad, GamepadAxis, WheelAxis, GamepadDpadAxis, WheelDpadAxis } public enum ShiftMode { Toggle, Hold } public struct BindingInput { public BindingKind Kind; public int Code; } public class BindsMenuWindow : MonoBehaviour { private struct BindingConflict { public BindingLayer Layer; public BindAction Action; } private enum Page { Bindings, BindingCapture, AxisCapture, SchemeSelect } private sealed class PageDef { public string Title; public BindAction[] Actions; } public const string FileName = "binds"; public const string ListenerName = "SebBindsMenu"; public const string ListenerData = "listener_SebBindsMenu"; private float _mouseYLock; private UIUtil _util; private WindowView _view; private Page _page = Page.SchemeSelect; private int _bindingsPageIndex; private BindingScheme _scheme; private BindAction _bindingCaptureAction; private BindingLayer _bindingCaptureLayer; private bool _isCapturingModifier; private bool _bindingCaptureMissingModifier; private float _axisCaptureEnterTime; private float _bindingCaptureEnterTime = -999f; private bool _bindingDupConfirmActive; private BindingInput _bindingDupPendingCaptured; private BindingLayer _bindingDupPendingLayer; private List _bindingDupConflicts; private string _bindingDupAxisConflict; private AxisAction _axisCaptureAction; private static readonly BindAction[] AllBindableActions = new BindAction[32] { BindAction.InteractOk, BindAction.Back, BindAction.Pause, BindAction.Drive, BindAction.Brake, BindAction.MapItems, BindAction.Jobs, BindAction.Camera, BindAction.ResetVehicle, BindAction.Headlights, BindAction.Horn, BindAction.CameraLookX, BindAction.CameraLookY, BindAction.RadioPower, BindAction.RadioScanRight, BindAction.RadioScanLeft, BindAction.RadioScanToggle, BindAction.FreeCam, BindAction.FreeCamSelect, BindAction.IgnitionToggle, BindAction.ToggleGearbox, BindAction.ShiftUp, BindAction.ShiftDown, BindAction.Clutch, BindAction.GearReverse, BindAction.GearNeutral, BindAction.Gear1, BindAction.Gear2, BindAction.Gear3, BindAction.Gear4, BindAction.Gear5, BindAction.Gear6 }; private static readonly BindAction[] RallyActions = new BindAction[3] { BindAction.Clutch, BindAction.ShiftUp, BindAction.ShiftDown }; private static readonly BindAction[] RallyGearActions = new BindAction[8] { BindAction.GearReverse, BindAction.GearNeutral, BindAction.Gear1, BindAction.Gear2, BindAction.Gear3, BindAction.Gear4, BindAction.Gear5, BindAction.Gear6 }; internal static float BindingCaptureHeartbeatTime { get; private set; } internal static int LastMenuActiveFrame { get; private set; } internal static int LastBindingCaptureFrame { get; private set; } internal static bool MenuActive { get { int frameCount = Time.frameCount; if (LastMenuActiveFrame != frameCount) { return LastMenuActiveFrame == frameCount - 1; } return true; } } internal static bool BindingCaptureActive { get { int frameCount = Time.frameCount; if (LastBindingCaptureFrame == frameCount || LastBindingCaptureFrame == frameCount - 1) { return true; } return Time.unscaledTime - BindingCaptureHeartbeatTime < 0.5f; } } public void FrameUpdate(WindowView view) { //IL_0076: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) LastMenuActiveFrame = Time.frameCount; if (_page == Page.BindingCapture) { LastBindingCaptureFrame = Time.frameCount; } if (view != null) { _view = view; if (_util == null) { _util = new UIUtil(); } _util.M = view.M; _util.R = view.R; _util.Nav = view.M.nav; Rect p = default(Rect); ((Rect)(ref p))..ctor(view.position * 8f, view.size * 8f); ((Rect)(ref p)).position = ((Rect)(ref p)).position + new Vector2(8f, 8f); if (((ScreenProgram)_util.M).mouseButtonUp) { _mouseYLock = 0f; } if (_mouseYLock > 0f) { ((ScreenProgram)_util.M).mouse.y = _mouseYLock; } DrawMenu(p); } } public void BackButtonPressed() { if (_page == Page.BindingCapture) { _bindingDupConfirmActive = false; _page = Page.Bindings; return; } if (_page == Page.AxisCapture) { _page = Page.Bindings; return; } if (_page == Page.Bindings) { _page = Page.SchemeSelect; return; } DesktopAppLauncher.TryOpenProgramListener(_util?.M, _util?.R, SebCoreMenuWindow.FileName, "listener_SebCoreMenu"); WindowView view = _view; if (view != null) { view.Kill(); } } private void DrawMenu(Rect p) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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) float center = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f - 16f; float y = ((Rect)(ref p)).y + 10f; float line = 12f; float sectionGap = 4f; if (_page == Page.SchemeSelect) { DrawSchemeSelect(p, center, ref y, line, sectionGap); } else if (_page == Page.BindingCapture) { Plugin.LogDebug("Binding capture open: " + BindingStore.GetActionLabel(_bindingCaptureAction) + " (" + LayerLabel(_bindingCaptureLayer) + ")"); DrawBindingCapture(p, center, ref y, line, sectionGap); } else if (_page == Page.AxisCapture) { Plugin.LogDebug("Axis capture open: " + _axisCaptureAction); DrawAxisCapture(p, center, ref y, line, sectionGap); } else { DrawBindings(p, center, ref y, line, sectionGap); } } private void DrawSchemeSelect(Rect p, float center, ref float y, float line, float sectionGap) { float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; bool flag = WheelInterop.IsWheelPluginPresent(); float num2 = ((Rect)(ref p)).y + ((Rect)(ref p)).height / 2f - 20f; if (flag) { num2 -= 12f; } _util.Label("Binds", num, ((Rect)(ref p)).y + 10f); _util.Label("Choose Input", num, ((Rect)(ref p)).y + 22f); if (_util.FancyButton("Controller", num, num2, 0f)) { _scheme = BindingScheme.Controller; _bindingsPageIndex = 0; _page = Page.Bindings; return; } if (_util.FancyButton("Keyboard", num, num2 + 24f, 0f)) { _scheme = BindingScheme.Keyboard; _bindingsPageIndex = 0; _page = Page.Bindings; return; } if (flag && _util.FancyButton("Wheel", num, num2 + 48f, 0f)) { _scheme = BindingScheme.Wheel; _bindingsPageIndex = 0; _page = Page.Bindings; return; } float num3 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 18f; if (_util.SimpleButtonRaw("Back", num, num3)) { DesktopAppLauncher.TryOpenProgramListener(_util.M, _util.R, SebCoreMenuWindow.FileName, "listener_SebCoreMenu"); WindowView view = _view; if (view != null) { view.Kill(); } } } private void DrawBindings(Rect p, float center, ref float y, float line, float sectionGap) { //IL_008f: 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_025b: Unknown result type (might be due to invalid IL or missing references) _util.Label("Binds", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); y += line; string text = ((_scheme == BindingScheme.Keyboard) ? "Keyboard" : ((_scheme == BindingScheme.Wheel) ? "Wheel" : "Controller")); _util.Label(text, ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); y += line; if (_scheme == BindingScheme.Wheel && !WheelInterop.HasCalibration()) { DrawWheelNeedsCalibration(p, center, ref y, line, sectionGap); return; } float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; float num2 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 18f; float num3 = ((Rect)(ref p)).x + 40f; float num4 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 40f; List pagesForScheme = GetPagesForScheme(); if (_util.SimpleButtonRaw("Prev", num3, num2)) { _bindingsPageIndex = PrevPageIndex(_bindingsPageIndex, pagesForScheme.Count); } if (_util.SimpleButtonRaw("Back", num, num2)) { _page = Page.SchemeSelect; } if (_util.SimpleButtonRaw("Next", num4, num2)) { _bindingsPageIndex = NextPageIndex(_bindingsPageIndex, pagesForScheme.Count); } y += sectionGap; if (pagesForScheme.Count == 0) { _util.Label("(no pages)", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); return; } if (_bindingsPageIndex >= pagesForScheme.Count) { _bindingsPageIndex = 0; } PageDef pageDef = pagesForScheme[_bindingsPageIndex]; _util.Label(pageDef.Title, ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); y += line + sectionGap; _util.Label(_bindingsPageIndex + 1 + "/" + pagesForScheme.Count, ((Rect)(ref p)).x + ((Rect)(ref p)).width - 18f, ((Rect)(ref p)).y + 10f); if (pageDef.Actions == null) { DrawAxesPage(p, center, ref y, line, sectionGap); } else { DrawBindingsButtonsPage(p, center, ref y, line, pageDef.Title, pageDef.Actions); } } private void DrawWheelNeedsCalibration(Rect p, float center, ref float y, float line, float sectionGap) { float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; float num2 = ((Rect)(ref p)).y + ((Rect)(ref p)).height / 2f - 18f; _util.Label("Wheel Not Calibrated", num, num2); _util.Label("Run the Calibration Wizard", num, num2 + line); _util.Label("before binding wheel inputs.", num, num2 + line * 2f); float num3 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 18f; float num4 = num3 - 12f; if (_util.SimpleButtonRaw("Calibrate", num, num4)) { WheelInterop.RequestOpenCalibrationWizard(); TryOpenWheelMenuAndFocus(); } if (_util.SimpleButtonRaw("Back", num, num3)) { _page = Page.SchemeSelect; } } private bool TryOpenWheelMenuAndFocus() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) return CartridgeApps.TryOpen(_util?.M, _util?.R, CartridgeApps.Wheel); } private static List GetPages() { return new List(); } private List GetPagesForScheme() { List list; if (_scheme == BindingScheme.Controller) { list = new List(); list.Add(new PageDef { Title = "Axes", Actions = null }); list.Add(new PageDef { Title = "Global", Actions = new BindAction[6] { BindAction.InteractOk, BindAction.Back, BindAction.Pause, BindAction.MapItems, BindAction.Jobs, BindAction.ResetVehicle } }); list.Add(new PageDef { Title = "Vehicle", Actions = new BindAction[3] { BindAction.Camera, BindAction.Headlights, BindAction.Horn } }); list.Add(new PageDef { Title = "FreeCam", Actions = new BindAction[2] { BindAction.FreeCam, BindAction.FreeCamSelect } }); list.Add(new PageDef { Title = "Radio", Actions = new BindAction[4] { BindAction.RadioPower, BindAction.RadioScanRight, BindAction.RadioScanLeft, BindAction.RadioScanToggle } }); List list2 = list; list2.Insert(3, new PageDef { Title = "Rally", Actions = RallyActions }); list2.Insert(4, new PageDef { Title = "Rally Gears", Actions = RallyGearActions }); { foreach (SebBindsApi.Page item in SebBindsApi.GetExtraPagesSnapshot()) { if (item != null && !string.IsNullOrWhiteSpace(item.Title) && item.Actions != null) { list2.Add(new PageDef { Title = item.Title.Trim(), Actions = item.Actions }); } } return list2; } } if (_scheme == BindingScheme.Wheel) { list = new List(); list.Add(new PageDef { Title = "Axes", Actions = null }); list.Add(new PageDef { Title = "Global", Actions = new BindAction[6] { BindAction.InteractOk, BindAction.Back, BindAction.Pause, BindAction.MapItems, BindAction.Jobs, BindAction.ResetVehicle } }); list.Add(new PageDef { Title = "Vehicle", Actions = new BindAction[3] { BindAction.Camera, BindAction.Headlights, BindAction.Horn } }); list.Add(new PageDef { Title = "FreeCam", Actions = new BindAction[2] { BindAction.FreeCam, BindAction.FreeCamSelect } }); list.Add(new PageDef { Title = "Radio", Actions = new BindAction[4] { BindAction.RadioPower, BindAction.RadioScanRight, BindAction.RadioScanLeft, BindAction.RadioScanToggle } }); List list3 = list; list3.Insert(3, new PageDef { Title = "Rally", Actions = RallyActions }); list3.Insert(4, new PageDef { Title = "Rally Gears", Actions = RallyGearActions }); { foreach (SebBindsApi.Page item2 in SebBindsApi.GetExtraPagesSnapshot()) { if (item2 != null && !string.IsNullOrWhiteSpace(item2.Title) && item2.Actions != null) { list3.Add(new PageDef { Title = item2.Title.Trim(), Actions = item2.Actions }); } } return list3; } } list = new List(); list.Add(new PageDef { Title = "Global", Actions = new BindAction[6] { BindAction.InteractOk, BindAction.Back, BindAction.Pause, BindAction.MapItems, BindAction.Jobs, BindAction.ResetVehicle } }); list.Add(new PageDef { Title = "Movement", Actions = new BindAction[4] { BindAction.MoveUp, BindAction.MoveDown, BindAction.MoveLeft, BindAction.MoveRight } }); list.Add(new PageDef { Title = "Vehicle", Actions = new BindAction[7] { BindAction.SteerLeft, BindAction.SteerRight, BindAction.Drive, BindAction.Brake, BindAction.Camera, BindAction.Headlights, BindAction.Horn } }); list.Add(new PageDef { Title = "Camera", Actions = new BindAction[4] { BindAction.LookUp, BindAction.LookDown, BindAction.LookLeft, BindAction.LookRight } }); list.Add(new PageDef { Title = "FreeCam", Actions = new BindAction[2] { BindAction.FreeCam, BindAction.FreeCamSelect } }); list.Add(new PageDef { Title = "Radio", Actions = new BindAction[4] { BindAction.RadioPower, BindAction.RadioScanRight, BindAction.RadioScanLeft, BindAction.RadioScanToggle } }); List list4 = list; list4.Insert(3, new PageDef { Title = "Rally", Actions = RallyActions }); list4.Insert(4, new PageDef { Title = "Rally Gears", Actions = RallyGearActions }); foreach (SebBindsApi.Page item3 in SebBindsApi.GetExtraPagesSnapshot()) { if (item3 != null && !string.IsNullOrWhiteSpace(item3.Title) && item3.Actions != null) { list4.Add(new PageDef { Title = item3.Title.Trim(), Actions = item3.Actions }); } } return list4; } private void DrawBindingsButtonsPage(Rect p, float center, ref float y, float line, string title, BindAction[] actions) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; if (_util.CycleButtonRaw("Modifier", BindingStore.GetBindingLabel(BindingStore.GetModifierBinding(_scheme)), center, y)) { _bindingCaptureAction = BindAction.InteractOk; _bindingCaptureLayer = BindingLayer.Normal; _bindingDupConfirmActive = false; _page = Page.BindingCapture; _bindingCaptureEnterTime = Time.unscaledTime; _isCapturingModifier = true; _bindingCaptureMissingModifier = false; return; } y += line; if (string.Equals(title, "Rally", StringComparison.OrdinalIgnoreCase)) { ShiftMode shiftMode = SebBindsApi.GetShiftMode(); if (_util.CycleButtonRaw("Shift Mode", SebBindsApi.GetShiftModeLabel(shiftMode), center, y)) { SebBindsApi.SetShiftMode(SebBindsApi.NextShiftMode(shiftMode)); } y += line; } y += 3f; if (actions != null && actions.Length != 0) { DrawBindingTable(p, actions, ref y, line); } float num2 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 30f; if (_util.SimpleButtonRaw("Reset Defaults", num, num2)) { BindingStore.ClearScheme(_scheme); AxisBindingStore.ClearScheme(_scheme); if (_scheme == BindingScheme.Controller) { DefaultPreset.TryInstallFromInputManager(Plugin.LastInputManager, true, forceReinstall: true); AxisDefaults.EnsureControllerDefaults(); } else if (_scheme == BindingScheme.Keyboard) { KeyboardDefaults.EnsureDefaults(); } PlayerPrefs.Save(); } } private void DrawAxesPage(Rect p, float center, ref float y, float line, float sectionGap) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (_scheme == BindingScheme.Wheel) { DrawWheelAxesRedirect(p, center, ref y, line, sectionGap); return; } float num = ((Rect)(ref p)).x + 12f; float num2 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f; _util.R.fontOptions.alignment = (Alignment)0; _util.R.fput("Axis", num, y, 0f, 13f, 0f, -1); _util.R.fontOptions.alignment = (Alignment)2; _util.R.fput("Binding", num2, y, 0f, 13f, 0f, -1); y += line; DrawAxisRow(AxisAction.MoveY, "Move Up/Down", num, num2, y); y += line; DrawAxisRow(AxisAction.MoveX, "Move Left/Right", num, num2, y); y += line; DrawAxisRow(AxisAction.Steering, "Steering", num, num2, y); y += line; DrawAxisRow(AxisAction.Throttle, "Throttle", num, num2, y); y += line; DrawAxisRow(AxisAction.Brake, "Brake", num, num2, y); y += line; DrawAxisRow(AxisAction.Clutch, "Clutch", num, num2, y); y += line; DrawAxisRow(AxisAction.CameraLookX, "Cam Look X", num, num2, y); y += line; DrawAxisRow(AxisAction.CameraLookY, "Cam Look Y", num, num2, y); y += line + sectionGap; } private void DrawWheelAxesRedirect(Rect p, float center, ref float y, float line, float sectionGap) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; float num2 = ((Rect)(ref p)).y + ((Rect)(ref p)).height / 2f - 18f; _util.Label("Wheel Axes need to be set", num, num2); _util.Label("in the Wheel menu.", num, num2 + line); _ = ((Rect)(ref p)).y; _ = ((Rect)(ref p)).height; float num3 = num2 + line * 2f + 8f; if (_util.FancyButton("Open Wheel Menu", num, num3, 0f)) { WheelInterop.RequestOpenAxisMapping(); if (CartridgeApps.EnsureListener(_util.M, CartridgeApps.Wheel)) { DesktopAppLauncher.TryOpenProgramListener(_util.M, _util.R, "wheel", "listener_G920Menu"); } } } private void DrawAxisRow(AxisAction axis, string label, float labelX, float bindRight, float y) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) _util.R.fontOptions.alignment = (Alignment)0; _util.R.fput(label, labelX, y, 0f, 13f, 0f, -1); BindingInput axisBinding = AxisBindingStore.GetAxisBinding(_scheme, axis); string text = ((axisBinding.Kind == BindingKind.None) ? "[none]" : ("[" + BindingStore.GetBindingLabel(axisBinding) + "]")); if (axisBinding.Kind != BindingKind.None && HasAxisConflictMark(axis, axisBinding)) { text += " !"; } int num = 96; int num2 = (int)(bindRight - (float)num); int num3 = (int)y; if (_util.M.MouseOver(num2, num3, num, 8)) { ((ScreenProgram)_util.M).mouseIcon = 128; if (((ScreenProgram)_util.M).mouseButton) { ((ScreenProgram)_util.M).mouseIcon = 160; } if (((ScreenProgram)_util.M).mouseButtonUp) { _axisCaptureAction = axis; _page = Page.AxisCapture; _axisCaptureEnterTime = Time.unscaledTime; AxisCapture.BeginCaptureSession(_scheme); return; } } _util.R.fontOptions.alignment = (Alignment)2; _util.R.fput(text, bindRight, y, 0f, 13f, 0f, -1); } private bool HasAxisConflictMark(AxisAction axis, BindingInput input) { foreach (AxisAction value in Enum.GetValues(typeof(AxisAction))) { if (value != axis && (axis != AxisAction.Steering || value != AxisAction.MoveX) && (axis != AxisAction.MoveX || value != AxisAction.Steering)) { BindingInput axisBinding = AxisBindingStore.GetAxisBinding(_scheme, value); if (axisBinding.Kind != BindingKind.None && axisBinding.Kind == input.Kind && axisBinding.Code == input.Code) { return true; } } } return false; } private void DrawBindingTable(Rect p, BindAction[] actions, ref float y, float line) { //IL_004b: 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_00f7: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref p)).x + 12f; float num2 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 84f; float num3 = ((Rect)(ref p)).x + ((Rect)(ref p)).width - 12f; _util.R.fontOptions.alignment = (Alignment)0; _util.R.fput("Action", num, y, 0f, 13f, 0f, -1); _util.R.fontOptions.alignment = (Alignment)2; _util.R.fput("Press", num2, y, 0f, 13f, 0f, -1); _util.R.fput("Modif.", num3, y, 0f, 13f, 0f, -1); y += line; int num4 = 11; for (int i = 0; i < actions.Length && i < num4; i++) { BindAction action = actions[i]; DrawBindingRow(p, action, num, num2, num3, y); y += line; } } private void DrawBindingRow(Rect p, BindAction action, float labelX, float pressRight, float holdRight, float y) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) _util.R.fontOptions.alignment = (Alignment)0; _util.R.fput(BindingStore.GetActionLabel(action), labelX, y, 0f, 13f, 0f, -1); DrawBindingCell(action, BindingLayer.Normal, pressRight, y); DrawBindingCell(action, BindingLayer.Modified, holdRight, y); } private void DrawBindingCell(BindAction action, BindingLayer layer, float rightX, float y) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) if (!IsLayerSupported(action, layer)) { _util.R.fontOptions.alignment = (Alignment)2; _util.R.fput("n/a", rightX, y, 0f, 13f, 0f, -1); return; } BindingInput binding = BindingStore.GetBinding(_scheme, layer, action); string text = ((binding.Kind == BindingKind.None) ? "[none]" : ("[" + BindingStore.GetBindingLabel(binding) + "]")); int num = 72; int num2 = (int)(rightX - (float)num); int num3 = (int)y; if (_util.M.MouseOver(num2, num3, num, 8)) { ((ScreenProgram)_util.M).mouseIcon = 128; if (((ScreenProgram)_util.M).mouseButton) { ((ScreenProgram)_util.M).mouseIcon = 160; } if (((ScreenProgram)_util.M).mouseButtonUp) { _bindingCaptureAction = action; _bindingCaptureLayer = layer; _bindingDupConfirmActive = false; _page = Page.BindingCapture; _bindingCaptureEnterTime = Time.unscaledTime; _isCapturingModifier = false; _bindingCaptureMissingModifier = layer == BindingLayer.Modified && BindingStore.GetModifierBinding(_scheme).Kind == BindingKind.None; return; } } _util.R.fontOptions.alignment = (Alignment)2; _util.R.fput(text, rightX, y, 0f, 13f, 0f, -1); } private void DrawBindingCapture(Rect p, float center, ref float y, float line, float sectionGap) { BindingCaptureHeartbeatTime = Time.unscaledTime; _util.Label("Binds", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); y += line; string text = (_isCapturingModifier ? "Modifier" : (BindingStore.GetActionLabel(_bindingCaptureAction) + " (" + LayerLabel(_bindingCaptureLayer) + ")")); float num = ((Rect)(ref p)).y + ((Rect)(ref p)).height / 2f - 18f; float num2 = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; float num3 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 30f; float num4 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 18f; if (!_isCapturingModifier && _bindingCaptureLayer == BindingLayer.Modified && BindingStore.GetModifierBinding(_scheme).Kind == BindingKind.None) { _bindingCaptureMissingModifier = true; } bool flag = Time.unscaledTime - _bindingCaptureEnterTime > 0.25f; if (_bindingCaptureMissingModifier) { _util.Label("Please set a", num2, num); _util.Label("modifier button first!", num2, num + line); if (flag && _util.SimpleButtonRaw("Back", num2, num4)) { _bindingDupConfirmActive = false; _isCapturingModifier = false; _bindingCaptureMissingModifier = false; _page = Page.Bindings; } return; } bool flag2 = !_isCapturingModifier && _bindingCaptureLayer == BindingLayer.Modified; BindingInput input = (flag2 ? BindingStore.GetModifierBinding(_scheme) : default(BindingInput)); bool flag3 = !flag2 || BindingEvaluator.IsDown(input); if (flag2 && !flag3) { _util.Label("Hold modifier to bind:", num2, num); _util.Label(text, num2, num + line); _util.Label("Then press button.", num2, num + line * 2f); } else { _util.Label("Press a button for:", num2, num); _util.Label(text, num2, num + line); } if (_bindingDupConfirmActive) { bool flag4 = _bindingDupConflicts != null && _bindingDupConflicts.Count > 0; if (flag4) { _util.Label("Also used by:", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num + line * 4f); List dupConflictsTextLines = GetDupConflictsTextLines(_bindingDupConflicts, 28); float num5 = num + line * 5f; if (dupConflictsTextLines != null) { for (int i = 0; i < dupConflictsTextLines.Count; i++) { _util.Label(dupConflictsTextLines[i], ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num5 + line * (float)i); } num5 += line * (float)Mathf.Max(1, dupConflictsTextLines.Count); } } if (!string.IsNullOrWhiteSpace(_bindingDupAxisConflict)) { float num6 = num + line * 6f; if (flag4) { num6 = num + line * (5f + (float)Mathf.Max(1, GetDupConflictsTextLines(_bindingDupConflicts, 28)?.Count ?? 1)); } _util.Label(_bindingDupAxisConflict, ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num6); } if (flag4) { _util.Label("Enter=Keep Esc=Try", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num + line * 7f); } if (_scheme == BindingScheme.Keyboard) { Keyboard current = Keyboard.current; if (current != null) { if (current.enterKey != null && ((ButtonControl)current.enterKey).wasPressedThisFrame) { ApplyPendingBinding(replaceDuplicates: false); return; } if (current.escapeKey != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) { _bindingDupConfirmActive = false; _bindingDupAxisConflict = null; _bindingDupConflicts = null; return; } } } float num7 = num3 - 12f; float num8 = num3; float num9 = num4; if (flag && _util.SimpleButtonRaw("Keep Both", num2, num7)) { ApplyPendingBinding(replaceDuplicates: false); } else if (flag && _util.SimpleButtonRaw("Replace", num2, num8)) { ApplyPendingBinding(replaceDuplicates: true); } else if (flag && _util.SimpleButtonRaw("Try Another", num2, num9)) { _bindingDupConfirmActive = false; _bindingDupAxisConflict = null; _bindingDupConflicts = null; } return; } if (!_bindingDupConfirmActive) { if (flag && _util.SimpleButtonRaw("Clear", num2, num3)) { if (_isCapturingModifier) { BindingStore.SetModifierBinding(_scheme, new BindingInput { Kind = BindingKind.None, Code = 0 }); } else { BindingStore.SetBinding(_scheme, _bindingCaptureLayer, _bindingCaptureAction, new BindingInput { Kind = BindingKind.None, Code = 0 }); } _bindingDupConfirmActive = false; _isCapturingModifier = false; _bindingCaptureMissingModifier = false; _page = Page.Bindings; return; } if (flag && _util.SimpleButtonRaw("Cancel", num2, num4)) { _bindingDupConfirmActive = false; _isCapturingModifier = false; _bindingCaptureMissingModifier = false; _page = Page.Bindings; return; } } if ((flag2 && !flag3) || (flag && (Object)(object)_util.M != (Object)null && ((ScreenProgram)_util.M).mouseButton && (_util.M.MouseOver((int)num2 - 32, (int)num3, 64, 8) || _util.M.MouseOver((int)num2 - 32, (int)num4, 64, 8))) || !InputCapture.TryCaptureNextBinding(_scheme, _bindingCaptureAction, _bindingCaptureLayer, out var input2) || (flag2 && input2.Kind == input.Kind && input2.Code == input.Code)) { return; } if (_isCapturingModifier) { BindingStore.SetModifierBinding(_scheme, input2); _bindingDupConfirmActive = false; _isCapturingModifier = false; _bindingCaptureMissingModifier = false; _page = Page.Bindings; return; } BindingLayer bindingCaptureLayer = _bindingCaptureLayer; string axisConflictForButton = GetAxisConflictForButton(_bindingCaptureAction); if (TryFindDuplicateBindings(input2, _bindingCaptureAction, bindingCaptureLayer, out var conflicts) || !string.IsNullOrWhiteSpace(axisConflictForButton)) { _bindingDupConfirmActive = true; _bindingDupPendingCaptured = input2; _bindingDupPendingLayer = bindingCaptureLayer; _bindingDupConflicts = conflicts ?? new List(); _bindingDupAxisConflict = axisConflictForButton; } else { ApplyBindingNow(input2, bindingCaptureLayer); _bindingDupConfirmActive = false; _bindingDupAxisConflict = null; _isCapturingModifier = false; _page = Page.Bindings; } } private void DrawAxisCapture(Rect p, float center, ref float y, float line, float sectionGap) { BindingCaptureHeartbeatTime = Time.unscaledTime; _util.Label("Binds", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, y); y += line; float num = ((Rect)(ref p)).y + ((Rect)(ref p)).height / 2f - 18f; _util.Label("Move an axis for:", ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num); _util.Label(_axisCaptureAction.ToString(), ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f, num + line); float num2 = ((Rect)(ref p)).x + ((Rect)(ref p)).width / 2f; float num3 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 30f; float num4 = ((Rect)(ref p)).y + ((Rect)(ref p)).height - 18f; bool flag = Time.unscaledTime - _axisCaptureEnterTime > 0.25f; BindingInput input; BindingInput input2; if (flag && _util.SimpleButtonRaw("Clear", num2, num3)) { AxisBindingStore.ClearAxisBinding(_scheme, _axisCaptureAction); _page = Page.Bindings; } else if (flag && _util.SimpleButtonRaw("Cancel", num2, num4)) { _page = Page.Bindings; } else if (flag && AxisCapture.TryCaptureNextAxis(_scheme, out input)) { AxisBindingStore.SetAxisBinding(_scheme, _axisCaptureAction, input); _page = Page.Bindings; } else if (flag && InputCapture.TryCaptureNextBinding(_scheme, BindAction.InteractOk, BindingLayer.Normal, out input2)) { if (_scheme == BindingScheme.Wheel && input2.Kind == BindingKind.Pov) { int num5 = Mathf.Clamp(input2.Code, 0, 3); input2 = new BindingInput { Kind = BindingKind.WheelDpadAxis, Code = ((num5 != 1 && num5 != 3) ? 1 : 0) }; } AxisBindingStore.SetAxisBinding(_scheme, _axisCaptureAction, input2); _page = Page.Bindings; } } private void ApplyPendingBinding(bool replaceDuplicates) { if (!_bindingDupConfirmActive) { return; } if (replaceDuplicates && _bindingDupConflicts != null) { foreach (BindingConflict bindingDupConflict in _bindingDupConflicts) { BindingStore.SetBinding(_scheme, bindingDupConflict.Layer, bindingDupConflict.Action, new BindingInput { Kind = BindingKind.None, Code = 0 }); } } if (replaceDuplicates) { ClearAxisConflictForButton(_bindingCaptureAction); } ApplyBindingNow(_bindingDupPendingCaptured, _bindingDupPendingLayer); _bindingDupConfirmActive = false; _bindingDupAxisConflict = null; _isCapturingModifier = false; _page = Page.Bindings; } private void ClearAxisConflictForButton(BindAction action) { switch (action) { case BindAction.Drive: AxisBindingStore.ClearAxisBinding(_scheme, AxisAction.Throttle); break; case BindAction.Brake: AxisBindingStore.ClearAxisBinding(_scheme, AxisAction.Brake); break; case BindAction.SteerLeft: case BindAction.SteerRight: AxisBindingStore.ClearAxisBinding(_scheme, AxisAction.Steering); break; } } private string GetAxisConflictForButton(BindAction action) { if (action == BindAction.Drive && HasAxis(AxisAction.Throttle)) { return "Axis: Throttle"; } if (action == BindAction.Brake && HasAxis(AxisAction.Brake)) { return "Axis: Brake"; } if ((action == BindAction.SteerLeft || action == BindAction.SteerRight) && HasAxis(AxisAction.Steering)) { return "Axis: Steering"; } return null; bool HasAxis(AxisAction a) { return AxisBindingStore.GetAxisBinding(_scheme, a).Kind != BindingKind.None; } } private void ApplyBindingNow(BindingInput captured, BindingLayer targetLayer) { BindingStore.SetBinding(_scheme, targetLayer, _bindingCaptureAction, captured); } private static bool SameBinding(BindingInput a, BindingInput b) { if (a.Kind == b.Kind) { return a.Code == b.Code; } return false; } private bool TryFindDuplicateBindings(BindingInput captured, BindAction targetAction, BindingLayer targetLayer, out List conflicts) { conflicts = null; BindAction[] allBindableActions = AllBindableActions; foreach (BindAction bindAction in allBindableActions) { if (IsDuplicateAllowed(bindAction, targetAction) || bindAction == targetAction) { continue; } BindingInput binding = BindingStore.GetBinding(_scheme, targetLayer, bindAction); if (binding.Kind != BindingKind.None && SameBinding(binding, captured)) { if (conflicts == null) { conflicts = new List(); } conflicts.Add(new BindingConflict { Layer = targetLayer, Action = bindAction }); } } if (conflicts != null) { return conflicts.Count > 0; } return false; } private static bool IsDuplicateAllowed(BindAction a, BindAction b) { if (a == b) { return true; } if ((a == BindAction.Back && b == BindAction.Brake) || (a == BindAction.Brake && b == BindAction.Back)) { return true; } if ((a == BindAction.Camera && b == BindAction.FreeCam) || (a == BindAction.FreeCam && b == BindAction.Camera)) { return true; } if ((a == BindAction.InteractOk && b == BindAction.FreeCamSelect) || (a == BindAction.FreeCamSelect && b == BindAction.InteractOk)) { return true; } if ((a == BindAction.Horn && b == BindAction.ShiftUp) || (a == BindAction.ShiftUp && b == BindAction.Horn)) { return true; } if ((a == BindAction.MapItems && b == BindAction.ShiftDown) || (a == BindAction.ShiftDown && b == BindAction.MapItems)) { return true; } if ((a == BindAction.MoveUp && b == BindAction.Drive) || (a == BindAction.Drive && b == BindAction.MoveUp)) { return true; } if ((a == BindAction.MoveLeft && b == BindAction.SteerLeft) || (a == BindAction.SteerLeft && b == BindAction.MoveLeft)) { return true; } if ((a == BindAction.MoveRight && b == BindAction.SteerRight) || (a == BindAction.SteerRight && b == BindAction.MoveRight)) { return true; } return false; } private static List GetDupConflictsTextLines(List conflicts, int maxCharsPerLine) { if (conflicts == null || conflicts.Count == 0) { return null; } List list = new List(); for (int i = 0; i < conflicts.Count; i++) { string actionLabel = BindingStore.GetActionLabel(conflicts[i].Action); if (!string.IsNullOrWhiteSpace(actionLabel) && !list.Contains(actionLabel)) { list.Add(actionLabel); } } return WrapCommaList(list, maxCharsPerLine); } private static List WrapCommaList(List items, int maxCharsPerLine) { if (items == null || items.Count == 0) { return null; } maxCharsPerLine = Mathf.Max(8, maxCharsPerLine); List list = new List(); string text = string.Empty; for (int i = 0; i < items.Count; i++) { string text2 = TrimItem(items[i]); if (string.IsNullOrEmpty(text2)) { continue; } if (string.IsNullOrEmpty(text)) { text = text2; continue; } string text3 = text + ", " + text2; if (text3.Length > maxCharsPerLine) { list.Add(text); text = text2; } else { text = text3; } } if (!string.IsNullOrEmpty(text)) { list.Add(text); } return list; string TrimItem(string s) { s = (s ?? string.Empty).Trim(); if (s.Length <= maxCharsPerLine) { return s; } if (maxCharsPerLine <= 3) { return s.Substring(0, maxCharsPerLine); } return s.Substring(0, maxCharsPerLine - 3) + "..."; } } private static string LayerLabel(BindingLayer layer) { if (layer != BindingLayer.Normal) { return "Modif."; } return "Press"; } private static bool IsLayerSupported(BindAction action, BindingLayer layer) { return true; } private static int NextPageIndex(int index, int count) { if (count <= 0) { return 0; } int num = index + 1; if (num >= count) { num = 0; } return num; } private static int PrevPageIndex(int index, int count) { if (count <= 0) { return 0; } int num = index - 1; if (num < 0) { num = count - 1; } return num; } } public static class BindingEvaluator { private const float AxisPressThreshold = 0.35f; private static int _axisCacheFrame = -1; private static Gamepad _axisCacheGamepad; private static float _lt; private static float _rt; private static float _lsx; private static float _lsy; private static float _rsx; private static float _rsy; private static float _plt; private static float _prt; private static float _plsx; private static float _plsy; private static float _prsx; private static float _prsy; public static void BeginFrame() { int frameCount = Time.frameCount; Gamepad current = Gamepad.current; if (_axisCacheFrame != frameCount || _axisCacheGamepad != current) { _plt = _lt; _prt = _rt; _plsx = _lsx; _plsy = _lsy; _prsx = _rsx; _prsy = _rsy; _axisCacheGamepad = current; if (current == null) { _lt = (_rt = (_lsx = (_lsy = (_rsx = (_rsy = 0f))))); _axisCacheFrame = frameCount; return; } _lt = SafeReadAxis((InputControl)(object)current.leftTrigger); _rt = SafeReadAxis((InputControl)(object)current.rightTrigger); _lsx = SafeReadAxis((InputControl)(object)((Vector2Control)current.leftStick).x); _lsy = SafeReadAxis((InputControl)(object)((Vector2Control)current.leftStick).y); _rsx = SafeReadAxis((InputControl)(object)((Vector2Control)current.rightStick).x); _rsy = SafeReadAxis((InputControl)(object)((Vector2Control)current.rightStick).y); _axisCacheFrame = frameCount; } } private static float SafeReadAxis(InputControl c) { if (c == null) { return 0f; } try { return c.ReadValue(); } catch { return 0f; } } public static float GetAxisValue(BindingInput input) { //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_0054: 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_005a: 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_002d: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (input.Kind == BindingKind.GamepadDpadAxis) { Gamepad current = Gamepad.current; if (current == null) { return 0f; } Vector2 val = ((InputControl)(object)current.dpad).ReadValue(); if (input.Code != 0) { return val.y; } return val.x; } if (input.Kind == BindingKind.WheelDpadAxis) { if (!WheelInterop.TryGetPov8Vector(out var v)) { return 0f; } Vector2 val2 = -v; if (input.Code != 0) { return val2.y; } return val2.x; } if (input.Kind == BindingKind.WheelAxis) { return WheelInterop.GetWheelRawAxisValue(input.Code); } if (input.Kind != BindingKind.GamepadAxis) { return 0f; } BeginFrame(); return input.Code switch { 0 => _lt, 1 => _rt, 2 => _lsx, 3 => _lsy, 4 => _rsx, 5 => _rsy, _ => 0f, }; } private static float GetPrevAxisValue(BindingInput input) { if (input.Kind != BindingKind.GamepadAxis) { return 0f; } BeginFrame(); return input.Code switch { 0 => _plt, 1 => _prt, 2 => _plsx, 3 => _plsy, 4 => _prsx, 5 => _prsy, _ => 0f, }; } internal static float GetPrevAxisValueForCapture(BindingInput input) { return GetPrevAxisValue(input); } public static bool IsDown(BindingInput input) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (input.Kind == BindingKind.None) { return false; } if (input.Kind == BindingKind.Button || input.Kind == BindingKind.Pov) { return WheelInterop.IsBindingDownForCurrentFrame(input); } if (input.Kind == BindingKind.Key) { Keyboard current = Keyboard.current; if (current == null) { return false; } Key val = (Key)Mathf.Max(0, input.Code); if (current[val] != null) { return ((ButtonControl)current[val]).isPressed; } return false; } if (input.Kind == BindingKind.MouseButton) { Mouse current2 = Mouse.current; if (current2 == null) { return false; } return input.Code switch { 0 => current2.leftButton.isPressed, 1 => current2.rightButton.isPressed, 2 => current2.middleButton.isPressed, _ => false, }; } if (input.Kind == BindingKind.GamepadButton) { if (TryGetGamepadButtonControl(Gamepad.current, input.Code, out var control)) { return control.isPressed; } return false; } if (input.Kind == BindingKind.GamepadAxis) { return GetAxisValue(input) > 0.35f; } if (input.Kind == BindingKind.WheelAxis) { return Mathf.Abs(GetAxisValue(input)) > 0.35f; } if (input.Kind == BindingKind.WheelDpadAxis) { return Mathf.Abs(GetAxisValue(input)) > 0.35f; } if (input.Kind == BindingKind.GamepadDpad) { Gamepad current3 = Gamepad.current; if (current3 == null) { return false; } return Mathf.Clamp(input.Code, 0, 3) switch { 0 => current3.dpad.up.isPressed, 1 => current3.dpad.right.isPressed, 2 => current3.dpad.down.isPressed, _ => current3.dpad.left.isPressed, }; } return false; } public static bool WasPressedThisFrame(BindingInput input) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (input.Kind == BindingKind.None) { return false; } if (input.Kind == BindingKind.Button || input.Kind == BindingKind.Pov) { return WheelInterop.IsBindingPressedThisFrameForCurrentFrame(input); } if (input.Kind == BindingKind.Key) { Keyboard current = Keyboard.current; if (current == null) { return false; } Key val = (Key)Mathf.Max(0, input.Code); if (current[val] != null) { return ((ButtonControl)current[val]).wasPressedThisFrame; } return false; } if (input.Kind == BindingKind.MouseButton) { Mouse current2 = Mouse.current; if (current2 == null) { return false; } return input.Code switch { 0 => current2.leftButton.wasPressedThisFrame, 1 => current2.rightButton.wasPressedThisFrame, 2 => current2.middleButton.wasPressedThisFrame, _ => false, }; } if (input.Kind == BindingKind.GamepadButton) { if (TryGetGamepadButtonControl(Gamepad.current, input.Code, out var control)) { return control.wasPressedThisFrame; } return false; } if (input.Kind == BindingKind.GamepadAxis) { float prevAxisValue = GetPrevAxisValue(input); float axisValue = GetAxisValue(input); if (prevAxisValue <= 0.35f) { return axisValue > 0.35f; } return false; } if (input.Kind == BindingKind.GamepadDpad) { Gamepad current3 = Gamepad.current; if (current3 == null) { return false; } return Mathf.Clamp(input.Code, 0, 3) switch { 0 => current3.dpad.up.wasPressedThisFrame, 1 => current3.dpad.right.wasPressedThisFrame, 2 => current3.dpad.down.wasPressedThisFrame, _ => current3.dpad.left.wasPressedThisFrame, }; } if (input.Kind == BindingKind.GamepadAxis) { float prevAxisValue2 = GetPrevAxisValue(input); float axisValue2 = GetAxisValue(input); if (prevAxisValue2 <= 0.35f) { return axisValue2 > 0.35f; } return false; } return false; } public static bool WasReleasedThisFrame(BindingInput input) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) if (input.Kind == BindingKind.None) { return false; } if (input.Kind == BindingKind.Button || input.Kind == BindingKind.Pov) { return WheelInterop.IsBindingReleasedThisFrameForCurrentFrame(input); } if (input.Kind == BindingKind.Key) { Keyboard current = Keyboard.current; if (current == null) { return false; } Key val = (Key)Mathf.Max(0, input.Code); if (current[val] != null) { return ((ButtonControl)current[val]).wasReleasedThisFrame; } return false; } if (input.Kind == BindingKind.MouseButton) { Mouse current2 = Mouse.current; if (current2 == null) { return false; } return input.Code switch { 0 => current2.leftButton.wasReleasedThisFrame, 1 => current2.rightButton.wasReleasedThisFrame, 2 => current2.middleButton.wasReleasedThisFrame, _ => false, }; } if (input.Kind == BindingKind.GamepadButton) { if (TryGetGamepadButtonControl(Gamepad.current, input.Code, out var control)) { return control.wasReleasedThisFrame; } return false; } if (input.Kind == BindingKind.GamepadAxis) { float prevAxisValue = GetPrevAxisValue(input); float axisValue = GetAxisValue(input); if (prevAxisValue > 0.35f) { return axisValue <= 0.35f; } return false; } if (input.Kind == BindingKind.GamepadDpad) { Gamepad current3 = Gamepad.current; if (current3 == null) { return false; } return Mathf.Clamp(input.Code, 0, 3) switch { 0 => current3.dpad.up.wasReleasedThisFrame, 1 => current3.dpad.right.wasReleasedThisFrame, 2 => current3.dpad.down.wasReleasedThisFrame, _ => current3.dpad.left.wasReleasedThisFrame, }; } if (input.Kind == BindingKind.GamepadAxis) { float prevAxisValue2 = GetPrevAxisValue(input); float axisValue2 = GetAxisValue(input); if (prevAxisValue2 > 0.35f) { return axisValue2 <= 0.35f; } return false; } return false; } internal static bool TryGetGamepadButtonControl(Gamepad g, int code, out ButtonControl control) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_003a: Expected I4, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Invalid comparison between Unknown and I4 control = null; if (g == null) { return false; } GamepadButton val = (GamepadButton)code; switch (val - 4) { default: if ((int)val != 32) { if ((int)val == 33) { control = g.rightTrigger; return true; } return false; } control = g.leftTrigger; return true; case 2: control = g.buttonSouth; return true; case 0: control = g.buttonNorth; return true; case 3: control = g.buttonWest; return true; case 1: control = g.buttonEast; return true; case 8: control = g.startButton; return true; case 9: control = g.selectButton; return true; case 6: control = g.leftShoulder; return true; case 7: control = g.rightShoulder; return true; case 4: control = g.leftStickButton; return true; case 5: control = g.rightStickButton; return true; } } } internal static class DefaultPreset { private const string PrefKeyPresetInstalled = "SebBinds_PresetInstalled"; internal static bool IsInstalled() { return PlayerPrefs.GetInt("SebBinds_PresetInstalled", 0) != 0; } internal static void MarkInstalled() { PlayerPrefs.SetInt("SebBinds_PresetInstalled", 1); PlayerPrefs.Save(); } internal static bool TryInstallFromInputManager(sInputManager input) { return TryInstallFromInputManager(input, null, forceReinstall: false); } internal static bool TryInstallFromInputManager(sInputManager input, bool? forceOnController, bool forceReinstall) { if (!forceReinstall && IsInstalled()) { return false; } if ((Object)(object)input == (Object)null) { return false; } PlayerInput component = ((Component)input).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.actions == (Object)null) { return false; } bool flag; if (forceOnController.HasValue) { flag = forceOnController.Value; } else { flag = false; try { flag = input.OnController(); } catch { } } bool flag2 = false; flag2 |= SetFromActionIfUnset(component, flag, "Click", BindAction.InteractOk); flag2 |= SetFromActionIfUnset(component, flag, "Break", BindAction.Back); flag2 |= SetFromActionIfUnset(component, flag, "Pause", BindAction.Pause); flag2 |= SetFromActionIfUnset(component, flag, "Inventory", BindAction.MapItems); flag2 |= SetFromActionIfUnset(component, flag, "Map", BindAction.Jobs); flag2 |= SetFromActionIfUnset(component, flag, "ChangeCamera", BindAction.Camera); flag2 |= SetFromActionIfUnset(component, flag, "Reset", BindAction.ResetVehicle); flag2 |= SetFromActionIfUnset(component, flag, "Headlights", BindAction.Headlights); flag2 |= SetFromActionIfUnset(component, flag, "Horn", BindAction.Horn); if (TrySetRadioFromAction(component, flag)) { flag2 = true; } else if (flag) { flag2 |= SetIfUnset(BindAction.RadioScanToggle, new BindingInput { Kind = BindingKind.GamepadDpad, Code = 0 }); flag2 |= SetIfUnset(BindAction.RadioScanRight, new BindingInput { Kind = BindingKind.GamepadDpad, Code = 1 }); flag2 |= SetIfUnset(BindAction.RadioPower, new BindingInput { Kind = BindingKind.GamepadDpad, Code = 2 }); flag2 |= SetIfUnset(BindAction.RadioScanLeft, new BindingInput { Kind = BindingKind.GamepadDpad, Code = 3 }); } if (BindingStore.GetModifierBinding().Kind == BindingKind.None) { BindingStore.SetModifierBinding(new BindingInput { Kind = BindingKind.None, Code = 0 }); } if (flag2) { MarkInstalled(); return true; } return false; } private static bool IsUnset(BindAction action) { BindingInput binding = BindingStore.GetBinding(BindingLayer.Normal, action); BindingInput binding2 = BindingStore.GetBinding(BindingLayer.Modified, action); if (binding.Kind == BindingKind.None) { return binding2.Kind == BindingKind.None; } return false; } private static bool SetIfUnset(BindAction target, BindingInput input) { if (!IsUnset(target)) { return false; } BindingStore.SetBinding(BindingLayer.Normal, target, input); return true; } private static bool SetFromActionIfUnset(PlayerInput pi, bool onController, string actionName, BindAction target) { if (!IsUnset(target)) { return false; } if ((Object)(object)pi == (Object)null || (Object)(object)pi.actions == (Object)null) { return false; } InputAction val = pi.actions[actionName]; if (val == null) { return false; } if (TryPickBindingInput(val, onController, out var input)) { BindingStore.SetBinding(BindingLayer.Normal, target, input); return true; } return false; } private static bool TrySetRadioFromAction(PlayerInput pi, bool onController) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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) InputAction val = pi.actions["Radio"]; if (val == null) { return false; } bool flag = false; for (int i = 0; i < val.bindings.Count; i++) { InputBinding val2 = val.bindings[i]; if (!((InputBinding)(ref val2)).isPartOfComposite) { continue; } string effectivePath = ((InputBinding)(ref val2)).effectivePath; if (!string.IsNullOrWhiteSpace(effectivePath) && (!onController || effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) && (onController || effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase) || effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) && TryParsePathToInput(effectivePath, out var input)) { switch ((((InputBinding)(ref val2)).name ?? string.Empty).ToLowerInvariant()) { case "up": flag |= SetIfUnset(BindAction.RadioScanToggle, input); flag = true; break; case "right": flag |= SetIfUnset(BindAction.RadioScanRight, input); flag = true; break; case "down": flag |= SetIfUnset(BindAction.RadioPower, input); flag = true; break; case "left": flag |= SetIfUnset(BindAction.RadioScanLeft, input); flag = true; break; } } } return flag; } private static bool TryPickBindingInput(InputAction action, bool onController, out BindingInput input) { //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_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < action.bindings.Count; i++) { InputBinding val = action.bindings[i]; if (((InputBinding)(ref val)).isComposite || ((InputBinding)(ref val)).isPartOfComposite) { continue; } string effectivePath = ((InputBinding)(ref val)).effectivePath; if (string.IsNullOrWhiteSpace(effectivePath)) { continue; } if (onController) { if (!effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { continue; } } else if (!effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase) && !effectivePath.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { continue; } if (TryParsePathToInput(effectivePath, out input)) { return true; } } for (int j = 0; j < action.bindings.Count; j++) { InputBinding val2 = action.bindings[j]; if (!((InputBinding)(ref val2)).isComposite && !((InputBinding)(ref val2)).isPartOfComposite) { string effectivePath2 = ((InputBinding)(ref val2)).effectivePath; if (!string.IsNullOrWhiteSpace(effectivePath2) && TryParsePathToInput(effectivePath2, out input)) { return true; } } } input = default(BindingInput); return false; } private static bool TryParsePathToInput(string path, out BindingInput input) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected I4, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected I4, but got Unknown input = default(BindingInput); if (string.IsNullOrWhiteSpace(path)) { return false; } string text = path.Trim(); if (text.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { if (TryParseKeyName(text.Substring("/".Length), out var key)) { input = new BindingInput { Kind = BindingKind.Key, Code = (int)key }; return true; } return false; } if (text.StartsWith("/", StringComparison.OrdinalIgnoreCase)) { switch (text.Substring("/".Length).ToLowerInvariant()) { case "leftbutton": input = new BindingInput { Kind = BindingKind.MouseButton, Code = 0 }; return true; case "rightbutton": input = new BindingInput { Kind = BindingKind.MouseButton, Code = 1 }; return true; case "middlebutton": input = new BindingInput { Kind = BindingKind.MouseButton, Code = 2 }; return true; default: return false; } } if (LooksLikeGamepadPath(text) && text.IndexOf("/dpad/", StringComparison.OrdinalIgnoreCase) >= 0) { int code = text.Substring(text.IndexOf("/dpad/", StringComparison.OrdinalIgnoreCase) + "/dpad/".Length).ToLowerInvariant() switch { "up" => 0, "right" => 1, "down" => 2, _ => 3, }; input = new BindingInput { Kind = BindingKind.GamepadDpad, Code = code }; return true; } if (LooksLikeGamepadPath(text)) { int num = text.IndexOf(">/", StringComparison.Ordinal); if (num < 0) { return false; } if (TryParseGamepadButtonName(text.Substring(num + 2), out var button)) { input = new BindingInput { Kind = BindingKind.GamepadButton, Code = (int)button }; return true; } return false; } return false; } private static bool TryParseGamepadButtonName(string name, out GamepadButton button) { button = (GamepadButton)0; if (string.IsNullOrWhiteSpace(name)) { return false; } return name.Trim().ToLowerInvariant() switch { "buttonsouth" => Set((GamepadButton)6, out button), "buttoneast" => Set((GamepadButton)5, out button), "buttonwest" => Set((GamepadButton)7, out button), "buttonnorth" => Set((GamepadButton)4, out button), "start" => Set((GamepadButton)12, out button), "select" => Set((GamepadButton)13, out button), "leftshoulder" => Set((GamepadButton)10, out button), "rightshoulder" => Set((GamepadButton)11, out button), "lefttrigger" => Set((GamepadButton)32, out button), "righttrigger" => Set((GamepadButton)33, out button), "leftstickpress" => Set((GamepadButton)8, out button), "rightstickpress" => Set((GamepadButton)9, out button), _ => false, }; } private static bool LooksLikeGamepadPath(string path) { if (string.IsNullOrWhiteSpace(path)) { return false; } int num = path.IndexOf('<'); int num2 = path.IndexOf('>'); if (num < 0 || num2 < 0 || num2 <= num) { return false; } string text = path.Substring(num + 1, num2 - num - 1); if (text.IndexOf("gamepad", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (string.Equals(text, "XInputController", StringComparison.OrdinalIgnoreCase)) { return true; } if (text.IndexOf("controller", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return false; } private static bool TryParseKeyName(string name, out Key key) { //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) key = (Key)0; if (string.IsNullOrWhiteSpace(name)) { return false; } string text = name.Trim(); string text2 = text.ToLowerInvariant(); switch (text2) { case "space": return Set((Key)1, out key); case "escape": case "esc": return Set((Key)60, out key); case "enter": case "return": return Set((Key)2, out key); case "tab": return Set((Key)3, out key); case "backspace": return Set((Key)65, out key); case "leftshift": return Set((Key)51, out key); case "rightshift": return Set((Key)52, out key); case "leftctrl": case "leftcontrol": return Set((Key)55, out key); case "rightctrl": case "rightcontrol": return Set((Key)56, out key); case "leftalt": return Set((Key)53, out key); case "rightalt": return Set((Key)54, out key); default: { if (text2.Length == 1 && text2[0] >= 'a' && text2[0] <= 'z' && Enum.TryParse(text2.ToUpperInvariant(), out Key result)) { return Set(result, out key); } if (text2.Length == 1 && text2[0] >= '0' && text2[0] <= '9' && Enum.TryParse("Digit" + text2, out Key result2)) { return Set(result2, out key); } switch (text2) { case "uparrow": return Set((Key)63, out key); case "downarrow": return Set((Key)64, out key); case "leftarrow": return Set((Key)61, out key); case "rightarrow": return Set((Key)62, out key); default: { if (text2.StartsWith("f", StringComparison.Ordinal) && text2.Length <= 3 && Enum.TryParse(text2.ToUpperInvariant(), out Key result3)) { return Set(result3, out key); } if (Enum.TryParse(text, ignoreCase: true, out Key result4)) { return Set(result4, out key); } return false; } } } } } private static bool Set(T v, out T output) { output = v; return true; } } internal static class InputCapture { internal static bool TryCaptureNextBinding(BindingScheme scheme, BindAction forAction, BindingLayer forLayer, out BindingInput input) { //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0118: Expected I4, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected I4, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected I4, but got Unknown if (scheme == BindingScheme.Wheel) { return WheelInterop.TryCaptureNextBinding(out input); } Gamepad current = Gamepad.current; if (scheme == BindingScheme.Controller && current != null) { BindingEvaluator.BeginFrame(); if (current.dpad.up.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.GamepadDpad, Code = 0 }; return true; } if (current.dpad.right.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.GamepadDpad, Code = 1 }; return true; } if (current.dpad.down.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.GamepadDpad, Code = 2 }; return true; } if (current.dpad.left.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.GamepadDpad, Code = 3 }; return true; } GamepadButton[] array = new GamepadButton[12]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); GamepadButton[] array2 = (GamepadButton[])(object)array; foreach (GamepadButton val in array2) { if (BindingEvaluator.TryGetGamepadButtonControl(current, (int)val, out var control) && control.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.GamepadButton, Code = (int)val }; return true; } } } Mouse current2 = Mouse.current; if (scheme == BindingScheme.Keyboard && current2 != null) { if (current2.leftButton.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.MouseButton, Code = 0 }; return true; } if (current2.rightButton.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.MouseButton, Code = 1 }; return true; } if (current2.middleButton.wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.MouseButton, Code = 2 }; return true; } } Keyboard current3 = Keyboard.current; if (scheme == BindingScheme.Keyboard && current3 != null) { Enumerator enumerator = current3.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current4 = enumerator.Current; if (current4 != null && ((ButtonControl)current4).wasPressedThisFrame) { input = new BindingInput { Kind = BindingKind.Key, Code = (int)current4.keyCode }; return true; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } input = default(BindingInput); return false; } } internal static class KeyboardDefaults { internal static void EnsureDefaults() { SetIfUnset(BindAction.InteractOk, new BindingInput { Kind = BindingKind.Key, Code = 19 }); SetIfUnset(BindAction.Back, new BindingInput { Kind = BindingKind.Key, Code = 1 }); SetIfUnset(BindAction.Brake, new BindingInput { Kind = BindingKind.Key, Code = 33 }); SetIfUnset(BindAction.MapItems, new BindingInput { Kind = BindingKind.Key, Code = 51 }); SetIfUnset(BindAction.Jobs, new BindingInput { Kind = BindingKind.Key, Code = 3 }); SetIfUnset(BindAction.Pause, new BindingInput { Kind = BindingKind.Key, Code = 60 }); SetIfUnset(BindAction.MoveUp, new BindingInput { Kind = BindingKind.Key, Code = 37 }); SetIfUnset(BindAction.MoveLeft, new BindingInput { Kind = BindingKind.Key, Code = 15 }); SetIfUnset(BindAction.MoveDown, new BindingInput { Kind = BindingKind.Key, Code = 33 }); SetIfUnset(BindAction.MoveRight, new BindingInput { Kind = BindingKind.Key, Code = 18 }); SetIfUnset(BindAction.SteerLeft, new BindingInput { Kind = BindingKind.Key, Code = 15 }); SetIfUnset(BindAction.SteerRight, new BindingInput { Kind = BindingKind.Key, Code = 18 }); SetIfUnset(BindAction.Drive, new BindingInput { Kind = BindingKind.Key, Code = 37 }); SetIfUnset(BindAction.Camera, new BindingInput { Kind = BindingKind.Key, Code = 17 }); SetIfUnset(BindAction.LookLeft, new BindingInput { Kind = BindingKind.Key, Code = 40 }); SetIfUnset(BindAction.LookRight, new BindingInput { Kind = BindingKind.Key, Code = 38 }); SetIfUnset(BindAction.ResetVehicle, new BindingInput { Kind = BindingKind.Key, Code = 32 }); SetIfUnset(BindAction.Headlights, new BindingInput { Kind = BindingKind.Key, Code = 22 }); SetIfUnset(BindAction.RadioPower, new BindingInput { Kind = BindingKind.Key, Code = 64 }); SetIfUnset(BindAction.RadioScanLeft, new BindingInput { Kind = BindingKind.Key, Code = 61 }); SetIfUnset(BindAction.RadioScanRight, new BindingInput { Kind = BindingKind.Key, Code = 62 }); SetIfUnset(BindAction.RadioScanToggle, new BindingInput { Kind = BindingKind.Key, Code = 63 }); SetIfUnset(BindAction.Horn, new BindingInput { Kind = BindingKind.Key, Code = 31 }); SetIfUnset(BindAction.IgnitionToggle, new BindingInput { Kind = BindingKind.Key, Code = 94 }); SetIfUnset(BindAction.IndicatorLeft, new BindingInput { Kind = BindingKind.Key, Code = 95 }); SetIfUnset(BindAction.IndicatorRight, new BindingInput { Kind = BindingKind.Key, Code = 96 }); SetIfUnset(BindAction.IndicatorHazards, new BindingInput { Kind = BindingKind.Key, Code = 97 }); SetIfUnset(BindAction.ShiftUp, new BindingInput { Kind = BindingKind.Key, Code = 80 }); SetIfUnset(BindAction.ShiftDown, new BindingInput { Kind = BindingKind.Key, Code = 81 }); SetIfUnset(BindAction.Clutch, new BindingInput { Kind = BindingKind.Key, Code = 84 }); SetIfUnset(BindAction.GearReverse, new BindingInput { Kind = BindingKind.Key, Code = 91 }); SetIfUnset(BindAction.GearNeutral, new BindingInput { Kind = BindingKind.Key, Code = 82 }); SetIfUnset(BindAction.Gear1, new BindingInput { Kind = BindingKind.Key, Code = 85 }); SetIfUnset(BindAction.Gear2, new BindingInput { Kind = BindingKind.Key, Code = 86 }); SetIfUnset(BindAction.Gear3, new BindingInput { Kind = BindingKind.Key, Code = 87 }); SetIfUnset(BindAction.Gear4, new BindingInput { Kind = BindingKind.Key, Code = 88 }); SetIfUnset(BindAction.Gear5, new BindingInput { Kind = BindingKind.Key, Code = 89 }); SetIfUnset(BindAction.Gear6, new BindingInput { Kind = BindingKind.Key, Code = 90 }); if (BindingStore.GetModifierBinding(BindingScheme.Keyboard).Kind == BindingKind.None) { BindingStore.SetModifierBinding(BindingScheme.Keyboard, new BindingInput { Kind = BindingKind.None, Code = 0 }); } } private static void SetIfUnset(BindAction action, BindingInput input) { BindingInput binding = BindingStore.GetBinding(BindingScheme.Keyboard, BindingLayer.Normal, action); BindingInput binding2 = BindingStore.GetBinding(BindingScheme.Keyboard, BindingLayer.Modified, action); if (binding.Kind == BindingKind.None && binding2.Kind == BindingKind.None) { BindingStore.SetBinding(BindingScheme.Keyboard, BindingLayer.Normal, action, input); } } } [BepInPlugin("shibe.easydeliveryco.sebbinds", "SebBinds", "1.1.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "shibe.easydeliveryco.sebbinds"; public const string PluginName = "SebBinds"; public const string PluginVersion = "1.1.4"; internal static ManualLogSource Log; internal static sInputManager LastInputManager; private static ConfigEntry _debugLogging; private static readonly BindingScheme[] SchemesControllerKeyboard = new BindingScheme[2] { BindingScheme.Controller, BindingScheme.Keyboard }; private static readonly BindingScheme[] SchemesControllerKeyboardWheel = new BindingScheme[3] { BindingScheme.Controller, BindingScheme.Keyboard, BindingScheme.Wheel }; private static int _defaultsEnsuredForInputInstanceId; private static float _resetHoldStart = -1f; private static bool _resetHoldFired; private static bool _resetHoldWasDown; private static bool _didMigrateLegacyBinds; private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //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: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _debugLogging = ((BaseUnityPlugin)this).Config.Bind("Logging", "debug_logging", false, "Log extra debug information."); Harmony val = new Harmony("shibe.easydeliveryco.sebbinds"); HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin), "SInputManager_Update_Postfix", (Type[])null) { priority = 0 }; val.Patch((MethodBase)AccessTools.Method(typeof(sInputManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(sRallyDriving), "CollectPlayerInput", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SRallyDriving_CollectPlayerInput_Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Loaded"); } internal static void LogDebug(string message) { if (_debugLogging != null && _debugLogging.Value) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[debug] " + message)); } } } private static bool IsRallyMenuActive() { try { return sEasyRallyToggle.active && sEasyRally.menuOpen; } catch { return false; } } private static void SInputManager_Update_Postfix(sInputManager __instance) { if ((Object)(object)__instance == (Object)null) { return; } LastInputManager = __instance; int num; try { num = ((Object)__instance).GetInstanceID(); } catch { num = 0; } if (_defaultsEnsuredForInputInstanceId != num) { _defaultsEnsuredForInputInstanceId = num; if (DefaultPreset.TryInstallFromInputManager(__instance)) { LogDebug("Installed default preset from game's InputActions"); } AxisDefaults.EnsureControllerDefaults(); KeyboardDefaults.EnsureDefaults(); if (!_didMigrateLegacyBinds) { _didMigrateLegacyBinds = true; MigrateLegacyBinds(); } } InjectBindings(__instance); } [HarmonyPatch(typeof(sInputManager), "ManualMode")] [HarmonyPostfix] private static void SInputManager_ManualMode_Postfix(sInputManager __instance) { if (!((Object)(object)__instance == (Object)null) && !PauseSystem.paused && !BindsMenuWindow.BindingCaptureActive) { bool flag = WheelInterop.IsWheelPluginPresent(); if (!flag || (!WheelInterop.IsWheelMenuActive() && !WheelInterop.IsWheelBindingCaptureActive() && !WheelInterop.IsWheelCalibrationWizardActive())) { BindingEvaluator.BeginFrame(); BindingScheme[] schemes = (flag ? SchemesControllerKeyboardWheel : SchemesControllerKeyboard); __instance.shiftUp = PressedAny(BindAction.ShiftUp, schemes); __instance.shiftDown = PressedAny(BindAction.ShiftDown, schemes); } } } private static void MigrateLegacyBinds() { BindingScheme[] array = (BindingScheme[])Enum.GetValues(typeof(BindingScheme)); foreach (BindingScheme scheme in array) { BindingLayer[] array2 = (BindingLayer[])Enum.GetValues(typeof(BindingLayer)); foreach (BindingLayer layer in array2) { if (BindingStore.GetBinding(scheme, layer, BindAction.Jobs).Kind == BindingKind.None) { BindingInput binding = BindingStore.GetBinding(scheme, layer, BindAction.Map); if (binding.Kind != BindingKind.None) { BindingStore.SetBinding(scheme, layer, BindAction.Jobs, binding); } } if (BindingStore.GetBinding(scheme, layer, BindAction.MapItems).Kind == BindingKind.None) { BindingInput binding2 = BindingStore.GetBinding(scheme, layer, BindAction.Items); if (binding2.Kind != BindingKind.None) { BindingStore.SetBinding(scheme, layer, BindAction.MapItems, binding2); } } } } } private static void InjectBindings(sInputManager input) { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0629: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_073a: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_06d5: Unknown result type (might be due to invalid IL or missing references) //IL_06da: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_06f7: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07ef: Unknown result type (might be due to invalid IL or missing references) //IL_0915: Unknown result type (might be due to invalid IL or missing references) //IL_0917: Unknown result type (might be due to invalid IL or missing references) //IL_0924: Unknown result type (might be due to invalid IL or missing references) //IL_0926: Unknown result type (might be due to invalid IL or missing references) //IL_0a33: Unknown result type (might be due to invalid IL or missing references) //IL_0a38: Unknown result type (might be due to invalid IL or missing references) //IL_0a97: Unknown result type (might be due to invalid IL or missing references) //IL_0a99: Unknown result type (might be due to invalid IL or missing references) //IL_0aa1: Unknown result type (might be due to invalid IL or missing references) //IL_0aa6: Unknown result type (might be due to invalid IL or missing references) //IL_0b32: Unknown result type (might be due to invalid IL or missing references) //IL_0b34: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)input == (Object)null) { return; } bool flag = WheelInterop.IsWheelPluginPresent(); bool num = flag && WheelInterop.IsWheelMenuActive(); bool flag2 = flag && WheelInterop.IsWheelBindingCaptureActive(); bool flag3 = flag && WheelInterop.IsWheelCalibrationWizardActive(); if (num) { return; } if (BindsMenuWindow.BindingCaptureActive) { input.selectPressed = false; input.selectReleased = false; input.backPressed = false; input.backReleased = false; input.pausePressed = false; input.mapPressed = false; input.inventoryPressed = false; input.inventoryReleased = false; input.inventoryHeld = false; input.cameraPressed = false; input.resetPressed = false; input.resetHeld = false; input.headlightsPressed = false; input.hornPressed = false; input.radioPressed = false; input.shiftUp = false; input.shiftDown = false; input.freeCamTogglePressed = false; input.freeCamSelectPressed = false; input.radioInput = Vector2.zero; input.mouseInput = Vector2.zero; input.driveInput = Vector2.zero; input.playerInput = Vector2.zero; input.cameraLook = Vector2.zero; return; } input.selectPressed = false; input.selectReleased = false; input.backPressed = false; input.backReleased = false; input.pausePressed = false; input.mapPressed = false; input.inventoryPressed = false; input.inventoryReleased = false; input.inventoryHeld = false; input.cameraPressed = false; input.resetPressed = false; input.resetHeld = false; input.headlightsPressed = false; input.hornPressed = false; input.radioPressed = false; input.shiftUp = false; input.shiftDown = false; input.freeCamTogglePressed = false; input.freeCamSelectPressed = false; input.radioInput = Vector2.zero; BindingEvaluator.BeginFrame(); BindingScheme[] schemes = (flag ? SchemesControllerKeyboardWheel : SchemesControllerKeyboard); BindingLayer ctrlLayer = BindingLayer.Normal; BindingLayer kbLayer = BindingLayer.Normal; BindingLayer wheelLayer = BindingLayer.Normal; BindingInput modifierBinding = BindingStore.GetModifierBinding(BindingScheme.Controller); if (modifierBinding.Kind != BindingKind.None && BindingEvaluator.IsDown(modifierBinding)) { ctrlLayer = BindingLayer.Modified; } BindingInput modifierBinding2 = BindingStore.GetModifierBinding(BindingScheme.Keyboard); if (modifierBinding2.Kind != BindingKind.None && BindingEvaluator.IsDown(modifierBinding2)) { kbLayer = BindingLayer.Modified; } if (flag) { BindingInput modifierBinding3 = BindingStore.GetModifierBinding(BindingScheme.Wheel); if (modifierBinding3.Kind != BindingKind.None && BindingEvaluator.IsDown(modifierBinding3)) { wheelLayer = BindingLayer.Modified; } } if (IsRallyMenuActive()) { ApplyRallyMenuBinds(input, DownAny, flag); return; } bool isWalking = false; if (flag) { WheelInterop.TryGetIsInWalkingMode(out isWalking); } float steer; float accel; bool flag4 = flag && WheelInterop.TryGetWheelLastInput(out steer, out accel); if (PauseSystem.paused && !BindsMenuWindow.BindingCaptureActive && !flag2 && !flag3 && WheelInterop.TryGetPov8Vector(out var v)) { Vector2 val = -v; if (val != Vector2.zero && ((Vector2)(ref input.mouseInput)).sqrMagnitude < 0.0001f) { if (Mathf.Abs(val.x) > 0.1f && Mathf.Abs(val.y) > 0.1f) { ((Vector2)(ref val)).Normalize(); } input.mouseInput = val; } if (val != Vector2.zero && ((Vector2)(ref input.radioInput)).sqrMagnitude < 0.0001f) { input.radioInput = val; } } if (isWalking && !PauseSystem.paused && !input.lockInput && WheelInterop.TryGetPov8Vector(out var v2)) { Vector2 val2 = -v2; if (val2 != Vector2.zero && ((Vector2)(ref input.playerInput)).sqrMagnitude < 0.0001f) { input.playerInput = val2; } } if (!PauseSystem.paused && !input.lockInput) { BindingInput axisBinding = AxisBindingStore.GetAxisBinding(AxisAction.MoveX); BindingInput axisBinding2 = AxisBindingStore.GetAxisBinding(AxisAction.MoveY); if (axisBinding.Kind == BindingKind.GamepadAxis || axisBinding2.Kind == BindingKind.GamepadAxis) { float num2 = ((axisBinding.Kind == BindingKind.GamepadAxis) ? BindingEvaluator.GetAxisValue(axisBinding) : 0f); float num3 = ((axisBinding2.Kind == BindingKind.GamepadAxis) ? BindingEvaluator.GetAxisValue(axisBinding2) : 0f); if (Mathf.Abs(num2) > 0.05f || Mathf.Abs(num3) > 0.05f) { input.playerInput = new Vector2(num2, num3); } } } if (!PauseSystem.paused && !input.lockInput) { float num4 = 0f; float num5 = 0f; if (Down(GetBind(BindingScheme.Keyboard, BindAction.MoveRight))) { num4 += 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.MoveLeft))) { num4 -= 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.MoveUp))) { num5 += 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.MoveDown))) { num5 -= 1f; } Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(num4, num5); if (((Vector2)(ref val3)).sqrMagnitude > 1f) { ((Vector2)(ref val3)).Normalize(); } if (val3 != Vector2.zero && ((Vector2)(ref input.playerInput)).sqrMagnitude < 0.0001f) { input.playerInput = val3; } } if (PressedAny(BindAction.Horn) || PressedAny(BindAction.ShiftUp)) { input.shiftUp = true; } if (PressedAny(BindAction.MapItems) || PressedAny(BindAction.Items) || PressedAny(BindAction.ShiftDown)) { input.shiftDown = true; } if (PressedAny(BindAction.Camera) || PressedAny(BindAction.FreeCam)) { input.freeCamTogglePressed = true; } if (PressedAny(BindAction.InteractOk) || PressedAny(BindAction.FreeCamSelect)) { input.freeCamSelectPressed = true; } if (input.lockInput) { return; } if (PressedAny(BindAction.InteractOk)) { input.selectPressed = true; } if (ReleasedAny(BindAction.InteractOk)) { input.selectReleased = true; } if (PressedAny(BindAction.Back)) { input.backPressed = true; } if (ReleasedAny(BindAction.Back)) { input.backReleased = true; } if (!PauseSystem.paused && !isWalking && DownAny(BindAction.Back)) { input.brakePressed = true; } if (!PauseSystem.paused && !flag4) { BindingInput axisBinding3 = AxisBindingStore.GetAxisBinding(AxisAction.Throttle); bool flag5 = false; if (axisBinding3.Kind == BindingKind.GamepadAxis) { float axisValue = BindingEvaluator.GetAxisValue(axisBinding3); if (axisValue > 0.05f) { Vector2 driveInput = input.driveInput; if (driveInput.y > -0.01f) { driveInput.y = Mathf.Max(driveInput.y, Mathf.Clamp01(axisValue)); } input.driveInput = driveInput; } flag5 = true; } if (!flag5 && DownAny(BindAction.Drive)) { Vector2 driveInput2 = input.driveInput; if (driveInput2.y > -0.01f) { driveInput2.y = Mathf.Max(driveInput2.y, 1f); } input.driveInput = driveInput2; } } if (!PauseSystem.paused && !isWalking && !flag4) { BindingInput axisBinding4 = AxisBindingStore.GetAxisBinding(AxisAction.Brake); bool flag6 = false; if (axisBinding4.Kind == BindingKind.GamepadAxis) { float axisValue2 = BindingEvaluator.GetAxisValue(axisBinding4); if (axisValue2 > 0.05f) { Vector2 driveInput3 = input.driveInput; driveInput3.y = Mathf.Min(driveInput3.y, 0f - Mathf.Clamp01(axisValue2)); input.driveInput = driveInput3; } flag6 = true; } if (!flag6 && DownAny(BindAction.Brake)) { Vector2 driveInput4 = input.driveInput; driveInput4.y = Mathf.Min(driveInput4.y, -1f); input.driveInput = driveInput4; } } if (!PauseSystem.paused && !flag4) { BindingInput axisBinding5 = AxisBindingStore.GetAxisBinding(AxisAction.Steering); bool flag7 = false; if (axisBinding5.Kind == BindingKind.GamepadAxis) { float axisValue3 = BindingEvaluator.GetAxisValue(axisBinding5); if (Mathf.Abs(axisValue3) > 0.05f) { Vector2 driveInput5 = input.driveInput; if (Mathf.Abs(driveInput5.x) < 0.15f) { driveInput5.x = Mathf.Clamp(axisValue3, -1f, 1f); input.driveInput = driveInput5; } } flag7 = true; } BindingInput b = GetBind(BindingScheme.Keyboard, BindAction.SteerLeft); BindingInput b2 = GetBind(BindingScheme.Keyboard, BindAction.SteerRight); float num6 = 0f; if (Down(b)) { num6 -= 1f; } if (Down(b2)) { num6 += 1f; } if (!flag7 && Mathf.Abs(num6) > 0.01f) { Vector2 driveInput6 = input.driveInput; if (Mathf.Abs(driveInput6.x) < 0.15f) { driveInput6.x = num6; input.driveInput = driveInput6; } } } if (!PauseSystem.paused) { BindingInput axisBinding6 = AxisBindingStore.GetAxisBinding(AxisAction.CameraLookX); BindingInput axisBinding7 = AxisBindingStore.GetAxisBinding(AxisAction.CameraLookY); if (axisBinding6.Kind == BindingKind.GamepadAxis) { float axisValue4 = BindingEvaluator.GetAxisValue(axisBinding6); if (Mathf.Abs(axisValue4) > 0.01f) { input.cameraLook.x = axisValue4; } } if (axisBinding7.Kind == BindingKind.GamepadAxis) { float axisValue5 = BindingEvaluator.GetAxisValue(axisBinding7); if (Mathf.Abs(axisValue5) > 0.01f) { input.cameraLook.y = axisValue5; } } if (((Vector2)(ref input.cameraLook)).sqrMagnitude < 0.0001f) { float num7 = 0f; float num8 = 0f; if (Down(GetBind(BindingScheme.Keyboard, BindAction.LookRight))) { num7 += 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.LookLeft))) { num7 -= 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.LookUp))) { num8 += 1f; } if (Down(GetBind(BindingScheme.Keyboard, BindAction.LookDown))) { num8 -= 1f; } Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(num7, num8); if (((Vector2)(ref val4)).sqrMagnitude > 1f) { ((Vector2)(ref val4)).Normalize(); } if (val4 != Vector2.zero) { input.cameraLook = val4; } } } if (PressedAny(BindAction.Pause)) { input.pausePressed = true; } if (Keyboard.current != null && Keyboard.current.escapeKey != null && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame) { input.pausePressed = true; } bool flag8 = AnyBindingExists(BindAction.Jobs); if ((!isWalking || PauseSystem.paused) && (PressedAny(BindAction.Jobs) || (!flag8 && PressedAny(BindAction.Map)))) { input.mapPressed = true; } BindAction action = (AnyBindingExists(BindAction.MapItems) ? BindAction.MapItems : (AnyBindingExists(BindAction.Items) ? BindAction.Items : BindAction.MapItems)); if (PressedAny(action)) { input.inventoryPressed = true; } if (ReleasedAny(action)) { input.inventoryReleased = true; } if (DownAny(action)) { input.inventoryHeld = true; } if (PressedAny(BindAction.Camera)) { input.cameraPressed = true; } ApplyHoldToReset(input, AnyBindingExists(BindAction.ResetVehicle), DownAny(BindAction.ResetVehicle), 0.6f); if (PressedAny(BindAction.Headlights)) { input.headlightsPressed = true; } if (PressedAny(BindAction.Horn)) { input.hornPressed = true; } Vector2 zero = Vector2.zero; if (DownAny(BindAction.RadioScanRight)) { zero.x = 1f; } else if (DownAny(BindAction.RadioScanLeft)) { zero.x = -1f; } if (DownAny(BindAction.RadioScanToggle)) { zero.y = 1f; } else if (DownAny(BindAction.RadioPower)) { zero.y = -1f; } input.radioInput = zero; bool flag9 = false; Vector2 zero2 = Vector2.zero; if (PressedAny(BindAction.RadioPower)) { flag9 = true; ((Vector2)(ref zero2))..ctor(0f, -1f); } else if (PressedAny(BindAction.RadioScanToggle)) { flag9 = true; ((Vector2)(ref zero2))..ctor(0f, 1f); } else if (PressedAny(BindAction.RadioScanRight)) { flag9 = true; ((Vector2)(ref zero2))..ctor(1f, 0f); } else if (PressedAny(BindAction.RadioScanLeft)) { flag9 = true; ((Vector2)(ref zero2))..ctor(-1f, 0f); } if (flag9) { input.radioPressed = true; input.radioInput = zero2; } bool AnyBindingExists(BindAction action2) { for (int i = 0; i < schemes.Length; i++) { BindingInput binding = BindingStore.GetBinding(schemes[i], BindingLayer.Normal, action2); BindingInput binding2 = BindingStore.GetBinding(schemes[i], BindingLayer.Modified, action2); if (binding.Kind != BindingKind.None || binding2.Kind != BindingKind.None) { return true; } } return false; } static bool Down(BindingInput input2) { if (input2.Kind != BindingKind.None) { return BindingEvaluator.IsDown(input2); } return false; } bool DownAny(BindAction action2) { for (int i = 0; i < schemes.Length; i++) { if (Down(GetBind(schemes[i], action2))) { return true; } } return false; } BindingInput GetBind(BindingScheme s, BindAction action2) { BindingLayer layer = LayerFor(s); return BindingStore.GetBinding(s, layer, action2); } BindingLayer LayerFor(BindingScheme s) { return s switch { BindingScheme.Wheel => wheelLayer, BindingScheme.Keyboard => kbLayer, _ => ctrlLayer, }; } static bool Pressed(BindingInput input2) { if (input2.Kind != BindingKind.None) { return BindingEvaluator.WasPressedThisFrame(input2); } return false; } bool PressedAny(BindAction action2) { for (int i = 0; i < schemes.Length; i++) { if (Pressed(GetBind(schemes[i], action2))) { return true; } } return false; } static bool Released(BindingInput input2) { if (input2.Kind != BindingKind.None) { return BindingEvaluator.WasReleasedThisFrame(input2); } return false; } bool ReleasedAny(BindAction action2) { for (int i = 0; i < schemes.Length; i++) { if (Released(GetBind(schemes[i], action2))) { return true; } } return false; } } private static void SRallyDriving_CollectPlayerInput_Postfix(sRallyDriving __instance) { if ((Object)(object)__instance == (Object)null || __instance.playerNumber < 0 || PauseSystem.paused || BindsMenuWindow.BindingCaptureActive) { return; } bool flag = WheelInterop.IsWheelPluginPresent(); if (flag && (WheelInterop.IsWheelMenuActive() || WheelInterop.IsWheelBindingCaptureActive() || WheelInterop.IsWheelCalibrationWizardActive())) { return; } if (IsRallyMenuActive()) { SuppressRallyDrivingInput(__instance); return; } BindingEvaluator.BeginFrame(); BindingScheme[] schemes = (flag ? SchemesControllerKeyboardWheel : SchemesControllerKeyboard); ApplyRallyClutch(__instance, schemes); if (__instance.automatic || (Object)(object)__instance.car == (Object)null || __instance.car.GuyActive || (Object)(object)__instance.gearbox == (Object)null) { return; } if (SebBindsApi.GetShiftMode() == ShiftMode.Hold) { ShiftRallyDirectGear(__instance, GetHeldDirectGear(schemes)); return; } if (PressedAny(BindAction.GearReverse, schemes)) { ShiftRallyDirectGear(__instance, -1); } if (PressedAny(BindAction.GearNeutral, schemes)) { ShiftRallyDirectGear(__instance, 0); } if (PressedAny(BindAction.Gear1, schemes)) { ShiftRallyDirectGear(__instance, 1); } if (PressedAny(BindAction.Gear2, schemes)) { ShiftRallyDirectGear(__instance, 2); } if (PressedAny(BindAction.Gear3, schemes)) { ShiftRallyDirectGear(__instance, 3); } if (PressedAny(BindAction.Gear4, schemes)) { ShiftRallyDirectGear(__instance, 4); } if (PressedAny(BindAction.Gear5, schemes)) { ShiftRallyDirectGear(__instance, 5); } if (PressedAny(BindAction.Gear6, schemes)) { ShiftRallyDirectGear(__instance, 6); } } private static int GetHeldDirectGear(BindingScheme[] schemes) { if (DownAny(BindAction.GearReverse, schemes)) { return -1; } if (DownAny(BindAction.GearNeutral, schemes)) { return 0; } if (DownAny(BindAction.Gear1, schemes)) { return 1; } if (DownAny(BindAction.Gear2, schemes)) { return 2; } if (DownAny(BindAction.Gear3, schemes)) { return 3; } if (DownAny(BindAction.Gear4, schemes)) { return 4; } if (DownAny(BindAction.Gear5, schemes)) { return 5; } if (DownAny(BindAction.Gear6, schemes)) { return 6; } return 0; } private static void ShiftRallyDirectGear(sRallyDriving rally, int displayGear) { if (!((Object)(object)rally == (Object)null) && !((Object)(object)rally.gearbox == (Object)null)) { int num = ((displayGear >= 0) ? (displayGear + 1) : 0); if (rally.gearbox.currentGear != num) { rally.gearbox.ShiftTo(num); } } } private static void ApplyRallyClutch(sRallyDriving rally, BindingScheme[] schemes) { bool flag = AnyBindingExists(BindAction.Clutch, schemes); bool flag2 = false; float num = (DownAny(BindAction.Clutch, schemes) ? 1f : 0f); for (int i = 0; i < schemes.Length; i++) { BindingInput axisBinding = AxisBindingStore.GetAxisBinding(schemes[i], AxisAction.Clutch); if (axisBinding.Kind != BindingKind.None) { flag2 = true; float num2 = BindingEvaluator.GetAxisValue(axisBinding); if (axisBinding.Kind == BindingKind.WheelAxis || axisBinding.Kind == BindingKind.WheelDpadAxis || axisBinding.Kind == BindingKind.GamepadDpadAxis) { num2 = Mathf.Abs(num2); } num = Mathf.Max(num, Mathf.Clamp01(num2)); } } if (flag || flag2) { rally.clutchInput = Mathf.MoveTowards(rally.clutchInput, num, Time.fixedDeltaTime * rally.clutchSensitivity); } } private static void SuppressRallyDrivingInput(sRallyDriving rally) { rally.throttleInputRaw = 0f; rally.throttleInput = 0f; rally.brakingInput = 0f; rally.steeringInputRaw = 0f; rally.steeringInput = 0f; rally.handbreakInput = false; rally.shiftUpInput = false; rally.shiftDownInput = false; rally.clutchInput = 0f; } private static void ApplyRallyMenuBinds(sInputManager input, Func downAny, bool wheelPluginPresent) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a1: 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) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) input.selectPressed = false; input.selectReleased = false; input.backPressed = false; input.backReleased = false; input.pausePressed = false; input.mapPressed = false; input.inventoryPressed = false; input.inventoryReleased = false; input.inventoryHeld = false; input.cameraPressed = false; input.resetPressed = false; input.resetHeld = false; input.headlightsPressed = false; input.hornPressed = false; input.radioPressed = false; input.shiftUp = false; input.shiftDown = false; input.freeCamTogglePressed = false; input.freeCamSelectPressed = false; input.radioInput = Vector2.zero; input.mouseInput = Vector2.zero; input.driveInput = Vector2.zero; input.playerInput = Vector2.zero; input.cameraLook = Vector2.zero; input.brakePressed = false; if (input.btn != null && input.pbtn != null && input.btnp != null) { bool up = input.pbtn.up; bool down = input.pbtn.down; bool left = input.pbtn.left; bool right = input.pbtn.right; bool a = input.pbtn.a; bool b = input.pbtn.b; bool start = input.pbtn.start; bool flag = input.pbtn.select; if (!input.menuInput) { up = input.btn.up; down = input.btn.down; left = input.btn.left; right = input.btn.right; a = input.btn.a; b = input.btn.b; start = input.btn.start; flag = input.btn.select; } bool flag2 = input.menuInput && input.btn.up; bool flag3 = input.menuInput && input.btn.down; bool flag4 = input.menuInput && input.btn.left; bool flag5 = input.menuInput && input.btn.right; bool flag6 = input.menuInput && input.btn.a; bool flag7 = input.menuInput && input.btn.b; bool flag8 = input.menuInput && input.btn.start; bool flag9 = input.menuInput && input.btn.select; flag4 |= downAny(BindAction.RadioScanLeft) || downAny(BindAction.MoveLeft) || downAny(BindAction.SteerLeft); flag5 |= downAny(BindAction.RadioScanRight) || downAny(BindAction.MoveRight) || downAny(BindAction.SteerRight); flag2 |= downAny(BindAction.RadioScanToggle) || downAny(BindAction.MoveUp); flag3 |= downAny(BindAction.RadioPower) || downAny(BindAction.MoveDown); flag6 |= downAny(BindAction.InteractOk) || downAny(BindAction.FreeCamSelect); flag7 |= downAny(BindAction.Back); flag8 |= downAny(BindAction.Pause); flag9 |= downAny(BindAction.Jobs) || downAny(BindAction.Map) || downAny(BindAction.MapItems); if (wheelPluginPresent && WheelInterop.TryGetPov8Vector(out var v)) { flag4 |= v.x < -0.25f; flag5 |= v.x > 0.25f; flag2 |= v.y > 0.25f; flag3 |= v.y < -0.25f; } input.btn.up = flag2; input.btn.down = flag3; input.btn.left = flag4; input.btn.right = flag5; input.btn.a = flag6; input.btn.b = flag7; input.btn.start = flag8; input.btn.select = flag9; input.pbtn.up = up; input.pbtn.down = down; input.pbtn.left = left; input.pbtn.right = right; input.pbtn.a = a; input.pbtn.b = b; input.pbtn.start = start; input.pbtn.select = flag; input.btnp.up = flag2 && !up; input.btnp.down = flag3 && !down; input.btnp.left = flag4 && !left; input.btnp.right = flag5 && !right; input.btnp.a = flag6 && !a; input.btnp.b = flag7 && !b; input.btnp.start = flag8 && !start; input.btnp.select = flag9 && !flag; } } private static BindingLayer GetActiveLayer(BindingScheme scheme) { BindingInput modifierBinding = BindingStore.GetModifierBinding(scheme); if (modifierBinding.Kind == BindingKind.None || !BindingEvaluator.IsDown(modifierBinding)) { return BindingLayer.Normal; } return BindingLayer.Modified; } private static bool AnyBindingExists(BindAction action, BindingScheme[] schemes) { for (int i = 0; i < schemes.Length; i++) { BindingInput binding = BindingStore.GetBinding(schemes[i], BindingLayer.Normal, action); BindingInput binding2 = BindingStore.GetBinding(schemes[i], BindingLayer.Modified, action); if (binding.Kind != BindingKind.None || binding2.Kind != BindingKind.None) { return true; } } return false; } private static bool DownAny(BindAction action, BindingScheme[] schemes) { for (int i = 0; i < schemes.Length; i++) { BindingInput binding = BindingStore.GetBinding(schemes[i], GetActiveLayer(schemes[i]), action); if (binding.Kind != BindingKind.None && BindingEvaluator.IsDown(binding)) { return true; } } return false; } private static bool PressedAny(BindAction action, BindingScheme[] schemes) { for (int i = 0; i < schemes.Length; i++) { BindingInput binding = BindingStore.GetBinding(schemes[i], GetActiveLayer(schemes[i]), action); if (binding.Kind != BindingKind.None && BindingEvaluator.WasPressedThisFrame(binding)) { return true; } } return false; } private static void ApplyHoldToReset(sInputManager input, bool isBound, bool isDown, float holdSeconds) { if ((Object)(object)input == (Object)null || !isBound) { _resetHoldStart = -1f; _resetHoldFired = false; _resetHoldWasDown = false; return; } if (isDown && !_resetHoldWasDown) { _resetHoldStart = Time.unscaledTime; _resetHoldFired = false; } if (isDown && !_resetHoldFired && _resetHoldStart >= 0f && Time.unscaledTime - _resetHoldStart >= holdSeconds) { input.resetHeld = true; input.resetPressed = true; _resetHoldFired = true; } if (!isDown) { _resetHoldStart = -1f; _resetHoldFired = false; } _resetHoldWasDown = isDown; } } public static class SebBindsApi { public sealed class Page { public string Id; public string Title; public BindAction[] Actions; } private static readonly object Sync = new object(); private static readonly List ExtraPages = new List(); private const string PrefKeyShiftMode = "SebBinds_ShiftMode"; private static readonly List AxisProviders = new List(); public static void RegisterActionsPage(string id, string title, params BindAction[] actions) { if (string.IsNullOrWhiteSpace(id)) { throw new ArgumentException("id is required", "id"); } if (string.IsNullOrWhiteSpace(title)) { throw new ArgumentException("title is required", "title"); } if (actions == null) { throw new ArgumentNullException("actions"); } Page page = new Page { Id = id.Trim(), Title = title.Trim(), Actions = actions }; lock (Sync) { for (int i = 0; i < ExtraPages.Count; i++) { if (string.Equals(ExtraPages[i].Id, page.Id, StringComparison.OrdinalIgnoreCase)) { ExtraPages[i] = page; return; } } ExtraPages.Add(page); } } public static ShiftMode GetShiftMode() { return (ShiftMode)Mathf.Clamp(PlayerPrefs.GetInt("SebBinds_ShiftMode", 0), 0, 1); } public static void SetShiftMode(ShiftMode mode) { PlayerPrefs.SetInt("SebBinds_ShiftMode", (int)mode); } public static ShiftMode NextShiftMode(ShiftMode mode) { if (mode != ShiftMode.Toggle) { return ShiftMode.Toggle; } return ShiftMode.Hold; } public static string GetShiftModeLabel(ShiftMode mode) { if (mode != ShiftMode.Hold) { return "Toggle"; } return "Hold"; } public static void RegisterAxisProvider(IAxisProvider provider) { if (provider == null) { throw new ArgumentNullException("provider"); } lock (Sync) { if (!AxisProviders.Contains(provider)) { AxisProviders.Add(provider); } } } internal static List GetAxisProvidersSnapshot() { lock (Sync) { return new List(AxisProviders); } } internal static List GetExtraPagesSnapshot() { lock (Sync) { return new List(ExtraPages); } } internal static bool HasExtraPage(string id) { if (string.IsNullOrWhiteSpace(id)) { return false; } lock (Sync) { for (int i = 0; i < ExtraPages.Count; i++) { if (string.Equals(ExtraPages[i].Id, id.Trim(), StringComparison.OrdinalIgnoreCase)) { return true; } } } return false; } } internal static class WheelInterop { private const string WheelPluginGuid = "shibe.easydeliveryco.seblogiwheel"; private static Type _wheelPluginType; private static Type _wheelBindingInputType; private static FieldInfo _wheelBindKindField; private static FieldInfo _wheelBindCodeField; private static MethodInfo _tryCaptureNextBinding; private static MethodInfo _isBindingDownForCurrentFrame; private static MethodInfo _isBindingPressedThisFrame; private static MethodInfo _isBindingReleasedThisFrame; private static MethodInfo _tryGetPov8Vector; private static MethodInfo _isWheelMenuActive; private static MethodInfo _isWheelBindingCaptureActive; private static MethodInfo _isWheelCalibrationWizardActive; private static MethodInfo _hasCalibration; private static MethodInfo _requestOpenCalibrationWizard; private static MethodInfo _requestOpenAxisMapping; private static MethodInfo _tryGetWheelLastInput; private static FieldInfo _isInWalkingModeField; private static MethodInfo _tryGetCachedWheelState; private static MethodInfo _getAxisValue; private static MethodInfo _getSteeringAxis; private static MethodInfo _getThrottleAxis; private static MethodInfo _getBrakeAxis; private static MethodInfo _getClutchAxis; private static MethodInfo _normalizeSteering; private static MethodInfo _normalizePedal; private static Type _axisIdType; private static readonly object[] _stateArgs = new object[1]; private static readonly object[] _axisArgs = new object[2]; private static readonly object[] _normSteerArgs = new object[1]; private static readonly object[] _normPedalArgs = new object[2]; private static readonly object[] _axisIdCache = new object[8]; private static object _tmpWheelBindingBoxed; private static readonly object[] _tmpWheelBindingArgs = new object[1]; private static void SetWheelBindingFields(object boxedWheelBindingInput, BindingInput input) { if (boxedWheelBindingInput != null && !(_wheelBindKindField == null) && !(_wheelBindCodeField == null)) { Type fieldType = _wheelBindKindField.FieldType; object value = ((!fieldType.IsEnum) ? Convert.ChangeType((int)input.Kind, fieldType) : Enum.ToObject(fieldType, (int)input.Kind)); _wheelBindKindField.SetValue(boxedWheelBindingInput, value); _wheelBindCodeField.SetValue(boxedWheelBindingInput, input.Code); } } private static Type GetWheelPluginType() { if (_wheelPluginType != null) { return _wheelPluginType; } if (!Chainloader.PluginInfos.TryGetValue("shibe.easydeliveryco.seblogiwheel", out var value) || value == null) { return null; } BaseUnityPlugin instance = value.Instance; _wheelPluginType = (((Object)(object)instance != (Object)null) ? ((object)instance).GetType() : null); return _wheelPluginType; } internal static bool IsWheelPluginPresent() { return Chainloader.PluginInfos.ContainsKey("shibe.easydeliveryco.seblogiwheel"); } private static bool EnsureWheelStateAccessors() { if (_tryGetCachedWheelState != null && _getAxisValue != null) { return true; } if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection()) { return false; } Type wheelPluginType = GetWheelPluginType(); if (wheelPluginType == null) { return false; } _tryGetCachedWheelState = wheelPluginType.GetMethod("TryGetCachedWheelState", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getAxisValue = wheelPluginType.GetMethod("GetAxisValue", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getSteeringAxis = wheelPluginType.GetMethod("GetSteeringAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getThrottleAxis = wheelPluginType.GetMethod("GetThrottleAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getBrakeAxis = wheelPluginType.GetMethod("GetBrakeAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _getClutchAxis = wheelPluginType.GetMethod("GetClutchAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _normalizeSteering = wheelPluginType.GetMethod("NormalizeSteering", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _normalizePedal = wheelPluginType.GetMethod("NormalizePedal", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (_getAxisValue != null) { try { _axisIdType = _getAxisValue.GetParameters()[1].ParameterType; } catch { _axisIdType = null; } } if (_tryGetCachedWheelState != null) { return _getAxisValue != null; } return false; } private static object GetAxisIdObject(int axisIdCode) { axisIdCode = Mathf.Clamp(axisIdCode, 0, 7); object obj = _axisIdCache[axisIdCode]; if (obj != null) { return obj; } object obj2 = ((!(_axisIdType != null) || !_axisIdType.IsEnum) ? ((object)axisIdCode) : Enum.ToObject(_axisIdType, axisIdCode)); _axisIdCache[axisIdCode] = obj2; return obj2; } private static bool EnsureWheelReflection() { Type wheelPluginType = GetWheelPluginType(); if (wheelPluginType == null) { return false; } if (_tryCaptureNextBinding != null && _isBindingDownForCurrentFrame != null && _isBindingPressedThisFrame != null && _isBindingReleasedThisFrame != null && _tryGetPov8Vector != null && _wheelBindingInputType != null) { return true; } _wheelBindingInputType = wheelPluginType.GetNestedType("BindingInput", BindingFlags.Public | BindingFlags.NonPublic); if (_wheelBindingInputType == null) { return false; } _wheelBindKindField = _wheelBindingInputType.GetField("Kind", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _wheelBindCodeField = _wheelBindingInputType.GetField("Code", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (_wheelBindKindField == null || _wheelBindCodeField == null) { return false; } _tryCaptureNextBinding = wheelPluginType.GetMethod("TryCaptureNextBinding", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isBindingDownForCurrentFrame = wheelPluginType.GetMethod("IsBindingDownForCurrentFrame", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isBindingPressedThisFrame = wheelPluginType.GetMethod("IsBindingPressedThisFrameForCurrentFrame", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isBindingReleasedThisFrame = wheelPluginType.GetMethod("IsBindingReleasedThisFrameForCurrentFrame", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _tryGetPov8Vector = wheelPluginType.GetMethod("TryGetPov8Vector", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _hasCalibration = wheelPluginType.GetMethod("HasCalibration", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _requestOpenCalibrationWizard = wheelPluginType.GetMethod("RequestOpenCalibrationWizard", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _requestOpenAxisMapping = wheelPluginType.GetMethod("RequestOpenAxisMapping", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _tryGetWheelLastInput = wheelPluginType.GetMethod("TryGetWheelLastInput", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isWheelMenuActive = wheelPluginType.GetMethod("IsWheelMenuActive", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isWheelBindingCaptureActive = wheelPluginType.GetMethod("IsBindingCaptureActive", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isWheelCalibrationWizardActive = wheelPluginType.GetMethod("IsCalibrationWizardActive", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _isInWalkingModeField = wheelPluginType.GetField("_isInWalkingMode", BindingFlags.Static | BindingFlags.NonPublic); if (_tryCaptureNextBinding != null && _isBindingDownForCurrentFrame != null && _isBindingPressedThisFrame != null && _isBindingReleasedThisFrame != null) { return _tryGetPov8Vector != null; } return false; } internal static bool HasCalibration() { if (!EnsureWheelReflection() || _hasCalibration == null) { return true; } try { return (bool)_hasCalibration.Invoke(null, null); } catch { return true; } } internal static void RequestOpenCalibrationWizard() { if (!EnsureWheelReflection() || _requestOpenCalibrationWizard == null) { return; } try { _requestOpenCalibrationWizard.Invoke(null, null); } catch { } } internal static void RequestOpenAxisMapping() { if (!EnsureWheelReflection() || _requestOpenAxisMapping == null) { return; } try { _requestOpenAxisMapping.Invoke(null, null); } catch { } } internal static float GetWheelAxisValue(int code) { try { if (!EnsureWheelStateAccessors() || _normalizeSteering == null || _normalizePedal == null) { return 0f; } _stateArgs[0] = null; bool flag; try { flag = (bool)_tryGetCachedWheelState.Invoke(null, _stateArgs); } catch { flag = false; } if (!flag || _stateArgs[0] == null) { return 0f; } object obj2 = _stateArgs[0]; MethodInfo methodInfo; switch (code) { case 0: { if (_getSteeringAxis == null) { return 0f; } object obj3 = _getSteeringAxis.Invoke(null, null); _axisArgs[0] = obj2; _axisArgs[1] = obj3; int num = (int)_getAxisValue.Invoke(null, _axisArgs); _normSteerArgs[0] = num; return (float)_normalizeSteering.Invoke(null, _normSteerArgs); } default: methodInfo = _getClutchAxis; break; case 2: methodInfo = _getBrakeAxis; break; case 1: methodInfo = _getThrottleAxis; break; } MethodInfo methodInfo2 = methodInfo; if (methodInfo2 == null) { return 0f; } object obj4 = methodInfo2.Invoke(null, null); _axisArgs[0] = obj2; _axisArgs[1] = obj4; int num2 = (int)_getAxisValue.Invoke(null, _axisArgs); int num3 = code switch { 2 => 1, 1 => 0, _ => 2, }; object obj5 = num3; try { _normPedalArgs[0] = num2; _normPedalArgs[1] = obj5; return (float)_normalizePedal.Invoke(null, _normPedalArgs); } catch { Type parameterType = _normalizePedal.GetParameters()[1].ParameterType; if (parameterType.IsEnum) { obj5 = Enum.ToObject(parameterType, num3); } _normPedalArgs[0] = num2; _normPedalArgs[1] = obj5; return (float)_normalizePedal.Invoke(null, _normPedalArgs); } } catch { return 0f; } } internal static float GetWheelRawAxisValue(int axisIdCode) { try { if (!EnsureWheelStateAccessors()) { return 0f; } _stateArgs[0] = null; bool flag; try { flag = (bool)_tryGetCachedWheelState.Invoke(null, _stateArgs); } catch { flag = false; } if (!flag || _stateArgs[0] == null) { return 0f; } object obj2 = _stateArgs[0]; object axisIdObject = GetAxisIdObject(axisIdCode); _axisArgs[0] = obj2; _axisArgs[1] = axisIdObject; return Mathf.Clamp(((float)(int)_getAxisValue.Invoke(null, _axisArgs) - 32767.5f) / 32767.5f, -1f, 1f); } catch { return 0f; } } internal static bool IsWheelMenuActive() { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection() || _isWheelMenuActive == null) { return false; } try { return (bool)_isWheelMenuActive.Invoke(null, null); } catch { return false; } } internal static bool IsWheelBindingCaptureActive() { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection() || _isWheelBindingCaptureActive == null) { return false; } try { return (bool)_isWheelBindingCaptureActive.Invoke(null, null); } catch { return false; } } internal static bool IsWheelCalibrationWizardActive() { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection() || _isWheelCalibrationWizardActive == null) { return false; } try { return (bool)_isWheelCalibrationWizardActive.Invoke(null, null); } catch { return false; } } internal static bool TryCaptureNextBinding(out BindingInput input) { input = default(BindingInput); if (!EnsureWheelReflection()) { return false; } object obj = Activator.CreateInstance(_wheelBindingInputType); object[] array = new object[1] { obj }; bool flag; try { flag = (bool)_tryCaptureNextBinding.Invoke(null, array); } catch { return false; } if (!flag) { return false; } if (array.Length < 1 || array[0] == null) { return false; } object obj3 = array[0]; int kind = (int)Convert.ChangeType(_wheelBindKindField.GetValue(obj3), typeof(int)); int code = (int)Convert.ChangeType(_wheelBindCodeField.GetValue(obj3), typeof(int)); input = new BindingInput { Kind = (BindingKind)kind, Code = code }; return true; } internal static bool IsBindingDownForCurrentFrame(BindingInput input) { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection()) { return false; } if (_tmpWheelBindingBoxed == null || _wheelBindingInputType == null || _tmpWheelBindingBoxed.GetType() != _wheelBindingInputType) { _tmpWheelBindingBoxed = Activator.CreateInstance(_wheelBindingInputType); } SetWheelBindingFields(_tmpWheelBindingBoxed, input); try { _tmpWheelBindingArgs[0] = _tmpWheelBindingBoxed; return (bool)_isBindingDownForCurrentFrame.Invoke(null, _tmpWheelBindingArgs); } catch { return false; } } internal static bool IsBindingPressedThisFrameForCurrentFrame(BindingInput input) { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection()) { return false; } if (_tmpWheelBindingBoxed == null || _wheelBindingInputType == null || _tmpWheelBindingBoxed.GetType() != _wheelBindingInputType) { _tmpWheelBindingBoxed = Activator.CreateInstance(_wheelBindingInputType); } SetWheelBindingFields(_tmpWheelBindingBoxed, input); try { _tmpWheelBindingArgs[0] = _tmpWheelBindingBoxed; return (bool)_isBindingPressedThisFrame.Invoke(null, _tmpWheelBindingArgs); } catch { return false; } } internal static bool IsBindingReleasedThisFrameForCurrentFrame(BindingInput input) { if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection()) { return false; } if (_tmpWheelBindingBoxed == null || _wheelBindingInputType == null || _tmpWheelBindingBoxed.GetType() != _wheelBindingInputType) { _tmpWheelBindingBoxed = Activator.CreateInstance(_wheelBindingInputType); } SetWheelBindingFields(_tmpWheelBindingBoxed, input); try { _tmpWheelBindingArgs[0] = _tmpWheelBindingBoxed; return (bool)_isBindingReleasedThisFrame.Invoke(null, _tmpWheelBindingArgs); } catch { return false; } } internal static bool TryGetPov8Vector(out Vector2 v) { //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_0026: 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_006b: 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) v = Vector2.zero; if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection()) { return false; } object[] array = new object[1] { v }; bool flag; try { flag = (bool)_tryGetPov8Vector.Invoke(null, array); } catch { return false; } if (!flag) { return false; } if (array.Length != 0 && array[0] is Vector2 val) { v = val; } return true; } internal static bool TryGetIsInWalkingMode(out bool isWalking) { isWalking = false; if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection() || _isInWalkingModeField == null) { return false; } try { if (_isInWalkingModeField.GetValue(null) is bool flag) { isWalking = flag; return true; } } catch { return false; } return false; } internal static bool TryGetWheelLastInput(out float steer, out float accel) { steer = 0f; accel = 0f; if (!IsWheelPluginPresent()) { return false; } if (!EnsureWheelReflection() || _tryGetWheelLastInput == null) { return false; } object[] array = new object[2] { 0f, 0f }; try { if (!(bool)_tryGetWheelLastInput.Invoke(null, array)) { return false; } if (array[0] is float num) { steer = num; } if (array[1] is float num2) { accel = num2; } return true; } catch { return false; } } } }