BsScriptInput.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /** @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_getPointerScreenPosition(Vector2I* position);
  57. static void internal_getPointerDelta(Vector2I* position);
  58. typedef void(__stdcall *OnButtonEventThunkDef) (ButtonCode, UINT32, MonoException**);
  59. typedef void(__stdcall *OnCharInputEventThunkDef) (UINT32, MonoException**);
  60. typedef void(__stdcall *OnPointerEventThunkDef) (MonoObject*, MonoObject*, PointerEventButton,
  61. bool, bool, bool, float, MonoException**);
  62. static OnButtonEventThunkDef OnButtonPressedThunk;
  63. static OnButtonEventThunkDef OnButtonReleasedThunk;
  64. static OnCharInputEventThunkDef OnCharInputThunk;
  65. static OnPointerEventThunkDef OnPointerPressedThunk;
  66. static OnPointerEventThunkDef OnPointerReleasedThunk;
  67. static OnPointerEventThunkDef OnPointerMovedThunk;
  68. static OnPointerEventThunkDef OnPointerDoubleClickThunk;
  69. };
  70. /** @} */
  71. }