未拾取图形输入板键码

未拾取图形输入板键码

我目前正在尝试将我的图形输入板上的按钮作为键码选取。由于更多程序支持键盘快捷键而不是额外的鼠标按钮(例如,Krita 似乎只支持左键单击和右键单击),因此我希望能够将平板电脑按钮视为键码,以便我可以在不同的程序中为它们分配快捷键。

到目前为止我做了什么

我创建了一个 udev hwdb 文件 ( /etc/udev/hwdb.d/90-huion.hwdb) 以将平板电脑的扫描代码映射到键代码。

我的 hwdb 文件如下所示:

evdev:input:b0003v256Cp006Ee0111*
 KEYBOARD_KEY_90001=a
 KEYBOARD_KEY_90002=a
 KEYBOARD_KEY_90003=a
 KEYBOARD_KEY_90004=a
 KEYBOARD_KEY_90005=a
 KEYBOARD_KEY_90006=a
 KEYBOARD_KEY_90007=a
 KEYBOARD_KEY_90008=a
 KEYBOARD_KEY_90009=a
 KEYBOARD_KEY_9000a=a
 MANUAL_OVERRIDE=1

搜索部分使用了我在此处找到的 event23 的值:

cat /sys/class/input/event23/device/id/bustype
> 0003
cat /sys/class/input/event23/device/id/product
> 006e
cat /sys/class/input/event23/device/id/vendor
> 256c
cat /sys/class/input/event23/device/id/version
> 0111

我无法根据设备名称进行映射,因为它有一个冒号 (HID 256c:006e Pad),而且我认为该名称与使用冒号作为分隔符的 hwdb 文件不能很好地配合。

我已将其加载hwdb.bin并重新加载并(重新)触发了 udev 规则

sudo systemd-hwdb update
sudo udevadmin trigger
sudo udevadm control --reload

我也尝试过用旧版本更新 hwdb,sudo udevadm hwdb --update没有任何区别。我还尝试过拔下并重新插入平板电脑。

使用udevadm info我可以看到我的文件正在使用(因此该MANUAL_OVERRIDE=1部分不执行任何操作)。 udevadm info输出:

P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1.1/1-2.1.1:1.0/0003:256C:006E.0004/input/input23/event23
N: input/event23
L: 0
S: input/by-id/usb-256c_006e-event-mouse
S: input/by-path/pci-0000:00:14.0-usb-0:2.1.1:1.0-event-mouse
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1.1/1-2.1.1:1.0/0003:256C:006E.0004/input/input23/event23
E: DEVNAME=/dev/input/event23
E: MAJOR=13
E: MINOR=87
E: SUBSYSTEM=input
E: USEC_INITIALIZED=5852671
E: KEYBOARD_KEY_90001=a
E: KEYBOARD_KEY_90002=a
E: KEYBOARD_KEY_90003=a
E: KEYBOARD_KEY_90004=a
E: KEYBOARD_KEY_90005=a
E: KEYBOARD_KEY_90006=a
E: KEYBOARD_KEY_90007=a
E: KEYBOARD_KEY_90008=a
E: KEYBOARD_KEY_90009=a
E: KEYBOARD_KEY_9000a=a
E: MANUAL_OVERRIDE=1
E: ID_INPUT=1
E: ID_INPUT_TABLET=1
E: ID_INPUT_KEY=1
E: ID_VENDOR=256c
E: ID_VENDOR_ENC=256c
E: ID_VENDOR_ID=256c
E: ID_MODEL=006e
E: ID_MODEL_ENC=006e
E: ID_MODEL_ID=006e
E: ID_REVISION=3000
E: ID_SERIAL=256c_006e
E: ID_TYPE=hid
E: ID_BUS=usb
E: ID_USB_INTERFACES=:030102:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usbhid
E: ID_PATH=pci-0000:00:14.0-usb-0:2.1.1:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_1_1_1_0
E: ID_INPUT_TABLET_PAD=1
E: LIBINPUT_DEVICE_GROUP=3/256c/6e:usb-0000:00:14.0-2.1
E: DEVLINKS=/dev/input/by-id/usb-256c_006e-event-mouse /dev/input/by-path/pci-0000:00:14.0-usb-0:2.1.1:1.0-event-mouse
E: TAGS=:power-switch:aaaaaaaaaa

