2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
in_x11.c
|
|
|
|
|
|
|
|
general x11 input driver
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
|
|
|
Copyright (C) 1999,2000 contributors of the QuakeForge project
|
|
|
|
Please see the file "AUTHORS" for a list of contributors
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
2001-09-28 06:26:31 +00:00
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define _BSD
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
2001-08-27 01:00:03 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2001-04-15 04:18:22 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/keysym.h>
|
2001-09-18 04:53:01 +00:00
|
|
|
#include <X11/Xutil.h>
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DGA
|
|
|
|
# include <X11/extensions/XShm.h>
|
|
|
|
# include <X11/extensions/xf86dga.h>
|
|
|
|
#endif
|
|
|
|
|
2001-07-05 20:35:42 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/input.h"
|
|
|
|
#include "QF/joystick.h"
|
|
|
|
#include "QF/keys.h"
|
2001-04-15 07:18:04 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-07-05 20:18:23 +00:00
|
|
|
#include "QF/sound.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/sys.h"
|
2001-04-15 07:18:04 +00:00
|
|
|
#include "QF/vid.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-07-05 20:18:23 +00:00
|
|
|
#include "compat.h"
|
2001-04-15 07:18:04 +00:00
|
|
|
#include "context_x11.h"
|
|
|
|
#include "dga_check.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-07-05 20:35:42 +00:00
|
|
|
cvar_t *in_snd_block;
|
2001-04-15 04:18:22 +00:00
|
|
|
cvar_t *in_dga;
|
|
|
|
|
|
|
|
static qboolean dga_avail;
|
|
|
|
static qboolean dga_active;
|
|
|
|
|
|
|
|
static keydest_t old_key_dest = key_none;
|
|
|
|
|
|
|
|
static int p_mouse_x, p_mouse_y;
|
|
|
|
|
|
|
|
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
|
|
|
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
|
2001-07-05 20:18:23 +00:00
|
|
|
#define FOCUS_MASK (FocusChangeMask)
|
|
|
|
#define INPUT_MASK (KEY_MASK | MOUSE_MASK | FOCUS_MASK)
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-08-30 20:04:13 +00:00
|
|
|
static void
|
|
|
|
dga_on (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_DGA
|
|
|
|
if (dga_avail && !dga_active) {
|
|
|
|
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),
|
|
|
|
XF86DGADirectMouse);
|
|
|
|
dga_active = true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dga_off (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_DGA
|
|
|
|
if (dga_avail && dga_active) {
|
|
|
|
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
|
|
|
|
dga_active = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
in_dga_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
if (in_grab && in_grab->int_val) {
|
|
|
|
if (var->int_val) {
|
|
|
|
dga_on ();
|
|
|
|
} else {
|
|
|
|
dga_off ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-27 01:00:03 +00:00
|
|
|
|
2001-08-16 16:41:40 +00:00
|
|
|
static void
|
|
|
|
XLateKey (XKeyEvent * ev, int *k, int *u)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
int key = 0;
|
2001-08-17 19:47:51 +00:00
|
|
|
KeySym keysym, shifted_keysym;
|
2001-08-16 16:41:40 +00:00
|
|
|
XComposeStatus compose;
|
|
|
|
unsigned char buffer[4];
|
|
|
|
int bytes;
|
|
|
|
int unicode;
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-08-17 19:47:51 +00:00
|
|
|
keysym = XLookupKeysym (ev, 0);
|
2001-08-27 01:00:03 +00:00
|
|
|
bytes = XLookupString (ev, buffer, sizeof(buffer), &shifted_keysym,
|
|
|
|
&compose);
|
2001-08-16 16:41:40 +00:00
|
|
|
unicode = buffer[0];
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
switch (keysym) {
|
|
|
|
case XK_KP_Page_Up:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP9;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Page_Up:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_PAGEUP;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Page_Down:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP3;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Page_Down:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_PAGEDOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Home:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP7;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Home:
|
|
|
|
key = K_HOME;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_End:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP1;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_End:
|
|
|
|
key = K_END;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Left:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP4;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Left:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LEFT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Right:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP6;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Right:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_RIGHT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Down:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP2;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Down:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_DOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Up:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP8;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Up:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_UP;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Escape:
|
|
|
|
key = K_ESCAPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Enter:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_ENTER;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Return:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_RETURN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Tab:
|
|
|
|
key = K_TAB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_F1:
|
|
|
|
key = K_F1;
|
|
|
|
break;
|
|
|
|
case XK_F2:
|
|
|
|
key = K_F2;
|
|
|
|
break;
|
|
|
|
case XK_F3:
|
|
|
|
key = K_F3;
|
|
|
|
break;
|
|
|
|
case XK_F4:
|
|
|
|
key = K_F4;
|
|
|
|
break;
|
|
|
|
case XK_F5:
|
|
|
|
key = K_F5;
|
|
|
|
break;
|
|
|
|
case XK_F6:
|
|
|
|
key = K_F6;
|
|
|
|
break;
|
|
|
|
case XK_F7:
|
|
|
|
key = K_F7;
|
|
|
|
break;
|
|
|
|
case XK_F8:
|
|
|
|
key = K_F8;
|
|
|
|
break;
|
|
|
|
case XK_F9:
|
|
|
|
key = K_F9;
|
|
|
|
break;
|
|
|
|
case XK_F10:
|
|
|
|
key = K_F10;
|
|
|
|
break;
|
|
|
|
case XK_F11:
|
|
|
|
key = K_F11;
|
|
|
|
break;
|
|
|
|
case XK_F12:
|
|
|
|
key = K_F12;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_BackSpace:
|
|
|
|
key = K_BACKSPACE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Delete:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_PERIOD;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_Delete:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_DELETE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Pause:
|
|
|
|
key = K_PAUSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Shift_L:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LSHIFT;
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Shift_R:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_RSHIFT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Execute:
|
|
|
|
case XK_Control_L:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LCTRL;
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Control_R:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LCTRL;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Mode_switch:
|
|
|
|
case XK_Alt_L:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LALT;
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Meta_L:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_LMETA;
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Alt_R:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_RALT;
|
|
|
|
break;
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Meta_R:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_RMETA;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Caps_Lock:
|
|
|
|
key = K_CAPSLOCK;
|
|
|
|
break;
|
|
|
|
case XK_KP_Begin:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP5;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
2001-08-20 02:06:55 +00:00
|
|
|
case XK_Scroll_Lock:
|
|
|
|
key = K_SCROLLOCK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_Num_Lock:
|
|
|
|
key = K_NUMLOCK;
|
|
|
|
break;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_Insert:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_INSERT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_KP_Insert:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP0;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XK_KP_Multiply:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_MULTIPLY;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_KP_Add:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_PLUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_KP_Subtract:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_MINUS;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_KP_Divide:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_KP_DIVIDE;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
2001-08-27 01:00:03 +00:00
|
|
|
/* For Sun keyboards */
|
2001-04-15 04:18:22 +00:00
|
|
|
case XK_F27:
|
|
|
|
key = K_HOME;
|
|
|
|
break;
|
|
|
|
case XK_F29:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_PAGEUP;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case XK_F33:
|
|
|
|
key = K_END;
|
|
|
|
break;
|
|
|
|
case XK_F35:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_PAGEDOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
|
2001-07-19 21:46:34 +00:00
|
|
|
/* Some high ASCII symbols, for azerty keymaps */
|
|
|
|
case XK_twosuperior:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_18;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
case XK_eacute:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_63;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
case XK_section:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_7;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
case XK_egrave:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_72;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
case XK_ccedilla:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_71;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
case XK_agrave:
|
2001-08-16 16:41:40 +00:00
|
|
|
key = K_WORLD_64;
|
2001-07-19 21:46:34 +00:00
|
|
|
break;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
default:
|
|
|
|
if (keysym < 128) {
|
|
|
|
/* ASCII keys */
|
|
|
|
key = keysym;
|
2001-08-16 16:41:40 +00:00
|
|
|
if ((key >= 'A') && (key <= 'Z')) {
|
2001-04-15 04:18:22 +00:00
|
|
|
key = key + ('a' - 'A');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-08-16 16:41:40 +00:00
|
|
|
*k = key;
|
|
|
|
*u = unicode;
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_key (XEvent * event)
|
|
|
|
{
|
2001-08-16 16:41:40 +00:00
|
|
|
int key, unicode;
|
2001-04-15 04:18:22 +00:00
|
|
|
if (old_key_dest != key_dest) {
|
|
|
|
old_key_dest = key_dest;
|
|
|
|
if (key_dest == key_game) {
|
|
|
|
XAutoRepeatOff (x_disp);
|
|
|
|
} else {
|
|
|
|
XAutoRepeatOn (x_disp);
|
|
|
|
}
|
|
|
|
}
|
2001-08-16 16:41:40 +00:00
|
|
|
XLateKey (&event->xkey, &key, &unicode);
|
|
|
|
Key_Event (key, unicode, event->type == KeyPress);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_button (XEvent * event)
|
|
|
|
{
|
|
|
|
int but;
|
|
|
|
|
|
|
|
but = event->xbutton.button;
|
|
|
|
if (but == 2)
|
|
|
|
but = 3;
|
|
|
|
else if (but == 3)
|
|
|
|
but = 2;
|
|
|
|
switch (but) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
2001-08-16 16:41:40 +00:00
|
|
|
Key_Event (M_BUTTON1 + but - 1, 0, event->type == ButtonPress);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2001-08-16 16:41:40 +00:00
|
|
|
Key_Event (M_WHEEL_UP, 0, event->type == ButtonPress);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2001-08-16 16:41:40 +00:00
|
|
|
Key_Event (M_WHEEL_DOWN, 0, event->type == ButtonPress);
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-05 20:18:23 +00:00
|
|
|
static void
|
|
|
|
event_focusout (XEvent * event)
|
|
|
|
{
|
|
|
|
XAutoRepeatOn (x_disp);
|
2001-07-05 20:35:42 +00:00
|
|
|
if (in_snd_block->int_val) {
|
|
|
|
S_BlockSound ();
|
|
|
|
CDAudio_Pause ();
|
|
|
|
}
|
2001-07-05 20:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_focusin (XEvent * event)
|
|
|
|
{
|
2001-07-05 20:35:42 +00:00
|
|
|
if (key_dest == key_game)
|
|
|
|
XAutoRepeatOff (x_disp);
|
2001-07-05 20:18:23 +00:00
|
|
|
S_UnblockSound ();
|
2001-07-05 20:35:42 +00:00
|
|
|
CDAudio_Resume ();
|
2001-07-05 20:18:23 +00:00
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
center_pointer (void)
|
|
|
|
{
|
|
|
|
XEvent event;
|
|
|
|
|
|
|
|
event.type = MotionNotify;
|
|
|
|
event.xmotion.display = x_disp;
|
|
|
|
event.xmotion.window = x_win;
|
|
|
|
event.xmotion.x = vid.width / 2;
|
|
|
|
event.xmotion.y = vid.height / 2;
|
|
|
|
XSendEvent (x_disp, x_win, False, PointerMotionMask, &event);
|
|
|
|
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0,
|
|
|
|
vid.width / 2, vid.height / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
event_motion (XEvent * event)
|
|
|
|
{
|
|
|
|
if (dga_active) {
|
2001-08-06 05:01:31 +00:00
|
|
|
in_mouse_x += event->xmotion.x_root;
|
|
|
|
in_mouse_y += event->xmotion.y_root;
|
2001-04-15 04:18:22 +00:00
|
|
|
} else {
|
2001-08-30 20:04:13 +00:00
|
|
|
if (vid_fullscreen->int_val || in_grab->int_val) {
|
2001-04-15 04:18:22 +00:00
|
|
|
if (!event->xmotion.send_event) {
|
2001-04-15 07:18:04 +00:00
|
|
|
in_mouse_x += (event->xmotion.x - p_mouse_x);
|
|
|
|
in_mouse_y += (event->xmotion.y - p_mouse_y);
|
2001-08-27 01:00:03 +00:00
|
|
|
if (abs (vid.width / 2 - event->xmotion.x) > vid.width / 4 ||
|
|
|
|
abs (vid.height / 2 - event->xmotion.y) > vid.height / 4) {
|
2001-04-15 04:18:22 +00:00
|
|
|
center_pointer ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2001-04-15 07:18:04 +00:00
|
|
|
in_mouse_x += (event->xmotion.x - p_mouse_x);
|
|
|
|
in_mouse_y += (event->xmotion.y - p_mouse_y);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
p_mouse_x = event->xmotion.x;
|
|
|
|
p_mouse_y = event->xmotion.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-30 20:04:13 +00:00
|
|
|
void
|
|
|
|
IN_LL_Grab_Input (void)
|
|
|
|
{
|
2001-09-05 03:14:41 +00:00
|
|
|
if (!x_disp || !x_win)
|
|
|
|
return;
|
2001-09-18 04:53:01 +00:00
|
|
|
X11_Grabber(true);
|
2001-08-30 20:04:13 +00:00
|
|
|
if (in_dga->int_val)
|
|
|
|
dga_on ();
|
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
|
2001-08-30 20:04:13 +00:00
|
|
|
void
|
|
|
|
IN_LL_Ungrab_Input (void)
|
|
|
|
{
|
2001-09-05 03:14:41 +00:00
|
|
|
if (!x_disp || !x_win)
|
|
|
|
return;
|
2001-08-30 20:04:13 +00:00
|
|
|
if (in_dga->int_val)
|
|
|
|
dga_off ();
|
2001-09-18 04:53:01 +00:00
|
|
|
X11_Grabber(false);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-15 07:18:04 +00:00
|
|
|
IN_LL_SendKeyEvents (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
/* Get events from X server. */
|
|
|
|
X11_ProcessEvents ();
|
|
|
|
}
|
|
|
|
|
2001-08-27 01:00:03 +00:00
|
|
|
/* Called at shutdown */
|
2001-04-15 04:18:22 +00:00
|
|
|
void
|
2001-04-15 07:18:04 +00:00
|
|
|
IN_LL_Shutdown (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
2001-04-15 07:18:04 +00:00
|
|
|
Con_Printf ("IN_LL_Shutdown\n");
|
|
|
|
in_mouse_avail = 0;
|
2001-04-15 04:18:22 +00:00
|
|
|
if (x_disp) {
|
|
|
|
XAutoRepeatOn (x_disp);
|
2001-08-30 20:32:27 +00:00
|
|
|
dga_off ();
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
X11_CloseDisplay ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-15 07:18:04 +00:00
|
|
|
IN_LL_Init (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
// open the display
|
|
|
|
if (!x_disp)
|
|
|
|
Sys_Error ("IN: No display!!\n");
|
|
|
|
if (!x_win)
|
|
|
|
Sys_Error ("IN: No window!!\n");
|
|
|
|
|
|
|
|
X11_OpenDisplay (); // call to increment the reference counter
|
|
|
|
|
|
|
|
{
|
|
|
|
int attribmask = CWEventMask;
|
|
|
|
|
|
|
|
XWindowAttributes attribs_1;
|
|
|
|
XSetWindowAttributes attribs_2;
|
|
|
|
|
|
|
|
XGetWindowAttributes (x_disp, x_win, &attribs_1);
|
|
|
|
|
|
|
|
attribs_2.event_mask = attribs_1.your_event_mask | INPUT_MASK;
|
|
|
|
|
|
|
|
XChangeWindowAttributes (x_disp, x_win, attribmask, &attribs_2);
|
|
|
|
}
|
|
|
|
|
|
|
|
X11_AddEvent (KeyPress, &event_key);
|
|
|
|
X11_AddEvent (KeyRelease, &event_key);
|
2001-07-05 20:18:23 +00:00
|
|
|
X11_AddEvent (FocusIn, &event_focusin);
|
|
|
|
X11_AddEvent (FocusOut, &event_focusout);
|
|
|
|
|
|
|
|
if (!COM_CheckParm ("-nomouse")) {
|
|
|
|
dga_avail = VID_CheckDGA (x_disp, NULL, NULL, NULL);
|
2001-09-18 04:53:01 +00:00
|
|
|
//if (vid_fullscreen->int_val) {
|
|
|
|
//Cvar_Set (in_grab, "1");
|
|
|
|
//in_grab->flags |= CVAR_ROM;
|
|
|
|
//IN_LL_Grab_Input ();
|
|
|
|
//}
|
2001-07-05 20:18:23 +00:00
|
|
|
|
|
|
|
X11_AddEvent (ButtonPress, &event_button);
|
|
|
|
X11_AddEvent (ButtonRelease, &event_button);
|
|
|
|
X11_AddEvent (MotionNotify, &event_motion);
|
2001-07-06 00:17:09 +00:00
|
|
|
|
|
|
|
in_mouse_avail = 1;
|
2001-07-05 20:18:23 +00:00
|
|
|
}
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-15 07:18:04 +00:00
|
|
|
IN_LL_Init_Cvars (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
2001-07-05 20:35:42 +00:00
|
|
|
in_snd_block= Cvar_Get ("in_snd_block", "0", CVAR_ARCHIVE, NULL,
|
|
|
|
"block sound output on window focus loss");
|
2001-08-30 20:04:13 +00:00
|
|
|
in_dga = Cvar_Get ("in_dga", "1", CVAR_ARCHIVE, in_dga_f,
|
2001-04-15 04:18:22 +00:00
|
|
|
"DGA Input support");
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:55:33 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
IN_LL_ClearStates (void)
|
|
|
|
{
|
|
|
|
}
|