- 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;
}
// update auto-repeat status
if (down)
{
/* 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)
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])

View file

@ -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,10 +960,15 @@ void HandleEvents(void)
switch(event.type) {
case KeyPress:
myxtime = event.xkey.time;
case KeyRelease:
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:
if (ignorefirst) {

View file

@ -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.
/* $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.
*/
// sv_user.c -- server code for moving users
#include "server.h"