XWarpPointer breaks raw mouse input.
Peter Hutterer
peter.hutterer at who-t.net
Thu Sep 9 16:00:13 PDT 2010
On Mon, Sep 06, 2010 at 06:52:09PM +0300, Mad Fish The One wrote:
> I'm writing a game, and I want raw mouse input to control camera (so no
> additional acceleration by X server) and don't want mouse to escape the
> window (for obvious reasons).
> I'm using XI_RawMotion events for raw mouse input, and XWarpPointer to not
> allow mouse escape the window.
> Well, the problem is, when XWarpPointer is called, XI_RawMotion is posted
> with coordinates of XWarpPointer's target point in screen coordinates. But
> it shouldn't - isn't it RAW input?
> How to do it right?
WarpPointer must generate normal motion events, that's a core protocol spec
requirement and labeled so in the XI2 specs as well.
we don't need raw events though.
A quick peek at the code seems we need something like a POINTER_WARP or
POINTER_NO_RAW flag to be passed into GPE to skip the creation of raw
events. that should be enough.
patches welcome of course. don't hold your breath that I'll get to
implementing it myself anytime soon, sorry.
> Minimal test case: http://pastebin.com/WFJULnYk
> (captures RawMotion events, and sends XWarpPointer sometimes).
> Compile as: "gcc warptest.c -o warptest -lX11 -lXi"
> You will see a series of normal events, and then a strange event generated
> by XWarpPointer.
>
> Anyway, is there a better method of containing pointer in a window without
> breaking Alt+Tab (that's what XGrabPointer does)?
no, there unfortunately isn't yet.
if you're not using the cursor itself because you're e.g. rendering your own
or it's not needed by the application, you can grab the slave devices
directly and detach them. in that case you don't have to worry about warp
pointer at all.
Cheers,
Peter
> Can you also recommend some general best practices with X input for games?
>
> P.S. Currently using X server 1.8.2 on Arch Linux.
More information about the xorg-devel
mailing list