Raw mouse input on X11/Linux

Started by
3 comments, last by Sik_the_hedgehog 9 years, 7 months ago

I need raw mouse movements (delta x,y) from the mouse on X11. I have Xinput2 working, except it stops sending events whenever a mouse button is down. From my understanding, this has to do with implied window grabbing. Is there a way around this? (The WarpMouse trick won't work here.)

Advertisement

I'm not a Linux developer, but I do know that windows in X11 have attributes, so I searched for "xwindow attributes", and found this: http://tronche.com/gui/x/xlib/window/attributes/override-redirect.html . Of course, if you are using a library (maybe SDL), it should've (probably?) already applied the correct window attributes for you.

Raw mouse input in Linux on SDL2 is not working properly though as far as I know. Could be wrong though, but it was one of the sticking points in the mailing list some time ago.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Yes, this can be made to work. Make sure you have the correct events selected.

A complete working example can be found here: OpenTK/Platform/X11/XI2MouseKeyboard.cs. This has been tested and is working on both X.org and XQuartz.

The source code is in C#, but most of it should be trivial to port to C or C++. Feel free to ask if you have any questions.

Edit: raw input has been pulled from SDL2 for some reason, which is rather unfortunate. You can only use regular input events (single mouse with pointer acceleration etc.)

Edit 2: do not use WarpMouse unless you really hate your users. That was necessary back in the core X11 days, due to the lack of relative motion events, but this is no longer necessary with XInput2. Do note that some devices, such as the VMware mouse driver, do not report relative motion events. Actual mice do not have this problem.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]


Edit: raw input has been pulled from SDL2 for some reason, which is rather unfortunate. You can only use regular input events (single mouse with pointer acceleration etc.)

It was never working properly in the first place. In fact I think only in OSX it ever worked properly.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

This topic is closed to new replies.

Advertisement