Add explicit support for Right Ctrl and Right Shift keys, #323

so far they were handled the same as their Left counterparts
This commit is contained in:
Daniel Gibson 2021-07-03 14:42:14 +02:00
parent ae2d3a7e99
commit 24a6643a60
4 changed files with 28 additions and 4 deletions

View file

@ -478,7 +478,8 @@ void idEditField::KeyDownEvent( int key ) {
}
// clear autocompletion buffer on normal key input
if ( key != K_CAPSLOCK && key != K_ALT && key != K_CTRL && key != K_SHIFT ) {
if ( key != K_CAPSLOCK && key != K_ALT && key != K_CTRL && key != K_SHIFT
&& key != K_RIGHT_CTRL && key != K_RIGHT_SHIFT ) { // TODO: K_RIGHT_ALT ?
ClearAutoComplete();
}
}

View file

@ -63,7 +63,7 @@ static const keyname_t keynames[] =
{"RIGHTARROW", K_RIGHTARROW, "#str_07026"},
{"ALT", K_ALT, "#str_07027"},
{"RIGHTALT", K_RIGHT_ALT, "#str_07027"},
//{"RIGHTALT", K_RIGHT_ALT, "#str_07027"}, // DG: renamed this, see below
{"CTRL", K_CTRL, "#str_07028"},
{"SHIFT", K_SHIFT, "#str_07029"},
@ -182,7 +182,13 @@ static const keyname_t keynames[] =
{"SEMICOLON", ';', "#str_07129"}, // because a raw semicolon separates commands
{"APOSTROPHE", '\'', "#str_07130"}, // because a raw apostrophe messes with parsing
{"QUOTE", '"', ""}, // raw quote can't be good either
{"QUOTE", '"', ""}, // DG: raw quote can't be good either
{"R_ALT", K_RIGHT_ALT, ""}, // DG: renamed this from RIGHTALT so it's shorter (but discernible) in the menu
{"R_CTRL", K_RIGHT_CTRL, ""}, // DG: added this one
{"R_SHIFT", K_RIGHT_SHIFT, ""}, // DG: added this one
// TODO: controller stuff
{NULL, 0, NULL}
};
@ -286,6 +292,15 @@ bool idKeyInput::IsDown( int keynum ) {
return false;
}
// DG: K_RIGHT_CTRL/SHIFT should be handled as different keys for bindings
// but the same for keyboard shortcuts in the console and such
// (this function is used for the latter)
if ( keynum == K_CTRL ) {
return keys[K_CTRL].down || keys[K_RIGHT_CTRL].down;
} else if ( keynum == K_SHIFT ) {
return keys[K_SHIFT].down || keys[K_RIGHT_SHIFT].down;
}
return keys[keynum].down;
}

View file

@ -198,6 +198,10 @@ typedef enum {
K_PRINT_SCR = 252, // SysRq / PrintScr
K_RIGHT_ALT = 253, // used by some languages as "Alt-Gr"
// DG: added the following two
K_RIGHT_CTRL = 254,
K_RIGHT_SHIFT = 255,
// DG: map all relevant scancodes from SDL to K_SC_* (taken from Yamagi Quake II)
// (relevant are ones that are likely to be keyboardlayout-dependent,
// i.e. printable characters of sorts, *not* Ctrl, Alt, F1, Del, ...)

View file

@ -283,12 +283,15 @@ static byte mapkey(SDL_Keycode key) {
return K_MENU;
case SDLK_LALT:
case SDLK_RALT:
return K_ALT;
case SDLK_RALT:
return K_RIGHT_ALT;
case SDLK_RCTRL:
return K_RIGHT_CTRL;
case SDLK_LCTRL:
return K_CTRL;
case SDLK_RSHIFT:
return K_RIGHT_SHIFT;
case SDLK_LSHIFT:
return K_SHIFT;
case SDLK_INSERT:
@ -403,6 +406,7 @@ static byte mapkey(SDL_Keycode key) {
case SDLK_PRINTSCREEN:
return K_PRINT_SCR;
case SDLK_MODE:
// FIXME: is this really right alt? (also mapping SDLK_RALT to K_RIGHT_ALT)
return K_RIGHT_ALT;
}