Serial mouse

From Alpine Linux

Introduction

A mouse connected to the serial port will not be recognized by an Xorg server automatically. In /var/log/Xorg.0.log there may be a message:

(II) The server relies on udev to provide the list of input devices.
If no devices become available, reconfigure udev or disable AutoAddDevices.

We will describe two ways of getting an usable serial mouse under X.org. In our example we have a Logitech serial mouse of the model M/N: M-M30 associated to the device /dev/ttyS0.

Getting information about the mouse

If the protocol for the serial mouse is unkown, the command

mouse-test /dev/ttyS0

from the package gpm can be used to get the necessary information. The program is interactive and will print at the end a message like:

Your mouse seems to be a 'mman' one  on "/dev/ttyS0" (24 matches)

The man page gpm-types contain a list of the protocols. In our case the lines

       mman Mouseman
              The  protocol  used  by the new Logitech devices with three but-
              tons.  It is backward compatible with the Microsoft protocol, so
              if  your mouse has three buttons and works with -t ms or similar
              decoders you may try -t mman instead to use the  middle  button.
              This  mouse  decoder  accepts  standard serial options, although
              they should not be needed.

gives us more information about the protocol. We can test the mouse in a virtual console by running:

gpm -m /dev/ttyS0 -t mman

Solution: Inform the Linux input subsystem

The serial port should already be known to udev:

udevadm info --name=/dev/ttyS0 --query=path

/devices/platform/serial8250/tty/ttyS0

But in the output of

cat /proc/bus/input/devices

there is no hint of its existence. Installing the package linuxconsoletools from the testing repository and executing

inputattach --mouseman /dev/ttyS0

should give us a working mouse for the X server. The command

inputattach --help

prints a list of the available protocols. In our case the line

  --mouseman       -mman     3-button Logitech / Genius mouse

tells us which one to use. Now the output of

cat /proc/bus/input/devices

should contain a section like:

I: Bus=0013 Vendor=0004 Product=0001 Version=0100
N: Name="Logitech M+ Mouse"
P: Phys=ttyS0/serio0/input0
S: Sysfs=/devices/platform/serial8250/tty/ttyS0/serio8/input/input9
U: Uniq=
H: Handlers=event2 mouse0 
B: PROP=0
B: EV=7
B: KEY=70000 0 0 0 0 0 0 0 0
B: REL=3

To start the inputattach command automatically create a file /etc/local.d/sermouse.start with the content:

#!/bin/sh
inputattach --daemon --mouseman /dev/ttyS0

Make it executable and add the service local to the default runlevel:

rc-update add local default

Then the command

rc

should start the new service. If you want to stop inputattach when stopping the local service, create an executable file /etc/local.d/sermouse.stop with content

#!/bin/sh
killall inputattach

Alternatively you can create a script in /etc/init.d to define a service for the serial mouse.

Solution: Configure the X.org server

This material is obsolete ...

Using Xorg -configure causes issues on many modern systems and is totally unnecessary. If the below configuration can be made to work, it should be placed in its own config file as opposed to generating a full-blown xorg.conf (perhaps try making an /etc/X11/xorg.conf.d/serial_mouse.conf?) (Discuss)

If you don't have a /etc/X11/xorg.conf, then generate one with the command

Xorg -configure

and modify (and move) the resulting file /root/xorg.conf.new to get a running X server. For instance you might have to know the correct driver for the "InputDevice" section for your graphics card. Include the section

Section "ServerFlags"
 Option "AutoAddDevices" "False"
EndSection

to disable hotplugging and set the "Device" and "Protocol" options in the "InputDevice" section for your mouse. In our case we have:

 Option "Protocol" "MouseMan"
 Option "Device" "/dev/ttyS0"

Then restart the X server. For instance:

rc-service lxdm restart

References