Message Boards

Topic: ZDoom-derived Ports & Mouse Information  (Read 14145 times)

Offline Dr. Sean

  • Developer
  • Posts: 69
  • G'd up from tha feet up
    • View Profile
    • Odamex - Helping middle-aged men relive their teen years
ZDoom-derived Ports & Mouse Information
« on: December 09, 2011, 12:06:33 »
After thorough investigation, I have discovered a great deal about the internals of how ZDoom 1.23 and its derivatives handle mouse input which I will try to distill here.  This post will be updated as more information is discovered.

Odamex's Mouse Input Types

Odamex uses DirectInput for its mouse input on the Windows platform and as of 0.5.6, it provides two mouse types: Doom and Odamex.  The input processing for the two types is identical and the only difference is with regard to the mouse_sensitivity cvar, where the mouse_sensitivity value with the Doom mouse type is always 5 less than the equivalent mouse_sensitivity value for the Odamex mouse type.

For example, Doom mouse type & mouse_sensitivity = 35 is equivalent to Odamex mouse type & mouse_sensitivity = 40.


ZDoom's Mouse Input Types

The most important factor relating to mouse input in ZDoom-derived ports is the cvar in_mouse.  With the default value of in_mouse = 0, the game selects the default method of mouse input for the OS, which is using DirectInput (also can be explicitly specified with in_mouse = 2). A value of in_mouse = 1 uses USER32.DLL calls (we'll call this Win32).  The overwhelming majority of players will have in_mouse set to 0 and therefore use the DirectInput mouse type.

ZDoom DirectInput Mouse

DirectInput (part of the DirectX library) retrieves "raw" mouse input values, unscaled by the OS.  This bypasses the Windows mouse sensitivity and acceleration settings.  When ZDoom uses this mouse type, it scales the mouse movement values along the x-axis by a factor of 4.0 and does not change the movement values along the y-axis.  

Users of this mouse type can easily convert their ZDoom mouse settings to Odamex's Doom mouse type using the following equations:
Doom mouse_sensitivity = (ZDoom mouse_sensitivity * 40) - 5
Doom m_pitch = (ZDoom m_pitch / 4)


So using the default ZDoom mouse_sensitivity = 1.0, a user should choose mouse_sensitivity = 35 when using the Doom mouse type in Odamex.  Using the default ZDoom m_pitch = 1.0, a user should choose m_pitch = 0.25 with the Doom mouse type in Odamex.  Since ZDoom does not offer mouse acceleration, players wanting the same feel in Odamex should set mouse_acceleration to 0.

ZDoom Win32 Mouse
The Win32 mouse type gets mouse values from the Windows OS like a normal desktop application.  Windows first applies its sensitivity scaling to the user's mouse input and then applies its acceleration curve if the user has not disabled it in the Windows Control Panel.  Finally, Windows passes the scaled mouse values to the game.

Windows uses a non-linear table to determine how its Control Panel sensitivity setting will scale the mouse input.  Players can scale their Zdoom mouse_sensitivity setting by the following table to match their Windows mouse sensitivity setting.

Windows Sensitivity Factors (when acceleration is disabled)
  • 1  0.03125
  • 2  0.0625
  • 3  0.25
  • 4  0.5
  • 5  0.75
  • 6  1.0
  • 7  1.5
  • 8  2.0
  • 9  2.5
  • 10 3.0
  • 11 3.5

If a player has not disabled acceleration (sometimes also called Enhanced Pointer Precision) in the Windows Control Panel, they also are subjected to Windows mouse acceleration as well as an different set of sensitivity scaling factors, as seen below.

Windows Sensitivity Factors (with acceleration enabled)
  • 1  0.1
  • 2  0.2
  • 3  0.4
  • 4  0.6
  • 5  0.8
  • 6  1.0
  • 7  1.2
  • 8  1.4
  • 9  1.6
  • 10 1.8
  • 11 2.0

Describing how the mouse pointer algorithm works is beyond the scope of this posting, however, my testing confirms that this reference (http://www.teamliquid.net/forum/viewmessage.php?topic_id=157790#13) appears to give a very accurate description of the algorithm used in Windows XP and Vista/7.

Finally, when ZDoom uses the Win32 mouse type, it scales the mouse movement values along the x-axis by a factor of 3.0 and scales movement along the y-axis by a factor of 2.0.

The below equations will allow most players to easily convert their mouse to the Doom mouse type in Odamex.  Note that the Windows Sensitivity Factor is given in the above table.

Doom mouse_sensitivity = (30 * (ZDoom mouse_sensitivity) * (Windows Sensitivity Factor)) - 5
Doom m_pitch = 0.5 * (ZDoom m_pitch) * (Windows Sensitivity Factor)
mouse_acceleration = 0 or 2.6 (depending on whether it's enabled in Windows Control Panel)
mouse_threshold = 6



Given a player who uses the default mouse_sensitivity = 1.0 and m_pitch = 1.0 in their ZDoom-derived port and uses the default mouse settings in the Windows Control Panel of sensitivity = 6 and acceleration turned on, they should use the following settings:
mouse_type = 0 (Doom mouse type)
mouse_sensitivity = 25
m_pitch = 0.5
mouse_acceleration = 2.6
mouse_threshold = 6

« Last Edit: January 25, 2012, 19:54:50 by Dr. Sean »
Odamex Development Team Member

Offline Xenaero

  • Posts: 11
  • With images of justice, or designs of liberty
    • View Profile
Re: ZDoom-derived Ports & Mouse Information
« Reply #1 on: February 15, 2012, 14:03:13 »
I want to give Sean a huge thanks for taking time to figure this out, it's a very significant feat and a huge help to players like myself who like to have the same sensitivity across multiple MP source ports. Awesome stuff, and a very handy topic.
And now a picture for the frame we set aside
Below the bassline a secret place awaits for us to hide
To pass the time as the war goes on-and-on
Post-apocalyptic sunset, Post-apocalyptic dawn

Offline Xenaero

  • Posts: 11
  • With images of justice, or designs of liberty
    • View Profile
Re: ZDoom-derived Ports & Mouse Information
« Reply #2 on: April 26, 2012, 09:28:17 »
I'm interested in seeing if mouse response time can be improved despite the locked framerate. Is this possible?
And now a picture for the frame we set aside
Below the bassline a secret place awaits for us to hide
To pass the time as the war goes on-and-on
Post-apocalyptic sunset, Post-apocalyptic dawn

Offline Dr. Sean

  • Developer
  • Posts: 69
  • G'd up from tha feet up
    • View Profile
    • Odamex - Helping middle-aged men relive their teen years
Re: ZDoom-derived Ports & Mouse Information
« Reply #3 on: April 26, 2012, 13:12:28 »
I'm interested in seeing if mouse response time can be improved despite the locked framerate. Is this possible?

This should theoretically be possible but not without some effort.  It would definitely change the feel of the mouse away from the original Doom feel.  If there's enough desire for that, I'll look into it for 0.6.x, but it would be a pretty big paradigm shift and it would have to be implemented in such a manner that the 35Hz input polling would be undisturbed and set as default.
Odamex Development Team Member

Offline Xenaero

  • Posts: 11
  • With images of justice, or designs of liberty
    • View Profile
Re: ZDoom-derived Ports & Mouse Information
« Reply #4 on: April 26, 2012, 14:30:57 »
I understand. Perhaps if such a thing were implemented it could give a greater advantage as opposed to the default setting, anyway, adding even more 'balance' variables to mess with. I was merely curious.
And now a picture for the frame we set aside
Below the bassline a secret place awaits for us to hide
To pass the time as the war goes on-and-on
Post-apocalyptic sunset, Post-apocalyptic dawn