No Description
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.

input.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /* The MIT License
  2. *
  3. * Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
  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. #ifndef INPUT_H
  24. #define INPUT_H
  25. enum EKeyCode {
  26. KC_UNKNOWN = 0x00,
  27. KC_ESCAPE = 0x01,
  28. KC_1 = 0x02,
  29. KC_2 = 0x03,
  30. KC_3 = 0x04,
  31. KC_4 = 0x05,
  32. KC_5 = 0x06,
  33. KC_6 = 0x07,
  34. KC_7 = 0x08,
  35. KC_8 = 0x09,
  36. KC_9 = 0x0A,
  37. KC_0 = 0x0B,
  38. KC_MINUS = 0x0C, // - on main keyboard
  39. KC_EQUALS = 0x0D,
  40. KC_BACK = 0x0E, // backspace
  41. KC_TAB = 0x0F,
  42. KC_Q = 0x10,
  43. KC_W = 0x11,
  44. KC_E = 0x12,
  45. KC_R = 0x13,
  46. KC_T = 0x14,
  47. KC_Y = 0x15,
  48. KC_U = 0x16,
  49. KC_I = 0x17,
  50. KC_O = 0x18,
  51. KC_P = 0x19,
  52. KC_LBRACKET = 0x1A,
  53. KC_RBRACKET = 0x1B,
  54. KC_RETURN = 0x1C, // Enter on main keyboard
  55. KC_LCONTROL = 0x1D,
  56. KC_A = 0x1E,
  57. KC_S = 0x1F,
  58. KC_D = 0x20,
  59. KC_F = 0x21,
  60. KC_G = 0x22,
  61. KC_H = 0x23,
  62. KC_J = 0x24,
  63. KC_K = 0x25,
  64. KC_L = 0x26,
  65. KC_SEMICOLON = 0x27,
  66. KC_APOSTROPHE = 0x28,
  67. KC_GRAVE = 0x29, // accent
  68. KC_LSHIFT = 0x2A,
  69. KC_BACKSLASH = 0x2B,
  70. KC_Z = 0x2C,
  71. KC_X = 0x2D,
  72. KC_C = 0x2E,
  73. KC_V = 0x2F,
  74. KC_B = 0x30,
  75. KC_N = 0x31,
  76. KC_M = 0x32,
  77. KC_COMMA = 0x33,
  78. KC_PERIOD = 0x34, // . on main keyboard
  79. KC_SLASH = 0x35, // / on main keyboard
  80. KC_RSHIFT = 0x36,
  81. KC_MULTIPLY = 0x37, // * on numeric keypad
  82. KC_LALT = 0x38, // left Alt
  83. KC_SPACE = 0x39,
  84. KC_CAPITAL = 0x3A,
  85. KC_F1 = 0x3B,
  86. KC_F2 = 0x3C,
  87. KC_F3 = 0x3D,
  88. KC_F4 = 0x3E,
  89. KC_F5 = 0x3F,
  90. KC_F6 = 0x40,
  91. KC_F7 = 0x41,
  92. KC_F8 = 0x42,
  93. KC_F9 = 0x43,
  94. KC_F10 = 0x44,
  95. KC_NUMLOCK = 0x45,
  96. KC_SCROLL = 0x46, // Scroll Lock
  97. KC_NUMPAD7 = 0x47,
  98. KC_NUMPAD8 = 0x48,
  99. KC_NUMPAD9 = 0x49,
  100. KC_SUBTRACT = 0x4A, // - on numeric keypad
  101. KC_NUMPAD4 = 0x4B,
  102. KC_NUMPAD5 = 0x4C,
  103. KC_NUMPAD6 = 0x4D,
  104. KC_ADD = 0x4E, // + on numeric keypad
  105. KC_NUMPAD1 = 0x4F,
  106. KC_NUMPAD2 = 0x50,
  107. KC_NUMPAD3 = 0x51,
  108. KC_NUMPAD0 = 0x52,
  109. KC_DECIMAL = 0x53, // . on numeric keypad
  110. KC_OEM_102 = 0x56, // < > | on UK/Germany keyboards
  111. KC_F11 = 0x57,
  112. KC_F12 = 0x58,
  113. KC_F13 = 0x64, // (NEC PC98)
  114. KC_F14 = 0x65, // (NEC PC98)
  115. KC_F15 = 0x66, // (NEC PC98)
  116. KC_KANA = 0x70, // (Japanese keyboard)
  117. KC_ABNT_C1 = 0x73, // / ? on Portugese (Brazilian) keyboards
  118. KC_CONVERT = 0x79, // (Japanese keyboard)
  119. KC_NOCONVERT = 0x7B, // (Japanese keyboard)
  120. KC_YEN = 0x7D, // (Japanese keyboard)
  121. KC_ABNT_C2 = 0x7E, // Numpad . on Portugese (Brazilian) keyboards
  122. KC_NUMPADEQUALS= 0x8D, // = on numeric keypad (NEC PC98)
  123. KC_PREVTRACK = 0x90, // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
  124. KC_AT = 0x91, // (NEC PC98)
  125. KC_COLON = 0x92, // (NEC PC98)
  126. KC_UNDERLINE = 0x93, // (NEC PC98)
  127. KC_KANJI = 0x94, // (Japanese keyboard)
  128. KC_STOP = 0x95, // (NEC PC98)
  129. KC_AX = 0x96, // (Japan AX)
  130. KC_UNLABELED = 0x97, // (J3100)
  131. KC_NEXTTRACK = 0x99, // Next Track
  132. KC_NUMPADENTER = 0x9C, // Enter on numeric keypad
  133. KC_RCONTROL = 0x9D,
  134. KC_MUTE = 0xA0, // Mute
  135. KC_CALCULATOR = 0xA1, // Calculator
  136. KC_PLAYPAUSE = 0xA2, // Play / Pause
  137. KC_MEDIASTOP = 0xA4, // Media Stop
  138. KC_VOLUMEDOWN = 0xAE, // Volume -
  139. KC_VOLUMEUP = 0xB0, // Volume +
  140. KC_WEBHOME = 0xB2, // Web home
  141. KC_NUMPADCOMMA = 0xB3, // , on numeric keypad (NEC PC98)
  142. KC_DIVIDE = 0xB5, // / on numeric keypad
  143. KC_SYSRQ = 0xB7,
  144. KC_RALT = 0xB8, // right Alt
  145. KC_PAUSE = 0xC5, // Pause
  146. KC_HOME = 0xC7, // Home on arrow keypad
  147. KC_UP = 0xC8, // UpArrow on arrow keypad
  148. KC_PGUP = 0xC9, // PgUp on arrow keypad
  149. KC_LEFT = 0xCB, // LeftArrow on arrow keypad
  150. KC_RIGHT = 0xCD, // RightArrow on arrow keypad
  151. KC_END = 0xCF, // End on arrow keypad
  152. KC_DOWN = 0xD0, // DownArrow on arrow keypad
  153. KC_PGDOWN = 0xD1, // PgDn on arrow keypad
  154. KC_INSERT = 0xD2, // Insert on arrow keypad
  155. KC_DELETE = 0xD3, // Delete on arrow keypad
  156. KC_LWIN = 0xDB, // Left Windows key
  157. KC_RWIN = 0xDC, // Right Windows key
  158. KC_APPS = 0xDD, // AppMenu key
  159. KC_POWER = 0xDE, // System Power
  160. KC_SLEEP = 0xDF, // System Sleep
  161. KC_WAKE = 0xE3, // System Wake
  162. KC_WEBSEARCH = 0xE5, // Web Search
  163. KC_WEBFAVORITES= 0xE6, // Web Favorites
  164. KC_WEBREFRESH = 0xE7, // Web Refresh
  165. KC_WEBSTOP = 0xE8, // Web Stop
  166. KC_WEBFORWARD = 0xE9, // Web Forward
  167. KC_WEBBACK = 0xEA, // Web Back
  168. KC_MYCOMPUTER = 0xEB, // My Computer
  169. KC_MAIL = 0xEC, // Mail
  170. KC_MEDIASELECT = 0xED // Media Select
  171. };
  172. enum EEvent {
  173. EV_KEY_DOWN = 0,
  174. EV_KEY_UP,
  175. EV_TEXT_ENTER,
  176. EV_MOUSE_LDOWN,
  177. EV_MOUSE_LUP,
  178. EV_MOUSE_MDOWN,
  179. EV_MOUSE_MUP,
  180. EV_MOUSE_RDOWN,
  181. EV_MOUSE_RUP,
  182. EV_MOUSE_WHEEL_UP,
  183. EV_MOUSE_WHEEL_DOWN,
  184. EV_MOUSE_MOVE
  185. };
  186. struct KeyEvent {
  187. char keychar;
  188. unsigned char keycode;
  189. bool ctrl;
  190. bool shift;
  191. bool alt;
  192. };
  193. struct MouseEvent {
  194. int x, y;
  195. };
  196. struct InputEvent {
  197. EEvent type;
  198. union {
  199. KeyEvent key;
  200. MouseEvent mouse;
  201. };
  202. };
  203. #endif // INPUT_H