# Setting joystick order through udev (or anything else...)

## nitro322

I have a weird problem with joysticks on my computer - I have several that I use at different times and for different games, and depending on what's plugged in a boot time they'll get detected in a different order.  Even my multimedia keyboard gets a js device assigned to it for some reason, which further screws up the ordering of the other devices.

In the past, I used some admittedly hackey udev rules to fix this.  Specifically:

```
$ cat /etc/udev/rules.d/99-custom.rules 

# Set joystick devices to be owned by games group

KERNEL=="js*", SUBSYSTEM=="input", MODE="660", GROUP="games"

# Set force-feedback devices to be owned by games group

KERNEL=="event*", SUBSYSTEM=="input", MODE="660", GROUP="games"

# Set joystick device priority

KERNEL=="js*", SUBSYSTEM=="input", ATTRS{name}=="Logitech Logitech Extreme 3D", NAME="input/js0"

KERNEL=="js*", SUBSYSTEM=="input", ATTRS{name}=="Logitech WingMan Cordless Gamepad", NAME="input/js1"

KERNEL=="js*", SUBSYSTEM=="input", ATTRS{name}=="Logitech Logitech USB Keyboard", NAME="input/js9
```

The first couple of lines is to make sure the devices are usable by my user account.  The last set is where the magic (used to) happen: it remaps my joystick to always be js0, my gamepad to always be js1, my keyboard that I really don't care about from a joystick perspective to always be js9, just to get it out the way, etc.  Have a couple more in there for js2, etc., but I left them out for brevity.

However, since the udev-197 upgrade this no longer works.  I can't find any error or warning messages in my logs, and the GROUP/MODE setting stuff does still work fine, so as far as I can tell this should still be valid, but nothing happens.  My keyboard is now assigned js1, and my gamepad js2.  I did verify that the device names haven't changed, and they have not.

Anyone know how I can make this work again?  Is there some special new magic I need for udev-197?

Alternatively, is there any way to accomplish the same thing without relying to udev?  That'd be fine as well, but I spent quite a while looking into this a couple years ago and udev was the only real option I could find.

Would greatly appreciate any pointers.  Thanks.

----------

## PaulBredbury

Don't redefine js[0-9]*. It's the same with eth0 and eth1 that the Internet is filled with moans about  :Wink: 

Use meaningful names, via SYMLINK+= or NAME:=

E.g. in /etc/udev/rules.d/10-local.rules

```
KERNEL=="js[0-9]*", SUBSYSTEM=="input", ATTRS{name}=="Logitech Logitech Extreme 3D", NAME:="input/js-extreme"
```

That "10" in the filename is important, so that the NAME gets assigned here first, and is tagged as unchangeable using ":".

----------

## nitro322

Hi, Paul.  Thanks for the reply.  Sorry this is coming back so late, but I somehow managed to miss your reply (which is a shame, because this has become even more of a nuisance in the past month).

I tried your suggestion (even copy/pasting your example below to ensure I wasn't mistyping), but unfortunately I'm still not able to rename any of the devices.  I get the same behavior - udev just complete ignores my settings now.  I also did moved the joystick stuff to 10-local.rules as you suggested.

I did some more searching a few weeks ago and stumbled across an alternate way of identifying devices.  Instead of:

KERNEL=="js[0-9]*", SUBSYSTEM=="input", ATTRS{name}=="Logitech Logitech Extreme 3D", NAME:="input/js-extreme"

I can supposedly use:

KERNEL=="js[p-9]*", ENV{ID_VENDOR}=="Logitech", ENV{ID_MODEL}=="Logitech_Extreme_3D", NAME:="input/js-joystick"

Again, though, I get no luck with that.

Do you have any other ideas?  or am I (hopefully) just doing something obviously wrong?

Also, related, do you have any suggestions on how to usefully debug udev?  I did some searching on this, but all I could find here was:

1. Setting udev_log="debug" in /etc/udev/udev.conf, but that seems to have no effect at all.

2. Setting udev_monitor="yes" in /etc/conf.d/udev, but that doesn't seem to provide any useful info.  It has a couple things about input, but nothing at all related to my joystick devices that I can find.

3. Setting udev_debug="yes" in the same file, but that's entirely useless.  only showing this:

```
$ cat /run/udevdebug.log 

error: /dev/sde: No medium found

error: /dev/sdf: No medium found

error: /dev/sdg: No medium found

<SNIP>
```

and repeating a few times.

Is there some way to tell why udev is rejecting or ignoring or just simply not seeing my joystick rules?  Would greatly appreciate any further guidance you can provide.

Thanks.

----------

## PaulBredbury

 *nitro322 wrote:*   

> [p-9]

 

Should be 0-9, without a p  :Laughing: 

Get some info to create a udev matching rule with:

```
udevadm info -a --name /dev/js0
```

For udev debugging - to turn on and back off (although I doubt you'll want/need it):

```
udevadm control --log-priority=debug

udevadm control --log-priority=err
```

----------

