我该如何纠正这个映射错误的触控笔按钮?

我该如何纠正这个映射错误的触控笔按钮?

我在 HP Spectre x360 上运行 Kubuntu 15.10,它的显示屏内置了非 Wacom 有源数字化仪。我使用双按钮触控笔,但第二个按钮不起作用。按下xinput按钮时,我无法显示任何状态变化;似乎 X 根本看不到它。确实evtest看到了一个事件,但它将按钮报告为BTN_TOOL_RUBBER而不是适当的BTN_STYLUS2

Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x4f3 product 0x2073 version 0x110
Input device name: "ELAN Touchscreen Pen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 256 (BTN_0)
    Event code 320 (BTN_TOOL_PEN)
    Event code 321 (BTN_TOOL_RUBBER)
    Event code 330 (BTN_TOUCH)
    Event code 331 (BTN_STYLUS)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value  23080
      Min        0
      Max    32256
      Resolution     110
    Event code 1 (ABS_Y)
      Value  10408
      Min        0
      Max    17920
      Resolution     108
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max      255
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1453608432.242049, type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value 1
Event: time 1453608432.242049, -------------- SYN_REPORT ------------

触控笔没有橡皮擦尖。input-kbd给了我扫描码并显示了同样的问题:

/dev/input/event8
   bustype : BUS_USB
   vendor  : 0x4f3
   product : 0x2073
   version : 272
   name    : "ELAN Touchscreen Pen"
   phys    : "usb-0000:00:14.0-4/input0"
   uniq    : ""
   bits ev : EV_SYN EV_KEY EV_ABS EV_MSC

map: 15 keys, size: 294/320
0xd0032 = 320  # BTN_TOOL_PEN
0xd0042 = 330  # BTN_TOUCH
0xd0044 = 331  # BTN_STYLUS
0xd003c = 321  # BTN_TOOL_RUBBER
0xd0045 = 256  # BTN_0
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH
0xd0042 = 330  # BTN_TOUCH

尝试使用input-kbd分配新地图时会出现“扫描代码超出范围”错误。直接使用setkeycodes d003c 332也不起作用(USB 键盘错误)。

更新:我尝试通过 udev 向 /etc/udev/hwdb.d 添加自定义 hwdb 文件来修复此问题,但似乎没有任何效果。

$ cat /etc/udev/hwdb.d/61-touchscreen-quirks.hwdb 
evdev:input:b0003v04f3p2073e0110*   # Matches ELAN Touchscreen devices
 KEYBOARD_KEY_d003c=14c             # Reassigns scancode from BTN_TOOL_RUBBER to BTN_STYLUS2

$ sudo udevadm --debug hwdb --update
calling: hwdb
reading file '/lib/udev/hwdb.d/20-OUI.hwdb'
reading file '/lib/udev/hwdb.d/20-acpi-vendor.hwdb'
reading file '/lib/udev/hwdb.d/20-bluetooth-vendor-product.hwdb'
reading file '/lib/udev/hwdb.d/20-libgphoto2-6.hwdb'
reading file '/lib/udev/hwdb.d/20-net-ifname.hwdb'
reading file '/lib/udev/hwdb.d/20-pci-classes.hwdb'
reading file '/lib/udev/hwdb.d/20-pci-vendor-model.hwdb'
reading file '/lib/udev/hwdb.d/20-sdio-classes.hwdb'
reading file '/lib/udev/hwdb.d/20-sdio-vendor-model.hwdb'
reading file '/lib/udev/hwdb.d/20-usb-classes.hwdb'
reading file '/lib/udev/hwdb.d/20-usb-media-players.hwdb'
reading file '/lib/udev/hwdb.d/20-usb-vendor-model.hwdb'
reading file '/lib/udev/hwdb.d/60-evdev.hwdb'
reading file '/lib/udev/hwdb.d/60-keyboard.hwdb'
reading file '/etc/udev/hwdb.d/61-touchscreen-quirks.hwdb'
reading file '/lib/udev/hwdb.d/69-libmtp.hwdb'
reading file '/lib/udev/hwdb.d/70-mouse.hwdb'
reading file '/lib/udev/hwdb.d/70-pointingstick.hwdb'
=== trie in-memory ===
nodes:             3899920 bytes (   97498)
children arrays:   1559952 bytes (   97497)
values arrays:     1241904 bytes (   77619)
strings:           1721567 bytes
strings incoming:  4005992 bytes (  240722)
strings dedup'ed:  2347672 bytes (  177476)
=== trie on-disk ===
size:              6863455 bytes
header:                 80 bytes
nodes:             2339952 bytes (   97498)
child pointers:    1559952 bytes (   97497)
value pointers:    1241904 bytes (   77619)
string store:      1721567 bytes
strings start:     5141888

