Linux 触摸屏指南

(c) 2002-2006 Christoph Baumann,cgb(at)debian.org

v3.4 -- 2006年11月7日 -- 本文档适用 GNU 自由文档许可证
本文档描述了如何在 XFree86 下设置触摸屏输入设备。由于作者只有机会使用 EloTouch(R) 和 MicroTouch(R) 的设备,因此本 HOWTO 主要是针对这些设备的。本 HOWTO 中的示例侧重于通过串行端口连接的设备,即 /dev/ttyS0 或 /dev/ttyS1。(欢迎提供有关 USB 设备的信息!)

1. 如何配置设备

2. 激活设备

3. 并行使用触摸屏和鼠标

4. XFree86 4 下的配置

5. Fujitsu LifeBook 上的触摸屏

6. X.Org 下的配置

7. 建议阅读


1. 如何配置设备

触摸屏设备在 XF86Config 文件(通常是 /etc/X11/XF86Config 或 /etc/XF86Config)的 Xinput 部分中配置。首先验证设备驱动模块是否存在。它们位于 /usr/X11R6/lib/modules/ 中(上述设备的模块是 xf86Elo.so 和 xf86MuTouch.so)。现在查看 XF86Config。应该有一个如下所示的部分

Section "Files"
...
ModulePath "/usr/X11R6/lib/modules"
...
EndSection

要使 X 服务器加载模块,必须有如下所示的部分

Section "Module"
Load "xf86Elo.so"
EndSection

现在是更棘手的部分。X 需要知道有关设备的一些参数。为此的部分如下所示(更多详细信息请参阅“man XF86Config”)

Section "Xinput"
 SubSection "Elographics"  
#the entry for a MicroTouch device would be SubSection "MicrotouchFinger"
  Port "/dev/ttyS1" # for a device at serial port 2
  DeviceName "TouchScreen" #could be any unambiguous name
  MinimumXPosition 300
  MaximumXPosition 3700
  MinimumYPosition 300
  MaximumYPosition 3700
  UntouchDelay 10 #not supported with MuTouch
  ReportDelay 10  #not supported with MuTouch
  AlwaysCore #activates the device on startup
 EndSubSection
EndSection

条目 MinimumXPosition 等的值当然是特定于硬件设置的(即取决于触摸屏相对于显示器的位置)。这些值确定了显示器上的点 (0,0) 和 (xmax,ymax)(xmax 和 ymax 取决于为 X 服务器选择的分辨率,例如 1024x768)在触摸屏上的映射位置。设备驱动程序读取这些值并插值其他坐标。为了说明

 --------------touch screen area-----------------
 I                                              I
 I  ########visible monitor area##############  I
 I  #x                                       #  I
 I  # (0,0)                                  #  I
 I  # (MinimumXPosition,MinimumYPosition)    #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #                                        #  I
 I  #     (MaximumXPosition,MaximumYPosition)#  I
 I  #                             (xmax,ymax)#  I
 I  #                                       x#  I
 I  ##########################################  I
 I                                              I
 ------------------------------------------------

