用evtest检测
sudo evtest
查看设备列表:
/dev/input/event0: Lid Switch
/dev/input/event1: Power Button
/dev/input/event2: Sleep Button
/dev/input/event3: Power Button
/dev/input/event4: AT Translated Set 2 keyboard
/dev/input/event5: Video Bus
/dev/input/event6: USB Optical Mouse
/dev/input/event7: AlpsPS/2 ALPS DualPoint Stick
/dev/input/event8: AlpsPS/2 ALPS DualPoint TouchPad
/dev/input/event9: Logitech USB Receiver
/dev/input/event10: Logitech USB Receiver
/dev/input/event11: HDA Intel PCH Dock Mic
/dev/input/event12: HDA Intel PCH Headset Mic
/dev/input/event13: HDA Intel PCH Dock Line Out
/dev/input/event14: HDA Intel PCH Headphone
/dev/input/event15: HDA Intel PCH HDMI/DP,pcm=3
/dev/input/event16: HDA Intel PCH HDMI/DP,pcm=7
/dev/input/event17: HDA Intel PCH HDMI/DP,pcm=8
/dev/input/event18: Integrated Webcam
/dev/input/event19: Dell WMI hotkeys
Select the device event number [0-19]: 9
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x46d product 0xc52d version 0x111
Input device name: "Logitech USB Receiver"
拿到第一个“ Logitech USB接收器”,它的事件ID为9。
Testing ... (interrupt to exit)
确定,现在evtest想要输入,只需单击Logitech远程按钮,即可得到此信息(简化):
[>] value 7003e (KEY_PRESENTATION)
[>] value 70029 (KEY_PRESENTATION)
[ ] value 70037 (KEY_DISPLAYTOGGLE)
< value 7004b (KEY_PAGEUP)
> value 7004e (KEY_PAGEDOWN)
注意:我发现多次单击[>]后给出7003e,然后是70029,然后是7003e,依此类推。我不知道为什么。
修改udev conf
现在我们有了输入代码,让我们看看udev conf:
sudo gedit /lib/udev/hwdb.d/60-keyboard.hwdb
搜索“ R400”,并用所需的内容,播放暂停和停止箭头键替换演示文稿和显示切换:
# Logitech Presenter R400
evdev:input:b0003v046DpC52D*
KEYBOARD_KEY_070029=playpause # bottom left [>] was "presentation"
KEYBOARD_KEY_07003e=playpause # bottom left [>] was "presentation"
KEYBOARD_KEY_070037=stopcd # bottom right [ ] was "displaytoggle"
如前所述,由于07003e和070029是相同的按钮,因此我为它们提供了相同的向上输出键。7004b和7004e默认情况下未出现在此处,可能是因为它们是本机PAGEUP和PAGEDOWN输入,并且与“ Logitech Presenter R400”无关。让我们添加它们:
KEYBOARD_KEY_07004b=previoussong # top left <
KEYBOARD_KEY_07004e=nextsong # top right >
这是我最后的conf:
KEYBOARD_KEY_07004b=previoussong # top left <
KEYBOARD_KEY_07004e=nextsong # top right >
KEYBOARD_KEY_070029=playpause # bottom left [>] was "presentation"
KEYBOARD_KEY_07003e=playpause # bottom left [>] was "presentation"
KEYBOARD_KEY_070037=stopcd # bottom right [ ] was "displaytoggle"
重新加载(新)规则
sudo udevadm hwdb --update
然后,使用我们之前选择的相同事件ID,这里是事件ID 9:
sudo udevadm trigger /dev/input/event9
您可以在网络浏览器中检查此新映射,例如:
$('body').on('keydown', function(e){ console.log(e.key) })
那给了我:
[>] ArrowUp
[ ] ArrowDown
< ArrowLeft
> ArrowRight