原文:Setting up multi-touch scrolling for Ubuntu 9.10 Karmic Koala Linux on Asus Eee 1005HA netbook
虽然本文是基于Asus EeePC 1005ha的,但是本文阐述的方法也适用于其他采用Synaptics的笔记本。
多点触控允许用户使用双指手势在触摸板上进行UI操作。苹果率先在Macbook引入了此技术,大大提高了在上网本上浏览网页的用户体验。最重要的手势是双指滚动文本。
苹果还有很多相关的手势专利,所以他们不会被默认启用。
真正的多点触控需要多点感知(电容)的触摸板支持。但是大多数笔记本都没有配备这种触摸板。不过很幸运,我们可以在压力敏感的触摸板上通过计算和技巧模拟出一些类似双指滚动的简单手势。
注意:Ubuntu HAL对Synaptics的支持有问题。只有最后那段shell脚本是有用的。在FDI文件中的HAL设定被忽略了。
设定Synaptics驱动
在终端中输入:
gksudo gedit /etc/hal/fdi/policy/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>
<merge key=”input.x11_options.SHMConfig” type=”string”>On</merge>
<merge key=”input.x11_options.EmulateTwoFingerMinZ” type=”string”>40</merge>
<merge key=”input.x11_options.VertTwoFingerScroll” type=”string”>1</merge>
<merge key=”input.x11_options.HorizTwoFingerScroll” type=”string”>1</merge>
<merge key=”input.x11_options.TapButton1″ type=”string”>1</merge>
<merge key=”input.x11_options.TapButton2″ type=”string”>3</merge>
<!–two finger tap -> middle clieck(3) –>
<merge key=”input.x11_options.TapButton3″ type=”string”>2</merge>
<!–three finger tap -> right click(2). almost impossible to click –>
</match>
</device>
</deviceinfo>
这个设定将允许我们使用synclient在终端观察触摸板的实时数据。
现在重启X:
sudo /etc/init.d/gdm restart
然后在终端中输入:
synclient -m 100
接着你将在终端看到这样的数据:
129.355 2912 3469 59 1 4 0 0 0 0 0 00000000 0 0 0 0 0 129.455 2952 3529 59 1 4 1 0 0 0 0 00000000 0 0 0 0 0 time x y z f w l r u d m multi gl gm gr gdx gdy 129.555 3283 3516 60 1 4 1 0 0 0 0 00000000 0 0 0 0 0 129.656 3928 3517 60 1 4 1 0 0 0 0 00000000 0 0 0 0 0 129.756 4364 3637 60 1 4 1 0 0 0 0 00000000 0 0 0 0 0 129.856 4020 3329 49 1 4 0 0 0 0 0 00000000 0 0 0 0 0 129.956 3634 3122 58 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.057 3320 2957 60 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.157 2779 3312 61 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.257 2557 3739 61 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.358 2636 3485 39 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.458 2659 3104 60 1 4 0 0 0 0 0 00000000 0 0 0 0 0 130.558 2671 2988 60 1 4 0 0 0 0 0 00000000 0 0 0 0 0
f表示触摸板上的手指数,w表示触摸区域的宽度,z表示触摸的压力。
如果你用两只手指按在触摸板上,f值等于2,这代表你的触摸板支持多点感应。不过很不幸运,看样子华硕EeePC 1005ha支持1个点。
模拟方法
Synaptics的驱动可以在以下环境模拟双指触摸:
- 触摸区域的宽度超过一定阈值(最小宽度)
- 触摸压力超过一定阈值
当出现以上情况,驱动会认为也许用户正在使用两个手指。注意,每种触摸板都有特定的值,不能互用。
Synaptics驱动设定的介绍在这里。我们可以在允许时使用xinput指令来修改Synaptics的驱动设置。开一个窗口,用synclient -m 100监控。再在另一个窗口修改阈值,直到你找到笔记本触摸板的模拟参数。下面是我的xinput测试,在firefox中滚动任意长的网页。
moo@huiskuttaja:~$ xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 32 7 moo@huiskuttaja:~$ xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 32 280 moo@huiskuttaja:~$ xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 32 11 moo@huiskuttaja:~$ xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 32 50 moo@huiskuttaja:~$
以下参数比较适合华硕EeePC 1005ha:
width(W):8 pressure(Z):10
你可以用synclient -l来dump现在的设置。
以下是最终在登录时运行的脚本(参见Ubuntu HAL对Synaptics的支持有问题):
#!/bin/sh # # Use xinput --list-props "SynPS/2 Synaptics TouchPad" to extract data # # Set multi-touch emulation parameters xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 32 10 xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 32 8 xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Two-Finger Scrolling" 8 1 xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 8 1 1 # Disable edge scrolling xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling" 8 0 0 0 # This will make cursor not to jump if you have two fingers on the touchpad and you list one # (which you usually do after two-finger scrolling) xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Synaptics Jumpy Cursor Threshold" 32 110
当你在双指滚动时,如果一只手指提前提出来,鼠标箭头会跳动。Synaptics的驱动好像没有相关设置可以用来过滤这样的问题事件。如果有朋友有解决方案,请务必留言。谢谢!
其他资源
- Linux 多点触控项目是一个收集Perl脚本的工程。这些脚本与多点事件有关。如果你想定制你的多点触控经验并且你有一些开发经验,这个地方可以帮助入门。
- 关于模拟多点触控的注意事项(看最后的留言)
- 诊断多点支持和HAL文件编辑
- 在Ubuntu 头脑风暴上的有关idea
- Synaptics X11 驱动源代码. Synaptics 驱动项目主页. 看起来它背后没有一个核心人物,除了维护和来自分销商的大量补丁。


十一月 6th, 2009 at 9:32 下午
顶一个,辛苦了!
十一月 6th, 2009 at 10:09 下午
我又来测试楼
十一月 17th, 2009 at 4:12 下午
收藏许久。前来测试