这种映射可以通过反复试验或读取设备的原始输出来完成(需要一些串行端口编程,请参阅“Linux 串行编程 HOWTO”)。对于 EloTouch 和 MicroTouch 类型,存在一个基本的校准工具(由本文档的作者编写,可以在 http://touchcal.sourceforge.net 找到)。


2. 激活设备

启动 X 后,在 X 终端中键入命令

xsetpointer <设备名称>

其中 <设备名称> 是在 XF86Config 中使用 DeviceName "....." 行定义的名称,在本例中它将是 TouchScreen。

要在启动时使设备工作,请在触摸屏部分中使用 AlwaysCore 选项(见上文)


3. 并行使用触摸屏和鼠标

要并行使用触摸屏和鼠标,您需要在 Xinput 部分中输入鼠标规格。这些定义应与 Pointer 部分中的定义相同。以下示例适用于 PS/2 鼠标

Section "Xinput" 
   SubSection "Mouse" 
      Protocol "PS/2" 
      Port "/dev/mouse" #could also be /dev/psaux 
      DeviceName "Mouse" 
      AlwaysCore 
   EndSubSection
...
EndSection 
有几个人指出了这一点,特别是 AlwaysCore 选项的用法。感谢大家。


4. XFree86 4 下的配置

(来自 Lee Monamy)

ELO 触摸屏的 XF86Config-4 示例

Section "InputDevice"
        Identifier "ELO touchscreen"
        Driver "elographics"
        Option  "Device"        "/dev/ttyS0"
        Option  "MinimumXPosition"      "300"
        Option  "MaximumXPosition"      "3700"
        Option  "MinimumYPosition"      "300"
        Option  "MaximumYPosition"      "3700"
        Option  "UntouchDelay"  "10"
        Option  "ReportDelay"   "10"
        Option  "SendCoreEvents"        "yes"
EndSection

此配置与版本 3 配置之间的显着区别在于,您指定的是 Device,*而不是* Port,否则会收到错误。此外,v3 中的 AlwaysCore 已被 SendCoreEvents 替换。

您还必须添加到 ServerLayout 部分,尽管 X 可能会说:“(II) XINPUT:添加扩展输入设备“TOUCHSCREEN”(类型:Elographics 触摸屏)”

Section "ServerLayout"
        Identifier      "Default Layout"
        Screen  "Default Screen"
        InputDevice "Generic Keyboard"
...
        InputDevice "ELO touchscreen"
EndSection

4.1 另一个配置示例

(来自 Dirk Mueller(适用于 Microtouch SMT3 系列))

Section "InputDevice"
        Identifier  "MicroTouchFinger"
        Driver      "mutouch"
        Option      "Type" "finger"
        Option      "Device" "/dev/ttyS0"
        Option      "ScreenNo" "0"
        Option      "MinimumXPosition" "0"
        Option      "MaximumXPosition" "16383"
        Option      "MinimumYPosition" "0"
        Option      "MaximumYPosition" "16383"
EndSection

选项“Type”可以是“finger”或“stylus”。由于 Microtouch 已被 3M-Touch 收购,资源位于 http://www.3M.com/3MTouchSystems/downloads/legacy.jhtml#Linux

4.2 附录

根据 Wong Yeow Sen 的说法,配置选项名称在 XFree86 4.2 中已更改(至少在 Red Hat 7.3 中)。如果您的校准值似乎未被解析,请尝试以下操作

...
        Option  "MinX"      "100"
        Option  "MaxX"      "4000"
        Option  "MinY"      "100"
        Option  "MaxY"      "4000"
...


5. Fujitsu LifeBook 上的触摸屏

(来自 Joerg Hau)

有关这些设备的信息可以在这里找到

"...

Harald Hoyer 的 Fujitsu Lifebook B112/B142/B2130 Linux 触摸面板驱动程序,http://parzelle.de/Linux/Lifebook/。不幸的是,这仅适用于 XFree 3.x,并且似乎此信息现在是“静态的”(已失效?)。

Kenan Esau 的 Lifebook B 系列触摸屏驱动程序,它是 Harald 的驱动程序到 XFree 4.x 的改编版本。 http://www.conan.de/lifebook/lifebook.html

我 [Joerg Hau] 在我的 Fujitsu LifeBook B142 上使用了 Kenan 的驱动程序(在 http://www.mysunrise.ch/users/joerg.hau/linux/b142.htm 中描述),它工作得非常好。

..."


6. X.Org 下的配置

(来自 Kenan Bektas)

Elo TouchSystems 2216 AccuTouch® USB 触摸显示器的 xorg.conf 示例

Section "InputDevice"
    Identifier "elo"
    Driver "elo"
    Option "AlwaysCore"
    Option "MinX"          "300"
    Option "MaxX"          "3700"
    Option "MinY"          "300"
    Option "MaxY"          "3700"
    Option "ScreenNumber"  "0"
    Option "ButtonNumber"  "1"
EndSection


7. 建议阅读