Linux Touch Screen HOWTO <author>作者: Christoph Baumann, <tt/cgb@debian.org/ <newline>译者: 陈敏剑 <tt/expns@yahoo.com/ <date>v3.0, 2002-07-06 <abstract> 这篇HOWTO描述如何在Linux上使用触摸屏. </abstract> <!-- Table of contents --> <toc> <!-- Begin the document --> <sect>介绍 <p>例子当中的设定连接是通过串行口serial port 进行的. 比如: /dev/ttyS0 或者 /dev/ttyS1. (欢迎提供USB devices 的资讯!) The GNU Free Documentation License applies to this document. <sect1>关於作者 <p>作者 Christoph Baumann 在工作中使用 EloTouch(R) 和 MicroTouch(R)公司的产品, 这个HOWTO就是源自於他对这些设备的 使用/研究 的经验. <sect>设定device <p>Touch screen 的设定是通过XF86Config文档中的Xinput部分来完成. (通常是 /etc/X11/XF86Config 或者是 /etc/XF86Config). 首先检查硬体的驱动模组是否存在. 它们应该在 /usr/X11R6/lib/modules/ (我使用的模组是 xf86Elo.so 和 xf86MuTouch.so , 它们分别是两个不同产商的模组).现在看一下XF86Config,应有一部分看起来像这样: <tscreen><code> Section "Files" ... ModulePath "/usr/X11R6/lib/modules" ... EndSection </code></tscreen> <p>如果要将模组挂进 X server ,应有一部分像这样: <tscreen><code> Section "Module" Load "xf86Elo.so" EndSection </code></tscreen> <p>现在到了最关建的时候了. X 需要设备的一些参数. 这部分看起来像是这样(想了解更多的细节请参照 "man XF86Config" ): <tscreen><code> 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 </code></tscreen> <p>MinimumXPosition 等等是硬体的细节设定( 设定touch screen 在显示设备上的位置). 数值将显示座标 (0,0) 和 (xmax,ymax) 映射到 Touch screen 设备上(xmax 和 ymax 取决於 Xserver 的莹幕区域, 比如 1024x768).图例: <tscreen><code> --------------touch screen 区域----------------- I I I ########### 莹幕的可视区域 ############### 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 ------------------------------------------------ </code></tscreen> <p>这个映射可以通过反覆试验,或者参照硬体输出的数据完成 (需要写一些在 serial port 方面的程式programming, 参照: "The Linux Serial Programming HOWTO"). 作者写了一个EloTouch 和 MicroTouch 产品的校准程式, 可在这里下载: <htmlurl url=" ftp://metalab.unc.edu/pub/linux/X11/xutils/touchcal-0.1.tar.gz" name=" ftp://metalab.unc.edu/pub/linux/X11/xutils/touchcal-0.1.tar.gz"> <sect>激活设备 <p>进入 X, 在终端上输入: <tscreen><code> xsetpointer < devicename> </code></tscreen> <p>< devicename> 是XF86Config 设定文档中的DeviceName ".....", 这个例子中它是 TouchScreen. 在touch screen section (see above) 设定 AlwaysCore 让它自动激活. <sect>使 touch screen 和滑鼠同步 <p> 使 touch screen 和滑鼠同步 你需要将滑鼠的设定加入Xinput-section. 这个设定和Pointer-section差不多. The following example is for a PS/2-mouse: <tscreen><code> Section "Xinput" SubSection "Mouse" Protocol "PS/2" Port "/dev/mouse" #could also be /dev/psaux DeviceName "Mouse" AlwaysCore EndSubSection ... EndSection </code></tscreen> <p>许多人提出了建议,尤其是 AlwaysCore 的用法.我感谢他们!! <sect>在 XFree86 4 之下进行设定 <p>(from Lee Monamy) ELO touch screen 的XF86Config-4设定: <tscreen><code> 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 </code></tscreen> <p>值得注意的是这个设定和 version 3 设定Device的不同, *not* a Port, otherwise you get an error.同样 version3 的 AlwaysCore 被 SendCoreEvents 取代. <p>你也要加入到ServerLayout,不用管X的信息: "(II) XINPUT: Adding extended input device "TOUCHSCREEN" (type: Elographics Touch Screen)" <tscreen><code> Section "ServerLayout" Identifier "Default Layout" Screen "Default Screen" InputDevice "Generic Keyboard" ... InputDevice "ELO touchscreen" EndSection </code> </tscreen> <sect1>其它的例子 <sect2>from Dirk Mueller (for Microtouch SMT3 Series): <p> <tscreen><code> 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 </code> </tscreen> <p>Option "Type" 可以是 "finger" 或 "stylus" Since Microtouch was bought by 3M-Touch, 参照 <htmlurl url=" http://www.3M.com/3MTouchSystems/downloads/legacy.jhtml#Linux" name=" http://www.3M.com/3MTouchSystems/downloads/legacy.jhtml#Linux"> <sect1>附录 <p> 依据 Wong Yeow Sen, 设定的 option 名字在 XFree86 4.2 (at least with Red Hat 7.3)有所改变. 如果你的校准有误差请试试这个: <tscreen><code> ... Option "MinX" "100" Option "MaxX" "4000" Option "MinY" "100" Option "MaxY" "4000" ... </code> </tscreen> <sect>Touch Screens on Fujitsu LifeBooks <p>(由 Joerg Hau 提供) <p>可以在下面找到你要的资讯: Harald Hoyer's Linux Touch Panel Drivers for the Fujitsu Lifebooks B112/B142/B2130, <htmlurl url="http://parzelle.de/Linux/Lifebook/" name="http://parzelle.de/Linux/Lifebook/">. 不幸的是, 它只针对XFree 3.x 并且没有更新 (dead?). <p>Kenan Esau's Lifebook Series B Touchscreen driver, which is the adaptation of Harald's driver to XFree 4.x. <htmlurl url="http://stlx01.stz-softwaretechnik.de/~ke/lifebook/lifebook.html" name="http://stlx01.stz-softwaretechnik.de/~ke/lifebook/lifebook.html">. <p> 我在Fujitsu LifeBook B142上 使用 Kenan's 的驱动程式( <htmlurl url="http://www.mysunrise.ch/users/joerg.hau/linux/b142.htm" name="http://www.mysunrise.ch/users/joerg.hau/linux/b142.htm"> ), and it works like a charm. <sect>建议阅读 <p> <itemize> <item>XF86Config 的 Manpage <item> <htmlurl url="http://www.elotouch.com/Support/linux.asp " name="http://www.elotouch.com/Support/linux.asp "> <item> <htmlurl url="http://www.microtouch.com/mthtml/05a1_drivers.htm" name="http://www.microtouch.com/mthtml/05a1_drivers.htm"> <item> <htmlurl url="http://www.hof-berlin.de/tablet/tablet.html" name="http://www.hof-berlin.de/tablet/tablet.html"> (感谢Christer Olofsson 将这个 URL 寄给我) <item>你自己的 touch screen 手册 :-) </itemize> </article>