我使用带有电阻式触摸屏的 7" 显示屏,ARM CPU 的嵌入式 Linux。制造商 Engicam,设计类似于 Freescale / NXP i.MX6 Sabre 板。
使用 Yocto 1.7.3 和 Engicam 板支持包,我创建了一个 X11 应用程序,基本上是一个 Firefox 浏览器。此应用程序的大部分工作都有一个例外:我无法点击/单击任何项目。当我触摸屏幕并四处移动时,光标将跟随我的手指,不幸的是单击或双击不起作用。
我的配置:
核心:Linux display 3.10.17-1.0.2_ga+g33597e3 #1 SMP PREEMPT Sun May 22 20:00:34 CEST 2016 armv7l GNU/Linux
电阻式触摸驱动程序:max11801_ts
和事件驱动程序evdev
。
/usr/share/X11/xorg.conf.d/10-evdev.conf
evdev( )的配置文件:
#
# Catch-all evdev loader for udev-based systems
# We don't simply match on any device since that also adds accelerometers
# and other devices that we don't really want to use. The list below
# matches everything but joysticks.
Section "InputClass"
Identifier "evdev pointer catchall"
MatchIsPointer "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev keyboard catchall"
MatchIsKeyboard "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev tablet catchall"
MatchIsTablet "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
EndSection
Section "InputClass"
Identifier "evdev touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "SHMConfig" "true"
Option "TapButton1" "1"
Option "EmulateThirdButton" "1"
Option "EmulateThirdButtonTimeout" "750"
Option "EmulateThirdButtonMoveThreshold" "30"
Option "Calibration" "0 4095 0 4095"
EndSection
最后一部分由 evdev 用于触摸屏。
在 X11 日志中,我看到 X11 加载 evdev 并接受设置:
X11 日志的一部分 ( /var/log/Xorg.0.log
):
[3738325.274] (**) max11801_ts: Applying InputClass "evdev touchscreen catchall"
[3738325.274] (II) LoadModule: "evdev"
[3738325.275] (II) Loading /usr/lib/xorg/modules/input/evdev_drv.so
[3738325.289] (II) Module evdev: vendor="X.Org Foundation"
[3738325.289] compiled for 1.14.4, module version = 2.9.0
[3738325.289] Module class: X.Org XInput Driver
[3738325.289] ABI class: X.Org XInput driver, version 19.1
[3738325.289] (II) Using input driver 'evdev' for 'max11801_ts'
[3738325.290] (**) max11801_ts: always reports core events
[3738325.293] (**) evdev: max11801_ts: Device: "/dev/input/event0"
[3738325.294] (--) evdev: max11801_ts: Vendor 0 Product 0
[3738325.295] (--) evdev: max11801_ts: Found absolute axes
[3738325.295] (--) evdev: max11801_ts: Found x and y absolute axes
[3738325.295] (--) evdev: max11801_ts: Found absolute touchscreen
[3738325.295] (II) evdev: max11801_ts: Configuring as touchscreen
[3738325.296] (**) Option "EmulateThirdButton" "1"
[3738325.296] (**) Option "EmulateThirdButtonTimeout" "750"
[3738325.296] (**) Option "EmulateThirdButtonMoveThreshold" "30"
[3738325.297] (**) evdev: max11801_ts: YAxisMapping: buttons 4 and 5
[3738325.297] (**) evdev: max11801_ts: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
[3738325.297] (**) Option "config_info" "udev:/sys/devices/soc0/soc.1/2100000.aips-bus/21a0000.i2c/i2c-0/0- 0048/input/input0/event0"
[3738325.297] (II) XINPUT: Adding extended input device "max11801_ts" (type: TOUCHSCREEN, id 6)
[3738325.299] (II) evdev: max11801_ts: initialized for absolute axes.
[3738325.300] (**) max11801_ts: (accel) keeping acceleration scheme 1
[3738325.301] (**) max11801_ts: (accel) acceleration profile 0
[3738325.301] (**) max11801_ts: (accel) acceleration factor: 2.000
[3738325.301] (**) max11801_ts: (accel) acceleration threshold: 4
[3738325.305] (II) config/udev: Adding input device max11801_ts (/dev/input/mouse0)
[3738325.305] (II) No input driver specified, ignoring this device.
[3738325.305] (II) This device may have been added with another device file.
xinput 还可以看到触摸设备:
# xinput list
| Virtual core pointer id=2 [master pointer (3)]
| > Virtual core XTEST pointer id=4 [slave pointer (2)]
| > max11801_ts id=6 [slave pointer (2)]
| Virtual core keyboard id=3 [master keyboard (2)]
| Virtual core XTEST keyboard id=5 [slave keyboard (3)]
不幸的是 evtest 没有看到任何点击(EV_KEY)(BTN_TOUCH)事件:
# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: max11801_ts
Select the device event number [0-0]: 0
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "max11801_ts"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 1308
Min 0
Max 4095
Event code 1 (ABS_Y)
Value 476
Min 0
Max 4095
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 1
Properties:
Testing ... (interrupt to exit)
Event: time 1464027536.266584, type 3 (EV_ABS), code 0 (ABS_X), value 1167
Event: time 1464027536.266584, type 3 (EV_ABS), code 1 (ABS_Y), value 2282
Event: time 1464027536.266584, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 1
Event: time 1464027536.266584, -------------- EV_SYN ------------
Event: time 1464027536.282916, type 3 (EV_ABS), code 0 (ABS_X), value 1168
Event: time 1464027536.282916, -------------- EV_SYN ------------
Event: time 1464027536.299472, type 3 (EV_ABS), code 0 (ABS_X), value 1169
Event: time 1464027536.299472, -------------- EV_SYN ------------
Event: time 1464027536.315900, type 3 (EV_ABS), code 0 (ABS_X), value 1171
Event: time 1464027536.315900, type 3 (EV_ABS), code 1 (ABS_Y), value 2281
Event: time 1464027536.315900, -------------- EV_SYN ------------
Event: time 1464027536.340587, type 3 (EV_ABS), code 0 (ABS_X), value 1172
Event: time 1464027536.340587, -------------- EV_SYN ------------
Event: time 1464027536.348821, type 3 (EV_ABS), code 0 (ABS_X), value 1173
Event: time 1464027536.348821, -------------- EV_SYN ------------
Event: time 1464027536.357047, type 3 (EV_ABS), code 0 (ABS_X), value 1174
Event: time 1464027536.357047, type 3 (EV_ABS), code 1 (ABS_Y), value 2283
Event: time 1464027536.357047, -------------- EV_SYN ------------
Event: time 1464027536.365190, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0
Event: time 1464027536.365190, -------------- EV_SYN ------------
测试做不是查看任何 EV_KEY /BTN_TOUCH 事件。
我做了一些更多的研究,发现 ts_test 将看到 BTN_TOUCH 事件:
# TSLIB_TSDEVICE=/dev/input/touchscreen0 ts_test
1464048778.716232: 399 239 1
1464048778.724452: 399 239 1
1464048778.732621: 399 239 1
1464048778.740965: 399 238 1
1464048778.749177: 399 237 1
1464048778.757422: 399 236 0
我假设最后一列是 BTN_TOUCH 事件。
我也尝试过 xinput_calibrator
# xinput_calibrator
Calibrating EVDEV driver for "max11801_ts" id=6
current calibration values (from XInput): min_x=0, max_x=4095 and min_y=0, max_y=4095
左上方的十字线会出现,当我用笔触摸十字线时,光标移动到这个位置,但xinput_calibrator
没有得到点击事件。
Firefox 也有同样的问题,我无法点击/单击任何项目。
为什么 evtest 没有看到 BTN_TOUCH 事件?这是配置问题还是错误?
如何获取点击事件?