我的 RF 无线键盘在每次按键/释放按键后不断向系统发送 XF86Forward KeyPress 和 KeyRelease 事件

我的 RF 无线键盘在每次按键/释放按键后不断向系统发送 XF86Forward KeyPress 和 KeyRelease 事件

一次跌倒后,我的 RF 无线键盘在每次按下/释放按键后都会不断向系统发送 XF86Forward KeyPress 和 KeyRelease 事件:

$ xev -event keyboard | egrep -w "KeyPress|KeyRelease|keycode"
KeyRelease event, serial 34, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    state 0x10, keycode 24 (keysym 0x61, a), same_screen YES,
KeyPress event, serial 37, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyRelease event, serial 38, synthetic NO, window 0x3c00001,
    state 0x10, keycode 24 (keysym 0x61, a), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyPress event, serial 311, synthetic NO, window 0x3c00001,
    state 0x10, keycode 56 (keysym 0x62, b), same_screen YES,
KeyPress event, serial 312, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyRelease event, serial 312, synthetic NO, window 0x3c00001,
    state 0x10, keycode 56 (keysym 0x62, b), same_screen YES,
KeyRelease event, serial 313, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyPress event, serial 313, synthetic NO, window 0x3c00001,
    state 0x10, keycode 54 (keysym 0x63, c), same_screen YES,
KeyPress event, serial 313, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyRelease event, serial 314, synthetic NO, window 0x3c00001,
    state 0x10, keycode 54 (keysym 0x63, c), same_screen YES,
KeyRelease event, serial 315, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyPress event, serial 315, synthetic NO, window 0x3c00001,
    state 0x10, keycode 40 (keysym 0x64, d), same_screen YES,
KeyPress event, serial 315, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
KeyRelease event, serial 316, synthetic NO, window 0x3c00001,
    state 0x10, keycode 40 (keysym 0x64, d), same_screen YES,
KeyRelease event, serial 317, synthetic NO, window 0x3c00001,
    state 0x10, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,

因此,我无法登录到 tty[1-6] 控制台,因为我输入的每个字符都会^@附加一个字符:

$ showkey -k
 kb mode was UNICODE
 [ if you are trying this under X, it might not work
 since the X server is also reading /dev/console ]

 press any key (program terminates 10s after last keypress)...
 keycode  28 release
 keycode  16 press
 keycode 159 press
 keycode  16 release
 keycode 159 release
 keycode  48 press
 keycode 159 press
 keycode  48 release
 keycode 159 release
 keycode  46 press
 keycode 159 press
 keycode  46 release
 keycode 159 release
 keycode  32 press
 keycode 159 press
 keycode  32 release
 keycode 159 release

EDIT0:据我说,我的 RAPOO 无线键盘+鼠标组合/proc/bus/input/devices有 2 个条目:/dev/input/eventX

$ cat /proc/bus/input/devices  | grep -P '^[NH]: ' | paste - - | grep RAPOO
N: Name="RAPOO RAPOO 5G Wireless Device"    H: Handlers=sysrq kbd event2 leds 
N: Name="RAPOO RAPOO 5G Wireless Device"    H: Handlers=kbd mouse0 event3 

看起来很合乎逻辑,因为鼠标使用与键盘相同的 RF 通道来与 USB 微型接收器通信。

EDIT1:根据上面的处理程序值/dev/input/event2似乎仅从键盘接收事件。这是evtest的输出/dev/input/event2

$ sudo evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x24ae product 0x2003 version 0x110
Input device name: "RAPOO RAPOO 5G Wireless Device"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
...
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 17 (EV_LED)
    Event code 0 (LED_NUML) state 0
    Event code 1 (LED_CAPSL) state 0
    Event code 2 (LED_SCROLLL) state 0
    Event code 3 (LED_COMPOSE) state 0
    Event code 4 (LED_KANA) state 0
Key repeat handling:
  Repeat type 20 (EV_REP)
    Repeat code 0 (REP_DELAY)
      Value    250
    Repeat code 1 (REP_PERIOD)
      Value     33
