mirror of
https://git.code.sf.net/p/quake/quake2forge
synced 2024-12-12 13:42:21 +00:00
- X11 key repeat fix.
- Added GPL blurb to sv_user.c
This commit is contained in:
parent
0caed99967
commit
a5b3a4adb2
3 changed files with 59 additions and 33 deletions
21
src/keys.c
21
src/keys.c
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* 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 <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -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])
|
||||||
|
|
25
src/rw_x11.c
25
src/rw_x11.c
|
@ -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,9 +960,14 @@ void HandleEvents(void)
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
myxtime = event.xkey.time;
|
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:
|
case KeyRelease:
|
||||||
|
if (!X11_KeyRepeat(dpy, &event)) {
|
||||||
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 MotionNotify:
|
case MotionNotify:
|
||||||
|
|
|
@ -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
|
||||||
// sv_user.c -- server code for moving users
|
* 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"
|
#include "server.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue