From 8f1ff1bddce3c1291994fa624486f2840b800f05 Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Fri, 17 Nov 2000 21:23:26 +0000 Subject: [PATCH] A few compile fixes. And of course the very slight rework of the input system, at least in_x11 gets shifts right for different keymaps. Oh, by the way, ALL other input targets are broken in a very 'will not compile' way. --- include/keys.h | 2 +- source/cl_input.c | 2 +- source/context_x11.c | 19 +++++++++---------- source/in_x11.c | 41 ++++++++++++----------------------------- source/joy_linux.c | 4 ++-- source/keys.c | 25 +++++++++++++++---------- source/quakefs.c | 2 +- 7 files changed, 41 insertions(+), 54 deletions(-) diff --git a/include/keys.h b/include/keys.h index 2661908..3dbce3f 100644 --- a/include/keys.h +++ b/include/keys.h @@ -172,7 +172,7 @@ extern char chat_buffer[]; extern int chat_bufferlen; extern qboolean chat_team; -void Key_Event (int key, qboolean down); +void Key_Event (int key, int alt, qboolean down); void Key_Init (void); void Key_Init_Cvars (void); void Key_WriteBindings (QFile *f); diff --git a/source/cl_input.c b/source/cl_input.c index 50513d4..9e7291e 100644 --- a/source/cl_input.c +++ b/source/cl_input.c @@ -590,6 +590,6 @@ void CL_ClearStates (void) for (i=0 ; i<256 ; i++) { if (keydown[i]) - Key_Event (i, false); + Key_Event (i, 0, false); } } diff --git a/source/context_x11.c b/source/context_x11.c index f86376b..5662d3a 100644 --- a/source/context_x11.c +++ b/source/context_x11.c @@ -242,16 +242,8 @@ x11_create_null_cursor (void) void x11_set_vidmode(int width, int height) { - int i; - int best_mode = 0, best_x = INT_MAX, best_y = INT_MAX; - - XGetScreenSaver (x_disp, &xss_timeout, &xss_interval, &xss_blanking, - &xss_exposures); - XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking, - xss_exposures); - -#ifdef XMESA const char *str = getenv("MESA_GLX_FX"); + if (str != NULL && *str != 'd') { if (tolower(*str) == 'w') { Cvar_Set (vid_fullscreen, "0"); @@ -259,7 +251,11 @@ x11_set_vidmode(int width, int height) Cvar_Set (vid_fullscreen, "1"); } } -#endif + + XGetScreenSaver (x_disp, &xss_timeout, &xss_interval, &xss_blanking, + &xss_exposures); + XSetScreenSaver (x_disp, 0, xss_interval, xss_blanking, + xss_exposures); #ifdef HAVE_VIDMODE if (!(hasvidmode = VID_CheckVMode(x_disp, NULL, NULL))) { @@ -270,6 +266,9 @@ x11_set_vidmode(int width, int height) XF86VidModeGetAllModeLines(x_disp, x_screen, &nummodes, &vidmodes); if (vid_fullscreen->int_val) { + int i; + int best_mode = 0, best_x = INT_MAX, best_y = INT_MAX; + for (i = 0; i < nummodes; i++) { if ((best_x > vidmodes[i]->hdisplay) || (best_y > vidmodes[i]->vdisplay)) { diff --git a/source/in_x11.c b/source/in_x11.c index 75348e7..672dfd0 100644 --- a/source/in_x11.c +++ b/source/in_x11.c @@ -93,12 +93,17 @@ static int p_mouse_x, p_mouse_y; #define INPUT_MASK (KEY_MASK | MOUSE_MASK) static int -XLateKey(XKeyEvent *ev) +XLateKey(XKeyEvent *ev, qboolean modified) { + char tmp[2]; int key = 0; KeySym keysym; - keysym = XLookupKeysym(ev, 0); + if (!modified) { + keysym = XLookupKeysym(ev, 0); + } else { + XLookupString(ev, tmp, 1, &keysym, NULL); + } switch(keysym) { case XK_KP_Page_Up: key = KP_PGUP; break; @@ -182,33 +187,11 @@ XLateKey(XKeyEvent *ev) case XK_F33: key = K_END; break; case XK_F35: key = K_PGDN; break; -#if 0 - case 0x021: key = '1';break;/* [!] */ - case 0x040: key = '2';break;/* [@] */ - case 0x023: key = '3';break;/* [#] */ - case 0x024: key = '4';break;/* [$] */ - case 0x025: key = '5';break;/* [%] */ - case 0x05e: key = '6';break;/* [^] */ - case 0x026: key = '7';break;/* [&] */ - case 0x02a: key = '8';break;/* [*] */ - case 0x028: key = '9';;break;/* [(] */ - case 0x029: key = '0';break;/* [)] */ - case 0x05f: key = '-';break;/* [_] */ - case 0x02b: key = '=';break;/* [+] */ - case 0x07c: key = '\'';break;/* [|] */ - case 0x07d: key = '[';break;/* [}] */ - case 0x07b: key = ']';break;/* [{] */ - case 0x022: key = '\'';break;/* ["] */ - case 0x03a: key = ';';break;/* [:] */ - case 0x03f: key = '/';break;/* [?] */ - case 0x03e: key = '.';break;/* [>] */ - case 0x03c: key = ',';break;/* [<] */ -#endif default: if (keysym < 128) { /* ASCII keys */ key = keysym; - if (key >= 'A' && key <= 'Z') { + if (!modified && ((key >= 'A') && (key <= 'Z'))) { key = key + ('a' - 'A'); } } @@ -222,7 +205,7 @@ XLateKey(XKeyEvent *ev) static void event_key (XEvent *event) { - Key_Event (XLateKey (&event->xkey), event->type == KeyPress); + Key_Event (XLateKey (&event->xkey, 0), XLateKey(&event->xkey, 1), event->type == KeyPress); } @@ -238,13 +221,13 @@ event_button (XEvent *event) case 1: case 2: case 3: - Key_Event(K_MOUSE1 + but - 1, event->type == ButtonPress); + Key_Event(K_MOUSE1 + but - 1, 0, event->type == ButtonPress); break; case 4: - Key_Event(K_MWHEELUP, event->type == ButtonPress); + Key_Event(K_MWHEELUP, 0, event->type == ButtonPress); break; case 5: - Key_Event(K_MWHEELDOWN, event->type == ButtonPress); + Key_Event(K_MWHEELDOWN, 0, event->type == ButtonPress); break; } } diff --git a/source/joy_linux.c b/source/joy_linux.c index 95bb91c..7cd1e58 100644 --- a/source/joy_linux.c +++ b/source/joy_linux.c @@ -98,10 +98,10 @@ JOY_Command (void) joy_buttons[event.number].current = event.value; if (joy_buttons[event.number].current > joy_buttons[event.number].old) { - Key_Event(K_AUX1 + event.number, true); + Key_Event(K_AUX1 + event.number, 0, true); } else { if (joy_buttons[event.number].current < joy_buttons[event.number].old) { - Key_Event(K_AUX1 + event.number, false); + Key_Event(K_AUX1 + event.number, 0, false); } } joy_buttons[event.number].old = joy_buttons[event.number].current; diff --git a/source/keys.c b/source/keys.c index 57fb77b..8c6dab5 100644 --- a/source/keys.c +++ b/source/keys.c @@ -34,6 +34,7 @@ #endif #include +#include #include #ifdef HAVE_STRINGS_H #include @@ -779,13 +780,20 @@ Should NOT be called during an interrupt! =================== */ void -Key_Event ( int key, qboolean down ) +Key_Event ( int key, int alt_key, qboolean down ) { char *kb; char cmd[1024]; // Con_Printf ("%i : %i\n", key, down); //@@@ + // They don't prove it, fall back to interal MESS. + if (alt_key == -1) { + if (keydown[K_SHIFT]) { + alt_key = keyshift[key]; + } + } + keydown[key] = down; if (!down) @@ -849,16 +857,13 @@ Key_Event ( int key, qboolean down ) if (!down) { kb = keybindings[key]; - if (kb && kb[0] == '+') - { + if (kb && kb[0] == '+') { snprintf (cmd, sizeof(cmd), "-%s %i\n", kb+1, key); Cbuf_AddText (cmd); } - if (keyshift[key] != key) - { - kb = keybindings[keyshift[key]]; - if (kb && kb[0] == '+') - { + if (islower(key)) { + kb = keybindings[toupper(key)]; + if (kb && kb[0] == '+') { snprintf (cmd, sizeof(cmd), "-%s %i\n", kb+1, key); Cbuf_AddText (cmd); } @@ -903,8 +908,8 @@ Key_Event ( int key, qboolean down ) if (!down) return; // other systems only care about key down events - if (keydown[K_SHIFT]) - key = keyshift[key]; + if (alt_key > 0) + key = alt_key; switch (key_dest) { diff --git a/source/quakefs.c b/source/quakefs.c index 9fe77f3..2de42f8 100644 --- a/source/quakefs.c +++ b/source/quakefs.c @@ -69,7 +69,7 @@ #include #ifndef HAVE_FNMATCH_PROTO -fnmatch (__const char *__pattern, __const char *__string, int __flags); +int fnmatch (__const char *__pattern, __const char *__string, int __flags); #endif