Properties:
Testing ... (interrupt to exit)
Event: time 1625417787.379951, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70058
Event: time 1625417787.379951, type 1 (EV_KEY), code 96 (KEY_KPENTER), value 0
Event: time 1625417787.379951, -------------- SYN_REPORT ------------
Event: time 1625417794.923958, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1625417794.923958, type 1 (EV_KEY), code 30 (KEY_A), value 1
Event: time 1625417794.923958, -------------- SYN_REPORT ------------
qEvent: time 1625417795.051954, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1625417795.051954, type 1 (EV_KEY), code 30 (KEY_A), value 0
Event: time 1625417795.051954, -------------- SYN_REPORT ------------
Event: time 1625417797.083970, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70005
Event: time 1625417797.083970, type 1 (EV_KEY), code 48 (KEY_B), value 1
Event: time 1625417797.083970, -------------- SYN_REPORT ------------
bEvent: time 1625417797.187973, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70005
Event: time 1625417797.187973, type 1 (EV_KEY), code 48 (KEY_B), value 0
Event: time 1625417797.187973, -------------- SYN_REPORT ------------
Event: time 1625417798.363970, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70006
Event: time 1625417798.363970, type 1 (EV_KEY), code 46 (KEY_C), value 1
Event: time 1625417798.363970, -------------- SYN_REPORT ------------
cEvent: time 1625417798.459960, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70006
Event: time 1625417798.459960, type 1 (EV_KEY), code 46 (KEY_C), value 0
Event: time 1625417798.459960, -------------- SYN_REPORT ------------
Event: time 1625417799.195958, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70007
Event: time 1625417799.195958, type 1 (EV_KEY), code 32 (KEY_D), value 1
Event: time 1625417799.195958, -------------- SYN_REPORT ------------
dEvent: time 1625417799.259976, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70007
Event: time 1625417799.259976, type 1 (EV_KEY), code 32 (KEY_D), value 0
Event: time 1625417799.259976, -------------- SYN_REPORT ------------
Event: time 1625417801.379970, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1625417801.379970, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1625417801.379970, -------------- SYN_REPORT ------------
Event: time 1625417801.587964, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70006
Event: time 1625417801.587964, type 1 (EV_KEY), code 46 (KEY_C), value 1
Event: time 1625417801.587964, -------------- SYN_REPORT ------------

EDIT2:而/dev/input/event3似乎从键盘和鼠标接收事件。这是(注意每次按键和释放按键后的事件)evtest的输出:/dev/input/event3KEY_FORWARD

$ sudo evtest /dev/input/event3
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x24ae product 0x2003 version 0x110
Input device name: "RAPOO RAPOO 5G Wireless Device"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    ...
  Event type 3 (EV_ABS)
    Event code 32 (ABS_VOLUME)
      Value      0
      Min        0
      Max      896
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1625418203.492208, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418203.492208, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1625418203.492208, -------------- SYN_REPORT ------------
Event: time 1625418205.620275, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418205.620275, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 1
Event: time 1625418205.620275, -------------- SYN_REPORT ------------
aEvent: time 1625418205.908189, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418205.908189, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1625418205.908189, -------------- SYN_REPORT ------------
Event: time 1625418207.076271, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418207.076271, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 1
Event: time 1625418207.076271, -------------- SYN_REPORT ------------
bEvent: time 1625418207.348222, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418207.348222, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1625418207.348222, -------------- SYN_REPORT ------------
Event: time 1625418208.356296, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418208.356296, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 1
Event: time 1625418208.356296, -------------- SYN_REPORT ------------
cEvent: time 1625418208.660204, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418208.660204, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1625418208.660204, -------------- SYN_REPORT ------------
Event: time 1625418209.636254, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418209.636254, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 1
Event: time 1625418209.636254, -------------- SYN_REPORT ------------
dEvent: time 1625418209.924202, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1625418209.924202, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1625418209.924202, -------------- SYN_REPORT ------------
Event: time 1625418211.564204, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1625418211.564204, type 1 (EV_KEY), code 272 (BTN_LEFT), value 1
Event: time 1625418211.564204, -------------- SYN_REPORT ------------
Event: time 1625418211.620212, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90001
Event: time 1625418211.620212, type 1 (EV_KEY), code 272 (BTN_LEFT), value 0
Event: time 1625418211.620212, -------------- SYN_REPORT ------------
Event: time 1625418216.572202, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1625418216.572202, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 1
Event: time 1625418216.572202, -------------- SYN_REPORT ------------
Event: time 1625418216.644212, type 4 (EV_MSC), code 4 (MSC_SCAN), value 90002
Event: time 1625418216.644212, type 1 (EV_KEY), code 273 (BTN_RIGHT), value 0
Event: time 1625418216.644212, -------------- SYN_REPORT ------------
Event: time 1625418218.780207, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 1625418218.780207, -------------- SYN_REPORT ------------
Event: time 1625418218.788214, type 2 (EV_REL), code 0 (REL_X), value -1
Event: time 1625418218.788214, -------------- SYN_REPORT ------------
^C

EDIT3:sudo timeout 5s evtest --grab /dev/input/eventX可以工作,但是 pb.就是它 :

/dev/input/event2只接收所有EV_KEY键盘事件,没有额外的KEY_FORWARD EV_KEY事件,也没有鼠标事件。并且/dev/input/event3似乎只接收鼠标事件和KEY_FORWARD EV_KEY键盘事件(没有其他EV_KEY事件)。

所以,我只使用/dev/input/event2,鼠标将无法工作,如果我仅使用/dev/input/event3,键盘将无法工作。

udevadm info确认/dev/input/event2用于键盘事件并/dev/input/event3用于鼠标事件:

$ udevadm info /dev/input/event2 | grep event-
S: input/by-id/usb-RAPOO_RAPOO_5G_Wireless_Device-event-kbd
S: input/by-path/pci-0000:00:1d.3-usb-0:1:1.0-event-kbd
E: DEVLINKS=/dev/input/by-id/usb-RAPOO_RAPOO_5G_Wireless_Device-event-kbd /dev/input/by-path/pci-0000:00:1d.3-usb-0:1:1.0-event-kbd
$ udevadm info /dev/input/event3 | grep event-
S: input/by-id/usb-RAPOO_RAPOO_5G_Wireless_Device-if01-event-mouse
S: input/by-path/pci-0000:00:1d.3-usb-0:1:1.1-event-mouse
E: DEVLINKS=/dev/input/by-path/pci-0000:00:1d.3-usb-0:1:1.1-event-mouse /dev/input/by-id/usb-RAPOO_RAPOO_5G_Wireless_Device-if01-event-mouse

如何阻止 RF 键盘发送 XF86Forward KeyPress 和 KeyRelease 事件?

答案1

好吧,我们总结一下:

第一步是使用evtest并查看内核输入层是否也发生这种情况。此外,射频键盘有时有多个与之关联的输入设备(evtest在所有输入设备上使用进行验证),因此,如果碰巧XF86Forward来自与实际按键不同的设备,则忽略该设备将是一个简单的解决方案。

事实证明,确实有两个设备。

下一步是evtest --grab在键+鼠标设备上使用,使事件专门发送到 evtest,这样它们就不会由 X 或 VT 处理。对于 VT,这可能有点棘手,因为我不知道切换 VT 是否会保持抓取。还要看看/dev/input/by-*如何在启动时正确识别设备。如果这有效,您可以尝试启动

evtest --grab /dev/input/... > /dev/null

或在启动过程中类似。

这不是一个选项,因为鼠标显然是键盘的一部分(或使用相同的射频通道?)也是需要的。

如果这仅适用于 X,则可以尝试仅将“鼠标”输入设备用作鼠标而不是键盘。但当您也想使用 VT 时,这不是一个选择。

因此,唯一剩下的就是编写一个自定义过滤器来删除XF86Forward事件,同时让鼠标事件通过。不久前有一个问题我简要地描述怎么做。您仍然需要能够使用具有uinput.

相关内容