Inside3D!
     

Making Mouse Behaviour Consistent on Windows

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials
View previous topic :: View next topic  
Author Message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Fri Mar 19, 2010 9:21 pm    Post subject: Making Mouse Behaviour Consistent on Windows Reply with quote

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:
static int      originalmouseparms[3], newmouseparms[3] = {0, 0, 1};

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

That's all. Very Happy

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. Wink
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Sat Mar 20, 2010 6:41 am    Post subject: Reply with quote

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

Code:

static   int   originalmouseparms[3], newmouseparms[3] = {0, 0, 0};//MH: acceleration level set to zero!


Thanks for pointing this out! Legacy anomalies must die! Very Happy
Back to top
View user's profile Send private message
mk



Joined: 04 Jul 2008
Posts: 94

PostPosted: Mon Apr 12, 2010 4:14 pm    Post subject: Reply with quote

I'm not sure if this inconsistency was intentional, but it was mentioned in WinQuake's readme:
Code:
----------------------
| 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).

_________________
Makaqu engine blog / website.

Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.
Back to top
View user's profile Send private message
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Mon Apr 12, 2010 5:45 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
mh



Joined: 12 Jan 2008
Posts: 909

PostPosted: Mon Apr 12, 2010 6:30 pm    Post subject: Reply with quote

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. Laughing

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. Very Happy
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group