Uncategorized

Handy joystick udev rules

To make a long story short, I haven’t blogged for ages, and the best way to resume any activity is, well… actually doing it.

Lately, I’ve been doing some experiments on my personal laptop, aiming to make it a good entertainment center, running on free software only. At an appropriate time, I will discuss how I’m proceeding in more depth.

For now, it’s enough to know that I’ve bought some cheap USB joysticks to play some games on this ‘entertainment center’ and, as allways, ended up doing some manual tweaks on the default settings on my GNU/Linux system.

Several games have the bad habit of assuming device paths under the filesystem hierarchy /dev/js*, while on any recent Ubuntu Linux version the udev rules will create the joystick device under /dev/input/js*. While I totally agree with that it’s better to have the joystick devices under /dev/input folder, it was not really good (for my own mental health) having to setup symbolic links manually. So I’ve done the usual udev man page reading and that was enough to solve the problem.

udev is the linux kernel device manager, it allows people to define persistant device names, as well as symbolic link names, triggering programs when a given device is loaded and a number of other interesting features. It’s not really the purpose of this post to give an in depth explanation of udev and unix device files. The bottom line is that udev allows you to define rules about what we are going to do with a given device when the correct module is loaded. Those rules are organized under the /etc/udev/rules.d/ directory. Those rules are applied orderly according with the 2 first numbers of the correspondent rules file.

The rules for persistent input on an ubuntu linux system are under /etc/udev/rules.d/60-persistent-input.rules, then I planned on adding a new rule that should be applied after this set of rules to create symbolic links. I just had to create an /etc/udev/rules.d/61-joystick-symlinks.rules (or any other name that pleases you except that the 1st 2 numbers should be > 60), with the following contents:

# Old emulators have this habit to hardcode references to /dev/js* instead of
# /dev/input/js*. This sucks, hence this rule was put in here.
KERNEL==”js*”, SYMLINK+=”js%n”

This solved the problem, and now my emulator activities are much more plug and play than before 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s