Skip to contentSkip to conversation

joypad naming problems

DISCUSSION Ljubomir Simin 2 participants 2 messages Sep 23, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

I have problem with setting udev rules. After reading
http://reactivated.net/writing_udev_rules.html I've decided to ask here for help, as this mailing list is noticed under "support". Sorry if this is not suitable place for this.

I have dedicated gaming machine which is operated only with 2 joypads. I want to make sure that no matter when or where the joypads are plugged in, they always get the same device names. This is crucial for numerous emulators I've set, which thinks js0 = first joypad, js1 = second joypad, and so on. Most of them are not configurable enough to use custom device names (so I can not use symlinks).
Currently, joypads get names "input/js0" and "input/js1" at startup. However, when I unplug the first one, and plug it again, it becomes "input/js2" thus making most programs and emulators useless. So I want to "bound" it to input/js0. To achieve this I've created rules file:

mythtv@revstation:~$ cat /etc/udev/rules.d/10-local.rules
SYSFS{idVendor}="046d", SYSFS{idProduct}="0216", NAME="input/js0", 
MODE="666", SYMLINK+="js0"
SYSFS{idVendor}="06a3", SYSFS{idProduct}="0109", NAME="input/js1", 
MODE="666", SYMLINK+="js1"

(SYMLINK is there "just to be sure". The most important part is NAME)

However, it seems they're not enough. Before unplugging situation looks like this:

mythtv@revstation:~$ udevinfo -q all -n /dev/input/js0
P: /class/input/input1/js0
N: input/js0
mythtv@revstation:~$ udevtest /class/input/input1/js0 input
main: looking at device '/class/input/input1/js0' from subsystem 'input'
main: opened class_dev->name='js0'
udev_rules_get_name: rule applied, 'js0' becomes 'input/js0'
run_program: '/sbin/grepmap --udev'
run_program: '/sbin/grepmap' (stdout) 'evdev'
run_program: '/sbin/grepmap' (stdout) 'evbug'
run_program: '/sbin/grepmap' returned with status 0
match_rule: 1 untrusted character(s) replaced
create_node: creating device node '/dev/input/js0', major = '13', minor = '0', 
mode = '0660', uid = '0', gid = '46'

But after re-plugging the first joypad:

mythtv@revstation:~$ udevtest /class/input/input1/js0 input
main: looking at device '/class/input/input1/js0' from subsystem 'input'
main: sysfs_open_class_device_path failed
mythtv@revstation:~$  

It didn't get js0, it got js2 again:

mythtv@revstation:~$ udevinfo -q all -n /dev/input/js0
no record for 'input/js0' in database
mythtv@revstation:~$ udevinfo -q all -n /dev/input/js2
P: /class/input/input5/js2
N: input/js2
mythtv@revstation:~$ udevtest /class/input/input5/js2 input
main: looking at device '/class/input/input5/js2' from subsystem 'input'
main: opened class_dev->name='js2'
udev_rules_get_name: rule applied, 'js2' becomes 'input/js2'
run_program: '/sbin/grepmap --udev'
run_program: '/sbin/grepmap' (stdout) 'evdev'
run_program: '/sbin/grepmap' (stdout) 'evbug'
run_program: '/sbin/grepmap' returned with status 0
match_rule: 1 untrusted character(s) replaced
create_node: creating device node '/dev/input/js2', major = '13', minor = '2', 
mode = '0660', uid = '0', gid = '46'

I have this line in /etc/udev/rules.d/20-names.rules (provided by default with Ubuntu). Is it guilty? When I comment it out, input/js* files does not get created during startup, and no joysticks work.

mythtv@revstation:~$ cat /etc/udev/rules.d/20-names.rules |grep js
KERNEL="js[0-9]*",                     NAME="input/%k"

What is wrong with my setup? How can I force joysticks to always have same device names?

Best regards,

Signature · 13 lines
Ljubomir Simin 
Registered Linux User #351181
http://counter.li.org 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 18 lines · Ljubomir Simin

Hi,

I have problem with setting udev rules. After reading
http://reactivated.net/writing_udev_rules.html I've decided to ask here for help, as this mailing list is noticed under "support". Sorry if this is not suitable place for this.

