Serial input device to kernel input

From ArchWiki

Although USB is the most popular way to connect input devices such as mice, serial input devices, such as older mice, and more exotic input devices such as 3Dconnexion Spaceballs are still quite usable, either with a serial port built into the computer, or via a USB to serial converter dongle.

The traditional way to support these serially attached input devices was to configure each application with the details such as which serial port the input device was attached to and what protocol the device used. As the most common application people used with a serial input device was / XFree86, this was not too much of a problem. However, if you used a variety of applications that needed to talk to the serial input device directly, you may encounter limitations to which serial input device or protocol each application supported. Some applications may not have supported a serial input device you would have preferred to use.

A better approach is to have the Linux kernel input subsystem manage the serially attached input device, and then present the input signals the device generates in the same way that USB and PS/2 input device signals are presented to applications, via the /dev/input/device files.

This guide describes the simple steps necessary to "attach" a serial input device to the Linux kernel input subsystem.


Install the linuxconsole package: the inputattach utility tells the kernel input subsystem which serial port the input device is attached to, and what type of device is attached to the specified serial port.


Once installed, view the inputattach --help, to see the large list of serial input devices the Linux kernel input subsystem supports.

For example, if you have a Logitech TrackMan Marble serial mouse you would specify --mouseman/-mman.

The default configuration file assumes a Microsoft serial mouse, and assumes the mouse is attached to the first serial port of the computer. The 'IAPARAMS' variable is an array of inputattach arguments. An inputattach instance will be started for each element. See inputattach --help for details on arguments.

Here is an example configuration, modified to suit a Logitech TrackMan Marble serial mouse:

# Configuration for inputattach
# IAPARAMS is an array of inputattach arguments, see 'inputattach --help'.
# An inputattach instance will be started for each element.

  "--mouseman /dev/ttyS0"


Start inputattach.service.

If you happen to be within Xorg when you do this, and have an InputDevice mouse section that specifies /dev/input/mice as the input device file, your new input device is likely to now be another source for Xorg mouse pointer movements, in addition to other input devices e.g., a USB mouse.

Another way to confirm that it worked is to check your system's kernel log using the dmesg utility. For a Logitech TrackMan Marble serial mouse, the kernel output is:

serio: Serial port ttyS0
input: Logitech M+ Mouse as /class/input/input6

To have your serial input device work every time you boot, enable inputattach.service.