synaptics安裝與設定

今天拿到我的小筆電acer D250,跑了X但是我發現其滑鼠有夠難用的,這是因為在xorg+hal的架構下面,會將我的touchpad以ps2 mouse來設定,因此這邊要處理一些這樣的hack。

首先我要將ps2 mouse改成touchpad的軀動,另外就是讓xorg完全不管input的工作,直接讓hal全部接管,因為hal也許是未來硬體設定的一個趨勢,所以現在漸漸的xorg.conf很多人都不太理它,或是不寫都可以,因為現在的xorg已經聰明到可以自動的設定,但是設定還是有些問題。

* 首先安裝synaptics軀動程式

# cd /usr/ports/x11-drivers/xf86-input-synaptics
# make install clean

* synaptics設定檔與hal相關資訊

synaptics可以在xorg.conf設定,也可以透過hal來設定,如果要使用hal來設定的話,就要自己訂它的policy fdi檔,所以來看一下它所附上的11-x11-synaptics.fdi

# cat /usr/local/share/hal/fdi/policy/10osvendor/11-x11-synaptics.fdi
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.touchpad">
<merge key="input.x11_driver" type="string">synaptics</merge>
<!-- Arbitrary options can be passed to the driver using
the input.x11_options property since xorg-server-1.5. -->
<!-- EXAMPLES:
Switch on shared memory, enables the driver to be configured at runtime
<merge key="input.x11_options.SHMConfig" type="string">true</merge>

Maximum movement of the finger for detecting a tap
<merge key="input.x11_options.MaxTapMove" type="string">2000</merge>

Enable vertical scrolling when dragging along the right edge
<merge key="input.x11_options.VertEdgeScroll" type="string">true</merge>

Enable vertical scrolling when dragging with two fingers anywhere on the touchpad
<merge key="input.x11_options.VertTwoFingerScroll" type="string">true</merge>

Enable horizontal scrolling when dragging with two fingers anywhere on the touchpad
<merge key="input.x11_options.HorizTwoFingerScroll" type="string">true</merge>

If on, circular scrolling is used
<merge key="input.x11_options.CircularScrolling" type="string">true</merge>

For other possible options, check CONFIGURATION DETAILS in synaptics man page
-->
</match>
</device>
</deviceinfo>

之後我們在看一下透過lshal所顯示出來hal所辨識的touchpad的資訊
udi = '/org/freedesktop/Hal/devices/psm_0'
freebsd.device_file = '/dev/psm0' (string)
freebsd.driver = 'psm' (string)
freebsd.unit = 0 (0x0) (int)
info.addons = {'hald-addon-mouse-sysmouse'} (string list)
info.capabilities = {'input', 'input.mouse'} (string list)
info.category = 'input.mouse' (string)
info.parent = '/org/freedesktop/Hal/devices/atkbdc_0' (string)
info.product = 'PS/2 Mouse' (string)
info.subsystem = 'platform' (string)
info.udi = '/org/freedesktop/Hal/devices/psm_0' (string)
input.device = '/dev/psm0' (string)
input.x11_driver = 'mouse' (string)
platform.id = 'psm.0' (string)

從這裡我們可以看出,這根本沒有match,因為由hal看出它所吃到的軀動還是一樣為mouse,而不是synaptics,可以仔細的看一下上面synaptics.fdi根本是有問題的
match key="info.capabilities" contains="input.touchpad"
它透過match key來看是否是正確為input.touchpad,但是由lshal可以看出,這並不match
info.capabilities = {'input', 'input.mouse'} (string list)
因此這個hack最重要的就是讓policy正確的去設定hal所辨識到的硬體資訊

* 讓硬體支援synaptics軀動

# vim /boot/loader.conf
hw.psm.synaptics_support="1"


* 讓hal正確辨識touchpad並設定synaptics的相關設定

自己新增一個hal的policy,我命名為synaptics.fdi
# vim /usr/local/etc/hal/fdi/policy/synaptics.fdi
<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.udi" string="/org/freedesktop/Hal/devices/psm_0">
<merge key="input.x11_driver" type="string">synaptics</merge>
<merge key="input.x11_options.Protocol" type="string">psm</merge>
<merge key="input.x11_options.Device" type="string">/dev/psm0</merge>
<merge key="input.x11_options.SHMConfig" type="string">false</merge>
<merge key="input.x11_options.LeftEdge" type="string">1200</merge>
<merge key="input.x11_options.RightEdge" type="string">5700</merge>
<merge key="input.x11_options.TopEdge" type="string">1200</merge>
<merge key="input.x11_options.BottomEdge" type="string">5000</merge>
<merge key="input.x11_options.VertEdgeScroll" type="string">true</merge>
<merge key="input.x11_options.HorizEdgeScroll" type="string">true</merge>
<merge key="input.x11_options.VertScrollDelta" type="string">300</merge>
<merge key="input.x11_options.HorizScrollDelta" type="string">300</merge>
<merge key="input.x11_options.MaxSpeed" type="string">0.15</merge>
<merge key="input.x11_options.MinSpeed" type="string">0.15</merge>
<merge key="input.x11_options.CircularScrolling" type="string">true</merge>
<merge key="input.x11_options.CircularPad" type="string">true</merge>
<merge key="input.x11_options.CircScrollTrigger" type="string">2</merge>
<merge key="input.x11_options.CircScrollDelta" type="string">0.3</merge>
</match>
</device>
</deviceinfo>

