Monday, May 24, 2010

Getting serial mice to work on Ubuntu

Serial mice have not worked on Linux for a very long while now. Mainly, it's due to the fact that serial devices do not support querying of capabilities. Linux has been steadily moving towards more dynamic hardware detection to basically eliminate error prone manual hardware configuration. There's also the scenario of moving hard disks between different hardware setups or changing of hardware due to upgrades to consider.

I do find Ubuntu's LiveUSB useful at work as a part of my personal toolbox. Nothing like a nice clean environment to run a Linux-based antivirus scan, or rescue data from a unbootable system. Unfortunately, that also means I sometimes end up with using a serial mouse and that's rather inconvenient.

To get things running, you'll need to use mdetect and inputattach from terminal. First, install mdetect if it's not already available, then run it to get some info on your mouse:

~$ sudo apt-get install mdetect
~$ sudo mdetect

You should get something like the following:


/dev/psaux seems to be a legacy PS/2 device and is irrelevant here. The second line basically tells us the driver we need to activate the serial mouse.

Simply use inputattach to tell what mouse driver to use for the mouse attached to the serial port:

~$ sudo inputattach --daemon --intellimouse /dev/ttyS0

/dev/ttyS0 is the first serial port (COM1). You may need to replace 0 with 1 (COM2) depending on your hardware.

To get a list of drivers supported by inputattach, run:

~$ inputattach --help

Making the activation permanent

If you're running from a LiveCD or LiveUSB with no persistence then there's not much you can do about running inputattach on every boot to get your serial mouse working unless you remaster the LiveCD. That's quite beyond the scope of this post.

For an installed environment however, you can add the inputattach command to /etc/rc.local so that the mouse gets activated on every system boot. Open /etc/rc.local with,

~$ sudo gedit /etc/rc.local

and add inputattach --intellimouse /dev/ttyS0 (change --intellimouse and /dev/ttyS0 accordingly) above the line that says exit 0 to make it work. Be sure to save the changes.


Serial Mouse Howto