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
|
|
|
|
|
{
|
|
|
|
|
private static AbstractInput inputModule;
|
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
|
|
|
|
|
{
|
|
|
|
|
inputModule = new InputSystem();
|
|
|
|
|
}
|
2020-10-09 21:11:15 +11:00
|
|
|
|
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.InputLegacyModule", LegacyInput.TInput))
|
2020-10-03 20:19:44 +10:00
|
|
|
|
{
|
|
|
|
|
inputModule = new LegacyInput();
|
|
|
|
|
}
|
2020-10-08 06:15:42 +11:00
|
|
|
|
|
2020-10-03 20:19:44 +10:00
|
|
|
|
if (inputModule == null)
|
|
|
|
|
{
|
|
|
|
|
ExplorerCore.LogWarning("Could not find any Input module!");
|
2020-10-07 16:20:34 +11:00
|
|
|
|
inputModule = new NoInput();
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-07 16:20:34 +11:00
|
|
|
|
inputModule.Init();
|
|
|
|
|
|
2020-10-03 20:19:44 +10:00
|
|
|
|
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-07 16:20:34 +11:00
|
|
|
|
public static Vector3 MousePosition => inputModule.MousePosition;
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
2020-10-07 16:20:34 +11:00
|
|
|
|
public static bool GetKeyDown(KeyCode key) => inputModule.GetKeyDown(key);
|
|
|
|
|
public static bool GetKey(KeyCode key) => inputModule.GetKey(key);
|
2020-10-03 20:19:44 +10:00
|
|
|
|
|
2020-10-07 16:20:34 +11:00
|
|
|
|
public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
|
|
|
|
|
public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
|
|
|
|
//#if CPP
|
|
|
|
|
//#pragma warning disable IDE1006
|
|
|
|
|
// // public extern static string compositionString { get; }
|
|
|
|
|
|
|
|
|
|
// internal delegate string get_compositionString_delegate();
|
|
|
|
|
// internal static get_compositionString_delegate get_compositionString_iCall =
|
|
|
|
|
// IL2CPP.ResolveICall<get_compositionString_delegate>("UnityEngine.Input::get_compositionString");
|
|
|
|
|
|
|
|
|
|
// public static string compositionString => get_compositionString_iCall();
|
|
|
|
|
|
|
|
|
|
// // public extern static Vector2 compositionCursorPos { get; set; }
|
|
|
|
|
|
|
|
|
|
// internal delegate Vector2 get_compositionCursorPos_delegate();
|
|
|
|
|
// internal static get_compositionCursorPos_delegate get_compositionCursorPos_iCall =
|
|
|
|
|
// IL2CPP.ResolveICall<get_compositionCursorPos_delegate>("UnityEngine.Input::get_compositionCursorPos");
|
|
|
|
|
|
|
|
|
|
// internal delegate void set_compositionCursorPos_delegate(Vector2 value);
|
|
|
|
|
// internal static set_compositionCursorPos_delegate set_compositionCursorPos_iCall =
|
|
|
|
|
// IL2CPP.ResolveICall<set_compositionCursorPos_delegate>("UnityEngine.Input::set_compositionCursorPos");
|
|
|
|
|
|
|
|
|
|
// public static Vector2 compositionCursorPos
|
|
|
|
|
// {
|
|
|
|
|
// get => get_compositionCursorPos_iCall();
|
|
|
|
|
// set => set_compositionCursorPos_iCall(value);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//#pragma warning restore IDE1006
|
|
|
|
|
//#endif
|
2020-10-03 20:19:44 +10:00
|
|
|
|
}
|
2020-10-09 21:11:15 +11:00
|
|
|
|
}
|