1 /* 2 keys.h 3 4 Key definitions and prototypes 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to: 21 22 Free Software Foundation, Inc. 23 59 Temple Place - Suite 330 24 Boston, MA 02111-1307, USA 25 26 */ 27 28 29 #ifndef _KEYS_H 30 #define _KEYS_H 31 32 #ifndef __QFCC__ 33 # include "QF/qtypes.h" 34 # include "QF/quakeio.h" 35 #endif 36 37 // these are the key numbers that should be passed to Key_Event 38 39 typedef enum { 40 /* The keyboard syms have been cleverly chosen to map to ASCII */ 41 QFK_UNKNOWN = 0, 42 QFK_FIRST = 0, 43 QFK_BACKSPACE = 8, 44 QFK_TAB = 9, 45 QFK_CLEAR = 12, 46 QFK_RETURN = 13, 47 QFK_PAUSE = 19, 48 QFK_ESCAPE = 27, 49 QFK_SPACE = 32, 50 QFK_EXCLAIM = 33, 51 QFK_QUOTEDBL = 34, 52 QFK_HASH = 35, 53 QFK_DOLLAR = 36, 54 QFK_PERCENT = 37, 55 QFK_AMPERSAND = 38, 56 QFK_QUOTE = 39, 57 QFK_LEFTPAREN = 40, 58 QFK_RIGHTPAREN = 41, 59 QFK_ASTERISK = 42, 60 QFK_PLUS = 43, 61 QFK_COMMA = 44, 62 QFK_MINUS = 45, 63 QFK_PERIOD = 46, 64 QFK_SLASH = 47, 65 QFK_0 = 48, 66 QFK_1 = 49, 67 QFK_2 = 50, 68 QFK_3 = 51, 69 QFK_4 = 52, 70 QFK_5 = 53, 71 QFK_6 = 54, 72 QFK_7 = 55, 73 QFK_8 = 56, 74 QFK_9 = 57, 75 QFK_COLON = 58, 76 QFK_SEMICOLON = 59, 77 QFK_LESS = 60, 78 QFK_EQUALS = 61, 79 QFK_GREATER = 62, 80 QFK_QUESTION = 63, 81 QFK_AT = 64, 82 /* 83 Skip uppercase letters 84 */ 85 QFK_LEFTBRACKET = 91, 86 QFK_BACKSLASH = 92, 87 QFK_RIGHTBRACKET = 93, 88 QFK_CARET = 94, 89 QFK_UNDERSCORE = 95, 90 QFK_BACKQUOTE = 96, 91 QFK_a = 97, 92 QFK_b = 98, 93 QFK_c = 99, 94 QFK_d = 100, 95 QFK_e = 101, 96 QFK_f = 102, 97 QFK_g = 103, 98 QFK_h = 104, 99 QFK_i = 105, 100 QFK_j = 106, 101 QFK_k = 107, 102 QFK_l = 108, 103 QFK_m = 109, 104 QFK_n = 110, 105 QFK_o = 111, 106 QFK_p = 112, 107 QFK_q = 113, 108 QFK_r = 114, 109 QFK_s = 115, 110 QFK_t = 116, 111 QFK_u = 117, 112 QFK_v = 118, 113 QFK_w = 119, 114 QFK_x = 120, 115 QFK_y = 121, 116 QFK_z = 122, 117 QFK_BRACELEFT = 123, 118 QFK_BAR = 124, 119 QFK_BRACERIGHT = 125, 120 QFK_ASCIITILDE = 126, 121 QFK_DELETE = 127, 122 /* End of ASCII mapped keysyms */ 123 124 /* International keyboard syms */ 125 QFK_WORLD_0 = 160, /* 0xA0 */ 126 QFK_WORLD_1 = 161, 127 QFK_WORLD_2 = 162, 128 QFK_WORLD_3 = 163, 129 QFK_WORLD_4 = 164, 130 QFK_WORLD_5 = 165, 131 QFK_WORLD_6 = 166, 132 QFK_WORLD_7 = 167, 133 QFK_WORLD_8 = 168, 134 QFK_WORLD_9 = 169, 135 QFK_WORLD_10 = 170, 136 QFK_WORLD_11 = 171, 137 QFK_WORLD_12 = 172, 138 QFK_WORLD_13 = 173, 139 QFK_WORLD_14 = 174, 140 QFK_WORLD_15 = 175, 141 QFK_WORLD_16 = 176, 142 QFK_WORLD_17 = 177, 143 QFK_WORLD_18 = 178, 144 QFK_WORLD_19 = 179, 145 QFK_WORLD_20 = 180, 146 QFK_WORLD_21 = 181, 147 QFK_WORLD_22 = 182, 148 QFK_WORLD_23 = 183, 149 QFK_WORLD_24 = 184, 150 QFK_WORLD_25 = 185, 151 QFK_WORLD_26 = 186, 152 QFK_WORLD_27 = 187, 153 QFK_WORLD_28 = 188, 154 QFK_WORLD_29 = 189, 155 QFK_WORLD_30 = 190, 156 QFK_WORLD_31 = 191, 157 QFK_WORLD_32 = 192, 158 QFK_WORLD_33 = 193, 159 QFK_WORLD_34 = 194, 160 QFK_WORLD_35 = 195, 161 QFK_WORLD_36 = 196, 162 QFK_WORLD_37 = 197, 163 QFK_WORLD_38 = 198, 164 QFK_WORLD_39 = 199, 165 QFK_WORLD_40 = 200, 166 QFK_WORLD_41 = 201, 167 QFK_WORLD_42 = 202, 168 QFK_WORLD_43 = 203, 169 QFK_WORLD_44 = 204, 170 QFK_WORLD_45 = 205, 171 QFK_WORLD_46 = 206, 172 QFK_WORLD_47 = 207, 173 QFK_WORLD_48 = 208, 174 QFK_WORLD_49 = 209, 175 QFK_WORLD_50 = 210, 176 QFK_WORLD_51 = 211, 177 QFK_WORLD_52 = 212, 178 QFK_WORLD_53 = 213, 179 QFK_WORLD_54 = 214, 180 QFK_WORLD_55 = 215, 181 QFK_WORLD_56 = 216, 182 QFK_WORLD_57 = 217, 183 QFK_WORLD_58 = 218, 184 QFK_WORLD_59 = 219, 185 QFK_WORLD_60 = 220, 186 QFK_WORLD_61 = 221, 187 QFK_WORLD_62 = 222, 188 QFK_WORLD_63 = 223, 189 QFK_WORLD_64 = 224, 190 QFK_WORLD_65 = 225, 191 QFK_WORLD_66 = 226, 192 QFK_WORLD_67 = 227, 193 QFK_WORLD_68 = 228, 194 QFK_WORLD_69 = 229, 195 QFK_WORLD_70 = 230, 196 QFK_WORLD_71 = 231, 197 QFK_WORLD_72 = 232, 198 QFK_WORLD_73 = 233, 199 QFK_WORLD_74 = 234, 200 QFK_WORLD_75 = 235, 201 QFK_WORLD_76 = 236, 202 QFK_WORLD_77 = 237, 203 QFK_WORLD_78 = 238, 204 QFK_WORLD_79 = 239, 205 QFK_WORLD_80 = 240, 206 QFK_WORLD_81 = 241, 207 QFK_WORLD_82 = 242, 208 QFK_WORLD_83 = 243, 209 QFK_WORLD_84 = 244, 210 QFK_WORLD_85 = 245, 211 QFK_WORLD_86 = 246, 212 QFK_WORLD_87 = 247, 213 QFK_WORLD_88 = 248, 214 QFK_WORLD_89 = 249, 215 QFK_WORLD_90 = 250, 216 QFK_WORLD_91 = 251, 217 QFK_WORLD_92 = 252, 218 QFK_WORLD_93 = 253, 219 QFK_WORLD_94 = 254, 220 QFK_WORLD_95 = 255, /* 0xFF */ 221 222 /* Numeric keypad */ 223 QFK_KP0 = 256, 224 QFK_KP1 = 257, 225 QFK_KP2 = 258, 226 QFK_KP3 = 259, 227 QFK_KP4 = 260, 228 QFK_KP5 = 261, 229 QFK_KP6 = 262, 230 QFK_KP7 = 263, 231 QFK_KP8 = 264, 232 QFK_KP9 = 265, 233 QFK_KP_PERIOD = 266, 234 QFK_KP_DIVIDE = 267, 235 QFK_KP_MULTIPLY = 268, 236 QFK_KP_MINUS = 269, 237 QFK_KP_PLUS = 270, 238 QFK_KP_ENTER = 271, 239 QFK_KP_EQUALS = 272, 240 241 /* Arrows + Home/End pad */ 242 QFK_UP = 273, 243 QFK_DOWN = 274, 244 QFK_RIGHT = 275, 245 QFK_LEFT = 276, 246 QFK_INSERT = 277, 247 QFK_HOME = 278, 248 QFK_END = 279, 249 QFK_PAGEUP = 280, 250 QFK_PAGEDOWN = 281, 251 252 /* Function keys */ 253 QFK_F1 = 282, 254 QFK_F2 = 283, 255 QFK_F3 = 284, 256 QFK_F4 = 285, 257 QFK_F5 = 286, 258 QFK_F6 = 287, 259 QFK_F7 = 288, 260 QFK_F8 = 289, 261 QFK_F9 = 290, 262 QFK_F10 = 291, 263 QFK_F11 = 292, 264 QFK_F12 = 293, 265 QFK_F13 = 294, 266 QFK_F14 = 295, 267 QFK_F15 = 296, 268 269 /* Key state modifier keys */ 270 QFK_NUMLOCK = 300, 271 QFK_CAPSLOCK = 301, 272 QFK_SCROLLOCK = 302, 273 QFK_RSHIFT = 303, 274 QFK_LSHIFT = 304, 275 QFK_RCTRL = 305, 276 QFK_LCTRL = 306, 277 QFK_RALT = 307, 278 QFK_LALT = 308, 279 QFK_RMETA = 309, 280 QFK_LMETA = 310, 281 QFK_LSUPER = 311, /* Left "Windows" key */ 282 QFK_RSUPER = 312, /* Right "Windows" key */ 283 QFK_MODE = 313, /* "Alt Gr" key */ 284 QFK_COMPOSE = 314, /* Multi-key compose key */ 285 286 /* Miscellaneous function keys */ 287 QFK_HELP = 315, 288 QFK_PRINT = 316, 289 QFK_SYSREQ = 317, 290 QFK_BREAK = 318, 291 QFK_MENU = 319, 292 QFK_POWER = 320, /* Power Macintosh power key */ 293 QFK_EURO = 321, /* Some european keyboards */ 294 QFK_UNDO = 322, 295 296 /* Japanese keys */ 297 QFK_KANJI, /* Kanji, Kanji convert */ 298 QFK_MUHENKAN, /* Cancel Conversion */ 299 QFK_HENKAN, /* Alias for Henkan_Mode */ 300 QFK_ROMAJI, /* to Romaji */ 301 QFK_HIRAGANA, /* to Hiragana */ 302 QFK_KATAKANA, /* to Katakana */ 303 QFK_HIRAGANA_KATAKANA, /* Hiragana/Katakana toggle */ 304 QFK_ZENKAKU, /* to Zenkaku */ 305 QFK_HANKAKU, /* to Hankaku */ 306 QFK_ZENKAKU_HANKAKU, /* Zenkaku/Hankaku toggle */ 307 QFK_TOUROKU, /* Add to Dictionary */ 308 QFK_MASSYO, /* Delete from Dictionary */ 309 QFK_KANA_LOCK, /* Kana Lock */ 310 QFK_KANA_SHIFT, /* Kana Shift */ 311 QFK_EISU_SHIFT, /* Alphanumeric Shift */ 312 QFK_EISU_TOGGLE, /* Alphanumeric toggle */ 313 QFK_KANJI_BANGOU, /* Codeinput */ 314 QFK_ZEN_KOHO, /* Multiple/All Candidate(s) */ 315 QFK_MAE_KOHO, /* Previous Candidate */ 316 317 /* some multi-media/browser keys */ 318 QFK_HOMEPAGE, 319 QFK_SEARCH, 320 QFK_MAIL, 321 QFK_FAVORITES, 322 QFK_AUDIOMUTE, 323 QFK_AUDIOLOWERVOLUME, 324 QFK_AUDIORAISEVOLUME, 325 QFK_AUDIOPLAY, 326 QFK_CALCULATOR, 327 QFK_REDO, 328 QFK_NEW, 329 QFK_RELOAD, 330 QFK_OPEN, 331 QFK_CLOSE, 332 QFK_REPLY, 333 QFK_MAILFORWARD, 334 QFK_SEND, 335 QFK_SAVE, 336 QFK_BACK, 337 QFK_FORWARD, 338 339 /* Add any other keys here */ 340 341 // 342 // mouse buttons generate virtual keys 343 // 344 QFM_BUTTON1, 345 QFM_BUTTON2, 346 QFM_BUTTON3, 347 QFM_WHEEL_UP, 348 QFM_WHEEL_DOWN, 349 QFM_BUTTON6, 350 QFM_BUTTON7, 351 QFM_BUTTON8, 352 QFM_BUTTON9, 353 QFM_BUTTON10, 354 QFM_BUTTON11, 355 QFM_BUTTON12, 356 QFM_BUTTON13, 357 QFM_BUTTON14, 358 QFM_BUTTON15, 359 QFM_BUTTON16, 360 QFM_BUTTON17, 361 QFM_BUTTON18, 362 QFM_BUTTON19, 363 QFM_BUTTON20, 364 QFM_BUTTON21, 365 QFM_BUTTON22, 366 QFM_BUTTON23, 367 QFM_BUTTON24, 368 QFM_BUTTON25, 369 QFM_BUTTON26, 370 QFM_BUTTON27, 371 QFM_BUTTON28, 372 QFM_BUTTON29, 373 QFM_BUTTON30, 374 QFM_BUTTON31, 375 QFM_BUTTON32, 376 377 // 378 // joystick buttons 379 // 380 QFJ_BUTTON1, 381 QFJ_BUTTON2, 382 QFJ_BUTTON3, 383 QFJ_BUTTON4, 384 QFJ_BUTTON5, 385 QFJ_BUTTON6, 386 QFJ_BUTTON7, 387 QFJ_BUTTON8, 388 QFJ_BUTTON9, 389 QFJ_BUTTON10, 390 QFJ_BUTTON11, 391 QFJ_BUTTON12, 392 QFJ_BUTTON13, 393 QFJ_BUTTON14, 394 QFJ_BUTTON15, 395 QFJ_BUTTON16, 396 QFJ_BUTTON17, 397 QFJ_BUTTON18, 398 QFJ_BUTTON19, 399 QFJ_BUTTON20, 400 QFJ_BUTTON21, 401 QFJ_BUTTON22, 402 QFJ_BUTTON23, 403 QFJ_BUTTON24, 404 QFJ_BUTTON25, 405 QFJ_BUTTON26, 406 QFJ_BUTTON27, 407 QFJ_BUTTON28, 408 QFJ_BUTTON29, 409 QFJ_BUTTON30, 410 QFJ_BUTTON31, 411 QFJ_BUTTON32, 412 413 QFK_LAST 414 } knum_t; 415 416 typedef enum { 417 key_unfocused, // engine has lost input focus 418 key_game, 419 key_demo, 420 key_console, 421 key_message, 422 key_menu, 423 424 key_last // enum size 425 } keydest_t; 426 427 #ifndef __QFCC__ 428 typedef struct { 429 int down[2]; // key nums holding it down 430 int state; // low bit is down state 431 } kbutton_t; 432 433 extern knum_t key_togglemenu; 434 extern knum_t key_toggleconsole; 435 436 typedef struct keybind_s { 437 char *str; 438 } keybind_t; 439 440 /** Input Mapping Table 441 */ 442 typedef struct imt_s { 443 struct imt_s *next; ///< list of tables attached to key_dest 444 struct imt_s *chain; ///< fallback table if key not bound 445 const char *name; ///< for user interaction 446 keybind_t bindings[QFK_LAST]; 447 int written; ///< avoid duplicate config file writes 448 } imt_t; 449 450 typedef struct keytarget_s { 451 imt_t *imts; 452 imt_t *active; 453 } keytarget_t; 454 455 extern int keydown[QFK_LAST]; 456 457 imt_t *Key_FindIMT (const char *imt_name); 458 void Key_CreateIMT (keydest_t kd, const char *imt_name, 459 const char *chain_imt_name); 460 461 struct cbuf_s; 462 void Key_Event (knum_t key, short unicode, qboolean down); 463 void Key_FocusEvent (int gain); 464 void Key_Init (struct cbuf_s *cb); 465 void Key_Init_Cvars (void); 466 void Key_WriteBindings (QFile *f); 467 void Key_ClearStates (void); 468 const char *Key_GetBinding (const char *imt_name, knum_t key); 469 void Key_SetBinding (imt_t *imt, knum_t keynum, const char *binding); 470 void Key_SetKeyDest(keydest_t kd); 471 typedef void keydest_callback_t (keydest_t); 472 void Key_KeydestCallback (keydest_callback_t *callback); 473 474 475 const char *Key_KeynumToString (knum_t keynum); 476 struct progs_s; 477 void Key_Progs_Init (struct progs_s *pr); 478 #endif 479 480 #endif // _KEYS_H 481