mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-26 22:40:50 +00:00
Merge pull request #551 from DanielGibson/scancode-input
Scancodes for Input and other keyboard input improvements
This commit is contained in:
commit
d1a53bdeec
7 changed files with 420 additions and 255 deletions
|
@ -130,7 +130,7 @@ CL_DrawInventory(void)
|
|||
cl.configstrings[CS_ITEMS + item]);
|
||||
bind = "";
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
for (j = 0; j < K_LAST; j++)
|
||||
{
|
||||
if (keybindings[j] && !Q_stricmp(keybindings[j], binding))
|
||||
{
|
||||
|
|
|
@ -64,6 +64,10 @@ keyname_t keynames[] = {
|
|||
{"ENTER", K_ENTER},
|
||||
{"ESCAPE", K_ESCAPE},
|
||||
{"SPACE", K_SPACE},
|
||||
{"SEMICOLON", ';'}, /* because a raw semicolon separates commands */
|
||||
{"DOUBLEQUOTE", '"'}, /* because "" has special meaning in configs */
|
||||
{"QUOTE", '\'' }, /* just to be sure */
|
||||
{"DOLLAR", '$'}, /* $ is used in macros => can occur in configs */
|
||||
{"BACKSPACE", K_BACKSPACE},
|
||||
|
||||
{"COMMAND", K_COMMAND},
|
||||
|
@ -80,6 +84,13 @@ keyname_t keynames[] = {
|
|||
{"CTRL", K_CTRL},
|
||||
{"SHIFT", K_SHIFT},
|
||||
|
||||
{"INS", K_INS},
|
||||
{"DEL", K_DEL},
|
||||
{"PGDN", K_PGDN},
|
||||
{"PGUP", K_PGUP},
|
||||
{"HOME", K_HOME},
|
||||
{"END", K_END},
|
||||
|
||||
{"F1", K_F1},
|
||||
{"F2", K_F2},
|
||||
{"F3", K_F3},
|
||||
|
@ -92,13 +103,28 @@ keyname_t keynames[] = {
|
|||
{"F10", K_F10},
|
||||
{"F11", K_F11},
|
||||
{"F12", K_F12},
|
||||
{"F13", K_F13},
|
||||
{"F14", K_F14},
|
||||
{"F15", K_F15},
|
||||
|
||||
{"INS", K_INS},
|
||||
{"DEL", K_DEL},
|
||||
{"PGDN", K_PGDN},
|
||||
{"PGUP", K_PGUP},
|
||||
{"HOME", K_HOME},
|
||||
{"END", K_END},
|
||||
{"KP_HOME", K_KP_HOME},
|
||||
{"KP_UPARROW", K_KP_UPARROW},
|
||||
{"KP_PGUP", K_KP_PGUP},
|
||||
{"KP_LEFTARROW", K_KP_LEFTARROW},
|
||||
{"KP_5", K_KP_5},
|
||||
{"KP_RIGHTARROW", K_KP_RIGHTARROW},
|
||||
{"KP_END", K_KP_END},
|
||||
{"KP_DOWNARROW", K_KP_DOWNARROW},
|
||||
{"KP_PGDN", K_KP_PGDN},
|
||||
{"KP_ENTER", K_KP_ENTER},
|
||||
{"KP_INS", K_KP_INS},
|
||||
{"KP_DEL", K_KP_DEL},
|
||||
{"KP_SLASH", K_KP_SLASH},
|
||||
{"KP_MINUS", K_KP_MINUS},
|
||||
{"KP_PLUS", K_KP_PLUS},
|
||||
{"KP_NUMLOCK", K_KP_NUMLOCK},
|
||||
{"KP_STAR", K_KP_STAR},
|
||||
{"KP_EQUALS", K_KP_EQUALS},
|
||||
|
||||
{"MOUSE1", K_MOUSE1},
|
||||
{"MOUSE2", K_MOUSE2},
|
||||
|
@ -106,6 +132,9 @@ keyname_t keynames[] = {
|
|||
{"MOUSE4", K_MOUSE4},
|
||||
{"MOUSE5", K_MOUSE5},
|
||||
|
||||
{"MWHEELUP", K_MWHEELUP},
|
||||
{"MWHEELDOWN", K_MWHEELDOWN},
|
||||
|
||||
{"JOY1", K_JOY1},
|
||||
{"JOY2", K_JOY2},
|
||||
{"JOY3", K_JOY3},
|
||||
|
@ -192,62 +221,74 @@ keyname_t keynames[] = {
|
|||
|
||||
{"JOY_BACK", K_JOY_BACK},
|
||||
|
||||
{"AUX1", K_AUX1},
|
||||
{"AUX2", K_AUX2},
|
||||
{"AUX3", K_AUX3},
|
||||
{"AUX4", K_AUX4},
|
||||
{"AUX5", K_AUX5},
|
||||
{"AUX6", K_AUX6},
|
||||
{"AUX7", K_AUX7},
|
||||
{"AUX8", K_AUX8},
|
||||
{"AUX9", K_AUX9},
|
||||
{"AUX10", K_AUX10},
|
||||
{"AUX11", K_AUX11},
|
||||
{"AUX12", K_AUX12},
|
||||
{"AUX13", K_AUX13},
|
||||
{"AUX14", K_AUX14},
|
||||
{"AUX15", K_AUX15},
|
||||
{"AUX16", K_AUX16},
|
||||
{"AUX17", K_AUX17},
|
||||
{"AUX18", K_AUX18},
|
||||
{"AUX19", K_AUX19},
|
||||
{"AUX20", K_AUX20},
|
||||
{"AUX21", K_AUX21},
|
||||
{"AUX22", K_AUX22},
|
||||
{"AUX23", K_AUX23},
|
||||
{"AUX24", K_AUX24},
|
||||
{"AUX25", K_AUX25},
|
||||
{"AUX26", K_AUX26},
|
||||
{"AUX27", K_AUX27},
|
||||
{"AUX28", K_AUX28},
|
||||
{"AUX29", K_AUX29},
|
||||
{"AUX30", K_AUX30},
|
||||
{"AUX31", K_AUX31},
|
||||
{"AUX32", K_AUX32},
|
||||
{"SUPER", K_SUPER},
|
||||
{"COMPOSE", K_COMPOSE},
|
||||
{"MODE", K_MODE},
|
||||
{"HELP", K_HELP},
|
||||
{"PRINT", K_PRINT},
|
||||
{"SYSREQ", K_SYSREQ},
|
||||
{"SCROLLOCK", K_SCROLLOCK},
|
||||
{"MENU", K_MENU},
|
||||
{"UNDO", K_UNDO},
|
||||
|
||||
{"KP_HOME", K_KP_HOME},
|
||||
{"KP_UPARROW", K_KP_UPARROW},
|
||||
{"KP_PGUP", K_KP_PGUP},
|
||||
{"KP_LEFTARROW", K_KP_LEFTARROW},
|
||||
{"KP_5", K_KP_5},
|
||||
{"KP_RIGHTARROW", K_KP_RIGHTARROW},
|
||||
{"KP_END", K_KP_END},
|
||||
{"KP_DOWNARROW", K_KP_DOWNARROW},
|
||||
{"KP_PGDN", K_KP_PGDN},
|
||||
{"KP_ENTER", K_KP_ENTER},
|
||||
{"KP_INS", K_KP_INS},
|
||||
{"KP_DEL", K_KP_DEL},
|
||||
{"KP_SLASH", K_KP_SLASH},
|
||||
{"KP_STAR", K_KP_STAR},
|
||||
{"KP_MINUS", K_KP_MINUS},
|
||||
{"KP_PLUS", K_KP_PLUS},
|
||||
// entries for the mapped scancodes, see comment above K_SC_A in keyboard.h
|
||||
#define MY_SC_ENTRY(X) { #X , K_ ## X }
|
||||
|
||||
{"MWHEELUP", K_MWHEELUP},
|
||||
{"MWHEELDOWN", K_MWHEELDOWN},
|
||||
// { "SC_A", K_SC_A },
|
||||
MY_SC_ENTRY(SC_A),
|
||||
MY_SC_ENTRY(SC_B),
|
||||
MY_SC_ENTRY(SC_C),
|
||||
MY_SC_ENTRY(SC_D),
|
||||
MY_SC_ENTRY(SC_E),
|
||||
MY_SC_ENTRY(SC_F),
|
||||
MY_SC_ENTRY(SC_G),
|
||||
MY_SC_ENTRY(SC_H),
|
||||
MY_SC_ENTRY(SC_I),
|
||||
MY_SC_ENTRY(SC_J),
|
||||
MY_SC_ENTRY(SC_K),
|
||||
MY_SC_ENTRY(SC_L),
|
||||
MY_SC_ENTRY(SC_M),
|
||||
MY_SC_ENTRY(SC_N),
|
||||
MY_SC_ENTRY(SC_O),
|
||||
MY_SC_ENTRY(SC_P),
|
||||
MY_SC_ENTRY(SC_Q),
|
||||
MY_SC_ENTRY(SC_R),
|
||||
MY_SC_ENTRY(SC_S),
|
||||
MY_SC_ENTRY(SC_T),
|
||||
MY_SC_ENTRY(SC_U),
|
||||
MY_SC_ENTRY(SC_V),
|
||||
MY_SC_ENTRY(SC_W),
|
||||
MY_SC_ENTRY(SC_X),
|
||||
MY_SC_ENTRY(SC_Y),
|
||||
MY_SC_ENTRY(SC_Z),
|
||||
MY_SC_ENTRY(SC_MINUS),
|
||||
MY_SC_ENTRY(SC_EQUALS),
|
||||
MY_SC_ENTRY(SC_LEFTBRACKET),
|
||||
MY_SC_ENTRY(SC_RIGHTBRACKET),
|
||||
MY_SC_ENTRY(SC_BACKSLASH),
|
||||
MY_SC_ENTRY(SC_NONUSHASH),
|
||||
MY_SC_ENTRY(SC_SEMICOLON),
|
||||
MY_SC_ENTRY(SC_APOSTROPHE),
|
||||
MY_SC_ENTRY(SC_GRAVE), // console key
|
||||
MY_SC_ENTRY(SC_COMMA),
|
||||
MY_SC_ENTRY(SC_PERIOD),
|
||||
MY_SC_ENTRY(SC_SLASH),
|
||||
MY_SC_ENTRY(SC_NONUSBACKSLASH),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL1),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL2),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL3),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL4),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL5),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL6),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL7),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL8),
|
||||
MY_SC_ENTRY(SC_INTERNATIONAL9),
|
||||
MY_SC_ENTRY(SC_THOUSANDSSEPARATOR),
|
||||
MY_SC_ENTRY(SC_DECIMALSEPARATOR),
|
||||
MY_SC_ENTRY(SC_CURRENCYUNIT),
|
||||
MY_SC_ENTRY(SC_CURRENCYSUBUNIT),
|
||||
|
||||
{"PAUSE", K_PAUSE},
|
||||
|
||||
{"SEMICOLON", ';'}, /* because a raw semicolon seperates commands */
|
||||
#undef MY_SC_ENTRY
|
||||
|
||||
{NULL, 0}
|
||||
};
|
||||
|
@ -695,9 +736,11 @@ Key_KeynumToString(int keynum)
|
|||
return "<KEY NOT FOUND>";
|
||||
}
|
||||
|
||||
if ((keynum > 32) && (keynum < 127))
|
||||
if ((keynum > 32) && (keynum < 127) && keynum != ';' && keynum != '"' && keynum != '\'' && keynum != '$')
|
||||
{
|
||||
/* printable ascii */
|
||||
/* printable ASCII, except for special cases that have special meanings
|
||||
in configs like quotes or ; (separates commands) or $ (used to expand
|
||||
cvars to their values in macros/commands) and thus need escaping */
|
||||
tinystr[0] = keynum;
|
||||
return tinystr;
|
||||
}
|
||||
|
@ -1053,13 +1096,6 @@ Key_Init(void)
|
|||
void
|
||||
Char_Event(int key)
|
||||
{
|
||||
/* console key is hardcoded, so the user can never unbind it */
|
||||
if ((key == '^') || (key == '~') || (key == '`'))
|
||||
{
|
||||
Con_ToggleConsole_f();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cls.key_dest)
|
||||
{
|
||||
/* Chat */
|
||||
|
@ -1164,10 +1200,13 @@ Key_Event(int key, qboolean down, qboolean special)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Toogle console though Shift + Escape */
|
||||
if (down && keydown[K_SHIFT] && key == K_ESCAPE)
|
||||
/* Toogle console through Shift + Escape or special K_CONSOLE key */
|
||||
if (key == K_CONSOLE || (keydown[K_SHIFT] && key == K_ESCAPE))
|
||||
{
|
||||
Con_ToggleConsole_f();
|
||||
if (down)
|
||||
{
|
||||
Con_ToggleConsole_f();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1175,7 +1214,7 @@ Key_Event(int key, qboolean down, qboolean special)
|
|||
if ((key >= K_MOUSE1 && key != K_JOY_BACK) && !keybindings[key] && (cls.key_dest != key_console) &&
|
||||
(cls.state == ca_active))
|
||||
{
|
||||
Com_Printf("%s is unbound, hit F4 to set.\n", Key_KeynumToString(key));
|
||||
Com_Printf("%s (%d) is unbound, hit F4 to set.\n", Key_KeynumToString(key), key);
|
||||
}
|
||||
|
||||
/* While in attract loop all keys besides F1 to F12 (to
|
||||
|
|
|
@ -47,16 +47,21 @@
|
|||
extern qboolean joy_altselector_pressed;
|
||||
|
||||
/* these are the key numbers that should be passed to Key_Event
|
||||
they must be mached by the low level key event processing! */
|
||||
they must be matched by the low level key event processing! */
|
||||
enum QKEYS {
|
||||
K_TAB = 9,
|
||||
K_ENTER = 13,
|
||||
K_ESCAPE = 27,
|
||||
// Note: ASCII keys are generally valid but don't get constants here,
|
||||
// just use 'a' (yes, lowercase) or '2' or whatever, however there are
|
||||
// some special cases when writing/parsing configs (space or quotes or
|
||||
// also ; and $ have a special meaning there so we use e.g. "SPACE" instead),
|
||||
// see keynames[] in cl_keyboard.c
|
||||
K_SPACE = 32,
|
||||
|
||||
K_BACKSPACE = 127,
|
||||
|
||||
K_COMMAND = 128,
|
||||
K_COMMAND = 128, // "Windows Key"
|
||||
K_CAPSLOCK,
|
||||
K_POWER,
|
||||
K_PAUSE,
|
||||
|
@ -212,40 +217,7 @@ enum QKEYS {
|
|||
// add other joystick/controller keys before this one and adjust it accordingly
|
||||
K_JOY_LAST_REGULAR_ALT = K_TRIG_RIGHT_ALT,
|
||||
|
||||
K_AUX1,
|
||||
K_AUX2,
|
||||
K_AUX3,
|
||||
K_AUX4,
|
||||
K_AUX5,
|
||||
K_AUX6,
|
||||
K_AUX7,
|
||||
K_AUX8,
|
||||
K_AUX9,
|
||||
K_AUX10,
|
||||
K_AUX11,
|
||||
K_AUX12,
|
||||
K_AUX13,
|
||||
K_AUX14,
|
||||
K_AUX15,
|
||||
K_AUX16,
|
||||
K_AUX17,
|
||||
K_AUX18,
|
||||
K_AUX19,
|
||||
K_AUX20,
|
||||
K_AUX21,
|
||||
K_AUX22,
|
||||
K_AUX23,
|
||||
K_AUX24,
|
||||
K_AUX25,
|
||||
K_AUX26,
|
||||
K_AUX27,
|
||||
K_AUX28,
|
||||
K_AUX29,
|
||||
K_AUX30,
|
||||
K_AUX31,
|
||||
K_AUX32,
|
||||
|
||||
K_SUPER,
|
||||
K_SUPER, // TODO: what is this? SDL doesn't seem to know it..
|
||||
K_COMPOSE,
|
||||
K_MODE,
|
||||
K_HELP,
|
||||
|
@ -255,6 +227,75 @@ enum QKEYS {
|
|||
K_MENU,
|
||||
K_UNDO,
|
||||
|
||||
// The following are mapped from SDL_Scancodes, used as a *fallback* for keys
|
||||
// whose SDL_KeyCode we don't have a K_ constant for, like German Umlaut keys.
|
||||
// The scancode name corresponds to the key at that position on US-QWERTY keyboards
|
||||
// *not* the one in the local layout (e.g. German 'Ö' key is K_SC_SEMICOLON)
|
||||
// !!! NOTE: if you add a scancode here, make sure to also add it to:
|
||||
// 1. keynames[] in cl_keyboard.c
|
||||
// 2. IN_TranslateScancodeToQ2Key() in input/sdl.c
|
||||
K_SC_A,
|
||||
K_SC_B,
|
||||
K_SC_C,
|
||||
K_SC_D,
|
||||
K_SC_E,
|
||||
K_SC_F,
|
||||
K_SC_G,
|
||||
K_SC_H,
|
||||
K_SC_I,
|
||||
K_SC_J,
|
||||
K_SC_K,
|
||||
K_SC_L,
|
||||
K_SC_M,
|
||||
K_SC_N,
|
||||
K_SC_O,
|
||||
K_SC_P,
|
||||
K_SC_Q,
|
||||
K_SC_R,
|
||||
K_SC_S,
|
||||
K_SC_T,
|
||||
K_SC_U,
|
||||
K_SC_V,
|
||||
K_SC_W,
|
||||
K_SC_X,
|
||||
K_SC_Y,
|
||||
K_SC_Z,
|
||||
// leaving out SDL_SCANCODE_1 ... _0, we handle them separately already
|
||||
// also return, escape, backspace, tab, space, already handled as keycodes
|
||||
K_SC_MINUS,
|
||||
K_SC_EQUALS,
|
||||
K_SC_LEFTBRACKET,
|
||||
K_SC_RIGHTBRACKET,
|
||||
K_SC_BACKSLASH,
|
||||
K_SC_NONUSHASH,
|
||||
K_SC_SEMICOLON,
|
||||
K_SC_APOSTROPHE,
|
||||
K_SC_GRAVE,
|
||||
K_SC_COMMA,
|
||||
K_SC_PERIOD,
|
||||
K_SC_SLASH,
|
||||
// leaving out lots of key incl. from keypad, we already handle them as normal keys
|
||||
K_SC_NONUSBACKSLASH,
|
||||
K_SC_INTERNATIONAL1, /**< used on Asian keyboards, see footnotes in USB doc */
|
||||
K_SC_INTERNATIONAL2,
|
||||
K_SC_INTERNATIONAL3, /**< Yen */
|
||||
K_SC_INTERNATIONAL4,
|
||||
K_SC_INTERNATIONAL5,
|
||||
K_SC_INTERNATIONAL6,
|
||||
K_SC_INTERNATIONAL7,
|
||||
K_SC_INTERNATIONAL8,
|
||||
K_SC_INTERNATIONAL9,
|
||||
K_SC_THOUSANDSSEPARATOR,
|
||||
K_SC_DECIMALSEPARATOR,
|
||||
K_SC_CURRENCYUNIT,
|
||||
K_SC_CURRENCYSUBUNIT,
|
||||
|
||||
// hardcoded pseudo-key to open the console, emitted when pressing the "console key"
|
||||
// (SDL_SCANCODE_GRAVE, the one between Esc, 1 and Tab) on layouts that don't
|
||||
// have a relevant char there (unlike Brazilian which has quotes there which you
|
||||
// want to be able to type in the console) - the user can't bind this key.
|
||||
K_CONSOLE,
|
||||
|
||||
K_LAST
|
||||
};
|
||||
|
||||
|
|
|
@ -162,66 +162,77 @@ IN_TranslateSDLtoQ2Key(unsigned int keysym)
|
|||
/* These must be translated */
|
||||
switch (keysym)
|
||||
{
|
||||
case SDLK_PAGEUP:
|
||||
key = K_PGUP;
|
||||
break;
|
||||
case SDLK_KP_9:
|
||||
key = K_KP_PGUP;
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
key = K_PGDN;
|
||||
break;
|
||||
case SDLK_KP_3:
|
||||
key = K_KP_PGDN;
|
||||
break;
|
||||
case SDLK_KP_7:
|
||||
key = K_KP_HOME;
|
||||
break;
|
||||
case SDLK_HOME:
|
||||
key = K_HOME;
|
||||
break;
|
||||
case SDLK_KP_1:
|
||||
key = K_KP_END;
|
||||
break;
|
||||
case SDLK_END:
|
||||
key = K_END;
|
||||
break;
|
||||
case SDLK_KP_4:
|
||||
key = K_KP_LEFTARROW;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
key = K_LEFTARROW;
|
||||
break;
|
||||
case SDLK_KP_6:
|
||||
key = K_KP_RIGHTARROW;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
key = K_RIGHTARROW;
|
||||
break;
|
||||
case SDLK_KP_2:
|
||||
key = K_KP_DOWNARROW;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
key = K_DOWNARROW;
|
||||
break;
|
||||
case SDLK_KP_8:
|
||||
key = K_KP_UPARROW;
|
||||
break;
|
||||
case SDLK_UP:
|
||||
key = K_UPARROW;
|
||||
break;
|
||||
case SDLK_ESCAPE:
|
||||
key = K_ESCAPE;
|
||||
break;
|
||||
case SDLK_KP_ENTER:
|
||||
key = K_KP_ENTER;
|
||||
case SDLK_TAB:
|
||||
key = K_TAB;
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
key = K_ENTER;
|
||||
break;
|
||||
case SDLK_TAB:
|
||||
key = K_TAB;
|
||||
case SDLK_ESCAPE:
|
||||
key = K_ESCAPE;
|
||||
break;
|
||||
case SDLK_BACKSPACE:
|
||||
key = K_BACKSPACE;
|
||||
break;
|
||||
case SDLK_LGUI:
|
||||
case SDLK_RGUI:
|
||||
key = K_COMMAND; // Win key
|
||||
break;
|
||||
case SDLK_CAPSLOCK:
|
||||
key = K_CAPSLOCK;
|
||||
break;
|
||||
case SDLK_POWER:
|
||||
key = K_POWER;
|
||||
break;
|
||||
case SDLK_PAUSE:
|
||||
key = K_PAUSE;
|
||||
break;
|
||||
|
||||
case SDLK_UP:
|
||||
key = K_UPARROW;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
key = K_DOWNARROW;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
key = K_LEFTARROW;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
key = K_RIGHTARROW;
|
||||
break;
|
||||
|
||||
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT:
|
||||
key = K_ALT;
|
||||
break;
|
||||
case SDLK_LCTRL:
|
||||
case SDLK_RCTRL:
|
||||
key = K_CTRL;
|
||||
break;
|
||||
case SDLK_LSHIFT:
|
||||
case SDLK_RSHIFT:
|
||||
key = K_SHIFT;
|
||||
break;
|
||||
case SDLK_INSERT:
|
||||
key = K_INS;
|
||||
break;
|
||||
case SDLK_DELETE:
|
||||
key = K_DEL;
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
key = K_PGDN;
|
||||
break;
|
||||
case SDLK_PAGEUP:
|
||||
key = K_PGUP;
|
||||
break;
|
||||
case SDLK_HOME:
|
||||
key = K_HOME;
|
||||
break;
|
||||
case SDLK_END:
|
||||
key = K_END;
|
||||
break;
|
||||
|
||||
case SDLK_F1:
|
||||
key = K_F1;
|
||||
break;
|
||||
|
@ -267,61 +278,71 @@ IN_TranslateSDLtoQ2Key(unsigned int keysym)
|
|||
case SDLK_F15:
|
||||
key = K_F15;
|
||||
break;
|
||||
case SDLK_BACKSPACE:
|
||||
key = K_BACKSPACE;
|
||||
|
||||
|
||||
case SDLK_KP_7:
|
||||
key = K_KP_HOME;
|
||||
break;
|
||||
case SDLK_KP_PERIOD:
|
||||
key = K_KP_DEL;
|
||||
case SDLK_KP_8:
|
||||
key = K_KP_UPARROW;
|
||||
break;
|
||||
case SDLK_DELETE:
|
||||
key = K_DEL;
|
||||
case SDLK_KP_9:
|
||||
key = K_KP_PGUP;
|
||||
break;
|
||||
case SDLK_PAUSE:
|
||||
key = K_PAUSE;
|
||||
break;
|
||||
case SDLK_LSHIFT:
|
||||
case SDLK_RSHIFT:
|
||||
key = K_SHIFT;
|
||||
break;
|
||||
case SDLK_LCTRL:
|
||||
case SDLK_RCTRL:
|
||||
key = K_CTRL;
|
||||
break;
|
||||
case SDLK_LGUI:
|
||||
case SDLK_RGUI:
|
||||
key = K_COMMAND;
|
||||
break;
|
||||
case SDLK_RALT:
|
||||
case SDLK_LALT:
|
||||
key = K_ALT;
|
||||
case SDLK_KP_4:
|
||||
key = K_KP_LEFTARROW;
|
||||
break;
|
||||
case SDLK_KP_5:
|
||||
key = K_KP_5;
|
||||
break;
|
||||
case SDLK_INSERT:
|
||||
key = K_INS;
|
||||
case SDLK_KP_6:
|
||||
key = K_KP_RIGHTARROW;
|
||||
break;
|
||||
case SDLK_KP_1:
|
||||
key = K_KP_END;
|
||||
break;
|
||||
case SDLK_KP_2:
|
||||
key = K_KP_DOWNARROW;
|
||||
break;
|
||||
case SDLK_KP_3:
|
||||
key = K_KP_PGDN;
|
||||
break;
|
||||
case SDLK_KP_ENTER:
|
||||
key = K_KP_ENTER;
|
||||
break;
|
||||
case SDLK_KP_0:
|
||||
key = K_KP_INS;
|
||||
break;
|
||||
case SDLK_KP_MULTIPLY:
|
||||
key = K_KP_STAR;
|
||||
break;
|
||||
case SDLK_KP_PLUS:
|
||||
key = K_KP_PLUS;
|
||||
break;
|
||||
case SDLK_KP_MINUS:
|
||||
key = K_KP_MINUS;
|
||||
case SDLK_KP_PERIOD:
|
||||
key = K_KP_DEL;
|
||||
break;
|
||||
case SDLK_KP_DIVIDE:
|
||||
key = K_KP_SLASH;
|
||||
break;
|
||||
case SDLK_MODE:
|
||||
key = K_MODE;
|
||||
case SDLK_KP_MINUS:
|
||||
key = K_KP_MINUS;
|
||||
break;
|
||||
case SDLK_KP_PLUS:
|
||||
key = K_KP_PLUS;
|
||||
break;
|
||||
case SDLK_NUMLOCKCLEAR:
|
||||
key = K_KP_NUMLOCK;
|
||||
break;
|
||||
case SDLK_KP_MULTIPLY:
|
||||
key = K_KP_STAR;
|
||||
break;
|
||||
case SDLK_KP_EQUALS:
|
||||
key = K_KP_EQUALS;
|
||||
break;
|
||||
|
||||
// TODO: K_SUPER ? Win Key is already K_COMMAND
|
||||
|
||||
case SDLK_APPLICATION:
|
||||
key = K_COMPOSE;
|
||||
break;
|
||||
case SDLK_MODE:
|
||||
key = K_MODE;
|
||||
break;
|
||||
case SDLK_HELP:
|
||||
key = K_HELP;
|
||||
break;
|
||||
|
@ -331,24 +352,16 @@ IN_TranslateSDLtoQ2Key(unsigned int keysym)
|
|||
case SDLK_SYSREQ:
|
||||
key = K_SYSREQ;
|
||||
break;
|
||||
case SDLK_SCROLLLOCK:
|
||||
key = K_SCROLLOCK;
|
||||
break;
|
||||
case SDLK_MENU:
|
||||
key = K_MENU;
|
||||
break;
|
||||
case SDLK_POWER:
|
||||
key = K_POWER;
|
||||
break;
|
||||
case SDLK_UNDO:
|
||||
key = K_UNDO;
|
||||
break;
|
||||
case SDLK_SCROLLLOCK:
|
||||
key = K_SCROLLOCK;
|
||||
break;
|
||||
case SDLK_NUMLOCKCLEAR:
|
||||
key = K_KP_NUMLOCK;
|
||||
break;
|
||||
case SDLK_CAPSLOCK:
|
||||
key = K_CAPSLOCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -356,6 +369,74 @@ IN_TranslateSDLtoQ2Key(unsigned int keysym)
|
|||
return key;
|
||||
}
|
||||
|
||||
static int
|
||||
IN_TranslateScancodeToQ2Key(SDL_Scancode sc)
|
||||
{
|
||||
|
||||
#define MY_SC_CASE(X) case SDL_SCANCODE_ ## X : return K_SC_ ## X;
|
||||
|
||||
switch( (int)sc ) // cast to int to shut -Wswitch up
|
||||
{
|
||||
// case SDL_SCANCODE_A : return K_SC_A;
|
||||
MY_SC_CASE(A)
|
||||
MY_SC_CASE(B)
|
||||
MY_SC_CASE(C)
|
||||
MY_SC_CASE(D)
|
||||
MY_SC_CASE(E)
|
||||
MY_SC_CASE(F)
|
||||
MY_SC_CASE(G)
|
||||
MY_SC_CASE(H)
|
||||
MY_SC_CASE(I)
|
||||
MY_SC_CASE(J)
|
||||
MY_SC_CASE(K)
|
||||
MY_SC_CASE(L)
|
||||
MY_SC_CASE(M)
|
||||
MY_SC_CASE(N)
|
||||
MY_SC_CASE(O)
|
||||
MY_SC_CASE(P)
|
||||
MY_SC_CASE(Q)
|
||||
MY_SC_CASE(R)
|
||||
MY_SC_CASE(S)
|
||||
MY_SC_CASE(T)
|
||||
MY_SC_CASE(U)
|
||||
MY_SC_CASE(V)
|
||||
MY_SC_CASE(W)
|
||||
MY_SC_CASE(X)
|
||||
MY_SC_CASE(Y)
|
||||
MY_SC_CASE(Z)
|
||||
MY_SC_CASE(MINUS)
|
||||
MY_SC_CASE(EQUALS)
|
||||
MY_SC_CASE(LEFTBRACKET)
|
||||
MY_SC_CASE(RIGHTBRACKET)
|
||||
MY_SC_CASE(BACKSLASH)
|
||||
MY_SC_CASE(NONUSHASH)
|
||||
MY_SC_CASE(SEMICOLON)
|
||||
MY_SC_CASE(APOSTROPHE)
|
||||
MY_SC_CASE(GRAVE)
|
||||
MY_SC_CASE(COMMA)
|
||||
MY_SC_CASE(PERIOD)
|
||||
MY_SC_CASE(SLASH)
|
||||
MY_SC_CASE(NONUSBACKSLASH)
|
||||
MY_SC_CASE(INTERNATIONAL1)
|
||||
MY_SC_CASE(INTERNATIONAL2)
|
||||
MY_SC_CASE(INTERNATIONAL3)
|
||||
MY_SC_CASE(INTERNATIONAL4)
|
||||
MY_SC_CASE(INTERNATIONAL5)
|
||||
MY_SC_CASE(INTERNATIONAL6)
|
||||
MY_SC_CASE(INTERNATIONAL7)
|
||||
MY_SC_CASE(INTERNATIONAL8)
|
||||
MY_SC_CASE(INTERNATIONAL9)
|
||||
MY_SC_CASE(THOUSANDSSEPARATOR)
|
||||
MY_SC_CASE(DECIMALSEPARATOR)
|
||||
MY_SC_CASE(CURRENCYUNIT)
|
||||
MY_SC_CASE(CURRENCYSUBUNIT)
|
||||
}
|
||||
|
||||
#undef MY_SC_CASE
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/*
|
||||
|
@ -374,6 +455,8 @@ IN_Update(void)
|
|||
static qboolean left_trigger = false;
|
||||
static qboolean right_trigger = false;
|
||||
|
||||
static int consoleKeyCode = 0;
|
||||
|
||||
/* Get and process an event */
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
|
@ -420,10 +503,15 @@ IN_Update(void)
|
|||
break;
|
||||
|
||||
case SDL_TEXTINPUT:
|
||||
if ((event.text.text[0] >= ' ') && (event.text.text[0] <= '~'))
|
||||
{
|
||||
int c = event.text.text[0];
|
||||
// also make sure we don't get the char that corresponds to the
|
||||
// "console key" (like "^" or "`") as text input
|
||||
if ((c >= ' ') && (c <= '~') && c != consoleKeyCode)
|
||||
{
|
||||
Char_Event(event.text.text[0]);
|
||||
Char_Event(c);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -453,13 +541,43 @@ IN_Update(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((event.key.keysym.sym >= SDLK_SPACE) && (event.key.keysym.sym < SDLK_DELETE))
|
||||
SDL_Keycode kc = event.key.keysym.sym;
|
||||
if(sc == SDL_SCANCODE_GRAVE && kc != '\'' && kc != '"')
|
||||
{
|
||||
Key_Event(event.key.keysym.sym, down, false);
|
||||
// special case/hack: open the console with the "console key"
|
||||
// (beneath Esc, left of 1, above Tab)
|
||||
// but not if the keycode for this is a quote (like on Brazilian
|
||||
// keyboards) - otherwise you couldn't type them in the console
|
||||
if((event.key.keysym.mod & (KMOD_CAPS|KMOD_SHIFT|KMOD_ALT|KMOD_CTRL|KMOD_GUI)) == 0)
|
||||
{
|
||||
// also, only do this if no modifiers like shift or AltGr or whatever are pressed
|
||||
// so kc will most likely be the ascii char generated by this and can be ignored
|
||||
// in case SDL_TEXTINPUT above (so we don't get ^ or whatever as text in console)
|
||||
// (can't just check for mod == 0 because numlock is a KMOD too)
|
||||
Key_Event(K_CONSOLE, down, true);
|
||||
consoleKeyCode = kc;
|
||||
}
|
||||
}
|
||||
else if ((kc >= SDLK_SPACE) && (kc < SDLK_DELETE))
|
||||
{
|
||||
Key_Event(kc, down, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Event(IN_TranslateSDLtoQ2Key(event.key.keysym.sym), down, true);
|
||||
int key = IN_TranslateSDLtoQ2Key(kc);
|
||||
if(key == 0)
|
||||
{
|
||||
// fallback to scancodes if we don't know the keycode
|
||||
key = IN_TranslateScancodeToQ2Key(sc);
|
||||
}
|
||||
if(key != 0)
|
||||
{
|
||||
Key_Event(key, down, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf("Pressed unknown key with SDL_Keycode %d, SDL_Scancode %d.\n", kc, (int)sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -281,39 +281,6 @@ Key_GetMenuKey(int key)
|
|||
case K_JOY30:
|
||||
case K_JOY31:
|
||||
|
||||
case K_AUX1:
|
||||
case K_AUX2:
|
||||
case K_AUX3:
|
||||
case K_AUX4:
|
||||
case K_AUX5:
|
||||
case K_AUX6:
|
||||
case K_AUX7:
|
||||
case K_AUX8:
|
||||
case K_AUX9:
|
||||
case K_AUX10:
|
||||
case K_AUX11:
|
||||
case K_AUX12:
|
||||
case K_AUX13:
|
||||
case K_AUX14:
|
||||
case K_AUX15:
|
||||
case K_AUX16:
|
||||
case K_AUX17:
|
||||
case K_AUX18:
|
||||
case K_AUX19:
|
||||
case K_AUX20:
|
||||
case K_AUX21:
|
||||
case K_AUX22:
|
||||
case K_AUX23:
|
||||
case K_AUX24:
|
||||
case K_AUX25:
|
||||
case K_AUX26:
|
||||
case K_AUX27:
|
||||
case K_AUX28:
|
||||
case K_AUX29:
|
||||
case K_AUX30:
|
||||
case K_AUX31:
|
||||
case K_AUX32:
|
||||
|
||||
case K_KP_ENTER:
|
||||
case K_ENTER:
|
||||
return K_ENTER;
|
||||
|
@ -842,7 +809,7 @@ M_UnbindCommand(char *command)
|
|||
|
||||
l = strlen(command);
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
for (j = 0; j < K_LAST; j++)
|
||||
{
|
||||
char *b;
|
||||
b = keybindings[j];
|
||||
|
@ -870,7 +837,7 @@ M_FindKeysForCommand(char *command, int *twokeys)
|
|||
l = strlen(command);
|
||||
count = 0;
|
||||
|
||||
for (j = 0; j < 256; j++)
|
||||
for (j = 0; j < K_LAST; j++)
|
||||
{
|
||||
char *b;
|
||||
b = keybindings[j];
|
||||
|
|
|
@ -791,7 +791,7 @@ void SCR_BeginLoadingPlaque(void);
|
|||
|
||||
void SV_Init(void);
|
||||
void SV_Shutdown(char *finalmsg, qboolean reconnect);
|
||||
void SV_Frame(int msec);
|
||||
void SV_Frame(int usec);
|
||||
|
||||
/* ======================================================================= */
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ SV_RunGameFrame(void)
|
|||
}
|
||||
|
||||
void
|
||||
SV_Frame(int msec)
|
||||
SV_Frame(int usec)
|
||||
{
|
||||
#ifndef DEDICATED_ONLY
|
||||
time_before_game = time_after_game = 0;
|
||||
|
@ -386,7 +386,7 @@ SV_Frame(int msec)
|
|||
return;
|
||||
}
|
||||
|
||||
svs.realtime += msec / 1000;
|
||||
svs.realtime += usec / 1000;
|
||||
|
||||
/* keep the random time dependent */
|
||||
randk();
|
||||
|
|
Loading…
Reference in a new issue