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 產品的校準程式, 可在這裡下載:
ftp://metalab.unc.edu/pub/linux/X11/xutils/touchcal-0.1.tar.gz