💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.5 KiB

  1. /*
  2. * Copyright (C) 2023 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_INPUT_MOUSE_EVENTS_HPP
  20. #define ANTKEEPER_INPUT_MOUSE_EVENTS_HPP
  21. #include <engine/input/mouse-button.hpp>
  22. #include <engine/input/mouse-motion-axis.hpp>
  23. #include <engine/input/mouse-scroll-axis.hpp>
  24. #include <engine/math/vector.hpp>
  25. #include <cstdint>
  26. namespace input {
  27. class mouse;
  28. /**
  29. * Event generated when a mouse has been moved.
  30. */
  31. struct mouse_moved_event
  32. {
  33. /// Mouse that generated the event.
  34. mouse* mouse{nullptr};
  35. /// Mouse position, in pixels, relative to the window.
  36. math::vec2<std::int32_t> position{0, 0};
  37. /// Relative movement of the mouse, in pixels.
  38. math::vec2<std::int32_t> difference{0, 0};
  39. };
  40. /**
  41. * Event generated when a mouse button has been pressed.
  42. */
  43. struct mouse_button_pressed_event
  44. {
  45. /// Mouse that generated the event.
  46. mouse* mouse{nullptr};
  47. /// Mouse position, in pixels, relative to the window, when the button was pressed.
  48. math::vec2<std::int32_t> position{0, 0};
  49. /// Mouse button being pressed.
  50. mouse_button button{0};
  51. };
  52. /**
  53. * Event generated when a mouse button has been released.
  54. */
  55. struct mouse_button_released_event
  56. {
  57. /// Mouse that generated the event.
  58. mouse* mouse{nullptr};
  59. /// Mouse position, in pixels, relative to the window, when the button was released.
  60. math::vec2<std::int32_t> position{0, 0};
  61. /// Mouse button being released.
  62. mouse_button button{0};
  63. };
  64. /**
  65. * Event generated when a mouse has been scrolled.
  66. */
  67. struct mouse_scrolled_event
  68. {
  69. /// Mouse that generated the event.
  70. mouse* mouse{nullptr};
  71. /// Mouse position, in pixels, relative to the window, when the mouse was scrolled.
  72. math::vec2<std::int32_t> position{0, 0};
  73. /// Scroll velocity.
  74. math::fvec2 velocity{0.0f, 0.0f};
  75. };
  76. } // namespace input
  77. #endif // ANTKEEPER_INPUT_MOUSE_EVENTS_HPP