BsScriptEditorVirtualInput.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEditorPrerequisites.h"
  5. #include "BsScriptObject.h"
  6. #include "BsInputConfiguration.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Interop class between C++ & CLR for EditorVirtualInput.
  11. */
  12. class BS_SCR_BED_EXPORT ScriptEditorVirtualInput : public ScriptObject<ScriptEditorVirtualInput>
  13. {
  14. public:
  15. SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEngine", "EditorVirtualInput")
  16. /**
  17. * @brief Must be called on library load. Hooks up necessary callbacks.
  18. */
  19. static void startUp();
  20. /**
  21. * @brief Must be called before library shutdown. Releases previously hooked callbacks.
  22. */
  23. static void shutDown();
  24. private:
  25. /**
  26. * @brief Triggered whenever a virtual button is pressed.
  27. *
  28. * @param btn Virtual button that was pressed.
  29. * @param deviceIdx Index of the device the button was pressed on.
  30. */
  31. static void onButtonDown(const VirtualButton& btn, UINT32 deviceIdx);
  32. /**
  33. * @brief Triggered whenever a virtual button is released.
  34. *
  35. * @param btn Virtual button that was released.
  36. * @param deviceIdx Index of the device the button was released on.
  37. */
  38. static void onButtonUp(const VirtualButton& btn, UINT32 deviceIdx);
  39. /**
  40. * @brief Triggered every frame while a virtual button is held down.
  41. *
  42. * @param btn Virtual button that is being held.
  43. * @param deviceIdx Index of the device the button is held.
  44. */
  45. static void onButtonHeld(const VirtualButton& btn, UINT32 deviceIdx);
  46. static HEvent OnButtonPressedConn;
  47. static HEvent OnButtonReleasedConn;
  48. static HEvent OnButtonHeldConn;
  49. ScriptEditorVirtualInput(MonoObject* instance);
  50. /************************************************************************/
  51. /* CLR HOOKS */
  52. /************************************************************************/
  53. typedef void(__stdcall *OnButtonEventThunkDef) (MonoObject*, UINT32, MonoException**);
  54. static OnButtonEventThunkDef OnButtonUpThunk;
  55. static OnButtonEventThunkDef OnButtonDownThunk;
  56. static OnButtonEventThunkDef OnButtonHeldThunk;
  57. };
  58. }