• Advertisement
Sign in to follow this  

Raw mouse input on X11/Linux

This topic is 1315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.)

Share this post


Link to post
Share on other sites
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.

Edited by tonemgub

Share this post


Link to post
Share on other sites

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.

Edited by Fiddler

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement