mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-01 12:20:54 +00:00
dga_check.h: DGA and VidMode check functions return qboolean, not
int. Cleaned up prototypes to not include variable names. dga_check.c: Fix bug in DGA detection that lead to segfault. in_x11.c: Better DGA input support for X targets; The -nodga parameter is gone, it is now the in_dga Cvar, which is dependant on the _windowed_mouse Cvar. in_dga is archived.
This commit is contained in:
parent
f0c35d7f9d
commit
afae879d2e
3 changed files with 74 additions and 108 deletions
|
@ -3,9 +3,8 @@
|
|||
|
||||
Definitions for XFree86 DGA and VidMode support
|
||||
|
||||
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
||||
Copyright (C) 2000 contributors of the QuakeForge project
|
||||
Please see the file "AUTHORS" for a list of contributors
|
||||
Copyright (C) 2000 Jeff Teunissen <deek@dusknet.dhs.org>
|
||||
Copyright (C) 2000 Marcus Sundberg [mackan@stacken.kth.se]
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -28,21 +27,17 @@
|
|||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef DGA_CHECK_H
|
||||
#define DGA_CHECK_H
|
||||
#ifndef __dga_check_h_
|
||||
#define __dga_check_h_
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "cvar.h"
|
||||
|
||||
extern cvar_t *vid_dga_mouseaccel;
|
||||
|
||||
/*
|
||||
VID_CheckDGA
|
||||
|
||||
Check for the presence of the XFree86-DGA support in the X server
|
||||
*/
|
||||
int VID_CheckDGA(Display *dpy, int *maj_ver, int *min_ver, int *hasvideo);
|
||||
qboolean VID_CheckDGA (Display *, int *, int *, int *);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -50,6 +45,6 @@ int VID_CheckDGA(Display *dpy, int *maj_ver, int *min_ver, int *hasvideo);
|
|||
|
||||
Check for the presence of the XFree86-VMode X server extension
|
||||
*/
|
||||
int VID_CheckVMode(Display *dpy, int *maj_ver, int *min_ver);
|
||||
qboolean VID_CheckVMode (Display *, int *, int *);
|
||||
|
||||
#endif /* DGA_CHECK_H */
|
||||
#endif // __dga_check_h_
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#if defined(HAVE_DGA)
|
||||
#ifdef HAVE_DGA
|
||||
#include <X11/extensions/xf86dga.h>
|
||||
#endif
|
||||
#if defined(HAVE_VIDMODE)
|
||||
#ifdef HAVE_VIDMODE
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
|
||||
#include <dga_check.h>
|
||||
#include "dga_check.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -48,31 +48,34 @@
|
|||
|
||||
Check for the presence of the XFree86-DGA X server extension
|
||||
*/
|
||||
int
|
||||
VID_CheckDGA(Display *dpy, int *maj_ver, int *min_ver, int *hasvideo)
|
||||
qboolean
|
||||
VID_CheckDGA (Display *dpy, int *maj_ver, int *min_ver, int *hasvideo)
|
||||
{
|
||||
#if defined(HAVE_DGA)
|
||||
#ifdef HAVE_DGA
|
||||
int event_base, error_base, dgafeat, dummy;
|
||||
|
||||
if (! XF86DGAQueryExtension(dpy, &event_base, &error_base)) {
|
||||
return 0;
|
||||
if (!XF86DGAQueryExtension (dpy, &event_base, &error_base)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maj_ver == NULL) maj_ver = &dummy;
|
||||
if (min_ver == NULL) min_ver = &dummy;
|
||||
if (!maj_ver) maj_ver = &dummy;
|
||||
if (!min_ver) min_ver = &dummy;
|
||||
|
||||
if (! XF86DGAQueryVersion(dpy, maj_ver, min_ver)) {
|
||||
return 0;
|
||||
if (!XF86DGAQueryVersion (dpy, maj_ver, min_ver)) {
|
||||
return false;
|
||||
}
|
||||
if (! XF86DGAQueryDirectVideo(dpy, DefaultScreen(dpy), &dgafeat)) {
|
||||
|
||||
if (!hasvideo) hasvideo = &dummy;
|
||||
|
||||
if (!XF86DGAQueryDirectVideo (dpy, DefaultScreen (dpy), &dgafeat)) {
|
||||
*hasvideo = 0;
|
||||
} else {
|
||||
*hasvideo = (dgafeat & XF86DGADirectPresent);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
#else
|
||||
return 0;
|
||||
return false;
|
||||
#endif // HAVE_DGA
|
||||
}
|
||||
|
||||
|
@ -82,26 +85,26 @@ VID_CheckDGA(Display *dpy, int *maj_ver, int *min_ver, int *hasvideo)
|
|||
|
||||
Check for the presence of the XFree86-VidMode X server extension
|
||||
*/
|
||||
int
|
||||
VID_CheckVMode(Display *dpy, int *maj_ver, int *min_ver)
|
||||
qboolean
|
||||
VID_CheckVMode (Display *dpy, int *maj_ver, int *min_ver)
|
||||
{
|
||||
#if defined(HAVE_VIDMODE)
|
||||
int event_base, error_base;
|
||||
int dummy;
|
||||
|
||||
if (! XF86VidModeQueryExtension(dpy, &event_base, &error_base)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maj_ver == NULL) maj_ver = &dummy;
|
||||
if (min_ver == NULL) min_ver = &dummy;
|
||||
|
||||
if (! XF86VidModeQueryVersion(dpy, maj_ver, min_ver)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
#else
|
||||
return 0;
|
||||
return false;
|
||||
#endif // HAVE_VIDMODE
|
||||
}
|
||||
|
|
118
source/in_x11.c
118
source/in_x11.c
|
@ -56,6 +56,7 @@
|
|||
#endif
|
||||
|
||||
#include "quakedef.h"
|
||||
#include "dga_check.h"
|
||||
#include "d_local.h"
|
||||
#include "sound.h"
|
||||
#include "keys.h"
|
||||
|
@ -72,24 +73,22 @@
|
|||
|
||||
cvar_t *_windowed_mouse;
|
||||
cvar_t *m_filter;
|
||||
cvar_t *in_dgamouse;
|
||||
#ifdef HAVE_DGA
|
||||
|
||||
cvar_t *in_dga;
|
||||
cvar_t *in_dga_mouseaccel;
|
||||
cvar_t *in_nodga_grab;
|
||||
#endif
|
||||
|
||||
static qboolean dga_avail;
|
||||
static qboolean dga_active;
|
||||
|
||||
static qboolean mouse_avail;
|
||||
static float mouse_x, mouse_y;
|
||||
static float old_mouse_x, old_mouse_y;
|
||||
static int p_mouse_x, p_mouse_y;
|
||||
static float old__windowed_mouse;
|
||||
|
||||
|
||||
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
|
||||
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
|
||||
#define INPUT_MASK (KEY_MASK | MOUSE_MASK)
|
||||
|
||||
|
||||
static int
|
||||
XLateKey(XKeyEvent *ev)
|
||||
{
|
||||
|
@ -218,14 +217,14 @@ XLateKey(XKeyEvent *ev)
|
|||
|
||||
|
||||
static void
|
||||
event_key(XEvent *event)
|
||||
event_key (XEvent *event)
|
||||
{
|
||||
Key_Event(XLateKey(&event->xkey), event->type == KeyPress);
|
||||
Key_Event (XLateKey (&event->xkey), event->type == KeyPress);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_button(XEvent *event)
|
||||
event_button (XEvent *event)
|
||||
{
|
||||
int but;
|
||||
|
||||
|
@ -267,15 +266,12 @@ center_pointer(void)
|
|||
|
||||
|
||||
static void
|
||||
event_motion(XEvent *event)
|
||||
event_motion (XEvent *event)
|
||||
{
|
||||
#ifdef HAVE_DGA
|
||||
if (in_dgamouse->int_val) {
|
||||
if (dga_active) {
|
||||
mouse_x += event->xmotion.x_root * in_dga_mouseaccel->value;
|
||||
mouse_y += event->xmotion.y_root * in_dga_mouseaccel->value;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
//printf("_windowed_mouse: %f\n", _windowed_mouse->int_val);
|
||||
//printf("CurrentTime: %ld\n", CurrentTime);
|
||||
if (_windowed_mouse->int_val) {
|
||||
|
@ -305,20 +301,33 @@ event_motion(XEvent *event)
|
|||
void
|
||||
IN_Commands (void)
|
||||
{
|
||||
static int old_windowed_mouse;
|
||||
static int old_in_dga;
|
||||
|
||||
JOY_Command ();
|
||||
|
||||
if (old__windowed_mouse != _windowed_mouse->int_val) {
|
||||
old__windowed_mouse = _windowed_mouse->int_val;
|
||||
if ((old_windowed_mouse != _windowed_mouse->int_val)
|
||||
|| (old_in_dga != in_dga->int_val)) {
|
||||
old_windowed_mouse = _windowed_mouse->int_val;
|
||||
|
||||
if (!_windowed_mouse->int_val) {
|
||||
/* ungrab the pointer */
|
||||
XUngrabPointer (x_disp, CurrentTime);
|
||||
} else {
|
||||
/* grab the pointer */
|
||||
if (_windowed_mouse->int_val) { // grab the pointer
|
||||
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
||||
GrabModeAsync, x_win, None, CurrentTime);
|
||||
// XGrabPointer (x_disp,x_win,True,0,GrabModeAsync,
|
||||
// GrabModeAsync,x_win,None,CurrentTime);
|
||||
#ifdef HAVE_DGA
|
||||
if (dga_avail && in_dga->int_val && !dga_active) {
|
||||
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp),
|
||||
XF86DGADirectMouse);
|
||||
dga_active = true;
|
||||
}
|
||||
#endif
|
||||
} else { // ungrab the pointer
|
||||
#ifdef HAVE_DGA
|
||||
if (dga_avail && in_dga->int_val && dga_active) {
|
||||
XF86DGADirectVideo (x_disp, DefaultScreen (x_disp), 0);
|
||||
dga_active = false;
|
||||
}
|
||||
#endif
|
||||
XUngrabPointer (x_disp, CurrentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -371,24 +380,6 @@ IN_Move (usercmd_t *cmd)
|
|||
mouse_x = mouse_y = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
static void IN_ExtraOptionDraw(unsigned int options_draw_cursor)
|
||||
{
|
||||
// Windowed Mouse
|
||||
M_Print(16, options_draw_cursor+=8, " Use Mouse");
|
||||
M_DrawCheckbox(220, options_draw_cursor, _windowed_mouse->int_val);
|
||||
}
|
||||
|
||||
static void IN_ExtraOptionCmd(int option_cursor)
|
||||
{
|
||||
switch (option_cursor) {
|
||||
case 1: // _windowed_mouse
|
||||
Cvar_SetValue (_windowed_mouse, !_windowed_mouse->int_val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
Called at shutdown
|
||||
*/
|
||||
|
@ -414,13 +405,14 @@ extern int scr_width, scr_height;
|
|||
void
|
||||
IN_Init (void)
|
||||
{
|
||||
// open the display
|
||||
// open the display
|
||||
if (!x_disp)
|
||||
Sys_Error("IN: No display!!\n");
|
||||
if (!x_win)
|
||||
Sys_Error("IN: No window!!\n");
|
||||
|
||||
x11_open_display (); // call to increment the reference counter
|
||||
|
||||
{
|
||||
int attribmask = CWEventMask;
|
||||
XWindowAttributes attribs_1;
|
||||
|
@ -435,42 +427,18 @@ IN_Init (void)
|
|||
|
||||
JOY_Init ();
|
||||
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse","0",CVAR_ARCHIVE,"None");
|
||||
m_filter = Cvar_Get ("m_filter","0",CVAR_ARCHIVE,"None");
|
||||
_windowed_mouse = Cvar_Get ("_windowed_mouse", "0", CVAR_ARCHIVE, "None");
|
||||
m_filter = Cvar_Get ("m_filter", "0", CVAR_ARCHIVE, "None");
|
||||
in_dga = Cvar_Get ("in_dga", "1", CVAR_ARCHIVE, "DGA Input support");
|
||||
in_dga_mouseaccel = Cvar_Get ("in_dga_mouseaccel", "1", CVAR_ARCHIVE,
|
||||
"None");
|
||||
|
||||
XAutoRepeatOff(x_disp);
|
||||
XAutoRepeatOff (x_disp);
|
||||
|
||||
if (COM_CheckParm("-nomouse"))
|
||||
return;
|
||||
#ifdef HAVE_DGA
|
||||
in_dgamouse = Cvar_Get ("in_dgamouse", "0", CVAR_ROM,
|
||||
"1 if you have DGA mouse support");
|
||||
in_dga_mouseaccel = Cvar_Get ("in_dga_mouseaccel", "1", CVAR_ARCHIVE,
|
||||
"None");
|
||||
in_nodga_grab = Cvar_Get ("in_nodga_grab", "0", CVAR_ROM,
|
||||
"grab keyboard and mouse input when using -nodga");
|
||||
|
||||
if (COM_CheckParm ("-nodga")) {
|
||||
if (in_nodga_grab->int_val) {
|
||||
XGrabKeyboard (x_disp, x_win, True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime);
|
||||
|
||||
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
||||
GrabModeAsync, x_win, None, CurrentTime);
|
||||
}
|
||||
} else {
|
||||
XGrabKeyboard (x_disp, x_win, True, GrabModeAsync,
|
||||
GrabModeAsync, CurrentTime);
|
||||
|
||||
XF86DGADirectVideo(x_disp, DefaultScreen(x_disp),
|
||||
XF86DGADirectMouse|XF86DGADirectKeyb);
|
||||
|
||||
XGrabPointer (x_disp, x_win, True, MOUSE_MASK, GrabModeAsync,
|
||||
GrabModeAsync, x_win, None, CurrentTime);
|
||||
|
||||
Cvar_SetROM (in_dgamouse, "1");
|
||||
}
|
||||
#endif
|
||||
dga_avail = VID_CheckDGA (x_disp, NULL, NULL, NULL);
|
||||
|
||||
mouse_x = mouse_y = 0.0;
|
||||
mouse_avail = 1;
|
||||
|
|
Loading…
Reference in a new issue