mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 05:31:29 +00:00
* Shift no longer modifies bound keys. Use in_shiftedKeys for the old
behaviour.
This commit is contained in:
parent
f63472025f
commit
d9cb8cb083
2 changed files with 40 additions and 23 deletions
1
README
1
README
|
@ -117,6 +117,7 @@ New cvars
|
||||||
r_GLlibCoolDownMsec - wait for some milliseconds to close GL library
|
r_GLlibCoolDownMsec - wait for some milliseconds to close GL library
|
||||||
com_altivec - enable use of altivec on PowerPC systems
|
com_altivec - enable use of altivec on PowerPC systems
|
||||||
s_backend - read only, indicates the current sound backend
|
s_backend - read only, indicates the current sound backend
|
||||||
|
in_shiftedKeys - non-SDL Linux only. Enables binding to shifted keys
|
||||||
cl_consoleHistory - read only, stores the console history
|
cl_consoleHistory - read only, stores the console history
|
||||||
cl_platformSensitivity - read only, indicates the mouse input scaling
|
cl_platformSensitivity - read only, indicates the mouse input scaling
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ static int mouseResetTime = 0;
|
||||||
|
|
||||||
static cvar_t *in_mouse;
|
static cvar_t *in_mouse;
|
||||||
static cvar_t *in_dgamouse; // user pref for dga mouse
|
static cvar_t *in_dgamouse; // user pref for dga mouse
|
||||||
|
static cvar_t *in_shiftedKeys; // obey modifiers for certain keys in non-console (comma, numbers, etc)
|
||||||
cvar_t *in_subframe;
|
cvar_t *in_subframe;
|
||||||
cvar_t *in_nograb; // this is strictly for developers
|
cvar_t *in_nograb; // this is strictly for developers
|
||||||
|
|
||||||
|
@ -199,6 +200,7 @@ static const char *Q_stristr( const char *s, const char *find)
|
||||||
static char *XLateKey(XKeyEvent *ev, int *key)
|
static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
{
|
{
|
||||||
static char buf[64];
|
static char buf[64];
|
||||||
|
static char bufnomod[2];
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
int XLookupRet;
|
int XLookupRet;
|
||||||
|
|
||||||
|
@ -208,14 +210,23 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
#ifdef KBD_DBG
|
#ifdef KBD_DBG
|
||||||
ri.Printf(PRINT_ALL, "XLookupString ret: %d buf: %s keysym: %x\n", XLookupRet, buf, keysym);
|
ri.Printf(PRINT_ALL, "XLookupString ret: %d buf: %s keysym: %x\n", XLookupRet, buf, keysym);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!in_shiftedKeys->integer) {
|
||||||
|
// also get a buffer without modifiers held
|
||||||
|
ev->state = 0;
|
||||||
|
XLookupRet = XLookupString(ev, bufnomod, sizeof bufnomod, &keysym, 0);
|
||||||
|
#ifdef KBD_DBG
|
||||||
|
ri.Printf(PRINT_ALL, "XLookupString (minus modifiers) ret: %d buf: %s keysym: %x\n", XLookupRet, buf, keysym);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
switch (keysym)
|
switch (keysym)
|
||||||
{
|
{
|
||||||
case XK_KP_Page_Up:
|
case XK_KP_Page_Up:
|
||||||
case XK_KP_9: *key = K_KP_PGUP; break;
|
case XK_KP_9: *key = K_KP_PGUP; break;
|
||||||
case XK_Page_Up: *key = K_PGUP; break;
|
case XK_Page_Up: *key = K_PGUP; break;
|
||||||
|
|
||||||
case XK_KP_Page_Down:
|
case XK_KP_Page_Down:
|
||||||
case XK_KP_3: *key = K_KP_PGDN; break;
|
case XK_KP_3: *key = K_KP_PGDN; break;
|
||||||
case XK_Page_Down: *key = K_PGDN; break;
|
case XK_Page_Down: *key = K_PGDN; break;
|
||||||
|
|
||||||
|
@ -239,7 +250,7 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
case XK_KP_2: *key = K_KP_DOWNARROW; break;
|
case XK_KP_2: *key = K_KP_DOWNARROW; break;
|
||||||
case XK_Down: *key = K_DOWNARROW; break;
|
case XK_Down: *key = K_DOWNARROW; break;
|
||||||
|
|
||||||
case XK_KP_Up:
|
case XK_KP_Up:
|
||||||
case XK_KP_8: *key = K_KP_UPARROW; break;
|
case XK_KP_8: *key = K_KP_UPARROW; break;
|
||||||
case XK_Up: *key = K_UPARROW; break;
|
case XK_Up: *key = K_UPARROW; break;
|
||||||
|
|
||||||
|
@ -274,7 +285,7 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
|
|
||||||
case XK_F12: *key = K_F12; break;
|
case XK_F12: *key = K_F12; break;
|
||||||
|
|
||||||
// bk001206 - from Ryan's Fakk2
|
// bk001206 - from Ryan's Fakk2
|
||||||
//case XK_BackSpace: *key = 8; break; // ctrl-h
|
//case XK_BackSpace: *key = 8; break; // ctrl-h
|
||||||
case XK_BackSpace: *key = K_BACKSPACE; break; // ctrl-h
|
case XK_BackSpace: *key = K_BACKSPACE; break; // ctrl-h
|
||||||
|
|
||||||
|
@ -287,13 +298,13 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
case XK_Shift_L:
|
case XK_Shift_L:
|
||||||
case XK_Shift_R: *key = K_SHIFT; break;
|
case XK_Shift_R: *key = K_SHIFT; break;
|
||||||
|
|
||||||
case XK_Execute:
|
case XK_Execute:
|
||||||
case XK_Control_L:
|
case XK_Control_L:
|
||||||
case XK_Control_R: *key = K_CTRL; break;
|
case XK_Control_R: *key = K_CTRL; break;
|
||||||
|
|
||||||
case XK_Alt_L:
|
case XK_Alt_L:
|
||||||
case XK_Meta_L:
|
case XK_Meta_L:
|
||||||
case XK_Alt_R:
|
case XK_Alt_R:
|
||||||
case XK_Meta_R: *key = K_ALT; break;
|
case XK_Meta_R: *key = K_ALT; break;
|
||||||
|
|
||||||
case XK_KP_Begin: *key = K_KP_5; break;
|
case XK_KP_Begin: *key = K_KP_5; break;
|
||||||
|
@ -318,16 +329,16 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
case XK_asterisk: *key = '8'; break;
|
case XK_asterisk: *key = '8'; break;
|
||||||
case XK_parenleft: *key = '9'; break;
|
case XK_parenleft: *key = '9'; break;
|
||||||
case XK_parenright: *key = '0'; break;
|
case XK_parenright: *key = '0'; break;
|
||||||
|
|
||||||
// weird french keyboards ..
|
// weird french keyboards ..
|
||||||
// NOTE: console toggle is hardcoded in cl_keys.c, can't be unbound
|
// NOTE: console toggle is hardcoded in cl_keys.c, can't be unbound
|
||||||
// cleaner would be .. using hardware key codes instead of the key syms
|
// cleaner would be .. using hardware key codes instead of the key syms
|
||||||
// could also add a new K_KP_CONSOLE
|
// could also add a new K_KP_CONSOLE
|
||||||
case XK_twosuperior: *key = '~'; break;
|
case XK_twosuperior: *key = '~'; break;
|
||||||
|
|
||||||
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472
|
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472
|
||||||
case XK_space:
|
case XK_space:
|
||||||
case XK_KP_Space: *key = K_SPACE; break;
|
case XK_KP_Space: *key = K_SPACE; break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (XLookupRet == 0)
|
if (XLookupRet == 0)
|
||||||
|
@ -341,16 +352,20 @@ static char *XLateKey(XKeyEvent *ev, int *key)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// XK_* tests failed, but XLookupString got a buffer, so let's try it
|
// XK_* tests failed, but XLookupString got a buffer, so let's try it
|
||||||
*key = *(unsigned char *)buf;
|
if (in_shiftedKeys->integer) {
|
||||||
if (*key >= 'A' && *key <= 'Z')
|
*key = *(unsigned char *)buf;
|
||||||
*key = *key - 'A' + 'a';
|
if (*key >= 'A' && *key <= 'Z')
|
||||||
// if ctrl is pressed, the keys are not between 'A' and 'Z', for instance ctrl-z == 26 ^Z ^C etc.
|
*key = *key - 'A' + 'a';
|
||||||
// see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19
|
// if ctrl is pressed, the keys are not between 'A' and 'Z', for instance ctrl-z == 26 ^Z ^C etc.
|
||||||
else if (*key >= 1 && *key <= 26)
|
// see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19
|
||||||
*key = *key + 'a' - 1;
|
else if (*key >= 1 && *key <= 26)
|
||||||
|
*key = *key + 'a' - 1;
|
||||||
|
} else {
|
||||||
|
*key = bufnomod[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -1734,6 +1749,7 @@ void IN_Init(void) {
|
||||||
// mouse variables
|
// mouse variables
|
||||||
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
||||||
in_dgamouse = Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE);
|
in_dgamouse = Cvar_Get ("in_dgamouse", "1", CVAR_ARCHIVE);
|
||||||
|
in_shiftedKeys = Cvar_Get ("in_shiftedKeys", "0", CVAR_ARCHIVE);
|
||||||
|
|
||||||
// turn on-off sub-frame timing of X events
|
// turn on-off sub-frame timing of X events
|
||||||
in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE);
|
in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE);
|
||||||
|
|
Loading…
Reference in a new issue