Synaptics Touchpad

Synaptics Touchpad

http://wiki.freebsd.org/SynapticsTouchpad

 

 

 

The Synaptics Touchpad is a pointing device, found on many laptops for instance. First, we discuss the problems with the current driver. Then we talk about a replacement driver to improve the quality and extend features.

 

 

 

Current driver in RELENG_7

 

Support for this device is already included in FreeBSD and can be enabled with the hw.psm.synaptics_support tunable. Without this, the touchpad is recognized as a standard 3-buttons mouse.

The current implementation provides the following features:

  • movement smoothing
  • tap detection with one finger
  • palm detection
  • support for extra buttons
  • support for guest devices

However it lacks several useful features:

  • precision with slow movements
  • tap detection with two or three fingers
  • tap-hold (to simulate a button kept pressed)
  • virtual scrolling (to simulate a wheel)
  • movement continuation (to continue a movement when the finger reaches a border)

An X.Org driver providing some of the missing features is available in the Ports tree but it requires further setup and its features are obviously unavailable for the console.

 

New driver

 

The development of the new driver will go through two phases:

  1. Bring the quality of the movement smoothing and tap-hold support on par with what is done internaly by the touchpad, when hw.psm.synaptics_support is not set.

  2. Add more features such as virtual scrolling.

 

Patch

 

The latest patch was committed to 8-CURRENT as revision r183888 on 10/14/2008. If you're using CVS or CVSup, check that src/sys/dev/atkbdc/psm.c as revision 1.100.

To be able to use horizontal scrolling with this new driver under X.Org (through sysmouse), you'll need a patch against xf86-input-mouse.

To apply it:

# cd /usr/ports/x11-drivers/xf86-input-mouse
# make patch
# cd work
# patch -p1 < xf86-input-mouse-sysmouse-horizontal-scrolling.patch
# cd ..
# make

 

 

Current features

 

  • better movement smoothing. It's comparable to the Microsoft Windows driver from Synaptics, except when the finger reaches touchpad borders where the movement becomes chaotic.
  • tap detection with one (left click), two (right click) or three (middle click) fingers.
  • tap-hold detection with one, two or three fingers.
  • virtual scrolling. For now, an area must be dedicated to virtual scrolling; typically, one on the right (vertical scrolling) and one at the bottom (horizontal scrolling). Also, a patch must be applied to xf86-input-mouse to handle horizontal scrolling from sysmouse. Later, virtual scrolling with two fingers will be re-added, as found on Apple MacBook.

 

How to use it

 

You must add the following line in /boot/loader.conf to enable the psm(4) Synaptics support.

hw.psm.synaptics_support="1"

 

You'll need moused(8) too. Add this to /etc/rc.conf:

moused_enable="YES"

 

To use it with X.Org, you'll have to disable Synaptics X.Org specific driver and configure a sysmouse mouse. Here's an example to add to /etc/X11/xorg.conf:

Section "InputDevice"
    Identifier      "Mouse0"
    Driver          "mouse"
    Option          "Protocol"      "auto"
    Option          "Device"        "/dev/sysmouse"
    Option          "ZAxisMapping"  "4 5 6 7"
EndSection

 

Horizontal scrolling is disabled by default. To enable it, you need to set a sysctl (in your /etc/sysctl.conf):

hw.psm.synaptics.vscroll_hor_area=1300

 

 

sysctl documentation

 

 

Palm detection

 

 

Finger pressure

 

 

hw.psm.synaptics.min_pressure: 16
hw.psm.synaptics.max_pressure: 220

 

If the pressure is less than min_pressure of above max_pressure, the packet is ignored but the current action isn't terminated. The pressure is comprised between 0 and 255. Here are some meaningful values, as stated by Synaptics specifications:

  • z = 0: no finger contact
  • z = 10: finger hovering near the pad
  • z = 30: very light finger contact
  • z = 80: normal finger contact
  • z = 110: very heavy finger contact
  • z = 200: finger lying flat on pad surface
  • z = 255: maximum reportable Z

 

Finger width

 

 

hw.psm.synaptics.max_width: 10

 

