in_mouse_accel patch from qize@gmx.net

This commit is contained in:
Bill Currie 2003-09-04 22:29:40 +00:00
parent a0875ea909
commit 6b036d14ed
4 changed files with 52 additions and 1 deletions

View file

@ -59,8 +59,8 @@ extern struct cvar_s *in_grab;
extern struct cvar_s *in_amp;
extern struct cvar_s *in_pre_amp;
extern struct cvar_s *m_filter;
extern struct cvar_s *in_mouse_accel;
extern struct cvar_s *in_freelook;
extern struct cvar_s *sensitivity;
extern struct cvar_s *lookstrafe;
extern qboolean in_mouse_avail;

View file

@ -69,6 +69,9 @@ void X11_RestoreVidMode (void);
void X11_SetCaption (const char *);
void X11_SetScreenSaver (void);
void X11_SetVidMode (int, int);
void X11_SaveMouseAcceleration (void);
void X11_RemoveMouseAcceleration (void);
void X11_RestoreMouseAcceleration (void);
qboolean X11_GetWindowCoords (int *ax, int *ay);
#endif // __context_x11_h_

View file

@ -114,6 +114,11 @@ static int xss_interval;
static int xss_blanking;
static int xss_exposures;
static qboolean accel_saved = false;
static int accel_numerator;
static int accel_denominator;
static int accel_threshold;
qboolean
X11_AddEvent (int event, void (*event_handler) (XEvent *))
@ -615,3 +620,29 @@ X11_RestoreScreenSaver (void)
XSetScreenSaver (x_disp, xss_timeout, xss_interval, xss_blanking,
xss_exposures);
}
void
X11_SaveMouseAcceleration (void)
{
accel_saved = true;
XGetPointerControl(x_disp, &accel_numerator, &accel_denominator,
&accel_threshold);
}
void
X11_RemoveMouseAcceleration (void)
{
XChangePointerControl(x_disp, false, false, 0, 0, 0);
}
void
X11_RestoreMouseAcceleration (void)
{
if (!accel_saved)
return;
XChangePointerControl(x_disp, true, true, accel_numerator,
accel_denominator, accel_threshold);
accel_saved = false;
}

View file

@ -78,6 +78,7 @@ static __attribute__ ((unused)) const char rcsid[] =
cvar_t *in_snd_block;
cvar_t *in_dga;
cvar_t *in_mouse_accel;
static qboolean dga_avail;
static qboolean dga_active;
@ -125,6 +126,17 @@ in_dga_f (cvar_t *var)
}
}
static void
in_mouse_accel_f (cvar_t *var)
{
if (var->int_val) {
X11_RestoreMouseAcceleration ();
} else {
X11_SaveMouseAcceleration ();
X11_RemoveMouseAcceleration ();
}
}
static void
in_paste_buffer_f (void)
{
@ -635,6 +647,8 @@ IN_LL_Shutdown (void)
XAutoRepeatOn (x_disp);
dga_off ();
}
if (!in_mouse_accel->int_val)
X11_RestoreMouseAcceleration();
X11_CloseDisplay ();
}
@ -690,6 +704,9 @@ IN_LL_Init_Cvars (void)
"block sound output on window focus loss");
in_dga = Cvar_Get ("in_dga", "1", CVAR_ARCHIVE, in_dga_f,
"DGA Input support");
in_mouse_accel = Cvar_Get ("in_mouse_accel", "1", CVAR_ARCHIVE,
in_mouse_accel_f,
"set to 0 to remove mouse acceleration");
}
void