XI2 DirectInput mouse implementation RFC (Tarballed)

Paul TBBle Hampson Paul.Hampson at Pobox.com
Sun Apr 19 06:46:17 CDT 2009

On Sun, Apr 19, 2009 at 12:46:20PM +0200, Stefan Dösinger wrote:
> Am Sonntag, 19. April 2009 10:41:34 schrieb Paul TBBle Hampson:
>> I've thrown together a rather-rough-but-working-in-a-limited-sense
>> implementation of XInput2-based DirectInput.

>> * Doesn't check for XInput2.h, so it won't build without it. (Laziness)
>>   It will _run_ without XInput2, falling back to the current dinput
>>   WndProc hooks even if compiled with XInput2 support.
> I'm not that much into all the input code, but I always understood it the way 
> that dinput should always use WndProc hooks, and winex11.drv implements the 
> relative movement part either with XI2 or warping if XI2 is not available. 
> Ie, there should be no difference between XI2 and legacy operation in 
> dinput.dll. That would, I think, make native dinput work as well as the 
> builtin one, and help apps that rely on hooks the same way native dinput 
> does(if there are any).

> The problem is that this means the warping has to be moved to winex11, which 
> is something Vitaliy tried before and failed

> I could be entirely wrong with that though. And I have no idea how that would 
> affect mouse grabbing, or window focus issues etc.

A WndProc hook can only work for Foreground-mode DI. In background mode,
you still expect to get movement messages without being in a position to

An example of an application that we could fix _now_ with the DI stuff
I've posted is Ventrilo, if we implemented gdikeyboard and the relevant
X11 entry points. That would allow Ventrilo's press-to-speak key to
operate irrespective of what program has the current focus. Right now it
only works if a Wine window has the focus in non-DI mode, and not at all
in DI mode.

Moving the WndProc hook and mouse-warping behaviour to X11 would
certainly be possible, and I suspect it'd end up somewhat with a mouse
driver in dinput which is almost exactly what my gdimouse is, which is
basically the existing mouse driver except that it feeds Acquire and
Deacquire to X11drv and receives messages from X11drv when an event

I haven't read Vitaly's old patches for moving mouse warping to X11drv
recently, but I did read them a while ago. The problem with moving the
warping to X11drv is that then every graphics driver _must_ implement
the hooks I've added in my patches, where as right now we have a
fallback mouse support mode which will work with any graphics driver,
and in fact would also work on Windows (I believe) because it simply
hooks WndProc, and does not need "real hardware" access, and has
well-documented and under-documented limitations because of it.

At best, any graphics driver except X11 w/out XI2 could have a
non-warping version of exclusive mouse operation, and a comprehensive
version of background mouse operation. At worst, only the XI2-enabled
X11 path would do anything except WndProc hook-based mouse warping, and
we'd just duplicate the existing code across all graphics drivers.

I'm blithely ignoring the fact that there's only one graphics driver
in-tree. ^_^

I'm attaching my DirectInput test program. It demonstrates both the
MSDN sample way of doing a background DI mouse reader, and also as it
happens a maybe-bug in Wine's DirectInput headers, in that you can't
use DIMOFS_X and similar as case labels.

It also demonstrates another problem with current Wine DI. If you put
its window up to the edge of the screen, and push your mouse against the
edge of the screen, your mouse movement against the edge of the screen
is lost.

I prolly should open bug reports for these other facets of DI that don't
work, but should, but I haven't checked to see if they have been
reported and just haven't had the exposure of the mouse-warping bug. I
was hoping that the one DI fix would take care of everything, I guess.

Paul "TBBle" Hampson, B.Sc, LPI, MCSE
Very-later-year Asian Studies student, ANU
The Boss, Bubblesworth Pty Ltd (ABN: 51 095 284 361)
Paul.Hampson at Pobox.com

Of course Pacman didn't influence us as kids. If it did,
we'd be running around in darkened rooms, popping pills and
listening to repetitive music.
 -- Kristian Wilson, Nintendo, Inc, 1989

License: http://creativecommons.org/licenses/by/2.5/au/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20090419/57475586/attachment.pgp>

More information about the wine-devel mailing list