I am trying to write a modified/custom USB keyboard driver. I'm having an issue with the irq handler not receiving key presses as expect.
What I've done:
- Made a copy of
/linux/driver/hid/usbhid/usbkbd.c
link and modifiedusb_kbd_id_table
to have only the vendor id and product id associated with my keyboard. - Built the modified driver.
- Inserted the modified driver with
sudo insmod usbkbd.ko
. - Prevented the keyboard from being associated with the standard HID driver by adding
usbhid:quirks=0x03eb:0x20ff:0x4
to/etc/default/grub
.
Behavior:
- Upon plugging in the keyboard, it is correctly associated with my driver. I know this because I see a
printk
statement that I added inusb_kbd_probe
show up in/var/log/syslog
. It actually shows up twice because the device has 2 interfaces. - The function
usb_kbd_irq
is repeatedly called in a loop. I have added aprintk
here as well and I see thatkbd->new
always has0
in every byte. - This loop continues rapidly and pressing any of the keys has no effect (
kbd->new
always has0
in every byte regardless of keys pressed).
I have tried using wireshark to view the usb trafic and I see that the host and device are going back and forth. I was expecting one way traffic. wireshark screenshot
I am confused about why the key presses have no effect. Shouldn't I see some data in kbd->new
if a key has been pressed?
Edit: Screen shot with device info at https://i.stack.imgur.com/lNq4e.png