Linux usb game controllers changing order after reboot
#1
Using XBMCbuntu Eden...

I wasn't sure whether this would be better suited to the xbmc forums or an emulator forum, but considering I've got an account here, I figured I'd try here first.

I am using advanced launcher to launch emulators. In the past, I had an arcade stick plugged into a usb port for use with MAME. I would then unplug it and plug in my N64 controller for use with an N64 emulator, reboot, and open the emulator. This would work fine, because the controller was always detected as the same number, but was a pain because of having to swap usb plugs and reboot.

I have several emulators and their respective controllers, so I wanted to simplify it by plugging in a usb hub and set up each emulator separately to use the right controller. This worked fine when I set it up, and I could switch back and forth between emulators and play with the right controller. The problem is that when I reboot, the usb devices on the hub seem to be randomly detected, and end up with different device numbers from what they were when I configured the emulators.

For example, when I first booted up after plugging in all the controllers, the arcade stick was detected as JOY5 and JOY6, so I went through and configured every button for players 1 and 2 to use JOY5 and JOY6 buttons, respectively. Then, after a reboot, the arcade sticks are now JOY3 and JOY4, so my configuration no longer works.

I'm just wondering if there's a way to force the devices to be detected in a particular order, or if there's something similar to fstab (I mount my drives using their UUID so that they are always mounted at the correct directories) that I could edit to force it to use the right controllers.

Any advice would be much appreciated. Smile Thanks
Reply
#2
udev rules can do what you want
Reply
#3
A common issue oft seen with USB tuners, which also confuse everything if they keep moving about.

As wsnipex says - udev. Have a look at this for a tuner example and tutorial... it should get you going:

http://www.mythtv.org/wiki/Device_Filenames_and_udev

I'd also look into the adapter_nr method as the easier method. I've no idea if it applies to game controllers, but it's worth 10 minutes to investigate it.
Reply
#4
Thanks to both of you. It looks like you are right that udev is what I need, but I'm having a hard time setting it up. I'll keep trying and post back if I can't get it sorted. Cheers Smile
Reply
#5
Update:

This worked fine for my arcade sticks, which are each on a separate usb inputs, and hence have unique identifying information. It took me a while to work out which attributes are static and which are not, but what I ended up with was

Code:
#Arcade Stick
KERNEL=="js?",ATTRS{name}=="DragonRise Inc.   Generic   USB  Joystick  ",ATTRS{phys}=="usb-0000:00:1d.0-2.1/input0",NAME="input/js0"
KERNEL=="js?",ATTRS{name}=="DragonRise Inc.   Generic   USB  Joystick  ",ATTRS{phys}=="usb-0000:00:1d.0-2.4/input0",NAME="input/js1"


#N64
KERNEL=="js?",ATTRS{name}=="HuiJia USB GamePad",ATTRS{phys}=="usb-0000:00:1d.0-2.2/input0", NAME="input/js2"
KERNEL=="js?",ATTRS{name}=="HuiJia USB GamePad",ATTRS{phys}=="usb-0000:00:1d.0-2.2/input0", NAME="input/js3"

#PS2
KERNEL=="js?",ATTRS{name}=="Twin USB Joystick",ATTRS{phys}=="usb-0000:00:1d.0-2.3/input0", NAME="input/js4"
KERNEL=="js?",ATTRS{name}=="Twin USB Joystick",ATTRS{phys}=="usb-0000:00:1d.0-2.3/input0", NAME="input/js5"

The ATTRS{phys} seems to be static (though obviously it would change if I swap ports, but it's the only way I can see to differentiate between the arcade controllers). The problem for the other four controllers is that ATTRS{phys} is the same for both controllers on each input (because it's a dual controller adapter on a single usb input). Every detail in udevadm output is identical for these except for "KERNEL" in the first block and "KERNELS" in the first parent block. Because both of these values change depending on what order the devices are detected in, I can't use those for matching.

Strangely, I tried to find udev rules written for my dual controller adapters, and I found this (the one detected as "HuiJia USB GamePad" is the mayflash controller):
http://raopinion.wordpress.com/2012/01/2...r-adapter/
which doesn't explain how to do what I need to do, but it makes a comment that both controllers will be detected as js0, because they are one usb device. But on my system, both dual adapters are detected twice, and each instance seems to correspond to the respective game controllers.

So to get to the point, the above code in my udev rules only works for the arcade sticks and not the other four controllers. I didn't expect the above code to work completely because of the ambiguity, but thought it might at least set js2 and js4. I also tried the environment variable method in the link provided by Prof Yaffle, but that didn't seem to work. The second example of how to resolve this ambiguity is not given with a lot of explanation, and I wasn't sure how to adapt it to my current situation. Anyone have any ideas about how to solve this Smile Cheers
Reply

Logout Mark Read Team Forum Stats Members Help
usb game controllers changing order after reboot0