writing a linux kernel module / driver for an old keyboard / hid device

667 Views Asked by At

I have an old Compaq keyboard that has a set of keys on top that do not work.

I have tried xev, evtest, evemu-record and libinput debug-events and every other key except those keys is recognized.

However when I turn on a wireshark usb recorder I get some output that looks like this:

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 

That means that the keys indeed work and I just need a to write a driver for it.

Now I have zero experience in writing linux driver but I took a look from linux/drivers/hid/ at github.com/torvalds/linux, specifically hid-asus.c and I know that I have to somehow identify each key stroke with respective hex value.

The problem is that I can figure out where to look since only the 0000, 0020 and 0030 lines of a hex dump stay the same and 0010 is different every time I record it trough wireshark.

I know this is maybe basic but can you point me in the right direction i.e. give some content I can read on on this subject or have any idea how I should proceed?

Output from 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

Here is the output from 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) 
0

There are 0 best solutions below