Making Mouse Behaviour Consistent on Windows

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Making Mouse Behaviour Consistent on Windows

Post by mh »

We all know that mouse behaviour in Quake is different depending on whether or not you're using DirectInput. Here's a quick one-liner to make it consistent.

Open in_win.c, find the declaration of newmouseparms. It should look like this:

Code: Select all

static int		originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
Change the 1 to a 0, like so:

Code: Select all

static int		originalmouseparms[3], newmouseparms[3] = {0, 0, 0};
That's all. :D

OK, so what's going on here?

Basically these mouse parameters refer to 3 factors that control how the mouse behaves. The first two are acceleration thresholds, and the third is an acceleration level. Setting them all to 0 replicates the behaviour of DirectInput exactly, which is to completely ignore the settings in your mouse control panel and just give flat unaccelerated input.

For bonus points you can cvar-ize them; that's an exercise left to the individual. ;)
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Post by r00k »

Remember the ol' "I should have had a V8!" slap to the head?
I almost knocked myself outta my chair!

Code: Select all

static	int	originalmouseparms[3], newmouseparms[3] = {0, 0, 0};//MH: acceleration level set to zero!
Thanks for pointing this out! Legacy anomalies must die! :D
mankrip
Posts: 924
Joined: Fri Jul 04, 2008 3:02 am

Post by mankrip »

I'm not sure if this inconsistency was intentional, but it was mentioned in WinQuake's readme:

Code: Select all

----------------------
| Notes on the mouse |
----------------------

If DirectInput is installed and functioning, WinQuake can use it for
mouse input, but does not do so automatically because DirectInput does
not work properly on all systems.  DirectInput can be enabled via the
command-line switch -dinput.  If DirectInput is not available or is
not enabled, WinQuake uses the normal Windows mouse APIs instead.
DirectInput provides slightly smoother motion; also, it tends to be
more responsive to fast spinning motions, and we recommend that you use
it if it works properly on your system.  You can determine if WQ uses
DirectInput on your system when you use -dinput by checking for
"DirectInput initialized" in the startup console text.  If not, you
might try installing DirectX 3 (note, though, that as I write this
there is no released DirectInput support for Windows NT, only Win95).
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

I think DirectInput disables mouse acceleration automatically. When you fix the bug pointed out by mh, DirectInput and non-DirectInput feel identical, although DirectInput is supposedly a couple billionths of a microsecond "more responsive".

Apparently (if I remember what LordHavoc told me) the WinQuake code actually used to work, but there was a Windows API change which changed the meaning of the parameters.

I removed DirectInput entirely from GoldQuake. It's deprecated, and WinQuake uses an old version anyway which only supports 4 mouse buttons among other things.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
mh
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Post by mh »

Sajt wrote:I think DirectInput disables mouse acceleration automatically. When you fix the bug pointed out by mh, DirectInput and non-DirectInput feel identical, although DirectInput is supposedly a couple billionths of a microsecond "more responsive".
Maybe on the slow CPUs in 1996 it made a difference, but best of luck finding a machine these days where you'd notice. :lol:
Sajt wrote:Apparently (if I remember what LordHavoc told me) the WinQuake code actually used to work, but there was a Windows API change which changed the meaning of the parameters.
That would make sense. It always seemed weird to me that there would be such a difference in feeling between the 2 modes. I guess it confirms that moving forward setting the third param to 0 is the way to go, maybe with a OS or DLL version check if we can determine when the change took place.
Sajt wrote:I removed DirectInput entirely from GoldQuake. It's deprecated, and WinQuake uses an old version anyway which only supports 4 mouse buttons among other things.
It's not that difficult to move up to the newer version, but all the same, unless you're committing to Windows-only it does make sense to remove it. The less platform-specific code you need to port, the better. :D
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
Post Reply