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