BsScriptInput.h 3.4 KB

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