Use XInput(2) for multiple mouse input, not devnodes

Registered by Nick Irvine

Currently, Panda3D requires raw access to /dev/input/event* nodes, and as these usually require root-level access, numerous hacks are proposed to get around the restriction. The XInput and XInput2 X extensions provide the ability to receive motion, button, key, etc. events from individual devices (not just the core/master devices). So it should be possible to drop the devbide reading and use X calls instead. XInput2 (over XInput1) gives us several additional possibilities, like getting untransformed values straight from the kernel driver (actual raw mode).

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
Discussion
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

<update>
 I will post a link here to the forums as ~rdb suggested when I make the post :)

After doing some more research, I realize my understanding of the concepts involved are a little flawed. Following is an overview:

XInput1 (XI1, the one that's been around for a decade) *does* allow us to read from multiple devices (including keyboards, in fact) independent of one another.

But XInput2 (XI2) adds these new features relevant to Panda on top of XI1, in addition to a bunch of API/ABI/protocol facelifts:
* Multiple "core" input devices. These are now called "master"/"virtual" devices , and there can be many of them. These are controlled independently by "slave"/"physical" devices, which are attached to a given master. *This* new ability is also called "MultiPointer X" (MPX).
* Subpixel coordinates.
* Raw (untransformed) data events.

Thus, while using XI2 would give us a few more features, even just using XI1 would give us better multiple mouse support.

There are a few pitfalls that we have to watch out for. See the specification for details.
</update>

I'd (~nfirvine) like to take a crack at implementing this, if I may. I'm not sure if it's entirely feasible or necessarily a better solution than raw reads of the devnodes, but I'd like to investigate.

Very intriguing! I (~rdb) hadn't heard of it before. It looks like this supports relative mouse mode, even, which we currently only support through the Xf86dga extension, and our implementation of it is a bit hacky.
There is a blueprint filed to create a better, universal mouse system. I'm not 100% sure if effort to integrate MPX/XInput2 will conflict with that. For Panda3D 2.0, it is very likely that we will do some redesign to the way that mouse input is handled. A bit of care is required when implementing this, so that any effort here won't be obsoleted later. Maybe it's a good idea to create a thread in the "Panda Features in Development" forum where a design can be discussed.
Do note, though, that we only require access to /dev/input/event* when raw mouse is requested, Panda3D can even be compiled without that code. But I do think that this is certainly worth investigation.
Thanks very much for looking into this!

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.