Decompiled source of UnityExplorerInputFixer v1.0.0

Mods/UnityExplorerInputFixer.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppTMPro;
using MelonLoader;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityExplorerInputFixer;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "UnityExplorerInputFixer", "1.0.0", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("UnityExplorerInputFixer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnityExplorerInputFixer")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("F011DC61-2F5A-48D6-BD27-CCB86F4A35B8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UnityExplorerInputFixer;

public class Main : MelonMod
{
	[HarmonyPatch(typeof(Input), "GetKey", new Type[] { typeof(KeyCode) })]
	public static class Input_GetKey
	{
		private static bool Prefix(ref bool __result)
		{
			if (IsTyping())
			{
				__result = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Input), "GetKeyUp", new Type[] { typeof(KeyCode) })]
	public static class Input_GetKeyUp
	{
		private static bool Prefix(ref bool __result)
		{
			if (IsTyping())
			{
				__result = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Input), "get_anyKeyDown")]
	public static class Input_AnyKeyDown
	{
		private static bool Prefix(ref bool __result)
		{
			if (IsTyping())
			{
				__result = false;
				return false;
			}
			return true;
		}
	}

	public static bool IsTyping()
	{
		EventSystem current = EventSystem.current;
		if ((Object)(object)current == (Object)null)
		{
			return false;
		}
		GameObject currentSelectedGameObject = current.currentSelectedGameObject;
		if ((Object)(object)currentSelectedGameObject == (Object)null)
		{
			return false;
		}
		InputField component = currentSelectedGameObject.GetComponent<InputField>();
		if ((Object)(object)component != (Object)null && component.isFocused)
		{
			if (!Input.GetKeyDown((KeyCode)13) && !Input.GetKeyDown((KeyCode)271))
			{
				return true;
			}
			component.DeactivateInputField();
		}
		TMP_InputField component2 = currentSelectedGameObject.GetComponent<TMP_InputField>();
		if ((Object)(object)component2 != (Object)null && component2.isFocused)
		{
			if (!Input.GetKeyDown((KeyCode)13) && !Input.GetKeyDown((KeyCode)271))
			{
				return true;
			}
			component2.DeactivateInputField(false);
		}
		if (GUIUtility.hotControl != 0)
		{
			return true;
		}
		return false;
	}
}