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

173 lines
3.7 KiB

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