BsScriptInput.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsScriptObject.h"
  4. #include "BsInputFwd.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Interop class between C++ & CLR for Input.
  9. */
  10. class BS_SCR_BE_EXPORT ScriptInput : public ScriptObject<ScriptInput>
  11. {
  12. public:
  13. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Input")
  14. /**
  15. * @brief Registers internal callbacks. Must be called on scripting system load.
  16. */
  17. static void startUp();
  18. /**
  19. * @brief Unregisters internal callbacks. Must be called on scripting system shutdown.
  20. */
  21. static void shutDown();
  22. private:
  23. ScriptInput(MonoObject* instance);
  24. /**
  25. * @brief Triggered when the specified button is pressed.
  26. */
  27. static void onButtonDown(const ButtonEvent& ev);
  28. /**
  29. * @brief Triggered when the specified button is released.
  30. */
  31. static void onButtonUp(const ButtonEvent& ev);
  32. /**
  33. * @brief Triggered when the specified character is entered.
  34. */
  35. static void onCharInput(const TextInputEvent& ev);
  36. /**
  37. * @brief Triggered when the pointer is moved.
  38. */
  39. static void onPointerMoved(const PointerEvent& ev);
  40. /**
  41. * @brief Triggered when a pointer button is pressed.
  42. */
  43. static void onPointerPressed(const PointerEvent& ev);
  44. /**
  45. * @brief Triggered when a pointer button is released.
  46. */
  47. static void onPointerReleased(const PointerEvent& ev);
  48. /**
  49. * @brief Triggered when a pointer button is double-clicked.
  50. */
  51. static void onPointerDoubleClick(const PointerEvent& ev);
  52. static HEvent OnButtonPressedConn;
  53. static HEvent OnButtonReleasedConn;
  54. static HEvent OnCharInputConn;
  55. static HEvent OnPointerPressedConn;
  56. static HEvent OnPointerReleasedConn;
  57. static HEvent OnPointerMovedConn;
  58. static HEvent OnPointerDoubleClickConn;
  59. /************************************************************************/
  60. /* CLR HOOKS */
  61. /************************************************************************/
  62. static bool internal_isButtonHeld(ButtonCode code, UINT32 deviceIdx);
  63. static bool internal_isButtonDown(ButtonCode code, UINT32 deviceIdx);
  64. static bool internal_isButtonUp(ButtonCode code, UINT32 deviceIdx);
  65. static bool internal_isPointerButtonHeld(PointerEventButton code);
  66. static bool internal_isPointerButtonDown(PointerEventButton code);
  67. static bool internal_isPointerButtonUp(PointerEventButton code);
  68. static bool internal_isPointerDoubleClicked();
  69. static float internal_getAxisValue(UINT32 axisType, UINT32 deviceIdx);
  70. static void internal_getPointerPosition(Vector2I* position);
  71. static void internal_getPointerDelta(Vector2I* position);
  72. typedef void(__stdcall *OnButtonEventThunkDef) (ButtonCode, UINT32, MonoException**);
  73. typedef void(__stdcall *OnCharInputEventThunkDef) (UINT32, MonoException**);
  74. typedef void(__stdcall *OnPointerEventThunkDef) (MonoObject*, MonoObject*, PointerEventButton,
  75. bool, bool, bool, float, MonoException**);
  76. static OnButtonEventThunkDef OnButtonPressedThunk;
  77. static OnButtonEventThunkDef OnButtonReleasedThunk;
  78. static OnCharInputEventThunkDef OnCharInputThunk;
  79. static OnPointerEventThunkDef OnPointerPressedThunk;
  80. static OnPointerEventThunkDef OnPointerReleasedThunk;
  81. static OnPointerEventThunkDef OnPointerMovedThunk;
  82. static OnPointerEventThunkDef OnPointerDoubleClickThunk;
  83. };
  84. }