- X11 key repeat fix.

- Added GPL blurb to sv_user.c
This commit is contained in:
Jamie Wilkinson 2002-12-23 00:00:16 +00:00
parent 0caed99967
commit a5b3a4adb2
3 changed files with 59 additions and 33 deletions

View file

@ -754,17 +754,16 @@ void Key_Event (int key, qboolean down, unsigned time)
return; return;
} }
// update auto-repeat status /* update auto-repeat status */
if (down) if (down) {
{
key_repeats[key]++; key_repeats[key]++;
if (key != K_BACKSPACE if (key != K_BACKSPACE &&
&& key != K_PAUSE key != K_PAUSE &&
&& key != K_PGUP key != K_PGUP &&
&& key != K_KP_PGUP key != K_KP_PGUP &&
&& key != K_PGDN key != K_PGDN &&
&& key != K_KP_PGDN key != K_KP_PGDN &&
&& key_repeats[key] > 1) key_repeats[key] > 1)
return; // ignore most autorepeats return; // ignore most autorepeats
if (key >= 200 && !keybindings[key]) if (key >= 200 && !keybindings[key])

View file

@ -925,6 +925,26 @@ int XLateKey(XKeyEvent *ev)
return key; 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) void HandleEvents(void)
{ {
XEvent event; XEvent event;
@ -940,10 +960,15 @@ void HandleEvents(void)
switch(event.type) { switch(event.type) {
case KeyPress: case KeyPress:
myxtime = event.xkey.time; myxtime = event.xkey.time;
case KeyRelease:
if (in_state && in_state->Key_Event_fp) if (in_state && in_state->Key_Event_fp)
in_state->Key_Event_fp(XLateKey(&event.xkey), event.type == KeyPress); in_state->Key_Event_fp(XLateKey(&event.xkey), event.type == KeyPress);
break; 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: case MotionNotify:
if (ignorefirst) { if (ignorefirst) {

View file

@ -1,23 +1,25 @@
/* /* $Id$
Copyright (C) 1997-2001 Id Software, Inc. *
* server code for moving users
This program is free software; you can redistribute it and/or *
modify it under the terms of the GNU General Public License * Copyright (C) 1997-2001 Id Software, Inc.
as published by the Free Software Foundation; either version 2 * Copyright (c) 2002 The Quakeforge Project.
of the License, or (at your option) any later version. *
* This program is free software; you can redistribute it and/or
This program is distributed in the hope that it will be useful, * modify it under the terms of the GNU General Public License
but WITHOUT ANY WARRANTY; without even the implied warranty of * as published by the Free Software Foundation; either version 2
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * of the License, or (at your option) any later version.
*
See the GNU General Public License for more details. * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
You should have received a copy of the GNU General Public License * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
along with this program; if not, write to the Free Software *
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 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
#include "server.h" #include "server.h"