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