Assigning a Mouse to a Specific Device Node
-
A few years ago I was trying to set up my control panel so I could use both the spinner and the trackball. I don't mean to use them both for the same game or at the same time. I finally got it worked out and it worked fine for years. That was on a Pi3 and I recently set up RetroPie on a Pi4. The one problem I've had is that I'm using the same configuration files and I don't have both devices (spinner and trackball) working.
I finally got both devices recognized on this thread about multiple mice being supported. I know it's a long thread, so a quick summary will help.
Summary: I couldn't get both devices recognized at the same time and the issue was that when I specified the index number in RGUI for the device, I was using the index number for /dev/input/mouseX, where X was 0 or 1. It turned out that the index number refers to /dev/input/eventY, where Y could be a larger range than 0 or 1. (On my older Pi3 system, Y can be from 0 to 5.) I used cat
/dev/input/mouseX
orcat /dev/input/eventY
to read the input from the devices and to figure out what device node was linked to which physical device.There are two problems, one on the Pi3, and it's an issue I'd like to resolve so I don't run into it with the setup on the Pi4, where I'm still working this out.
Problem: My RetroPie system is in an arcade cabinet and the control panel has 2 USB connectors that plug into my Pi. I also have a keyboard attached, but no mouse. I found I had to use a specific order for the plugs. I had my USB memory stick in the first USB slot on the Pi3 and the remaining 3 wires (keyboard, and 2 for the control panel) had to be inserted in a specific order, otherwise it would change what device /dev/input/eventY would point to.
Desired Outcome: It would be really nice if I could make this work without having to keep the USB devices in order.
Possible Solution: (Well, part of a possible solution?) I learned, while using OctoPrint for controlling 2 3D printers from one Raspberry Pi, how to use udev to detect a specific USB device and to create a device node for that device. (For instance, the USB node for my Prusa printer was /dev/prusa01, created on boot by udev.) The problem with this is that, in RGUI, I see I specify the device by just using an index, which is the number added on to /dev/input/event. Is there some way I can point the configuration info to a distinct device node (such as /dev/input/spinner) instead of /dev/input/eventX?
That would be a help, since it would mean the devices did not all have to go into a specific USB jack and whatever order I (or a friend - since friends use this system) put the jacks in, I could still point to that one device node in the configuration file.
-
Re-linking the device under
/dev
to a different name will not help in your case, since RetroArch will enumerate the devices withevent
only.Since all your devices are USB, try something like usbreset. Run it in the desired order to reset the devices you'd like re-ordered and see if it helps - you should do that on start-up/reboot only, since you have the devices always connected.
-
@mitu said in Assigning a Mouse to a Specific Device Node:
Re-linking the device under
/dev
to a different name will not help in your case, since RetroArch will enumerate the devices withevent
only.And, of course, I just found a new complication. I'm comparing my setup on a Pi3 with the new Pi4 and I'm using
cat /dev/input/eventX
to look for which node is linked to the spinner and the trackball. And I'm finding that they are /dev/input/mouse0 and /dev/input/mouse1, but mouse0 does NOT have it's own /dev/input/eventX node. It does show input on event0, but so does every input device, all the buttons, both spinner and trackball, and the keyboard. But mouse0 does not have a corresponding eventX node. It's going to take some time to figure out just what's going on with that.Do the event nodes provide the same data as the mouse nodes? If so, and it's been a while since I've worked at this level, but if so, I would think there's a way to create a new node that's an alias or link to the mouse node.
Since all your devices are USB, try something like usbreset. Run it in the desired order to reset the devices you'd like re-ordered and see if it helps - you should do that on start-up/reboot only, since you have the devices always connected.
Reading info on resetusb now. I'm also thinking that I could use that or udev to set the nodes to the highest index number I can use, such as /dev/input/event98 and /dev/input/event99. Do you know if the search terms in resetusb work the same as the terms when setting up rules for udev?
-
@Tango said in Assigning a Mouse to a Specific Device Node:
Reading info on resetusb now. I'm also thinking that I could use that or udev to set the nodes to the highest index number I can use, such as /dev/input/event98 and /dev/input/event99. Do you know if the search terms in resetusb work the same as the terms when setting up rules for udev?
You can't rename an device node with
udev
rules AFAIK. -
I did find something else - just after I made my last post.
cat /dev/input/event0
does show the input for the spinner, but it also shows input from my keyboard, and all the joysticks and buttons on my control panel. And when I checked just what showed up withcat /dev/input/event7
, it did show the input from the trackball, but, again, showed input from my keyboard, the joysticks, and all the buttons on my control panel.My older and working Pi3 system is down now and I'll have to take it down to the barn and plug in the USB connectors again to see if the extra input data (from the keyboard and all the controllers) showed up on the eventX nodes. Shouldn't the node be showing data from only one device when I use
cat
to read what's coming in on a device node? Or is the input from all the other hardware normal?@mitu said in Assigning a Mouse to a Specific Device Node:
You can't rename an device node with udev rules AFAIK.
I may be mis-remembering and I may have used it to create links, not a renamed or replaced node path. I know, when I was using OctoPrint on a Pi4, I had 2 instances of it, one controlling a Prusa printer and one controlling an Ender 3 Pro. For convenience and due to my forgetfulness, I had the devices
/dev/prusa00
and/dev/e3p00
setup (via the udev rules) so I could easily remember what node to use in each instance of OctoPrint on that system. It came in handy when I had to turn printers off or make adjustments and have to reconnect and wasn't sure what node each one normally used. (For instance, one printer might use/dev/ttyACM0
normally, but I could never remember that for sure (I might have the wrong node path right there). But I could remember the nodes I made easily and quickly.So that might work - I can probably find key terms in the info for the devices and, if those nodes I created were basically symlinks, then I can set up nodes to something like,
/dev/event98
for the spinner and/dev/event99
for the trackball - whether that's creating nodes ore aliases I can use. It would give me consistent paths to use so even if the USB plugs are not in order, the index numbers would always be right. -
@Tango said in Assigning a Mouse to a Specific Device Node:
So that might work - I can probably find key terms in the info for the devices and, if those nodes I created were basically symlinks, then I can set up nodes to something like, /dev/event98 for the spinner and /dev/event99 for the trackball - whether that's creating nodes ore aliases I can use. It would give me consistent paths to use so even if the USB plugs are not in order, the index numbers would always be right.
It would work, but you'd have to bump the indices with +2, since the original nodes would still be queried/found by RetroArch.
-
@mitu said in Assigning a Mouse to a Specific Device Node:
It would work, but you'd have to bump the indices with +2, since the original nodes would still be queried/found by RetroArch.
I'm not clear what you mean by that. Bump the indices as in
/dev/input/event97
and/dev/input/event99
for the link/alias nodes I create?And if RetroArch finds them, does that matter if I specify, in the config file (edited using RGUI - that's what I was using a few years ago? Would it just look at the indices I specify in the config file and ignore the other nodes it finds?
-
@Tango said in Assigning a Mouse to a Specific Device Node:
I'm not clear what you mean by that. Bump the indices as in /dev/input/event97 and /dev/input/event99 for the link/alias nodes I create?
If you're using
udev
rules to create additional (symlinked) inodes with a certain name, then you'd have the following situation:- system creates
event0
, you determine that you want it symlinked toevent51
- system creates 2nd node
event1
, you determine you that you want it symlinked toevent52
.
Now, you've ordered the nodes
event50
andevent51
as you wished, but RetroArch will still findevent0
andevent1
. Since you're configuring - in RetroArch - theevent
nodes you created with the rules, the confgured indices in RetroArch will be 2 and 3, instead of 0 and 1. That's what I mean by 'bumping the indices`.And if RetroArch finds them, does that matter if I specify, in the config file (edited using RGUI - that's what I was using a few years ago? Would it just look at the indices I specify in the config file and ignore the other nodes it finds?
I don't understand what you mean here. You specify the index in the configuration file, just like before, if the device exists then RetroArch will use it.
- system creates
-
I'm missing something here that I'm sure is quite obvious - but let me clarify one other point first: I found that
cat /dev/input/event0
showed data whenever I pushed any buttons, moved any control joysticks, and typed any keys on the keyboard, but also it was the only eventX node that showed data for the spinner. Is that normal - for the event node for a mouse to show other data?@mitu said in Assigning a Mouse to a Specific Device Node:
@Tango said in Assigning a Mouse to a Specific Device Node:
I'm not clear what you mean by that. Bump the indices as in /dev/input/event97 and /dev/input/event99 for the link/alias nodes I create?
If you're using
udev
rules to create additional (symlinked) inodes with a certain name, then you'd have the following situation:- system creates
event0
, you determine that you want it symlinked toevent51
- system creates 2nd node
event1
, you determine you that you want it symlinked toevent52
.
Now, you've ordered the nodes
event50
andevent51
as you wished, but RetroArch will still findevent0
andevent1
. Since you're configuring - in RetroArch - theevent
nodes you created with the rules, the confgured indices in RetroArch will be 2 and 3, instead of 0 and 1. That's what I mean by 'bumping the indices`.I can see this in two different ways and it's not your fault - I tend to see things from angles that don't always make sense to others. I think, though, this is the way that makes the most sense. Is this correct:
Right now the mouse event nodes are event0 and event7. Then I use udev to create nodes event50 and event51. Does RetroArch read that and see 4 mouse event devices? So it would be indexed like this?
RetroArch 0 ->
event0
RetroArch 1 ->event7
RetroArch 2 ->event50
RetroArch 3 ->event 51
Is that correct?
And, if that's the case, and udev is able to distinguish between the spinner and the trackball, so if the USB cables get swapped, I can use rules to make sure the spinner is always
event50
, even though it'sevent50
, RetroArch would always see it as index 3 because it's what RetroArch sees as mouse #3? - system creates
-
Any chance I'm interpreting this correctly? I want to be sure I know just how it's all working so I can configure and troubleshoot this to use specific node paths.
-
Feel free to experiment and report back your findings.
-
@mitu said in Assigning a Mouse to a Specific Device Node:
Feel free to experiment and report back your findings.
I'm trying to find out the systems normal behavior and trying to make sure I understand what you were saying - I'm not clear what you mean by "bump the indices." I do get that you've explained it, but I'm still not clear and I provided an example. I can experiment, but that will mean spending a few days working it out and, since it's a known behavior, I was hoping to start with a baseline.
So if I have my dev nodes as I asked about above:
/dev/input/event0
/dev/input/event1But I'm finding those get switched if the USB plugs are switched, so I use udev to always create:
/dev/input/event50
/dev/input/event51Then if I want to use event50, do I set the index in RetroArch to 50? Does RetroArch use the index numbers on the nodes, or does it just count the nodes and start at 0 and increment by 1 for each new node, in spite of whatever the index number on the node name is?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.