InputEvents.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 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. #ifdef USE_OPENGL
  26. #include <GL/glfw3.h>
  27. #endif
  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_DX, DX); // int
  46. PARAM(P_DY, DY); // int
  47. PARAM(P_BUTTONS, Buttons); // int
  48. PARAM(P_QUALIFIERS, Qualifiers); // int
  49. }
  50. /// Mouse wheel moved.
  51. EVENT(E_MOUSEWHEEL, MouseWheel)
  52. {
  53. PARAM(P_WHEEL, Wheel); // int
  54. PARAM(P_BUTTONS, Buttons); // int
  55. PARAM(P_QUALIFIERS, Qualifiers); // int
  56. }
  57. /// Key pressed.
  58. EVENT(E_KEYDOWN, KeyDown)
  59. {
  60. PARAM(P_KEY, Key); // int
  61. PARAM(P_BUTTONS, Buttons); // int
  62. PARAM(P_QUALIFIERS, Qualifiers); // int
  63. PARAM(P_REPEAT, Repeat); // bool
  64. }
  65. /// Key released.
  66. EVENT(E_KEYUP, KeyUp)
  67. {
  68. PARAM(P_KEY, Key); // int
  69. PARAM(P_BUTTONS, Buttons); // int
  70. PARAM(P_QUALIFIERS, Qualifiers); // int
  71. }
  72. /// Character typed on the keyboard.
  73. EVENT(E_CHAR, Char)
  74. {
  75. PARAM(P_CHAR, Char); // int
  76. PARAM(P_BUTTONS, Buttons); // int
  77. PARAM(P_QUALIFIERS, Qualifiers); // int
  78. }
  79. /// Application activation state changed.
  80. EVENT(E_ACTIVATION, Activation)
  81. {
  82. PARAM(P_ACTIVE, Active); // bool
  83. PARAM(P_MINIMIZED, Minimized); // bool
  84. }
  85. static const int MOUSEB_LEFT = 1;
  86. static const int MOUSEB_RIGHT = 2;
  87. static const int MOUSEB_MIDDLE = 4;
  88. static const int QUAL_SHIFT = 1;
  89. static const int QUAL_CTRL = 2;
  90. static const int QUAL_ALT = 4;
  91. static const int QUAL_ANY = 8;
  92. #ifndef USE_OPENGL
  93. static const int KEY_BACKSPACE = 0x08;
  94. static const int KEY_TAB = 0x09;
  95. static const int KEY_RETURN = 0x0d;
  96. static const int KEY_PAUSE = 0x13;
  97. static const int KEY_CAPSLOCK = 0x14;
  98. static const int KEY_ESC = 0x1b;
  99. static const int KEY_SPACE = 0x20;
  100. static const int KEY_PAGEUP = 0x21;
  101. static const int KEY_PAGEDOWN = 0x22;
  102. static const int KEY_END = 0x23;
  103. static const int KEY_HOME = 0x24;
  104. static const int KEY_LEFT = 0x25;
  105. static const int KEY_UP = 0x26;
  106. static const int KEY_RIGHT = 0x27;
  107. static const int KEY_DOWN = 0x28;
  108. static const int KEY_INSERT = 0x2d;
  109. static const int KEY_DELETE = 0x2e;
  110. static const int KEY_LWIN = 0x5b;
  111. static const int KEY_RWIN = 0x5c;
  112. static const int KEY_APPS = 0x5d;
  113. static const int KEY_NUMPAD0 = 0x60;
  114. static const int KEY_NUMPAD1 = 0x61;
  115. static const int KEY_NUMPAD2 = 0x62;
  116. static const int KEY_NUMPAD3 = 0x63;
  117. static const int KEY_NUMPAD4 = 0x64;
  118. static const int KEY_NUMPAD5 = 0x65;
  119. static const int KEY_NUMPAD6 = 0x66;
  120. static const int KEY_NUMPAD7 = 0x67;
  121. static const int KEY_NUMPAD8 = 0x68;
  122. static const int KEY_NUMPAD9 = 0x69;
  123. static const int KEY_MULTIPLY = 0x6a;
  124. static const int KEY_ADD = 0x6b;
  125. static const int KEY_SUBTRACT = 0x6d;
  126. static const int KEY_DECIMAL = 0x6e;
  127. static const int KEY_DIVIDE = 0x6f;
  128. static const int KEY_F1 = 0x70;
  129. static const int KEY_F2 = 0x71;
  130. static const int KEY_F3 = 0x72;
  131. static const int KEY_F4 = 0x73;
  132. static const int KEY_F5 = 0x74;
  133. static const int KEY_F6 = 0x75;
  134. static const int KEY_F7 = 0x76;
  135. static const int KEY_F8 = 0x77;
  136. static const int KEY_F9 = 0x78;
  137. static const int KEY_F10 = 0x79;
  138. static const int KEY_F11 = 0x7a;
  139. static const int KEY_F12 = 0x7b;
  140. static const int KEY_F13 = 0x7c;
  141. static const int KEY_F14 = 0x7d;
  142. static const int KEY_F15 = 0x7e;
  143. static const int KEY_F16 = 0x7f;
  144. static const int KEY_F17 = 0x80;
  145. static const int KEY_F18 = 0x81;
  146. static const int KEY_F19 = 0x82;
  147. static const int KEY_F20 = 0x83;
  148. static const int KEY_F21 = 0x84;
  149. static const int KEY_F22 = 0x85;
  150. static const int KEY_F23 = 0x86;
  151. static const int KEY_F24 = 0x87;
  152. static const int KEY_NUMLOCK = 0x90;
  153. static const int KEY_SCROLLLOCK = 0x91;
  154. static const int KEY_LSHIFT = 0xa0;
  155. static const int KEY_RSHIFT = 0xa1;
  156. static const int KEY_LCTRL = 0xa2;
  157. static const int KEY_RCTRL = 0xa3;
  158. static const int KEY_LALT = 0xa4;
  159. static const int KEY_RALT = 0xa5;
  160. #else
  161. static const int KEY_BACKSPACE = GLFW_KEY_BACKSPACE;
  162. static const int KEY_TAB = GLFW_KEY_TAB;
  163. static const int KEY_RETURN = GLFW_KEY_ENTER;
  164. static const int KEY_PAUSE = GLFW_KEY_PAUSE;
  165. static const int KEY_CAPSLOCK = GLFW_KEY_CAPS_LOCK;
  166. static const int KEY_ESC = GLFW_KEY_ESC;
  167. static const int KEY_SPACE = GLFW_KEY_SPACE;
  168. static const int KEY_PAGEUP = GLFW_KEY_PAGEUP;
  169. static const int KEY_PAGEDOWN = GLFW_KEY_PAGEDOWN;
  170. static const int KEY_END = GLFW_KEY_END;
  171. static const int KEY_HOME = GLFW_KEY_HOME;
  172. static const int KEY_LEFT = GLFW_KEY_LEFT;
  173. static const int KEY_UP = GLFW_KEY_UP;
  174. static const int KEY_RIGHT = GLFW_KEY_RIGHT;
  175. static const int KEY_DOWN = GLFW_KEY_DOWN;
  176. static const int KEY_INSERT = GLFW_KEY_INSERT;
  177. static const int KEY_DELETE = GLFW_KEY_DEL;
  178. static const int KEY_LWIN = GLFW_KEY_LSUPER;
  179. static const int KEY_RWIN = GLFW_KEY_RSUPER;
  180. static const int KEY_APPS = GLFW_KEY_MENU;
  181. static const int KEY_NUMPAD0 = GLFW_KEY_KP_0;
  182. static const int KEY_NUMPAD1 = GLFW_KEY_KP_1;
  183. static const int KEY_NUMPAD2 = GLFW_KEY_KP_2;
  184. static const int KEY_NUMPAD3 = GLFW_KEY_KP_3;
  185. static const int KEY_NUMPAD4 = GLFW_KEY_KP_4;
  186. static const int KEY_NUMPAD5 = GLFW_KEY_KP_5;
  187. static const int KEY_NUMPAD6 = GLFW_KEY_KP_6;
  188. static const int KEY_NUMPAD7 = GLFW_KEY_KP_7;
  189. static const int KEY_NUMPAD8 = GLFW_KEY_KP_8;
  190. static const int KEY_NUMPAD9 = GLFW_KEY_KP_9;
  191. static const int KEY_MULTIPLY = GLFW_KEY_KP_MULTIPLY;
  192. static const int KEY_ADD = GLFW_KEY_KP_ADD;
  193. static const int KEY_SUBTRACT = GLFW_KEY_KP_SUBTRACT;
  194. static const int KEY_DECIMAL = GLFW_KEY_KP_DECIMAL;
  195. static const int KEY_DIVIDE = GLFW_KEY_KP_DIVIDE;
  196. static const int KEY_F1 = GLFW_KEY_F1;
  197. static const int KEY_F2 = GLFW_KEY_F2;
  198. static const int KEY_F3 = GLFW_KEY_F3;
  199. static const int KEY_F4 = GLFW_KEY_F4;
  200. static const int KEY_F5 = GLFW_KEY_F5;
  201. static const int KEY_F6 = GLFW_KEY_F6;
  202. static const int KEY_F7 = GLFW_KEY_F7;
  203. static const int KEY_F8 = GLFW_KEY_F8;
  204. static const int KEY_F9 = GLFW_KEY_F9;
  205. static const int KEY_F10 = GLFW_KEY_F10;
  206. static const int KEY_F11 = GLFW_KEY_F11;
  207. static const int KEY_F12 = GLFW_KEY_F12;
  208. static const int KEY_F13 = GLFW_KEY_F13;
  209. static const int KEY_F14 = GLFW_KEY_F14;
  210. static const int KEY_F15 = GLFW_KEY_F15;
  211. static const int KEY_F16 = GLFW_KEY_F16;
  212. static const int KEY_F17 = GLFW_KEY_F17;
  213. static const int KEY_F18 = GLFW_KEY_F18;
  214. static const int KEY_F19 = GLFW_KEY_F19;
  215. static const int KEY_F20 = GLFW_KEY_F20;
  216. static const int KEY_F21 = GLFW_KEY_F21;
  217. static const int KEY_F22 = GLFW_KEY_F22;
  218. static const int KEY_F23 = GLFW_KEY_F23;
  219. static const int KEY_F24 = GLFW_KEY_F24;
  220. static const int KEY_NUMLOCK = GLFW_KEY_KP_NUM_LOCK;
  221. static const int KEY_SCROLLLOCK = GLFW_KEY_SCROLL_LOCK;
  222. static const int KEY_LSHIFT = GLFW_KEY_LSHIFT;
  223. static const int KEY_RSHIFT = GLFW_KEY_RSHIFT;
  224. static const int KEY_LCTRL = GLFW_KEY_LCTRL;
  225. static const int KEY_RCTRL = GLFW_KEY_RCTRL;
  226. static const int KEY_LALT = GLFW_KEY_LALT;
  227. static const int KEY_RALT = GLFW_KEY_RALT;
  228. #endif