BsScriptEditorVirtualInput.h 2.0 KB

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