CmRawInputHandler.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmInputFwd.h"
  4. #include <boost/signal.hpp>
  5. #include "CmVector2I.h"
  6. namespace CamelotFramework
  7. {
  8. struct RawAxisState
  9. {
  10. Vector2I rel;
  11. Vector2I abs;
  12. };
  13. enum class RawInputAxis
  14. {
  15. Mouse_XY,
  16. Mouse_Z,
  17. Joy_1,
  18. Joy_2,
  19. Joy_3,
  20. Joy_4,
  21. Joy_5,
  22. Joy_6,
  23. Joy_7,
  24. Joy_8,
  25. Joy_9,
  26. Joy_10,
  27. Joy_11,
  28. Joy_12,
  29. Joy_13,
  30. Joy_14,
  31. Joy_15,
  32. Joy_16,
  33. Count
  34. };
  35. /**
  36. * @brief Represents a specific way of acquiring low-level input. InputManager (which provides a higher level input)
  37. * must have at least one InputHandler attached. Attach events handler to the provided signals to handle input.
  38. */
  39. class CM_EXPORT RawInputHandler
  40. {
  41. public:
  42. RawInputHandler() {}
  43. virtual ~RawInputHandler() {}
  44. boost::signal<void(ButtonCode)> onButtonDown;
  45. boost::signal<void(ButtonCode)> onButtonUp;
  46. boost::signal<void(const RawAxisState&, RawInputAxis)> onAxisMoved;
  47. /**
  48. * @brief Called every frame by InputManager. Capture input here if needed.
  49. */
  50. virtual void update() {}
  51. /**
  52. * @brief Called by InputManager whenever window in focus changes.
  53. */
  54. virtual void inputWindowChanged(const RenderWindow& win) {}
  55. };
  56. }