触摸屏设备在 XF86Config 文件中的 Xinput 部分进行配置(通常是 /etc/X11/XF86Config 或 /etc/XF86Config)。 首先验证设备驱动模块是否存在。 它们位于 /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 找到)。