Forum

Making Mouse Behaviour Consistent on Windows

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Making Mouse Behaviour Consistent on Windows

Postby mh » Fri Mar 19, 2010 9:21 pm

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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby r00k » Sat Mar 20, 2010 6:41 am

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
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby mankrip » Mon Apr 12, 2010 4:14 pm

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
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby Sajt » Mon Apr 12, 2010 5:45 pm

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.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby mh » Mon Apr 12, 2010 6:30 pm

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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am


Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest