From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- Rewired/Rewired.Utils/ExternalTools.cs | 171 +++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 Rewired/Rewired.Utils/ExternalTools.cs (limited to 'Rewired/Rewired.Utils/ExternalTools.cs') diff --git a/Rewired/Rewired.Utils/ExternalTools.cs b/Rewired/Rewired.Utils/ExternalTools.cs new file mode 100644 index 0000000..d22fdd5 --- /dev/null +++ b/Rewired/Rewired.Utils/ExternalTools.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Rewired.Internal; +using Rewired.Utils.Interfaces; +using Rewired.Utils.Platforms.Windows; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.Windows; + +namespace Rewired.Utils; + +[EditorBrowsable(EditorBrowsableState.Never)] +public class ExternalTools : IExternalTools +{ + private static Func _getPlatformInitializerDelegate; + + private bool _isEditorPaused; + + private Action _EditorPausedStateChangedEvent; + + public static Func getPlatformInitializerDelegate + { + get + { + return _getPlatformInitializerDelegate; + } + set + { + _getPlatformInitializerDelegate = value; + } + } + + public bool isEditorPaused => _isEditorPaused; + + public bool UnityInput_IsTouchPressureSupported => UnityEngine.Input.touchPressureSupported; + + public event Action EditorPausedStateChangedEvent + { + add + { + _EditorPausedStateChangedEvent = (Action)Delegate.Combine(_EditorPausedStateChangedEvent, value); + } + remove + { + _EditorPausedStateChangedEvent = (Action)Delegate.Remove(_EditorPausedStateChangedEvent, value); + } + } + + public event Action XboxOneInput_OnGamepadStateChange; + + public void Destroy() + { + } + + public object GetPlatformInitializer() + { + return Main.GetPlatformInitializer(); + } + + public string GetFocusedEditorWindowTitle() + { + return string.Empty; + } + + public bool IsEditorSceneViewFocused() + { + return false; + } + + public bool LinuxInput_IsJoystickPreconfigured(string name) + { + return false; + } + + public int XboxOneInput_GetUserIdForGamepad(uint id) + { + return 0; + } + + public ulong XboxOneInput_GetControllerId(uint unityJoystickId) + { + return 0uL; + } + + public bool XboxOneInput_IsGamepadActive(uint unityJoystickId) + { + return false; + } + + public string XboxOneInput_GetControllerType(ulong xboxControllerId) + { + return string.Empty; + } + + public uint XboxOneInput_GetJoystickId(ulong xboxControllerId) + { + return 0u; + } + + public void XboxOne_Gamepad_UpdatePlugin() + { + } + + public bool XboxOne_Gamepad_SetGamepadVibration(ulong xboxOneJoystickId, float leftMotor, float rightMotor, float leftTriggerLevel, float rightTriggerLevel) + { + return false; + } + + public void XboxOne_Gamepad_PulseVibrateMotor(ulong xboxOneJoystickId, int motorInt, float startLevel, float endLevel, ulong durationMS) + { + } + + public void GetDeviceVIDPIDs(out List vids, out List pids) + { + vids = new List(); + pids = new List(); + } + + public int GetAndroidAPILevel() + { + return -1; + } + + public void WindowsStandalone_ForwardRawInput(IntPtr rawInputHeaderIndices, IntPtr rawInputDataIndices, uint indicesCount, IntPtr rawInputData, uint rawInputDataSize) + { + UnityEngine.Windows.Input.ForwardRawInput(rawInputHeaderIndices, rawInputDataIndices, indicesCount, rawInputData, rawInputDataSize); + } + + public bool UnityUI_Graphic_GetRaycastTarget(object graphic) + { + if (graphic as Graphic == null) + { + return false; + } + return (graphic as Graphic).raycastTarget; + } + + public void UnityUI_Graphic_SetRaycastTarget(object graphic, bool value) + { + if (!(graphic as Graphic == null)) + { + (graphic as Graphic).raycastTarget = value; + } + } + + public float UnityInput_GetTouchPressure(ref Touch touch) + { + return touch.pressure; + } + + public float UnityInput_GetTouchMaximumPossiblePressure(ref Touch touch) + { + return touch.maximumPossiblePressure; + } + + public IControllerTemplate CreateControllerTemplate(Guid typeGuid, object payload) + { + return ControllerTemplateFactory.Create(typeGuid, payload); + } + + public Type[] GetControllerTemplateTypes() + { + return ControllerTemplateFactory.templateTypes; + } + + public Type[] GetControllerTemplateInterfaceTypes() + { + return ControllerTemplateFactory.templateInterfaceTypes; + } +} -- cgit v1.1-26-g67d0