1 #include "../../core/core.h"
2 #include "../../core/usb.h"
3 #include "../../usbspec/usb11spec.h"
4 #include "../../../malloc.h"
5 #include "../../../string.h"
9 struct usb_driver hidkb = {
11 .probe = usb_hidkb_probe,
12 .check = usb_hidkb_check,
18 usb_register_driver(&hidkb);
22 void usb_hidkb_probe()
24 struct usb_device *dev;
25 struct element *iterator = core.devices->head;
27 while(iterator != NULL) {
28 dev = (struct usb_device*)iterator->data;
30 if(dev->conf->intf->bInterfaceClass == HID_CLASSCODE &&
31 dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */
32 dev->conf->intf->bInterfaceProtocol == 1) { /* keyboard? */
35 hidkb.data = (void*) dev;
38 iterator=iterator->next;
43 void usb_hidkb_check()
47 struct kbrep *usb_hidkb_getChars() {
48 struct usb_device *dev = (struct usb_device*) hidkb.data;
49 struct kbrep *ret = (struct kbrep*) malloc(sizeof(struct kbrep));
52 s8 epnum = dev->conf->intf->endp->bEndpointAddress & 0xf;
53 (void) usb_interrupt_read(dev, epnum, (u8*) ret, 8, 0);
54 printf("============\nusb_interrupt_read:\n");
55 hexdump((void*)ret, 8);