调试

测试

据我所知,这应该是映射平板电脑按钮所需的全部内容,甚至看起来(大部分)有希望evtest

Testing ... (interrupt to exit)
Event: time 1589801905.094479, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1589801905.094479, type 1 (EV_KEY), code 30 (KEY_A), value 1
Event: time 1589801905.094479, -------------- SYN_REPORT ------------
Event: time 1589801905.252456, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1589801905.252456, type 1 (EV_KEY), code 30 (KEY_A), value 0
Event: time 1589801905.252456, -------------- SYN_REPORT ------------
Event: time 1589801906.960440, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1589801906.960440, type 1 (EV_KEY), code 30 (KEY_A), value 1
...
Event: time 1589801913.582373, -------------- SYN_REPORT ------------
Event: time 1589801913.936376, type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000a
Event: time 1589801913.936376, type 1 (EV_KEY), code 30 (KEY_A), value 1
Event: time 1589801913.936376, -------------- SYN_REPORT ------------
Event: time 1589801914.086370, type 4 (EV_MSC), code 4 (MSC_SCAN), value 9000a
Event: time 1589801914.086370, type 1 (EV_KEY), code 30 (KEY_A), value 0
Event: time 1589801914.086370, -------------- SYN_REPORT ------------
Event: time 1589801914.992371, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1589801914.992371, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
Event: time 1589801914.992371, -------------- SYN_REPORT ------------
Event: time 1589801915.154366, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1589801915.154366, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 0
Event: time 1589801915.154366, -------------- SYN_REPORT ------------
Event: time 1589801915.358379, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1589801915.358379, type 1 (EV_KEY), code 305 (BTN_EAST), value 1
Event: time 1589801915.358379, -------------- SYN_REPORT ------------
Event: time 1589801915.446357, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1589801915.446357, type 1 (EV_KEY), code 305 (BTN_EAST), value 0
Event: time 1589801915.446357, -------------- SYN_REPORT ------------

除了最后两个按钮(BTN_SOUTH 和 BTN_EAST)似乎没有被映射(可能是因为它们具有与映射的按钮相同的扫描码)之外,所有其他按钮都正确报告code 30 (KEY_A)(如果您知道为什么这些按钮)我很想知道两个按钮没有映射,但这不是我现在想要关注的问题)。

谢夫

仅使用xev似乎未正确映射的两个按钮,以下是xev这两个按钮的控制台输出:

ButtonPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 8912753, (1,806), root:(971,821),
    state 0x0, button 15, same_screen YES

ButtonRelease event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 8912953, (1,806), root:(971,821),
    state 0x0, button 15, same_screen YES

ButtonPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 8913377, (1,806), root:(971,821),
    state 0x0, button 16, same_screen YES

ButtonRelease event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 8913581, (1,806), root:(971,821),
    state 0x0, button 16, same_screen YES

在进行 hwdb 更改之前,按钮被选取为按钮 1-3 和 8-16(未映射的按钮 15 和 16 在 的输出中分别是按钮 BTN_SOUTH 和 BTN_EAST evtest),但现在xev看不到其中的大多数(仅未映射的 15 和 16)。

消息

使用sudo dmesg --follow我没有看到任何看起来像未知按键的事件。

埃维梅努

evemu-describehwdb 更改之前的输出:

# EVEMU 1.3
# Kernel: 5.7.0-1-MANJARO
# DMI: dmi:bvnAmericanMegatrendsInc.:bvr1205:bd05/11/2018:svnSystemmanufacturer:pnSystemProductName:pvrSystemVersion:rvnASUSTeKCOMPUTERINC.:rnPRIMEZ270-P:rvrRevX.0x:cvnDefaultstring:ct3:cvrDefaultstring:
# Input device name: "HID 256c:006e Pad"
# Input device ID: bus 0x03 vendor 0x256c product 0x6e version 0x111
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#     Event code 15 (SYN_MAX)
#   Event type 1 (EV_KEY)
#     Event code 256 (BTN_0)
#     Event code 257 (BTN_1)
#     Event code 258 (BTN_2)
#     Event code 259 (BTN_3)
#     Event code 260 (BTN_4)
#     Event code 261 (BTN_5)
#     Event code 262 (BTN_6)
#     Event code 263 (BTN_7)
#     Event code 264 (BTN_8)
#     Event code 265 (BTN_9)
#     Event code 304 (BTN_SOUTH)
#     Event code 305 (BTN_EAST)
#     Event code 306 (BTN_C)
#     Event code 331 (BTN_STYLUS)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value        0
#       Min          0
#       Max          1
#       Fuzz         0
#       Flat         0
#       Resolution   0
#     Event code 1 (ABS_Y)
#       Value        0
#       Min          0
#       Max          1
#       Fuzz         0
#       Flat         0
#       Resolution   0
#   Event type 4 (EV_MSC)
#     Event code 4 (MSC_SCAN)
# Properties:
N: HID 256c:006e Pad
I: 0003 256c 006e 0111
...

