BsScriptInput.h 3.5 KB

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