• Alexios
  • coding
  • linux
  • c
  • mature
  • released

For a few years, back in simpler times, I used Jon Atkins' imwheelto get X11 to understand the many buttons on my old Primax mouse. Traditionally, X11 only allowed for up to six buttons, and mine had eight (two were used for wheel events, as always). Imwheel allowed me to translate the buttons X11 didn't know about to key events (but not before I hacked it a bit).

Unfortunately, my input devices seem to have outgrown imwheel. I now have a Logitech USB keyboard and USB mouse, both with extra buttons, wheels, knobs et cetera. None of them would work with X11 out of the box, and many weren't even detected.

This is where evrouter comes in useful. It performes the following following closely allied tasks:

  • It makes X11 aware of input devices and events it doesn't support, for one reason or another. For example, thanks to the wonders of USB HID descriptors, the wheel on my Logitech keyboard is completely ignored by X11, even though the Linux kernel reads and parses its events just fine.

  • It allows modern input events to be fed to old applications. Pine, for instance, knows nothing about wheels.

  • It allows hotkey-like operation. This is very useful for the special keys on multimedia keyboards.

  • It can act differently depending on the currently focused window.

As of 2008 and 2009, many of these tasks are obsolete, but old software and old input devices are still around, and evrouter can make your input devices do things programmers of device drivers and application software never intended (or, in some cases, never had enough imagination to anticipate).

All this is accomplished thanks to the Linux 2.4 (and above) Event Interface (CONFIG_INPUT_EVDEV), which currently evrouter depends on. The program parses input events, uses a user-specified ruleset to transform them to other events based on various conditions, and acts on them. Currently, evrouter can perform the following actions:

  • It can simulate X11 key events.
  • It can simulate X11 mouse button events.
  • It can control XMMS (note: binaries for version 0.3.4 have this feature disabled).
  • It can run shell commands (which should perform nearly every other task conceivable).

What's New?

Version 0.4: I've incorporated a patch found on this page that adds support for SW (switch) events.

Version 0.3.4: I've finally found the time to fix an annoying bug whereby removing a USB device evrouter was watching would cause the program to die with a Segmentation Fault.

Known Issues

If you have Ubuntu's Intrepid Ibex distribution, evrouter won't work. Nothing else which accesses event devices will, either — as long as you're running an X server. The X server acquires exclusive access to the event devices, precluding any other process from using them concurrently. I'm working on this one (in a way, I've been working on this one for a while. A couple of the enhancements I've been thinking about could fix this issue). You may want to peruse Ubuntu support tickets 298963 and 267682.

Many thanks to Dominik Ałaszewski for the heads-up and the links.

Download

The tool is available as source, Debian and RPM packages. It's provided under the terms of the GNU General Public License, version 2.