Linux – “Merging” two input device drivers/nodes to one device node

driversinputlinux

Okay, I have two joysticks attached to my linux box and they show up as /dev/js0 and /dev/js1. My problem is, I have a third party application, (that I cannot change), that uses a joystick, and it can only listen to one node, (so only one joystick at a time).

I can determine which node the application will "listen" to, (e.g. /dev/js0), but I can only specify one node. This means I can determine which joystick the application will use, but that also means it can only use one joystick at a time. I have been tasked to come up with a way that this application can use both joysticks at the same time in an either/or scenario and not one or the other.

Is there a way to redirect the outputs of the two joystick nodes into a third node to which I could then point the application? Is there another way that comes to mind to somehow "merge" these two drivers/nodes into one?

I tried creating a new third node, (dev/js2) using mknod, but I couldn't figure out how to redirect the output of js0 and js1 to js2.

I'm also not opposed to doing this using a small program and udev, but I'm not sure how to go about it.

Best Answer

Quickly searching, it appears that there is a Linux Joystick Mapper on Sourceforge which claims to do what you want.

I believe it is built on top of uinput which is probably what you'll want to use if you have to build your own. There wrappers to that in various languages, so you won't necessarily have to work in C. Python appears to definitely by possible.

Related Question