If the finger width is above max_width, the packet is ignored but the current action isn't terminated. The width is comprised between 4 and 15. Here are some meningful values, as stated by Synaptics specifications:

  • w = 4-7: finger of normal width (capPalmDetect needed)
  • w = 8-14: very wide finger or palm (capPalmDetect needed)
  • w = 15: maximum reportable width (capPalmDetect needed

 

Movement smoothing

 

To smooth the movement, we use a weighted average then a division where both the weight and the divisor vary, depending on the movement speed. See "How it works".

 

hw.psm.synaptics.weight_current: 3
hw.psm.synaptics.weight_previous: 6
hw.psm.synaptics.weight_previous_na: 20
hw.psm.synaptics.weight_len_squared: 2000

 

weight_current and weight_previous define the range of weights to use when calculating the average. weight_previous_na is used instead of weight_previous when the finger is inside the noisy area (see "Touchpad borders").

TODO: explain weight_len_squared.

 

hw.psm.synaptics.div_min: 9
hw.psm.synaptics.div_max: 17
hw.psm.synaptics.div_max_na: 30
hw.psm.synaptics.div_len: 100

 

div_min and div_max define the range of divisors to when calculating the final delta for x & y. div_max_na is used instead of div_max when the finger is inside the noisy area (see "Touchpad borders").

TODO: explain div_len.

 

hw.psm.synaptics.multiplicator: 10000

 

This multiplicator is used during averages and divisions to increase the precision.

 

Touchpad borders

 

The touchpad borders generate a lot of noise in the reported coordinates. There are two sets of sysctl to control this area.

 

hw.psm.synaptics.margin_top: 200
hw.psm.synaptics.margin_right: 200
hw.psm.synaptics.margin_bottom: 200
hw.psm.synaptics.margin_left: 200

 

These margins act as a high-pass filter: for instance, the point [50; 170] will be reported as [200;200].

 

hw.psm.synaptics.na_top: 1783
hw.psm.synaptics.na_right: 563
hw.psm.synaptics.na_bottom: 1408
hw.psm.synaptics.na_left: 1600

 

na stands for noisy area. Movements inside these larger margins will be smoothed using different max weight and divisor. See "Movement smoothing".

 

Points history

 

 

hw.psm.synaptics.window_min: 4
hw.psm.synaptics.window_max: 10

 

window_min indicates the minimum number of packets to receive before an action is considered to be real and wanted. window_max is the maximum number of packets to use in calculations.

 

Tap and tap-hold

 

 

hw.psm.synaptics.tap_max_delta: 80
hw.psm.synaptics.tap_min_queue: 2

 

tap_max_delta is the maximum delta between points to treat the action as a tap. This is to prevent any unwanted click. tap_min_queue is the minimum number of packets needed to consider a tap.

 

hw.psm.synaptics.taphold_timeout: 125000

 

taphold_timeout is the time (in microseconds) between two taps to consider a tap-hols action.

 

Virtual scrolling

 

 

hw.psm.synaptics.vscroll_hor_area: 1300
hw.psm.synaptics.vscroll_ver_area: -600
hw.psm.synaptics.vscroll_min_delta: 50
hw.psm.synaptics.vscroll_div_min: 100
hw.psm.synaptics.vscroll_div_max: 150

 

An area must be dedicated to virtual scrolling for now. This area is defined by vscroll_hor_area (positive for an area at the bottom, negative for an area at the top) for horizontal scrolling and vscroll_ver_area (positive for an area on the left, negative for an area on the right) for vertical scrolling. vscroll_min_delta is the minimum delta between points to consider a scrolling action. This is to prevent unwanted scrolling when tapping for instance. vscroll_div_min and vscroll_div_max are the divisors used instead of div_min and div_max respectively.

 

How it works

 

 

Movement smoothing and tap-hold support

 

The smoothing is based on a weighted average:

Toggle line numbers
   1 average = (weight_current * delta + weight_previous * average) / (weight_current + weight_preivous)

 

where :

  • average is the previous average, which is kept between each packet.

  • delta is the relative movement.

  • weight_current and weight_previous are configurable weights.

This average is calculated for each axis (x & y) separately.

The problem with a simple weighted average as above is that the user has to choose between a smooth but laggy movement (weight_previous greater then weight_current) or a sharp but imprecise movement at slow speed (weight_previous smaller or equal to weight_current).

The idea is then to change weight_previous based on the last packets:

  • If the movement is slow, we keep weight_previous at its original value.

  • If the movement is fast, weight_previous decreases and may reach 0 for the fastest movements.

Internaly, the driver keeps the last 10 packets. Here is the simplified algorithm:

Toggle line numbers
   1 dx = abs(new_x - older_x) + 1; /* +1: to avoid a division by zero below. */
   2 dy = abs(new_y - older_y) + 1;
   3 
   4 /* "len" is really the length squared. */
   5 len = (dx * dx) + (dy * dy);
   6 
   7 /* "sysctl_weight_len_squared" is the length squared at which the
   8  * "weight_previous" will start to decrease. */
   9 weight_previous = sysctl_weight_len_squared * weight_previous / len;
  10 weight_previous = imin(weight_previous, sysctl_weight_previous);

 

The driver will do almost the same with the divisor to calculate the acceleration. The rest of the division is also kept between each packet; otherwise, with slow movements, the pointer doesn't reproduce well what the finger is doing.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
触摸板开关 for Synaptics TouchPad 触摸板开关使用说明v1.4 20080828 只用键盘操作方法 # 本程序运行后,在任何时候按下列热键即可实现相应功能: * 按Win+Z 开关触摸板 * 按Win+S 显示本窗口 * 按Win+J 仅关闭显示器(也适用于台式机) * 按Win+K 关闭显示器并且锁定电脑(也适用于台式机) * 按Win+Q 退出本程序 # 先按Alt+Tab多次使本程序成为当前窗口,然后: * 按Alt+Z 开关触摸板 * 按Alt+F4 退出本程序 * 按Esc键 最小化,可减少内存占用量 # 推荐先最小化本程序窗口,然后用上列Win系列热键操作。 # 如果命令行参数中包含“quiet”,则不弹出操作方法提示对话框。 # 本程序的主要功能是:触摸板开关 和 关闭显示器,主要是笔记本电脑上使用。 临时禁用触摸板--打开/关闭笔记本电脑的触摸板,当外接鼠标时可停止笔记本自带的触摸板工作,以免打字时候手指移动造成误操作。 关闭显示器--触动鼠标或任意键可以重新打开屏幕。在电脑下载文件、挂机升级或者人暂时离开,不希望电脑停止工作时可以使用此功能,可以有效延长LCD灯管寿命,且可节能。 按Win+K 关闭显示器并且锁定电脑--可用来取代系统内置的Win+L。 # 开发本程序只是为了方便自己使用笔记本电脑,玩玩编程而已。 # 本程序是在中文Windows XP SP3 + 中文Visual Basic 6.0平台上开发的。 # 本程序只在中文Windows XP SP3平台上测试通过,其它平台未知。 # 本程序估计适用于绝大多数使用Synaptics公司生产的触摸板(Synaptics TouchPad)的笔记本电脑, 事实上,绝大多数笔记本电脑上使用的触摸板是Synaptics公司生产的。 # 如果在其它中文Windows XP平台上不能正常运行,可能会改用英文Delphi重新编程, 从而推出适应性更好的版本。 ## 如果不能正常运行,请先下载并安装触摸板最新驱动程序即可使用,下载地址: http://drivers.synaptics.com/Synaptics_Driver_v10_1_8_XP32.exe 版权所有,免费使用,欢迎传播,多提建议 ============================================ 版本变化: V1.0:仅实现最简单的触摸板开关功能,不支持全局热键。 V1.1:增加关闭显示器和锁定电脑功能,仍不支持全局热键。 V1.2:支持全局热键(Win系列热键),大大方便使用,不隐身。 V1.3:支持全局热键(Win系列热键),大大方便使用,且以隐身于后台运行方式实现系统内存占用少的目的。 V1.4:支持命令行参数“quiet”;防止同一程序执行多次;优化源代码模块布局。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值