2020-10-03 20:19:44 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Explorer.Input;
|
2020-10-09 21:11:15 +11:00
|
|
|
|
#if CPP
|
|
|
|
|
using UnhollowerBaseLib;
|
|
|
|
|
#endif
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
|
|
|
|
namespace Explorer
|
|
|
|
|
{
|
|
|
|
|
public static class InputManager
|
|
|
|
|
{
|
2020-10-12 20:15:41 +11:00
|
|
|
|
private static IAbstractInput m_inputModule;
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
2020-10-12 20:15:41 +11:00
|
|
|
|
if (InputSystem.TKeyboard != null || (ReflectionHelpers.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
|
2020-10-03 20:19:44 +10:00
|
|
|
|
{
|
2020-10-12 20:15:41 +11:00
|
|
|
|
m_inputModule = new InputSystem();
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
2020-10-12 20:15:41 +11:00
|
|
|
|
else if (LegacyInput.TInput != null || (ReflectionHelpers.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
|
2020-10-03 20:19:44 +10:00
|
|
|
|
{
|
2020-10-12 20:15:41 +11:00
|
|
|
|
m_inputModule = new LegacyInput();
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
2020-10-08 06:15:42 +11:00
|
|
|
|
|
2020-10-12 20:15:41 +11:00
|
|
|
|
if (m_inputModule == null)
|
2020-10-03 20:19:44 +10:00
|
|
|
|
{
|
|
|
|
|
ExplorerCore.LogWarning("Could not find any Input module!");
|
2020-10-12 20:15:41 +11:00
|
|
|
|
m_inputModule = new NoInput();
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 20:15:41 +11:00
|
|
|
|
m_inputModule.Init();
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 20:15:41 +11:00
|
|
|
|
public static Vector3 MousePosition => m_inputModule.MousePosition;
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
2020-10-12 20:15:41 +11:00
|
|
|
|
public static bool GetKeyDown(KeyCode key) => m_inputModule.GetKeyDown(key);
|
|
|
|
|
public static bool GetKey(KeyCode key) => m_inputModule.GetKey(key);
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
2020-10-12 20:15:41 +11:00
|
|
|
|
public static bool GetMouseButtonDown(int btn) => m_inputModule.GetMouseButtonDown(btn);
|
|
|
|
|
public static bool GetMouseButton(int btn) => m_inputModule.GetMouseButton(btn);
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-11 20:49:14 +11:00
|
|
|
|
#if CPP
|
|
|
|
|
internal delegate void d_ResetInputAxes();
|
2020-10-11 22:57:46 +11:00
|
|
|
|
internal static d_ResetInputAxes ResetInputAxes_iCall =
|
2020-10-11 20:49:14 +11:00
|
|
|
|
IL2CPP.ResolveICall<d_ResetInputAxes>("UnityEngine.Input::ResetInputAxes");
|
|
|
|
|
|
|
|
|
|
public static void ResetInputAxes() => ResetInputAxes_iCall();
|
|
|
|
|
#else
|
|
|
|
|
public static void ResetInputAxes() => UnityEngine.Input.ResetInputAxes();
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
#if CPP
|
|
|
|
|
#pragma warning disable IDE1006
|
|
|
|
|
// public extern static string compositionString { get; }
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
internal delegate IntPtr d_get_compositionString();
|
|
|
|
|
internal static d_get_compositionString get_compositionString_iCall =
|
|
|
|
|
IL2CPP.ResolveICall<d_get_compositionString>("UnityEngine.Input::get_compositionString");
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
public static string compositionString => IL2CPP.Il2CppStringToManaged(get_compositionString_iCall());
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
// public extern static Vector2 compositionCursorPos { get; set; }
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
internal delegate void d_get_compositionCursorPos(out Vector2 ret);
|
|
|
|
|
internal static d_get_compositionCursorPos get_compositionCursorPos_iCall =
|
|
|
|
|
IL2CPP.ResolveICall<d_get_compositionCursorPos>("UnityEngine.Input::get_compositionCursorPos_Injected");
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
internal delegate void set_compositionCursorPos_delegate(ref Vector2 value);
|
|
|
|
|
internal static set_compositionCursorPos_delegate set_compositionCursorPos_iCall =
|
|
|
|
|
IL2CPP.ResolveICall<set_compositionCursorPos_delegate>("UnityEngine.Input::set_compositionCursorPos_Injected");
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
public static Vector2 compositionCursorPos
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
get_compositionCursorPos_iCall(out Vector2 ret);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
set => set_compositionCursorPos_iCall(ref value);
|
|
|
|
|
}
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-14 20:47:19 +11:00
|
|
|
|
#pragma warning restore IDE1006
|
|
|
|
|
#endif
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
2020-10-09 21:11:15 +11:00
|
|
|
|
}
|