I have dedicated gaming machine which is operated only with 2 joypads. I want to make sure that no matter when or where the joypads are plugged in, they always get the same device names. This is crucial for numerous emulators I've set, which thinks js0 = first joypad, js1 = second joypad, and so on. Most of them are not configurable enough to use custom device names (so I can not use symlinks).
Currently, joypads get names "input/js0" and "input/js1" at startup. However, when I unplug the first one, and plug it again, it becomes "input/js2" thus making most programs and emulators useless. So I want to "bound" it to input/js0. To achieve this I've created rules file:

Quoted 8 lines
mythtv@revstation:~$ cat /etc/udev/rules.d/10-local.rules
SYSFS{idVendor}="046d", SYSFS{idProduct}="0216", NAME="input/js0",
MODE="666", SYMLINK+="js0"
SYSFS{idVendor}="06a3", SYSFS{idProduct}="0109", NAME="input/js1",
MODE="666", SYMLINK+="js1"

(SYMLINK is there "just to be sure". The most important part is NAME)

Which version of udev? Which version of kernel?

Quoted 7 lines

However, it seems they're not enough. Before unplugging situation looks like this:

mythtv@revstation:~$ udevinfo -q all -n /dev/input/js0
P: /class/input/input1/js0
N: input/js0

please show

udevinfo -a -p /sys/class/input/input1/js0

Quoted 39 lines
mythtv@revstation:~$ udevtest /class/input/input1/js0 input
main: looking at device '/class/input/input1/js0' from subsystem 'input'
main: opened class_dev->name='js0'
udev_rules_get_name: rule applied, 'js0' becomes 'input/js0'
run_program: '/sbin/grepmap --udev'
run_program: '/sbin/grepmap' (stdout) 'evdev'
run_program: '/sbin/grepmap' (stdout) 'evbug'
run_program: '/sbin/grepmap' returned with status 0
match_rule: 1 untrusted character(s) replaced
create_node: creating device node '/dev/input/js0', major = '13', minor > '0', mode = '0660', uid = '0', gid = '46'

But after re-plugging the first joypad:

mythtv@revstation:~$ udevtest /class/input/input1/js0 input
main: looking at device '/class/input/input1/js0' from subsystem 'input'
main: sysfs_open_class_device_path failed
mythtv@revstation:~$

It didn't get js0, it got js2 again:

mythtv@revstation:~$ udevinfo -q all -n /dev/input/js0
no record for 'input/js0' in database
mythtv@revstation:~$ udevinfo -q all -n /dev/input/js2
P: /class/input/input5/js2
N: input/js2
mythtv@revstation:~$ udevtest /class/input/input5/js2 input
main: looking at device '/class/input/input5/js2' from subsystem 'input'
main: opened class_dev->name='js2'
udev_rules_get_name: rule applied, 'js2' becomes 'input/js2'
run_program: '/sbin/grepmap --udev'
run_program: '/sbin/grepmap' (stdout) 'evdev'
run_program: '/sbin/grepmap' (stdout) 'evbug'
run_program: '/sbin/grepmap' returned with status 0
match_rule: 1 untrusted character(s) replaced
create_node: creating device node '/dev/input/js2', major = '13', minor > '2', mode = '0660', uid = '0', gid = '46'
Quoted 4 lines

I have this line in /etc/udev/rules.d/20-names.rules (provided by default with Ubuntu). Is it guilty? When I comment it out, input/js* files does not get created during startup, and no joysticks work.

yes it will override your rule in any case; but atm your rule does not even kick in.

- -andrey

Quoted 9 lines
mythtv@revstation:~$ cat /etc/udev/rules.d/20-names.rules |grep js
KERNEL="js[0-9]*",                     NAME="input/%k"

What is wrong with my setup? How can I force joysticks to always have same device names?

Best regards,

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFFTlUR6LMutpd94wRApppAJ4wzwL63WvFXXAafKCuyCBl36GApQCdEi3w Y+wND37vpBq6X2h5ZNkjTak.s4
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel