will boot sysmenu when press reset button and again license stuff
[ppcskel.git] / usb / drivers / class / hid.c
1 /*
2         ppcskel - a Free Software replacement for the Nintendo/BroadOn bootloader.
3         hid driver
4
5 Copyright (C) 2009     Bernhard Urban <lewurm@gmx.net>
6 Copyright (C) 2009     Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
7
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
10 */
11
12 #include "../../core/core.h"
13 #include "../../core/usb.h"
14 #include "../../usbspec/usb11spec.h"
15 #include "../../../malloc.h"
16 #include "../../../string.h"
17
18 #include "hid.h"
19
20 struct usb_driver hidkb = {
21         .name     = "hidkb",
22         .probe  = usb_hidkb_probe,
23         .check  = usb_hidkb_check,
24         .data     = NULL
25 };
26
27 void usb_hidkb_init()
28 {
29         usb_register_driver(&hidkb);
30 }
31
32 void usb_hidkb_probe()
33 {
34         struct usb_device *dev;
35         struct element *iterator = core.devices->head;
36         
37         while(iterator != NULL) {
38                 dev = (struct usb_device*)iterator->data;
39
40                 if(dev->conf->intf->bInterfaceClass == HID_CLASSCODE &&
41                                 dev->conf->intf->bInterfaceSubClass == 1 && /* keyboard support boot protocol? */
42                                 dev->conf->intf->bInterfaceProtocol == 1) { /* keyboard? */
43                         hidkb.data = (void*) dev;
44                 }
45
46                 iterator=iterator->next;
47         }
48 }
49
50 void usb_hidkb_check()
51 {
52 }
53
54 struct kbrep *usb_hidkb_getChars() {
55         struct usb_device *dev = (struct usb_device*) hidkb.data;
56         struct kbrep *ret = (struct kbrep*) malloc(sizeof(struct kbrep));
57
58         memset(ret, 0, 8);
59         s8 epnum = dev->conf->intf->endp->bEndpointAddress & 0xf;
60         (void) usb_interrupt_read(dev, epnum, (u8*) ret, 8, 0);
61         printf("============\nusb_interrupt_read:\n");
62         hexdump((void*)ret, 8);
63
64         return ret;
65 }
66