$ sudo udevadm -d control --reload
calling: control

$ sudo udevadm -d trigger /dev/input/event*
calling: trigger

$ sudo udevadm info -q all -p /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/0003:04F3:2073.0004/input/input9
P: /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/0003:04F3:2073.0004/input/input9
E: ABS=1000003
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/0003:04F3:2073.0004/input/input9
E: EV=1b
E: ID_BUS=usb
E: ID_FOR_SEAT=input-pci-0000_00_14_0-usb-0_4_1_0
E: ID_INPUT=1
E: ID_INPUT_TABLET=1
E: ID_MODEL=Touchscreen
E: ID_MODEL_ENC=Touchscreen
E: ID_MODEL_ID=2073
E: ID_PATH=pci-0000:00:14.0-usb-0:4:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_4_1_0
E: ID_REVISION=5107
E: ID_SERIAL=ELAN_Touchscreen
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030000:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=ELAN
E: ID_VENDOR_ENC=ELAN
E: ID_VENDOR_ID=04f3
E: KEY=c03 1 0 0 0 0
E: MODALIAS=input:b0003v04F3p2073e0110-e0,1,3,4,k100,140,141,14A,14B,ra0,1,18,m4,lsfw
E: MSC=10
E: NAME="ELAN Touchscreen Pen"
E: PHYS="usb-0000:00:14.0-4/input0"
E: PRODUCT=3/4f3/2073/110
E: PROP=0
E: SUBSYSTEM=input
E: TAGS=:seat:
E: UNIQ=""
E: USEC_INITIALIZED=4595650

我在这里做错了什么,或者,有什么更好的方法可以做到这一点?

答案1

我终于能够BTN_STYLUS2使用重新映射扫描码ir-keytable。命令是:

sudo ir-keytable --device /dev/input/event8 --set-key 0xd003c=BTN_STYLUS2

但是,虽然我看到扫描码已成功重新绑定,但按钮仍然无效。evtest按下按钮时不再报告任何事件。

在此之前,按下该按钮时没有MSC_SCAN报告任何事件evtest,但其他按钮和笔触摸都报告了扫描码。当时我觉得这不过是个奇怪的怪癖,但现在看来该按钮确实没有生成扫描码。那么,它是如何evtest报告键码事件的呢?这真难倒我了,现在我把它归咎于内核错误。

最后,我只是拼凑了一个 bash 脚本来监视evtest事件BTN_TOOL_RUBBER并模拟右键单击xdotool

#!/bin/bash

# Find the input device number.
devicename="ELAN Touchscreen Pen"
numevents=$(ls /dev/input | grep -c event*)
for ((devnr=0;devnr<$numevents;devnr++)); do
    input-kbd $devnr | grep -q "$devicename"
    if [[ $? == 0 ]]; then
        break
    fi
done

# Listen for BTN_TOOL_RUBBER events.
evtest /dev/input/event$devnr | while read line; do
for value in {0..1}; do
    echo $line | grep -q "type 1 (EV_KEY), code 321 (BTN_TOOL_RUBBER), value $value"
    if [[ $? == 0 ]]; then
        case $value in
            0)  xdotool mouseup 3   ;;
            1)  xdotool mousedown 3 ;;
        esac
    fi
done
done

无论如何,这基本上给了我想要的基本功能。它并不完美:鼠标释放事件仅在笔离开接近度时发生,而不是在按钮释放时发生(这是BTN_TOOL_RUBBER在 中报告键盘释放事件的时候evtest),但它工作得很好,所以我不会尝试调试内核。

答案2

我的 Surface Pro 3 也遇到了同样的问题,并通过以下方式解决:

https://forums.linuxmint.com/viewtopic.php?f=59&t=312005&p=1762496#p1762496

在设备列出后xsetwacom list device,您可以轻松地重新映射按钮xsetwacom

答案3

这个是一年前的文件,但我想说的是,你的hwdb文件几乎是正确的。但是:

  1. 右边必须是十进制,而不是十六进制,所以使用332not 14c
  2. 左侧来自evtestnot input-kbd(不要问,因为我真的不知道)。具体来说,它来自紧接在事件(或错误映射的键)之前的行value中的字段。MSC_SCANBTN_TOOL_RUBBER

就我的情况来说:

type 4 (EV_MSC), code 4 (MSC_SCAN), value d0045

所以我的完整hwdb文件是:

evdev:input:b0003v04F3p21D0*
  KEYBOARD_KEY_d0045=332
  1. sudo udevadm hwdb --update
  2. sudo udevadm trigger /dev/input/event*
  3. 重启。

相关内容