KeyInput.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __KEYINPUT_H__
  21. #define __KEYINPUT_H__
  22. /*
  23. ===============================================================================
  24. Key Input
  25. ===============================================================================
  26. */
  27. // these are the key numbers that are used by the key system
  28. // normal keys should be passed as lowercased ascii
  29. // Some high ascii (> 127) characters that are mapped directly to keys on
  30. // western european keyboards are inserted in this table so that those keys
  31. // are bindable (otherwise they get bound as one of the special keys in this
  32. // table)
  33. typedef enum {
  34. K_TAB = 9,
  35. K_ENTER = 13,
  36. K_ESCAPE = 27,
  37. K_SPACE = 32,
  38. K_BACKSPACE = 127,
  39. K_COMMAND = 128,
  40. K_CAPSLOCK,
  41. K_SCROLL,
  42. K_POWER,
  43. K_PAUSE,
  44. K_UPARROW = 133,
  45. K_DOWNARROW,
  46. K_LEFTARROW,
  47. K_RIGHTARROW,
  48. // The 3 windows keys
  49. K_LWIN = 137,
  50. K_RWIN,
  51. K_MENU,
  52. K_ALT = 140,
  53. K_CTRL,
  54. K_SHIFT,
  55. K_INS,
  56. K_DEL,
  57. K_PGDN,
  58. K_PGUP,
  59. K_HOME,
  60. K_END,
  61. K_F1 = 149,
  62. K_F2,
  63. K_F3,
  64. K_F4,
  65. K_F5,
  66. K_F6,
  67. K_F7,
  68. K_F8,
  69. K_F9,
  70. K_F10,
  71. K_F11,
  72. K_F12,
  73. K_INVERTED_EXCLAMATION = 161, // upside down !
  74. K_F13,
  75. K_F14,
  76. K_F15,
  77. K_KP_HOME = 165,
  78. K_KP_UPARROW,
  79. K_KP_PGUP,
  80. K_KP_LEFTARROW,
  81. K_KP_5,
  82. K_KP_RIGHTARROW,
  83. K_KP_END,
  84. K_KP_DOWNARROW,
  85. K_KP_PGDN,
  86. K_KP_ENTER,
  87. K_KP_INS,
  88. K_KP_DEL,
  89. K_KP_SLASH,
  90. K_SUPERSCRIPT_TWO = 178, // superscript 2
  91. K_KP_MINUS,
  92. K_ACUTE_ACCENT = 180, // accute accent
  93. K_KP_PLUS,
  94. K_KP_NUMLOCK,
  95. K_KP_STAR,
  96. K_KP_EQUALS,
  97. K_MASCULINE_ORDINATOR = 186,
  98. // K_MOUSE enums must be contiguous (no char codes in the middle)
  99. K_MOUSE1 = 187,
  100. K_MOUSE2,
  101. K_MOUSE3,
  102. K_MOUSE4,
  103. K_MOUSE5,
  104. K_MOUSE6,
  105. K_MOUSE7,
  106. K_MOUSE8,
  107. K_MWHEELDOWN = 195,
  108. K_MWHEELUP,
  109. //------------------------
  110. // K_JOY codes must be contiguous, too
  111. //------------------------
  112. K_JOY1 = 197,
  113. K_JOY2,
  114. K_JOY3,
  115. K_JOY4,
  116. K_JOY5,
  117. K_JOY6,
  118. K_JOY7,
  119. K_JOY8,
  120. K_JOY9,
  121. K_JOY10,
  122. K_JOY11,
  123. K_JOY12,
  124. K_JOY13,
  125. K_JOY14,
  126. K_JOY15,
  127. K_JOY16,
  128. K_JOY_STICK1_UP,
  129. K_JOY_STICK1_DOWN,
  130. K_JOY_STICK1_LEFT,
  131. K_JOY_STICK1_RIGHT,
  132. K_JOY_STICK2_UP,
  133. K_JOY_STICK2_DOWN,
  134. K_JOY_STICK2_LEFT,
  135. K_JOY_STICK2_RIGHT,
  136. K_JOY_TRIGGER1,
  137. K_JOY_TRIGGER2,
  138. K_JOY_DPAD_UP,
  139. K_JOY_DPAD_DOWN,
  140. K_JOY_DPAD_LEFT,
  141. K_JOY_DPAD_RIGHT,
  142. K_GRAVE_A = 229, // lowercase a with grave accent
  143. K_AUX1 = 230,
  144. K_CEDILLA_C = 231, // lowercase c with Cedilla
  145. K_GRAVE_E = 232, // lowercase e with grave accent
  146. K_AUX2,
  147. K_AUX3,
  148. K_AUX4,
  149. K_GRAVE_I = 236, // lowercase i with grave accent
  150. K_AUX5,
  151. K_AUX6,
  152. K_AUX7,
  153. K_AUX8,
  154. K_TILDE_N = 241, // lowercase n with tilde
  155. K_GRAVE_O = 242, // lowercase o with grave accent
  156. K_AUX9,
  157. K_AUX10,
  158. K_AUX11,
  159. K_AUX12,
  160. K_AUX13,
  161. K_AUX14,
  162. K_GRAVE_U = 249, // lowercase u with grave accent
  163. K_AUX15,
  164. K_AUX16,
  165. K_PRINT_SCR = 252, // SysRq / PrintScr
  166. K_RIGHT_ALT = 253, // used by some languages as "Alt-Gr"
  167. K_LAST_KEY = 254 // this better be < 256!
  168. } keyNum_t;
  169. class idKeyInput {
  170. public:
  171. static void Init( void );
  172. static void Shutdown( void );
  173. static void ArgCompletion_KeyName( const idCmdArgs &args, void(*callback)( const char *s ) );
  174. static void PreliminaryKeyEvent( int keyNum, bool down );
  175. static bool IsDown( int keyNum );
  176. static int GetUsercmdAction( int keyNum );
  177. static bool GetOverstrikeMode( void );
  178. static void SetOverstrikeMode( bool state );
  179. static void ClearStates( void );
  180. static int StringToKeyNum( const char *str );
  181. static const char * KeyNumToString( int keyNum, bool localized );
  182. static void SetBinding( int keyNum, const char *binding );
  183. static const char * GetBinding( int keyNum );
  184. static bool UnbindBinding( const char *bind );
  185. static int NumBinds( const char *binding );
  186. static bool ExecKeyBinding( int keyNum );
  187. static const char * KeysFromBinding( const char *bind );
  188. static const char * BindingFromKey( const char *key );
  189. static bool KeyIsBoundTo( int keyNum, const char *binding );
  190. static void WriteBindings( idFile *f );
  191. };
  192. #endif /* !__KEYINPUT_H__ */