InputEvents.h 8.7 KB

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