XInput instead of raw devnodes

Hi all,

I’m working on a patch to Panda that would make working with multiple mice on Linux easier. Right now, Panda reads the /dev/input/event* devnodes directly in order to support multiple mice. There are two main problems with this:

  1. It requires this ugly hack on most distros I’ve seen, and even then, this poses a security risk.
  2. It only gives us “raw” values direct from the driver, untransformed by X.

My solution to this is to use the X extensions XInput (XI1) and XInput2 (XI2). XI1 has been around a long time and can be used to get the data from multiple mice. XI2 is very new (only added to Ubuntu 10.04), but allows us to listen for raw or transformed events.

I’ve created a Launchpad blueprint for this, and am writing up research and progress at my website.

I would be very interested to know what people think about this approach, especially if they think it to be a fool’s errand.

whatever you do. dropping raw input is a bad idea. for some kind of games you’d want higher accuracy than than a single screen pixel. if you can support multiple mice, without security leaks and provide raw and transformed input… go for it!

I do think that it will be worthwhile to support this. Maybe we can keep the old raw mouse interface for systems that don’t support XInput, but that would be a fallback.

ThomasEgi: XInput supports relative sub-pixel precision movement, while raw input doesn’t. So this actually sounds much more appealing.
Our current subpixel mouse movement support goes through the Xxf86dga extension, and I find it to be rather hackish.

Let me clarify: XInput2 supports both raw and transformed mouse data, from multiple sources; I am not dropping raw mode. Also, as rdb mentioned, XInput2 supports subpixel precision, so in theory you shouldn’t be losing any (significant) precision, even in transformed mode.

One thing I am concerned about is adding features that are not supported by all platforms. AFAIK, when using multiple mice in Windows, you must use raw values. So the ability to use untransformed data would not be available on Windows. I’m not sure about OS X or iPhone.

What’s the Panda3D philosophy on this? Do we provide the feature and put a big “Caveat Emptor: this feature is not available on Windows!” in the documentation and let devs decide whether they care or not, or just leave it out?[/b]
[/quote]

We generally try to wrap interfaces that vary considerably between platforms in a new API that presents a more consistent interface.

This has its own set of drawbacks, of course; one is that you need to keep your new API up-to-date with useful and desired features.

One of our plans is to replace the current mouselook mechanism with a higher-level API that implements mouselook, and/or reads raw data from devices, appropriately for each platform. When this is done, issues like the low-level support for mouse handling may be less important.

David