DispatcherBase.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. using UnityEngine.EventSystems;
  8. namespace SC.XR.Unity.Module_InputSystem {
  9. public abstract class DispatcherBase : SCModule {
  10. public InputDevicePartDispatchEventBase inputDevicePartDispatchEventBase;
  11. public DispatcherBase(InputDevicePartDispatchEventBase inputDevicePartDispatchEventBase) {
  12. this.inputDevicePartDispatchEventBase = inputDevicePartDispatchEventBase;
  13. }
  14. /// <summary>
  15. /// When Any part Device of Any key Down will invoke this delegate
  16. /// </summary>
  17. /// <param name="keyCode">which key</param>
  18. /// <param name="part">which part,part.PartType</param>
  19. static event AnyKeyEventDelegate AnyKeyDownDelegate;
  20. /// <summary>
  21. /// When Any part Device of Any key Up will invoke this delegate
  22. /// </summary>
  23. /// <param name="keyCode">which key</param>
  24. /// <param name="part">which part,part.PartType</param>
  25. static event AnyKeyEventDelegate AnyKeyUpDelegate;
  26. /// <summary>
  27. /// When Any part Device of Any key Long will invoke this delegate
  28. /// </summary>
  29. /// <param name="keyCode">which key</param>
  30. /// <param name="part">which part,part.PartType</param>
  31. static event AnyKeyEventDelegate AnyKeyLongDelegate;
  32. public static void KeyDownDelegateInvoke(InputKeyCode keyCode,InputDevicePartBase inputDevicePart) {
  33. AnyKeyDownDelegate?.Invoke(keyCode, inputDevicePart);
  34. }
  35. public static void KeyUpDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  36. AnyKeyUpDelegate?.Invoke(keyCode, inputDevicePart);
  37. }
  38. public static void KeyLongDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  39. AnyKeyLongDelegate?.Invoke(keyCode, inputDevicePart);
  40. }
  41. public static void KeyDownDelegateRegister(AnyKeyEventDelegate keyDownEventDelegate) { AnyKeyDownDelegate += keyDownEventDelegate; }
  42. public static void KeyDownDelegateUnRegister(AnyKeyEventDelegate keyDownEventDelegate) { AnyKeyDownDelegate -= keyDownEventDelegate; }
  43. public static void KeyUpDelegateRegister(AnyKeyEventDelegate keyUpEventDelegate) { AnyKeyUpDelegate += keyUpEventDelegate; }
  44. public static void KeyUpDelegateUnRegister(AnyKeyEventDelegate keyUpEventDelegate) { AnyKeyUpDelegate -= keyUpEventDelegate; }
  45. public static void KeyLongDelegateRegister(AnyKeyEventDelegate keyLongEventDelegate) { AnyKeyLongDelegate += keyLongEventDelegate; }
  46. public static void KeyLongDelegateUnRegister(AnyKeyEventDelegate keyLongEventDelegate) { AnyKeyLongDelegate -= keyLongEventDelegate; }
  47. }
  48. }