InputEvents.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2012 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "Object.h"
  25. #include <SDL_joystick.h>
  26. #include <SDL_keycode.h>
  27. /// Mouse button pressed.
  28. EVENT(E_MOUSEBUTTONDOWN, MouseButtonDown)
  29. {
  30. PARAM(P_BUTTON, Button); // int
  31. PARAM(P_BUTTONS, Buttons); // int
  32. PARAM(P_QUALIFIERS, Qualifiers); // int
  33. }
  34. /// Mouse button released.
  35. EVENT(E_MOUSEBUTTONUP, MouseButtonUp)
  36. {
  37. PARAM(P_BUTTON, Button); // int
  38. PARAM(P_BUTTONS, Buttons); // int
  39. PARAM(P_QUALIFIERS, Qualifiers); // int
  40. }
  41. /// Mouse moved.
  42. EVENT(E_MOUSEMOVE, MouseMove)
  43. {
  44. PARAM(P_DX, DX); // int
  45. PARAM(P_DY, DY); // int
  46. PARAM(P_BUTTONS, Buttons); // int
  47. PARAM(P_QUALIFIERS, Qualifiers); // int
  48. }
  49. /// Mouse wheel moved.
  50. EVENT(E_MOUSEWHEEL, MouseWheel)
  51. {
  52. PARAM(P_WHEEL, Wheel); // int
  53. PARAM(P_BUTTONS, Buttons); // int
  54. PARAM(P_QUALIFIERS, Qualifiers); // int
  55. }
  56. /// Key pressed.
  57. EVENT(E_KEYDOWN, KeyDown)
  58. {
  59. PARAM(P_KEY, Key); // int
  60. PARAM(P_BUTTONS, Buttons); // int
  61. PARAM(P_QUALIFIERS, Qualifiers); // int
  62. PARAM(P_REPEAT, Repeat); // bool
  63. }
  64. /// Key released.
  65. EVENT(E_KEYUP, KeyUp)
  66. {
  67. PARAM(P_KEY, Key); // int
  68. PARAM(P_BUTTONS, Buttons); // int
  69. PARAM(P_QUALIFIERS, Qualifiers); // int
  70. }
  71. /// Character typed on the keyboard.
  72. EVENT(E_CHAR, Char)
  73. {
  74. PARAM(P_CHAR, Char); // int
  75. PARAM(P_BUTTONS, Buttons); // int
  76. PARAM(P_QUALIFIERS, Qualifiers); // int
  77. }
  78. /// Finger pressed on the screen.
  79. EVENT(E_TOUCHBEGIN, TouchBegin)
  80. {
  81. PARAM(P_TOUCHID, TouchID); // int
  82. PARAM(P_X, X); // int
  83. PARAM(P_Y, Y); // int
  84. PARAM(P_PRESSURE, Pressure); // float
  85. }
  86. /// Finger released from the screen.
  87. EVENT(E_TOUCHEND, TouchEnd)
  88. {
  89. PARAM(P_TOUCHID, TouchID); // int
  90. PARAM(P_X, X); // int
  91. PARAM(P_Y, Y); // int
  92. }
  93. /// Finger moved on the screen.
  94. EVENT(E_TOUCHMOVE, TouchMove)
  95. {
  96. PARAM(P_TOUCHID, TouchID); // int
  97. PARAM(P_X, X); // int
  98. PARAM(P_Y, Y); // int
  99. PARAM(P_DX, DX); // int
  100. PARAM(P_DY, DY); // int
  101. PARAM(P_PRESSURE, Pressure); // float
  102. }
  103. /// Joystick button pressed.
  104. EVENT(E_JOYSTICKBUTTONDOWN, JoystickButtonDown)
  105. {
  106. PARAM(P_JOYSTICK, Joystick); // int
  107. PARAM(P_BUTTON, Button); // int
  108. }
  109. /// Joystick button released.
  110. EVENT(E_JOYSTICKBUTTONUP, JoystickButtonUp)
  111. {
  112. PARAM(P_JOYSTICK, Joystick); // int
  113. PARAM(P_BUTTON, Button); // int
  114. }
  115. /// Joystick axis moved.
  116. EVENT(E_JOYSTICKAXISMOVE, JoystickAxisMove)
  117. {
  118. PARAM(P_JOYSTICK, Joystick); // int
  119. PARAM(P_AXIS, Button); // int
  120. PARAM(P_POSITION, Position); // float
  121. }
  122. /// Joystick POV hat moved.
  123. EVENT(E_JOYSTICKHATMOVE, JoystickHatMove)
  124. {
  125. PARAM(P_JOYSTICK, Joystick); // int
  126. PARAM(P_HAT, Button); // int
  127. PARAM(P_POSITION, Position); // int
  128. }
  129. /// Application activation state changed.
  130. EVENT(E_ACTIVATION, Activation)
  131. {
  132. PARAM(P_ACTIVE, Active); // bool
  133. PARAM(P_MINIMIZED, Minimized); // bool
  134. }
  135. static const int MOUSEB_LEFT = 1;
  136. static const int MOUSEB_MIDDLE = 2;
  137. static const int MOUSEB_RIGHT = 4;
  138. static const int QUAL_SHIFT = 1;
  139. static const int QUAL_CTRL = 2;
  140. static const int QUAL_ALT = 4;
  141. static const int QUAL_ANY = 8;
  142. static const int KEY_BACKSPACE = SDLK_BACKSPACE;
  143. static const int KEY_TAB = SDLK_TAB;
  144. static const int KEY_RETURN = SDLK_RETURN;
  145. static const int KEY_SHIFT = SDLK_LSHIFT;
  146. static const int KEY_CTRL = SDLK_LCTRL;
  147. static const int KEY_ALT = SDLK_LALT;
  148. static const int KEY_PAUSE = SDLK_PAUSE;
  149. static const int KEY_CAPSLOCK = SDLK_CAPSLOCK;
  150. static const int KEY_ESC = SDLK_ESCAPE;
  151. static const int KEY_SPACE = SDLK_SPACE;
  152. static const int KEY_PAGEUP = SDLK_PAGEUP;
  153. static const int KEY_PAGEDOWN = SDLK_PAGEDOWN;
  154. static const int KEY_END = SDLK_END;
  155. static const int KEY_HOME = SDLK_HOME;
  156. static const int KEY_LEFT = SDLK_LEFT;
  157. static const int KEY_UP = SDLK_UP;
  158. static const int KEY_RIGHT = SDLK_RIGHT;
  159. static const int KEY_DOWN = SDLK_DOWN;
  160. static const int KEY_SELECT = SDLK_SELECT;
  161. static const int KEY_PRINTSCREEN = SDLK_PRINTSCREEN;
  162. static const int KEY_INSERT = SDLK_INSERT;
  163. static const int KEY_DELETE = SDLK_DELETE;
  164. static const int KEY_LWIN = SDLK_LGUI;
  165. static const int KEY_RWIN = SDLK_RGUI;
  166. static const int KEY_APPS = SDLK_APPLICATION;
  167. static const int KEY_NUMPAD0 = SDLK_KP_0;
  168. static const int KEY_NUMPAD1 = SDLK_KP_1;
  169. static const int KEY_NUMPAD2 = SDLK_KP_2;
  170. static const int KEY_NUMPAD3 = SDLK_KP_3;
  171. static const int KEY_NUMPAD4 = SDLK_KP_4;
  172. static const int KEY_NUMPAD5 = SDLK_KP_5;
  173. static const int KEY_NUMPAD6 = SDLK_KP_6;
  174. static const int KEY_NUMPAD7 = SDLK_KP_7;
  175. static const int KEY_NUMPAD8 = SDLK_KP_8;
  176. static const int KEY_NUMPAD9 = SDLK_KP_9;
  177. static const int KEY_MULTIPLY = SDLK_KP_MULTIPLY;
  178. static const int KEY_ADD = SDLK_KP_PLUS;
  179. static const int KEY_SUBTRACT = SDLK_KP_MINUS;
  180. static const int KEY_DECIMAL = SDLK_KP_PERIOD;
  181. static const int KEY_DIVIDE = SDLK_KP_DIVIDE;
  182. static const int KEY_F1 = SDLK_F1;
  183. static const int KEY_F2 = SDLK_F2;
  184. static const int KEY_F3 = SDLK_F3;
  185. static const int KEY_F4 = SDLK_F4;
  186. static const int KEY_F5 = SDLK_F5;
  187. static const int KEY_F6 = SDLK_F6;
  188. static const int KEY_F7 = SDLK_F7;
  189. static const int KEY_F8 = SDLK_F8;
  190. static const int KEY_F9 = SDLK_F9;
  191. static const int KEY_F10 = SDLK_F10;
  192. static const int KEY_F11 = SDLK_F11;
  193. static const int KEY_F12 = SDLK_F12;
  194. static const int KEY_F13 = SDLK_F13;
  195. static const int KEY_F14 = SDLK_F14;
  196. static const int KEY_F15 = SDLK_F15;
  197. static const int KEY_F16 = SDLK_F16;
  198. static const int KEY_F17 = SDLK_F17;
  199. static const int KEY_F18 = SDLK_F18;
  200. static const int KEY_F19 = SDLK_F19;
  201. static const int KEY_F20 = SDLK_F20;
  202. static const int KEY_F21 = SDLK_F21;
  203. static const int KEY_F22 = SDLK_F22;
  204. static const int KEY_F23 = SDLK_F23;
  205. static const int KEY_F24 = SDLK_F24;
  206. static const int KEY_NUMLOCK = SDLK_NUMLOCKCLEAR;
  207. static const int KEY_SCROLLLOCK = SDLK_SCROLLLOCK;
  208. static const int KEY_LSHIFT = SDLK_LSHIFT;
  209. static const int KEY_RSHIFT = SDLK_RSHIFT;
  210. static const int KEY_LCTRL = SDLK_LCTRL;
  211. static const int KEY_RCTRL = SDLK_RCTRL;
  212. static const int KEY_LALT = SDLK_LALT;
  213. static const int KEY_RALT = SDLK_RALT;
  214. static const int HAT_CENTER = SDL_HAT_CENTERED;
  215. static const int HAT_UP = SDL_HAT_UP;
  216. static const int HAT_RIGHT = SDL_HAT_RIGHT;
  217. static const int HAT_DOWN = SDL_HAT_DOWN;
  218. static const int HAT_LEFT = SDL_HAT_LEFT;