如何解决为旧键盘/隐藏设备编写 linux 内核模块/驱动程序
我有一个旧的 Compaq 键盘,上面有一组不起作用的键。
我尝试过 xev
、evtest
、evemu-record
和 libinput debug-events
,除这些键之外的所有其他键都被识别。
然而,当我打开一个wireshark USB录音机时,我得到了一些看起来像这样的输出:
0000 00 a8 6e e5 73 9c ff ff 42 01 82 0a 01 00 2d 00 ..o.s...C.....-.
0010 9e ab f1 5f 00 00 00 00 06 c6 03 00 00 00 00 00 ..._............
0020 06 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 ................
0030 02 00 00 00 00 00 00 00 04 02 00 00 00 00 00 00 ................
0040 04 00 00 00 00 00 ......
0000 00 a8 6e e5 73 9c ff ff 42 01 82 0a 01 00 2d 00 ..o.s...C.....-.
0010 a0 ab f1 5f 00 00 00 00 66 64 01 00 00 00 00 00 ..._....fd......
0020 06 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 ................
0030 02 00 00 00 00 00 00 00 04 02 00 00 00 00 00 00 ................
0040 04 00 00 10 00 00
这意味着密钥确实有效,我只需要为它编写一个驱动程序。
现在我在编写 linux 驱动程序方面的经验为零,但我查看了 github.com/torvalds/linux 的 linux/drivers/hid/
,特别是 hid-asus.c
,我知道我必须以某种方式识别每个击键十六进制值。
问题是我可以弄清楚在哪里看,因为只有十六进制转储的 0000
、0020
和 0030
行保持不变而 0010
不同每次我通过wireshark录制它。
我知道这可能是基本的,但你能指出我正确的方向吗,即提供一些我可以阅读的关于这个主题的内容,或者知道我应该如何进行?
来自 evtest
的输出:
/dev/input/event12: Compaq Compaq Internet Keyboard
/dev/input/event13: Compaq Compaq Internet Keyboard Consumer Control
/dev/input/event14: Compaq Compaq Internet Keyboard System Control
/dev/input/event15: Compaq Compaq Internet Keyboard
这是 lsusb
的输出:
Bus 001 Device 010: ID 049f:000e Compaq Computer Corp. Internet Keyboard
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x049f Compaq Computer Corp.
idProduct 0x000e Internet Keyboard
bcdDevice 1.00
iManufacturer 1 Compaq
iProduct 2 Compaq Internet Keyboard
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x003b
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 2 Compaq Internet Keyboard
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 50mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 3 Compaq Internet Keyboard
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 65
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 24
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 0
iInterface 4 Compaq Internet Keyboard
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 499
Report Descriptors:
** UNAVAILABLE **
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0006 1x 6 bytes
bInterval 3
Device Status: 0x0000
(Bus Powered)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。