仔細看可以看出我已經修改了match的方式,直接使用udi直接指定hal所辨識到的硬體,用我的方式來設定,以上有幾個很重要部份一定要設定
input.x11_driver 設定為 synaptics
input.x11_options.Protocol 設定為 psm
input.x11_options.Device 設定為 /dev/psm0
在synaptics的man文件之前有特別提到linux, freebsd, unix等等所設定protocol不同,另外就是必須要指定它device是那一個。而上面所提到的其它設定都是自己使用touchpad自己tune出來的,最後會提供如何客製到自己方便使用。

完成上面以後,重啟hald

* 看lshal所顯示的資訊是否正確

udi = '/org/freedesktop/Hal/devices/psm_0'
freebsd.device_file = '/dev/psm0' (string)
freebsd.driver = 'psm' (string)
freebsd.unit = 0 (0x0) (int)
info.addons = {'hald-addon-mouse-sysmouse'} (string list)
info.capabilities = {'input', 'input.mouse'} (string list)
info.category = 'input.mouse' (string)
info.parent = '/org/freedesktop/Hal/devices/atkbdc_0' (string)
info.product = 'PS/2 Mouse' (string)
info.subsystem = 'platform' (string)
info.udi = '/org/freedesktop/Hal/devices/psm_0' (string)
input.device = '/dev/psm0' (string)
input.x11_driver = 'synaptics' (string)
input.x11_options.BottomEdge = '5000' (string)
input.x11_options.CircScrollDelta = '0.3' (string)
input.x11_options.CircScrollTrigger = '2' (string)
input.x11_options.CircularPad = 'true' (string)
input.x11_options.CircularScrolling = 'true' (string)
input.x11_options.Device = '/dev/psm0' (string)
input.x11_options.HorizEdgeScroll = 'true' (string)
input.x11_options.HorizScrollDelta = '300' (string)
input.x11_options.LeftEdge = '1200' (string)
input.x11_options.MaxSpeed = '0.15' (string)
input.x11_options.MinSpeed = '0.15' (string)
input.x11_options.Protocol = 'psm' (string)
input.x11_options.RightEdge = '5700' (string)
input.x11_options.SHMConfig = 'false' (string)
input.x11_options.TopEdge = '1200' (string)
input.x11_options.VertEdgeScroll = 'true' (string)
input.x11_options.VertScrollDelta = '300' (string)
platform.id = 'psm.0' (string)

由這裡已經可以看出,本來是由mouse軀動程式來支援的ps2 mouse,但是我們加了policy之後,換成透過synaptics來支援ps2 mouse,這已經達到我們的目地了,但是還差一點,因為xorg.conf裡面的input mouse section會和hal相互衝突,所以我們要讓hal全部接管的話,我們必須讓xorg完全不處理,而讓hal來處理。

* 修改xorg.conf

如果你都直接讓xorg自動來處理這個部份的話,那你這邊就不需要修改了,但是如果像我會讓xorg不判斷錯誤的話,我還是會自己來處理xorg.conf的設定檔部份,那麼我就必須要修改了。
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
EndSection

Section "Files"
ModulePath "/usr/local/lib/xorg/modules/"
FontPath "/usr/local/lib/X11/fonts/misc/"
FontPath "/usr/local/lib/X11/fonts/TTF/"
FontPath "/usr/local/lib/X11/fonts/OTF/"
FontPath "/usr/local/lib/X11/fonts/artwiz-aleczapka-en/"
FontPath "/usr/local/lib/X11/fonts/TrueType/"
FontPath "/usr/local/lib/X11/fonts/Type1/"
FontPath "/usr/local/lib/X11/fonts/100dpi/"
FontPath "/usr/local/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
Load "extmod"
Load "record"
Load "dbe"
Load "glx"
Load "dri"
Load "dri2"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
EndSection

Section "Device"
Identifier "Card0"
Driver "intel"
VendorName "Intel Corporation"
BoardName "Mobile 945GME Express Integrated Graphics Controller"
BusID "PCI:0:2:0"
EndSection

Section "Screen"
Identifier "Screen0"
device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection

由上面可以看出我把input的所有設定都移除了,這就是讓xorg不理會輸入裝置怎麼設定,而是直接交由hal來做自動設定,那麼我們剛剛上面所指定的hal policy只要正確的話,我們就可以正確的使用了。

* 個人化synaptics

先將policy中的input.x11_options.SHMConfig設為true這樣才可以透過share memory來溝通。

之後進入X下面之後開啟terminal輸入synclient來啟動設定程式,如果不知道如何使用的話,先去看一下man裡面對synclinet的設定說明。

以上搞定之後,建議把input.x11_options.SHMConfig再設為false這樣比較安全。

1 意見:

    你好
    拜讀你的文章,指定x11_driver=synaptics, device=/dev/psm0, 而 protocol不論是用 psm或是auto-dev皆無法在Xorg作動, 但是確可以在console作動。
    想請問一下還有什麼要特別注意的地方?
    謝謝