BsRawInputHandler.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsInputFwd.h"
  4. #include "BsEvent.h"
  5. #include "BsVector2I.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Contains relative and absolute position
  10. * of an input axis. Relative state represents
  11. * the difference between current and last state.
  12. */
  13. struct RawAxisState
  14. {
  15. RawAxisState()
  16. :rel(0.0f), abs(0.0f)
  17. { }
  18. float rel;
  19. float abs;
  20. };
  21. /**
  22. * @brief Represents a specific way of acquiring low-level input. InputManager (which provides a higher level input)
  23. * must have at least one RawInputHandler attached. Raw input handlers receive input as sent by the hardware
  24. * without OS modifications.
  25. *
  26. * Attach events handler to the provided signals to handle input.
  27. */
  28. class BS_CORE_EXPORT RawInputHandler
  29. {
  30. public:
  31. RawInputHandler() {}
  32. virtual ~RawInputHandler() {}
  33. /**
  34. * @brief Triggered when user presses a button. Parameters
  35. * include device index, button code of the pressed button,
  36. * and a timestamp of the button press event.
  37. */
  38. Event<void(UINT32, ButtonCode, UINT64)> onButtonDown;
  39. /**
  40. * @brief Triggered when user releases a button. Parameters
  41. * include device index, button code of the released button,
  42. * and a timestamp of the button release event.
  43. */
  44. Event<void(UINT32, ButtonCode, UINT64)> onButtonUp;
  45. /**
  46. * @brief Triggered whenever the specified axis state changes.
  47. * Parameters include device index, axis state data, and axis type.
  48. */
  49. Event<void(UINT32, const RawAxisState&, UINT32)> onAxisMoved;
  50. /**
  51. * @brief Called once per frame. Capture input here if needed.
  52. *
  53. * @note Internal method.
  54. */
  55. virtual void _update() {}
  56. /**
  57. * @brief Called whenever the active window changes.
  58. *
  59. * @param win Newly active window.
  60. *
  61. * @note Internal method.
  62. */
  63. virtual void _inputWindowChanged(const RenderWindow& win) {}
  64. };
  65. }