aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-03-24 21:46:07 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-03-24 21:46:07 +0000
commitacc265da41dae1f0f38231673db2829ce6492c55 (patch)
treec83bc632ecfb10a2bb0c6c51e354e20fa1c5d089
parentf09fb92fca047f5a015a2bf264d1b44590a091e8 (diff)
downloadioquake3-aero-acc265da41dae1f0f38231673db2829ce6492c55.tar.gz
ioquake3-aero-acc265da41dae1f0f38231673db2829ce6492c55.zip
* Shift no longer modifies bound keys. Use in_shiftedKeys for the old
behaviour. git-svn-id: svn://svn.icculus.org/quake3/trunk@667 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r--README1
-rw-r--r--code/unix/linux_glimp.c62
2 files changed, 40 insertions, 23 deletions
diff --git a/README b/README
index 075f3db..e4b3505 100644
--- a/README
+++ b/README
@@ -117,6 +117,7 @@ New cvars
r_GLlibCoolDownMsec - wait for some milliseconds to close GL library
com_altivec - enable use of altivec on PowerPC systems
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_platformSensitivity - read only, indicates the mouse input scaling
diff --git a/code/unix/linux_glimp.c b/code/unix/linux_glimp.c
index 1a0b4fd..44ffeb3 100644
--- a/code/unix/linux_glimp.c
+++ b/code/unix/linux_glimp.c
@@ -117,6 +117,7 @@ static int mouseResetTime = 0;
static cvar_t *in_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_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 buf[64];
+ static char bufnomod[2];
KeySym keysym;
int XLookupRet;
@@ -208,14 +210,23 @@ static char *XLateKey(XKeyEvent *ev, int *key)
#ifdef KBD_DBG
ri.Printf(PRINT_ALL, "XLookupString ret: %d buf: %s keysym: %x\n", XLookupRet, buf, keysym);
#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)
{
- case XK_KP_Page_Up:
+ case XK_KP_Page_Up:
case XK_KP_9: *key = K_KP_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_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_Down: *key = K_DOWNARROW; break;
- case XK_KP_Up:
+ case XK_KP_Up:
case XK_KP_8: *key = K_KP_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;
- // bk001206 - from Ryan's Fakk2
+ // bk001206 - from Ryan's Fakk2
//case XK_BackSpace: *key = 8; 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_R: *key = K_SHIFT; break;
- case XK_Execute:
- case XK_Control_L:
+ case XK_Execute:
+ case XK_Control_L:
case XK_Control_R: *key = K_CTRL; break;
- case XK_Alt_L:
- case XK_Meta_L:
- case XK_Alt_R:
+ case XK_Alt_L:
+ case XK_Meta_L:
+ case XK_Alt_R:
case XK_Meta_R: *key = K_ALT; 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_parenleft: *key = '9'; break;
case XK_parenright: *key = '0'; break;
-
+
// weird french keyboards ..
// 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
// could also add a new K_KP_CONSOLE
case XK_twosuperior: *key = '~'; break;
-
- // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472
- case XK_space:
- case XK_KP_Space: *key = K_SPACE; break;
+
+ // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=472
+ case XK_space:
+ case XK_KP_Space: *key = K_SPACE; break;
default:
if (XLookupRet == 0)
@@ -341,16 +352,20 @@ static char *XLateKey(XKeyEvent *ev, int *key)
else
{
// XK_* tests failed, but XLookupString got a buffer, so let's try it
- *key = *(unsigned char *)buf;
- if (*key >= 'A' && *key <= 'Z')
- *key = *key - 'A' + 'a';
- // if ctrl is pressed, the keys are not between 'A' and 'Z', for instance ctrl-z == 26 ^Z ^C etc.
- // see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19
- else if (*key >= 1 && *key <= 26)
- *key = *key + 'a' - 1;
+ if (in_shiftedKeys->integer) {
+ *key = *(unsigned char *)buf;
+ if (*key >= 'A' && *key <= 'Z')
+ *key = *key - 'A' + 'a';
+ // if ctrl is pressed, the keys are not between 'A' and 'Z', for instance ctrl-z == 26 ^Z ^C etc.
+ // see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=19
+ else if (*key >= 1 && *key <= 26)
+ *key = *key + 'a' - 1;
+ } else {
+ *key = bufnomod[0];
+ }
}
break;
- }
+ }
return buf;
}
@@ -1734,6 +1749,7 @@ void IN_Init(void) {
// mouse variables
in_mouse = Cvar_Get ("in_mouse", "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
in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE);