diff --git a/src/Core/Input/InputManager.cs b/src/Core/Input/InputManager.cs index 5234d75..6d0f11e 100644 --- a/src/Core/Input/InputManager.cs +++ b/src/Core/Input/InputManager.cs @@ -47,32 +47,43 @@ namespace UnityExplorer.Core.Input private static void InitHandler() { + // First, just try to use the legacy input, see if its working. + // The InputSystem package may be present but not actually activated, so we can find out this way. + + if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null)) + { + try + { + m_inputModule = new LegacyInput(); + CurrentType = InputType.Legacy; + + // make sure its working + GetKeyDown(KeyCode.F5); + + ExplorerCore.Log("Initialized Legacy Input support"); + return; + } + catch + { + // It's not working, we'll fall back to InputSystem. + } + } + if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null)) { try { m_inputModule = new InputSystem(); CurrentType = InputType.InputSystem; - - // make sure its working, the package may be present but not enabled. - GetKeyDown(KeyCode.F5); - + ExplorerCore.Log("Initialized new InputSystem support."); return; } - catch + catch (Exception ex) { - ExplorerCore.LogWarning("The InputSystem package was found but it does not seem to be working, defaulting to legacy Input..."); + ExplorerCore.Log(ex); } } - if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null)) - { - m_inputModule = new LegacyInput(); - CurrentType = InputType.Legacy; - - return; - } - ExplorerCore.LogWarning("Could not find any Input Module Type!"); m_inputModule = new NoInput(); CurrentType = InputType.None; diff --git a/src/Core/Input/InputSystem.cs b/src/Core/Input/InputSystem.cs index a7b0309..f961edb 100644 --- a/src/Core/Input/InputSystem.cs +++ b/src/Core/Input/InputSystem.cs @@ -12,8 +12,6 @@ namespace UnityExplorer.Core.Input { public InputSystem() { - ExplorerCore.Log("Initializing new InputSystem support..."); - m_kbCurrentProp = TKeyboard.GetProperty("current"); m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey }); diff --git a/src/Core/Input/LegacyInput.cs b/src/Core/Input/LegacyInput.cs index e6ded8f..c662fa2 100644 --- a/src/Core/Input/LegacyInput.cs +++ b/src/Core/Input/LegacyInput.cs @@ -10,8 +10,6 @@ namespace UnityExplorer.Core.Input { public LegacyInput() { - ExplorerCore.Log("Initializing Legacy Input support..."); - m_mousePositionProp = TInput.GetProperty("mousePosition"); m_mouseDeltaProp = TInput.GetProperty("mouseScrollDelta"); m_getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) });