<!doctype linuxdoc system>

<!-- 2002年10月25日
 -->

<article>

<!-- Title information -->

<title>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 &lt devicename&gt 
</code></tscreen> 
<p>&lt devicename&gt 是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>    

