* Shift no longer modifies bound keys. Use in_shiftedKeys for the old

behaviour.
This commit is contained in:
Tim Angus 2006-03-24 21:46:07 +00:00
parent f63472025f
commit d9cb8cb083
2 changed files with 40 additions and 23 deletions

1
README
View File

@ -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

View File

@ -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;
@ -209,6 +211,15 @@ static char *XLateKey(XKeyEvent *ev, int *key)
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:
@ -325,9 +336,9 @@ static char *XLateKey(XKeyEvent *ev, int *key)
// 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,13 +352,17 @@ 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;
} }
@ -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);