Serial mouse

=Introduction=
A mouse connected to the serial port will not be recognized by an Xorg server automatically. In 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 .
=Getting information about the mouse=
If the protocol for the serial mouse is unkown, the command from the package 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:
=Solution: Inform the Linux input subsystem=
The serial port should already be known to udev:
/devices/platform/serial8250/tty/ttyS0
But in the output of there is no hint of its existence. Installing the package from the community repository and executing
should give us a working mouse for the X server.
The command
 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 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 with the content:
#!/bin/sh
inputattach --daemon --mouseman /dev/ttyS0
Make it executable and add the service local to the default runlevel:
Then the command
 should start the new service. If you want to stop inputattach when stopping the local service, create an executable file with content
#!/bin/sh
killall inputattach
Alternatively you can create a script in to define a service for the serial mouse.
=Solution: Configure the X.org server=
 
If you don't have a /etc/X11/xorg.conf, then generate one with the command
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:
=References=
*Serial input device to kernel input - ArchWiki
*Feature #2532: Request for package: linuxconsoletools
*How to run script at startup (alpine-devel Archives)
*local.d Gentoo Wiki
Category:Hardware