InputEvents.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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_keycode.h>
  26. /// Mouse button pressed.
  27. EVENT(E_MOUSEBUTTONDOWN, MouseButtonDown)
  28. {
  29. PARAM(P_BUTTON, Button); // int
  30. PARAM(P_BUTTONS, Buttons); // int
  31. PARAM(P_QUALIFIERS, Qualifiers); // int
  32. }
  33. /// Mouse button released.
  34. EVENT(E_MOUSEBUTTONUP, MouseButtonUp)
  35. {
  36. PARAM(P_BUTTON, Button); // int
  37. PARAM(P_BUTTONS, Buttons); // int
  38. PARAM(P_QUALIFIERS, Qualifiers); // int
  39. }
  40. /// Mouse moved.
  41. EVENT(E_MOUSEMOVE, MouseMove)
  42. {
  43. PARAM(P_DX, DX); // int
  44. PARAM(P_DY, DY); // int
  45. PARAM(P_BUTTONS, Buttons); // int
  46. PARAM(P_QUALIFIERS, Qualifiers); // int
  47. }
  48. /// Mouse wheel moved.
  49. EVENT(E_MOUSEWHEEL, MouseWheel)
  50. {
  51. PARAM(P_WHEEL, Wheel); // int
  52. PARAM(P_BUTTONS, Buttons); // int
  53. PARAM(P_QUALIFIERS, Qualifiers); // int
  54. }
  55. /// Key pressed.
  56. EVENT(E_KEYDOWN, KeyDown)
  57. {
  58. PARAM(P_KEY, Key); // int
  59. PARAM(P_BUTTONS, Buttons); // int
  60. PARAM(P_QUALIFIERS, Qualifiers); // int
  61. PARAM(P_REPEAT, Repeat); // bool
  62. }
  63. /// Key released.
  64. EVENT(E_KEYUP, KeyUp)
  65. {
  66. PARAM(P_KEY, Key); // int
  67. PARAM(P_BUTTONS, Buttons); // int
  68. PARAM(P_QUALIFIERS, Qualifiers); // int
  69. }
  70. /// Character typed on the keyboard.
  71. EVENT(E_CHAR, Char)
  72. {
  73. PARAM(P_CHAR, Char); // int
  74. PARAM(P_BUTTONS, Buttons); // int
  75. PARAM(P_QUALIFIERS, Qualifiers); // int
  76. }
  77. /// Finger pressed on the screen.
  78. EVENT(E_TOUCHBEGIN, TouchBegin)
  79. {
  80. PARAM(P_TOUCHID, TouchID); // int
  81. PARAM(P_X, X); // int
  82. PARAM(P_Y, Y); // int
  83. PARAM(P_PRESSURE, Pressure); // int
  84. }
  85. /// Finger released from the screen.
  86. EVENT(E_TOUCHEND, TouchEnd)
  87. {
  88. PARAM(P_TOUCHID, TouchID); // int
  89. PARAM(P_X, X); // int
  90. PARAM(P_Y, Y); // int
  91. }
  92. /// Finger moved on the screen.
  93. EVENT(E_TOUCHMOVE, TouchMove)
  94. {
  95. PARAM(P_TOUCHID, TouchID); // int
  96. PARAM(P_X, X); // int
  97. PARAM(P_Y, Y); // int
  98. PARAM(P_DX, DX); // int
  99. PARAM(P_DY, DY); // int
  100. PARAM(P_PRESSURE, Pressure); // int
  101. }
  102. /// Application activation state changed.
  103. EVENT(E_ACTIVATION, Activation)
  104. {
  105. PARAM(P_ACTIVE, Active); // bool
  106. PARAM(P_MINIMIZED, Minimized); // bool
  107. }
  108. static const int MOUSEB_LEFT = 1;
  109. static const int MOUSEB_MIDDLE = 2;
  110. static const int MOUSEB_RIGHT = 4;
  111. static const int QUAL_SHIFT = 1;
  112. static const int QUAL_CTRL = 2;
  113. static const int QUAL_ALT = 4;
  114. static const int QUAL_ANY = 8;
  115. static const int KEY_BACKSPACE = SDLK_BACKSPACE;
  116. static const int KEY_TAB = SDLK_TAB;
  117. static const int KEY_RETURN = SDLK_RETURN;
  118. static const int KEY_SHIFT = SDLK_LSHIFT;
  119. static const int KEY_CTRL = SDLK_LCTRL;
  120. static const int KEY_ALT = SDLK_LALT;
  121. static const int KEY_PAUSE = SDLK_PAUSE;
  122. static const int KEY_CAPSLOCK = SDLK_CAPSLOCK;
  123. static const int KEY_ESC = SDLK_ESCAPE;
  124. static const int KEY_SPACE = SDLK_SPACE;
  125. static const int KEY_PAGEUP = SDLK_PAGEUP;
  126. static const int KEY_PAGEDOWN = SDLK_PAGEDOWN;
  127. static const int KEY_END = SDLK_END;
  128. static const int KEY_HOME = SDLK_HOME;
  129. static const int KEY_LEFT = SDLK_LEFT;
  130. static const int KEY_UP = SDLK_UP;
  131. static const int KEY_RIGHT = SDLK_RIGHT;
  132. static const int KEY_DOWN = SDLK_DOWN;
  133. static const int KEY_SELECT = SDLK_SELECT;
  134. static const int KEY_PRINTSCREEN = SDLK_PRINTSCREEN;
  135. static const int KEY_INSERT = SDLK_INSERT;
  136. static const int KEY_DELETE = SDLK_DELETE;
  137. static const int KEY_LWIN = SDLK_LGUI;
  138. static const int KEY_RWIN = SDLK_RGUI;
  139. static const int KEY_APPS = SDLK_APPLICATION;
  140. static const int KEY_NUMPAD0 = SDLK_KP_0;
  141. static const int KEY_NUMPAD1 = SDLK_KP_1;
  142. static const int KEY_NUMPAD2 = SDLK_KP_2;
  143. static const int KEY_NUMPAD3 = SDLK_KP_3;
  144. static const int KEY_NUMPAD4 = SDLK_KP_4;
  145. static const int KEY_NUMPAD5 = SDLK_KP_5;
  146. static const int KEY_NUMPAD6 = SDLK_KP_6;
  147. static const int KEY_NUMPAD7 = SDLK_KP_7;
  148. static const int KEY_NUMPAD8 = SDLK_KP_8;
  149. static const int KEY_NUMPAD9 = SDLK_KP_9;
  150. static const int KEY_MULTIPLY = SDLK_KP_MULTIPLY;
  151. static const int KEY_ADD = SDLK_KP_PLUS;
  152. static const int KEY_SUBTRACT = SDLK_KP_MINUS;
  153. static const int KEY_DECIMAL = SDLK_KP_PERIOD;
  154. static const int KEY_DIVIDE = SDLK_KP_DIVIDE;
  155. static const int KEY_F1 = SDLK_F1;
  156. static const int KEY_F2 = SDLK_F2;
  157. static const int KEY_F3 = SDLK_F3;
  158. static const int KEY_F4 = SDLK_F4;
  159. static const int KEY_F5 = SDLK_F5;
  160. static const int KEY_F6 = SDLK_F6;
  161. static const int KEY_F7 = SDLK_F7;
  162. static const int KEY_F8 = SDLK_F8;
  163. static const int KEY_F9 = SDLK_F9;
  164. static const int KEY_F10 = SDLK_F10;
  165. static const int KEY_F11 = SDLK_F11;
  166. static const int KEY_F12 = SDLK_F12;
  167. static const int KEY_F13 = SDLK_F13;
  168. static const int KEY_F14 = SDLK_F14;
  169. static const int KEY_F15 = SDLK_F15;
  170. static const int KEY_F16 = SDLK_F16;
  171. static const int KEY_F17 = SDLK_F17;
  172. static const int KEY_F18 = SDLK_F18;
  173. static const int KEY_F19 = SDLK_F19;
  174. static const int KEY_F20 = SDLK_F20;
  175. static const int KEY_F21 = SDLK_F21;
  176. static const int KEY_F22 = SDLK_F22;
  177. static const int KEY_F23 = SDLK_F23;
  178. static const int KEY_F24 = SDLK_F24;
  179. static const int KEY_NUMLOCK = SDLK_NUMLOCKCLEAR;
  180. static const int KEY_SCROLLLOCK = SDLK_SCROLLLOCK;
  181. static const int KEY_LSHIFT = SDLK_LSHIFT;
  182. static const int KEY_RSHIFT = SDLK_RSHIFT;
  183. static const int KEY_LCTRL = SDLK_LCTRL;
  184. static const int KEY_RCTRL = SDLK_RCTRL;
  185. static const int KEY_LALT = SDLK_LALT;
  186. static const int KEY_RALT = SDLK_RALT;