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