diff --git a/src/keys.c b/src/keys.c index f26b6e5..b3c491e 100644 --- a/src/keys.c +++ b/src/keys.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include @@ -754,18 +754,17 @@ void Key_Event (int key, qboolean down, unsigned time) return; } - // update auto-repeat status - if (down) - { - key_repeats[key]++; - if (key != K_BACKSPACE - && key != K_PAUSE - && key != K_PGUP - && key != K_KP_PGUP - && key != K_PGDN - && key != K_KP_PGDN - && key_repeats[key] > 1) - return; // ignore most autorepeats + /* update auto-repeat status */ + if (down) { + key_repeats[key]++; + if (key != K_BACKSPACE && + key != K_PAUSE && + key != K_PGUP && + key != K_KP_PGUP && + key != K_PGDN && + key != K_KP_PGDN && + key_repeats[key] > 1) + return; // ignore most autorepeats if (key >= 200 && !keybindings[key]) Com_Printf ("%s is unbound, hit F4 to set.\n", Key_KeynumToString (key) ); diff --git a/src/rw_x11.c b/src/rw_x11.c index 103e4fa..69cb80f 100644 --- a/src/rw_x11.c +++ b/src/rw_x11.c @@ -925,6 +925,26 @@ int XLateKey(XKeyEvent *ev) return key; } +/* Check to see if this is a repeated key. + * (shamelessly lifted from icculus quake2 who + * shamelessly lifted from SDL who + * shamelessly lifted from GII -- thanks guys! :) */ +int X11_KeyRepeat(Display * dpy, XEvent * evt) { + XEvent peekevt; + int repeated = 0; + + if (XPending(dpy)) { + XPeekEvent(dpy, &peekevt); + if ((peekevt.type == KeyPress) && + (peekevt.xkey.keycode == evt->xkey.keycode) && + ((peekevt.xkey.time - evt->xkey.time) < 2)) { + repeated = 1; + XNextEvent(dpy, &peekevt); + } + } + return repeated; +} + void HandleEvents(void) { XEvent event; @@ -940,9 +960,14 @@ void HandleEvents(void) switch(event.type) { case KeyPress: myxtime = event.xkey.time; + if (in_state && in_state->Key_Event_fp) + in_state->Key_Event_fp(XLateKey(&event.xkey), event.type == KeyPress); + break; case KeyRelease: + if (!X11_KeyRepeat(dpy, &event)) { if (in_state && in_state->Key_Event_fp) in_state->Key_Event_fp (XLateKey(&event.xkey), event.type == KeyPress); + } break; case MotionNotify: diff --git a/src/sv_user.c b/src/sv_user.c index 07ea752..786ce74 100644 --- a/src/sv_user.c +++ b/src/sv_user.c @@ -1,23 +1,25 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -// sv_user.c -- server code for moving users +/* $Id$ + * + * server code for moving users + * + * Copyright (C) 1997-2001 Id Software, Inc. + * Copyright (c) 2002 The Quakeforge Project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ #include "server.h"