DispatcherBase.cs 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /// <summary>
  33. /// When Any part Device of Any key TouchEnter will invoke this delegate
  34. /// </summary>
  35. /// <param name="keyCode">which key</param>
  36. /// <param name="part">which part,part.PartType</param>
  37. static event AnyKeyEventDelegate AnyKeyTouchEnterDelegate;
  38. /// <summary>
  39. /// When Any part Device of Any key TouchExit will invoke this delegate
  40. /// </summary>
  41. /// <param name="keyCode">which key</param>
  42. /// <param name="part">which part,part.PartType</param>
  43. static event AnyKeyEventDelegate AnyKeyTouchExitDelegate;
  44. public static void KeyDownDelegateInvoke(InputKeyCode keyCode,InputDevicePartBase inputDevicePart) {
  45. AnyKeyDownDelegate?.Invoke(keyCode, inputDevicePart);
  46. }
  47. public static void KeyUpDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  48. AnyKeyUpDelegate?.Invoke(keyCode, inputDevicePart);
  49. }
  50. public static void KeyLongDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  51. AnyKeyLongDelegate?.Invoke(keyCode, inputDevicePart);
  52. }
  53. public static void KeyTouchEnterDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  54. AnyKeyTouchEnterDelegate?.Invoke(keyCode, inputDevicePart);
  55. }
  56. public static void KeyTouchExitDelegateInvoke(InputKeyCode keyCode, InputDevicePartBase inputDevicePart) {
  57. AnyKeyTouchExitDelegate?.Invoke(keyCode, inputDevicePart);
  58. }
  59. public static void KeyDownDelegateRegister(AnyKeyEventDelegate keyDownEventDelegate) { AnyKeyDownDelegate += keyDownEventDelegate; }
  60. public static void KeyDownDelegateUnRegister(AnyKeyEventDelegate keyDownEventDelegate) { AnyKeyDownDelegate -= keyDownEventDelegate; }
  61. public static void KeyUpDelegateRegister(AnyKeyEventDelegate keyUpEventDelegate) { AnyKeyUpDelegate += keyUpEventDelegate; }
  62. public static void KeyUpDelegateUnRegister(AnyKeyEventDelegate keyUpEventDelegate) { AnyKeyUpDelegate -= keyUpEventDelegate; }
  63. public static void KeyLongDelegateRegister(AnyKeyEventDelegate keyLongEventDelegate) { AnyKeyLongDelegate += keyLongEventDelegate; }
  64. public static void KeyLongDelegateUnRegister(AnyKeyEventDelegate keyLongEventDelegate) { AnyKeyLongDelegate -= keyLongEventDelegate; }
  65. public static void KeyTouchEnterDelegateRegister(AnyKeyEventDelegate keyTouchEnterEventDelegate) { AnyKeyTouchEnterDelegate += keyTouchEnterEventDelegate; }
  66. public static void KeyTouchEnterDelegateUnRegister(AnyKeyEventDelegate keyTouchEnterEventDelegate) { AnyKeyTouchEnterDelegate -= keyTouchEnterEventDelegate; }
  67. public static void KeyTouchExitDelegateRegister(AnyKeyEventDelegate keyTouchExitEventDelegate) { AnyKeyTouchExitDelegate += keyTouchExitEventDelegate; }
  68. public static void KeyTouchExitDelegateUnRegister(AnyKeyEventDelegate keyTouchExitEventDelegate) { AnyKeyTouchExitDelegate -= keyTouchExitEventDelegate; }
  69. }
  70. }