💿🐜 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.

170 lines
3.8 KiB

  1. /*
  2. * Copyright (C) 2021 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_EVENTS_HPP
  20. #define ANTKEEPER_INPUT_EVENTS_HPP
  21. #include "event/event.hpp"
  22. #include "input/scancode.hpp"
  23. #include "input/keyboard.hpp"
  24. #include "input/mouse.hpp"
  25. #include "input/game-controller.hpp"
  26. /**
  27. * Input event which indicates a keyboard key has been pressed.
  28. */
  29. class key_pressed_event: public event<key_pressed_event>
  30. {
  31. public:
  32. virtual event_base* clone() const;
  33. input::keyboard* keyboard;
  34. input::scancode scancode;
  35. };
  36. /**
  37. * Input event which indicates a keyboard key has been released.
  38. */
  39. class key_released_event: public event<key_released_event>
  40. {
  41. public:
  42. virtual event_base* clone() const;
  43. input::keyboard* keyboard;
  44. input::scancode scancode;
  45. };
  46. /**
  47. * Input event which indicates a mouse has been moved.
  48. */
  49. class mouse_moved_event: public event<mouse_moved_event>
  50. {
  51. public:
  52. virtual event_base* clone() const;
  53. input::mouse* mouse;
  54. int x;
  55. int y;
  56. int dx;
  57. int dy;
  58. };
  59. /**
  60. * Input event which indicates a mouse button has been pressed.
  61. */
  62. class mouse_button_pressed_event: public event<mouse_button_pressed_event>
  63. {
  64. public:
  65. virtual event_base* clone() const;
  66. input::mouse* mouse;
  67. int button;
  68. int x;
  69. int y;
  70. };
  71. /**
  72. * Input event which indicates a mouse button has been released.
  73. */
  74. class mouse_button_released_event: public event<mouse_button_released_event>
  75. {
  76. public:
  77. virtual event_base* clone() const;
  78. input::mouse* mouse;
  79. int button;
  80. int x;
  81. int y;
  82. };
  83. /**
  84. * Input event which indicates a mouse wheel has been scrolled.
  85. */
  86. class mouse_wheel_scrolled_event: public event<mouse_wheel_scrolled_event>
  87. {
  88. public:
  89. virtual event_base* clone() const;
  90. input::mouse* mouse;
  91. int x;
  92. int y;
  93. };
  94. /**
  95. * Input event which indicates a controller has been connected.
  96. */
  97. class game_controller_connected_event: public event<game_controller_connected_event>
  98. {
  99. public:
  100. virtual event_base* clone() const;
  101. input::game_controller* controller;
  102. bool reconnected;
  103. };
  104. /**
  105. * Input event which indicates a controller has been disconnected.
  106. */
  107. class game_controller_disconnected_event: public event<game_controller_disconnected_event>
  108. {
  109. public:
  110. virtual event_base* clone() const;
  111. input::game_controller* controller;
  112. };
  113. /**
  114. * Input event which indicates a controller button has been pressed.
  115. */
  116. class game_controller_button_pressed_event: public event<game_controller_button_pressed_event>
  117. {
  118. public:
  119. virtual event_base* clone() const;
  120. input::game_controller* controller;
  121. input::game_controller_button button;
  122. };
  123. /**
  124. * Input event which indicates a controller button has been released.
  125. */
  126. class game_controller_button_released_event: public event<game_controller_button_released_event>
  127. {
  128. public:
  129. virtual event_base* clone() const;
  130. input::game_controller* controller;
  131. input::game_controller_button button;
  132. };
  133. /**
  134. * Input event which indicates a controller axis has been moved.
  135. */
  136. class game_controller_axis_moved_event: public event<game_controller_axis_moved_event>
  137. {
  138. public:
  139. virtual event_base* clone() const;
  140. input::game_controller* controller;
  141. input::game_controller_axis axis;
  142. float value;
  143. };
  144. #endif // ANTKEEPER_INPUT_EVENTS_HPP