串口鼠标
简介
连接到串口的鼠标不会被 Xorg 服务器自动识别。在 /var/log/Xorg.0.log 中可能会有如下消息
(II) The server relies on udev to provide the list of input devices. If no devices become available, reconfigure udev or disable AutoAddDevices.
我们将介绍两种在 X.org 下使用串口鼠标的方法。在我们的例子中,我们有一个罗技串口鼠标,型号为 M/N: M-M30,连接到设备 /dev/ttyS0。
获取鼠标信息
如果串口鼠标的协议未知,可以使用命令
mouse-test /dev/ttyS0
来自软件包 gpm,可以用来获取必要的信息。该程序是交互式的,最后会打印类似如下的消息
Your mouse seems to be a 'mman' one on "/dev/ttyS0" (24 matches)
man
手册 gpm-types
包含了协议列表。在我们的例子中,这些行
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.
为我们提供了更多关于协议的信息。我们可以通过运行以下命令在虚拟控制台中测试鼠标
gpm -m /dev/ttyS0 -t mman
解决方案:通知 Linux 输入子系统
串口应该已经被 udev 识别
udevadm info --name=/dev/ttyS0 --query=path
/devices/platform/serial8250/tty/ttyS0
但是在以下命令的输出中
cat /proc/bus/input/devices
没有关于其存在的任何提示。从 community 仓库安装软件包 linuxconsoletools 并执行
inputattach --mouseman /dev/ttyS0
应该会为 X 服务器提供一个可用的鼠标。命令
inputattach --help
打印可用协议的列表。在我们的例子中,这行
--mouseman -mman 3-button Logitech / Genius mouse
告诉我们该使用哪个。现在,以下命令的输出
cat /proc/bus/input/devices
应该包含类似如下的部分
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
要自动启动 inputattach
命令,创建一个文件 /etc/local.d/sermouse.start,内容如下
#!/bin/sh inputattach --daemon --mouseman /dev/ttyS0
使其可执行,并将服务 local
添加到 default
运行级别
rc-update add local default
然后执行命令
rc-service local start
应该会启动新服务。如果要在停止 local
服务时停止 inputattach
,创建一个可执行文件 /etc/local.d/sermouse.stop,内容如下
#!/bin/sh killall inputattach
或者,您可以在 /etc/init.d 中创建一个脚本来为串口鼠标定义一个服务。
解决方案:配置 X.org 服务器
![]() 在许多现代系统上使用 Xorg -configure 会导致问题,并且完全没有必要。如果以下配置可以工作,则应将其放置在自己的配置文件中,而不是生成完整的 xorg.conf(也许可以尝试创建一个 /etc/X11/xorg.conf.d/serial_mouse.conf?) (讨论) |
如果您没有 /etc/X11/xorg.conf
,则可以使用以下命令生成一个
Xorg -configure
并修改(和移动)生成的文件 /root/xorg.conf.new
以获得运行的 X 服务器。例如,您可能需要知道显卡 "InputDevice"
部分的正确驱动程序。包含以下部分
Section "ServerFlags" Option "AutoAddDevices" "False" EndSection
禁用热插拔,并在鼠标的 "InputDevice"
部分中设置 "Device"
和 "Protocol"
选项。在我们的例子中,我们有
Option "Protocol" "MouseMan" Option "Device" "/dev/ttyS0"
然后重启 X 服务器。例如
rc-service lxdm restart