dlls/dinput/mouse.c warp handling

Lionel Ulmer lionel.ulmer at free.fr
Thu Jun 17 02:58:01 CDT 2004

On Thu, Jun 17, 2004 at 09:19:29AM +0200, James Dean Anderson wrote:
> No, not exactly. There are several things in wine I don't know yet (eg 
> what does GEN_EVENT do exactly / what are these critical-sections / etc.).

Welln this is related to the way DInput works: you have two ways to get
informations from your devices, either you get an immediate picture of the
device state at a given time (GetDeviceState) or you can get all the
individual timestamped events that occured since last time you queried the
device (GetDeviceData).

So GEN_EVENT simply queues a hardwware event into the queue that can be
queried via 'GetDeviceData'.

The critical sections are here because you can have one thread queuing
events (Wine's hardware event thread) while another (the game) can access
the data, which means you need to protect against concurrent usage.

> But I think doing mouse-warping in 3 states and across different 
> functions is much to complicated and while it works great in MaxPayne, 
> it behaves strangely in WWIIOL.

The warping in three states has been disabled for a long time now (it is
only enabled if you #define MOUSE_HACK). It's an idea that worked once, but
not anymore due to mouse event compression in some core part of Wine's input
handling. The idea was that, basically, as the fact of warping the mouse
WILL generate an X11 event for you, you could detect when the warp was
actually done by checking when the ext mouse position corresponds to your
warp position. Which would prevent some 'glitches' if you got a queued X11
event back from before the warp buf after you issued the warp command to the
X11 server.

As to doing it only in the 'mouse even hook' I agree that it is cleaner that
way (I missed this line when checking your patch so I thought that you
removed warping completely :-) ). The only problem here is that you may have
a LOT more warps done that way than in the previous way. For example, if X11
generates 10 X mouse events for each game 'frame', you will warp your mouse
10 times more with your code than with the current one (which only warped
the mouse when the game actually queries the device).

But the main way to rework this would be to put the complete warping stuff
in the X11 driver (as the way it's done now is fundamentally flawed for some

Note also that it would be much nicer to do a 'rectangle' warp instead of a
'point' wrap: do not wrap on each mouse event, but only when the mouse goes
out of a centered rectangle which would be about half the size of the
screen. This would have the advantage of smoother mouse movements as it
would minimize a lot the number of warps.

And DGAMouse support / X11 extension writing would be the other way :-)


		 Lionel Ulmer - http://www.bbrox.org/

More information about the wine-devel mailing list