之后:

# EVEMU 1.3
# Kernel: 5.7.0-1-MANJARO
# DMI: dmi:bvnAmericanMegatrendsInc.:bvr1205:bd05/11/2018:svnSystemmanufacturer:pnSystemProductName:pvrSystemVersion:rvnASUSTeKCOMPUTERINC.:rnPRIMEZ270-P:rvrRevX.0x:cvnDefaultstring:ct3:cvrDefaultstring:
# Input device name: "HID 256c:006e Pad"
# Input device ID: bus 0x03 vendor 0x256c product 0x6e version 0x111
# Supported events:
#   Event type 0 (EV_SYN)
#     Event code 0 (SYN_REPORT)
#     Event code 1 (SYN_CONFIG)
#     Event code 2 (SYN_MT_REPORT)
#     Event code 3 (SYN_DROPPED)
#     Event code 4 ((null))
#     Event code 5 ((null))
#     Event code 6 ((null))
#     Event code 7 ((null))
#     Event code 8 ((null))
#     Event code 9 ((null))
#     Event code 10 ((null))
#     Event code 11 ((null))
#     Event code 12 ((null))
#     Event code 13 ((null))
#     Event code 14 ((null))
#     Event code 15 (SYN_MAX)
#   Event type 1 (EV_KEY)
#     Event code 30 (KEY_A)
#     Event code 256 (BTN_0)
#     Event code 304 (BTN_SOUTH)
#     Event code 305 (BTN_EAST)
#     Event code 306 (BTN_C)
#     Event code 331 (BTN_STYLUS)
#   Event type 3 (EV_ABS)
#     Event code 0 (ABS_X)
#       Value        0
#       Min          0
#       Max          1
#       Fuzz         0
#       Flat         0
#       Resolution   0
#     Event code 1 (ABS_Y)
#       Value        0
#       Min          0
#       Max          1
#       Fuzz         0
#       Flat         0
#       Resolution   0
#   Event type 4 (EV_MSC)
#     Event code 4 (MSC_SCAN)
# Properties:
N: HID 256c:006e Pad
I: 0003 256c 006e 0111
...

尝试不同的设备

为了检查我是否做错了什么,我用 USB 鼠标尝试了非常类似的操作(我没有映射扫描代码 90001,因为这是左键单击)。我的鼠标被拿起xev,当我右键单击或滚动时,我得到了我所期望的字母“a”(因此,如果您在问题中看到任何杂散字母 a,这就是原因)。我比较了xev键盘和鼠标的输出:

带键盘的 Xev(无映射)
KeyPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 4209087, (-1,721), root:(969,736),
    state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 4209151, (-1,721), root:(969,736),
    state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False
Xev 与鼠标(按钮映射到“a”)
MappingNotify event, serial 34, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248

KeyPress event, serial 34, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 4211519, (-1,721), root:(969,736),
    state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XmbLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x3a00001,
    root 0x6bd, subw 0x0, time 4211679, (-1,721), root:(969,736),
    state 0x0, keycode 38 (keysym 0x61, a), same_screen YES,
    XLookupString gives 1 bytes: (61) "a"
    XFilterEvent returns: False

装置

有问题的平板电脑是我安装的“Huion New 1060Plus”,digimend-kernel-drivers-dkms-git我认为我的平板电脑正在使用 evdev 驱动程序(我没有安装替代的 wacom 驱动程序xf86-input-wacom,但我已经libwacom安装了,因为它由libinput和使用gnome-settings-daemon)。除了按钮的问题之外,平板电脑工作正常,包括笔压。

使用的指南

我主要遵循以下来源的指南:

相关内容