2 ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
5 Copyright (C) 2009 Bernhard Urban <lewurm@gmx.net>
6 Copyright (C) 2009 Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
8 # This code is licensed to you under the terms of the GNU GPL, version 2;
9 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
12 #include "../../core/core.h"
13 #include "../../core/usb.h"
14 #include "../../usbspec/usb11spec.h"
15 #include "../../../malloc.h"
16 #include "../../../string.h"
20 struct usb_driver hidkb = {
22 .probe = usb_hidkb_probe,
23 .check = usb_hidkb_check,
29 usb_register_driver(&hidkb);
33 void usb_hidkb_probe()
35 struct usb_device *dev;
36 struct element *iterator = core.devices->head;
38 while(iterator != NULL) {
39 dev = (struct usb_device*)iterator->data;
41 if(dev->conf->intf->bInterfaceClass == HID_CLASSCODE &&
42 dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */
43 dev->conf->intf->bInterfaceProtocol == 1) { /* keyboard? */
46 hidkb.data = (void*) dev;
49 iterator=iterator->next;
54 void usb_hidkb_check()
58 struct kbrep *usb_hidkb_getChars() {
59 struct usb_device *dev = (struct usb_device*) hidkb.data;
60 struct kbrep *ret = (struct kbrep*) malloc(sizeof(struct kbrep));
63 s8 epnum = dev->conf->intf->endp->bEndpointAddress & 0xf;
64 (void) usb_interrupt_read(dev, epnum, (u8*) ret, 8, 0);
65 printf("============\nusb_interrupt_read:\n");
66 hexdump((void*)ret, 8);