LibXenon
Bare-metal Xbox 360 homebrew library
Loading...
Searching...
No Matches
usbhid.c
Go to the documentation of this file.
1/* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * USB Human Interface Driver File: usbhid.c
5 *
6 * This module deals with keyboards, mice, etc. It's very simple,
7 * and only the "boot protocol" is supported.
8 *
9 * Author: Mitch Lichtenberg
10 *
11 *********************************************************************
12 *
13 * Copyright 2000,2001,2002,2003,2005
14 * Broadcom Corporation. All rights reserved.
15 *
16 * This software is furnished under license and may be used and
17 * copied only in accordance with the following terms and
18 * conditions. Subject to these conditions, you may download,
19 * copy, install, use, modify and distribute modified or unmodified
20 * copies of this software in source and/or binary form. No title
21 * or ownership is transferred hereby.
22 *
23 * 1) Any source code used, modified or distributed must reproduce
24 * and retain this copyright notice and list of conditions
25 * as they appear in the source file.
26 *
27 * 2) No right is granted to use any trade name, trademark, or
28 * logo of Broadcom Corporation. The "Broadcom Corporation"
29 * name may not be used to endorse or promote products derived
30 * from this software without the prior written permission of
31 * Broadcom Corporation.
32 *
33 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
37 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
38 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
39 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
41 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
42 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
43 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
45 * THE POSSIBILITY OF SUCH DAMAGE.
46 ********************************************************************* */
47
48
49#include "cfe.h"
50
51#include "usbchap9.h"
52#include "usbd.h"
53
54/* For systems with non-coherent DMA, allocate all buffers to be
55 cache-aligned and multiples of a cache line in size, so that they
56 can be safely flushed or invalidated. */
57
58#define CACHE_ALIGN 32 /* XXX place holder, big enough to now. */
59#define BUFF_ALIGN 16
60#define ALIGN(n,align) (((n)+((align)-1)) & ~((align)-1))
61
62#define usb_dma_alloc(n) (KMALLOC(ALIGN((n),CACHE_ALIGN),BUFF_ALIGN))
63#define usb_dma_free(p) (KFREE(p))
64
65/* *********************************************************************
66 * Constants
67 ********************************************************************* */
68
69#define HID_BOOT_PROTOCOL 0
70#define HID_REPORT_PROTOCOL 1
71
72#define HID_DEVTYPE_UNKNOWN 0
73#define HID_DEVTYPE_KBD 1
74#define HID_DEVTYPE_MOUSE 2
75#define HID_DEVTYPE_MAX 2
76
77#define UBR_KBD_MODS 0
78#define UBR_KBD_RSVD 1
79#define UBR_KBD_KEYS 2
80#define UBR_KBD_NUMKEYS 6
81#define UBR_KBD_MAX 8
82
83#define KBD_MOD_LCTRL 0x01
84#define KBD_MOD_LSHIFT 0x02
85#define KBD_MOD_LALT 0x04
86#define KBD_MOD_LWIN 0x08
87
88#define KBD_MOD_RCTRL 0x10
89#define KBD_MOD_RSHIFT 0x20
90#define KBD_MOD_RALT 0x40
91#define KBD_MOD_RWIN 0x80
92
93/* *********************************************************************
94 * Macros
95 ********************************************************************* */
96
97#define usbhid_set_protocol(dev,protocol,ifc) \
98 usb_simple_request(dev,0x21,0x0B,0,ifc)
99
100
101/* *********************************************************************
102 * Forward Definitions
103 ********************************************************************* */
104
105static int usbhid_attach(usbdev_t *dev,usb_driver_t *drv);
106static int usbhid_detach(usbdev_t *dev);
107
108/* *********************************************************************
109 * Structures
110 ********************************************************************* */
111
112typedef struct usbhid_softc_s {
120
122 "Human-Interface Device",
123 usbhid_attach,
124 usbhid_detach
125};
126
127static char *usbhid_devtypes[3] = {
128 "Unknown",
129 "Keyboard",
130 "Mouse"};
131
132#ifdef CFG_VGACONSOLE
133extern int pcconsole_enqueue(uint8_t ch);
134#endif
135
136
137/* *********************************************************************
138 * Constants for keyboard table
139 ********************************************************************* */
140
141#define FLG_NUM 0x0001 /* Toggles: same as bits for LEDs */
142#define FLG_CAPS 0x0002
143#define FLG_SCROLL 0x0004
144#define FLG_SHIFT 0x0008 /* Shifts */
145#define FLG_CTRL 0x0100
146#define FLG_ALT 0x0200
147#define FLG_FKEY 0x0400 /* function keys */
148#define FLG_NKPD 0x0800 /* numeric keypad */
149#define FLG_ASCII 0x1000 /* regular ASCII character */
150#define FLG_NONE 0x2000
151
152
153/* *********************************************************************
154 * Structures for keyboard table
155 ********************************************************************* */
156
157#define KC_RESPLEN 4
158typedef struct keycode_s {
164
165
166/* *********************************************************************
167 * Scan code conversion table
168 ********************************************************************* */
169
170static keycode_t usbhid_scantable[] = {
171 { FLG_NONE, "", "", "" }, /* 0 */
172 { FLG_NONE, "", "", "" }, /* 1 */
173 { FLG_NONE, "", "", "" }, /* 2 */
174 { FLG_NONE, "", "", "" }, /* 3 */
175 { FLG_ASCII, "a", "A", "\001" }, /* 4 a */
176 { FLG_ASCII, "b", "B", "\002" }, /* 5 b */
177 { FLG_ASCII, "c", "C", "\003" }, /* 6 c */
178 { FLG_ASCII, "d", "D", "\004" }, /* 7 d */
179 { FLG_ASCII, "e", "E", "\005" }, /* 8 e */
180 { FLG_ASCII, "f", "F", "\006" }, /* 9 f */
181 { FLG_ASCII, "g", "G", "\007" }, /* 10 g */
182 { FLG_ASCII, "h", "H", "\010" }, /* 11 h */
183 { FLG_ASCII, "i", "I", "\011" }, /* 12 i */
184 { FLG_ASCII, "j", "J", "\n" }, /* 13 j */
185 { FLG_ASCII, "k", "K", "\013" }, /* 14 k */
186 { FLG_ASCII, "l", "L", "\014" }, /* 15 l */
187 { FLG_ASCII, "m", "M", "\r" }, /* 16 m */
188 { FLG_ASCII, "n", "N", "\016" }, /* 17 n */
189 { FLG_ASCII, "o", "O", "\017" }, /* 18 o */
190 { FLG_ASCII, "p", "P", "\020" }, /* 19 p */
191 { FLG_ASCII, "q", "Q", "\021" }, /* 20 q */
192 { FLG_ASCII, "r", "R", "\022" }, /* 21 r */
193 { FLG_ASCII, "s", "S", "\023" }, /* 22 s */
194 { FLG_ASCII, "t", "T", "\024" }, /* 23 t */
195 { FLG_ASCII, "u", "U", "\025" }, /* 24 u */
196 { FLG_ASCII, "v", "V", "\026" }, /* 25 v */
197 { FLG_ASCII, "w", "W", "\027" }, /* 26 w */
198 { FLG_ASCII, "x", "X", "\030" }, /* 27 x */
199 { FLG_ASCII, "y", "Y", "\031" }, /* 28 y */
200 { FLG_ASCII, "z", "Z", "\032" }, /* 29 z */
201
202 { FLG_ASCII, "1", "!", "!" }, /* 30 1 */
203 { FLG_ASCII, "2", "@", "\000" }, /* 31 2 */
204 { FLG_ASCII, "3", "#", "#" }, /* 32 3 */
205 { FLG_ASCII, "4", "$", "$" }, /* 33 4 */
206 { FLG_ASCII, "5", "%", "%" }, /* 34 5 */
207 { FLG_ASCII, "6", "^", "\036" }, /* 35 6 */
208 { FLG_ASCII, "7", "&", "&" }, /* 36 7 */
209 { FLG_ASCII, "8", "*", "\010" }, /* 37 8 */
210 { FLG_ASCII, "9", "(", "(" }, /* 38 9 */
211 { FLG_ASCII, "0", ")", ")" }, /* 39 0 */
212
213 { FLG_ASCII, "\r", "\r", "\n" }, /* 40 ENT */
214 { FLG_ASCII, "\033", "\033", "\033" }, /* 41 ESC */
215 { FLG_ASCII, "\177", "\177", "\010" }, /* 42 <- */
216 { FLG_ASCII, "\t", "\177\t", "\t" }, /* 43 ->| */
217 { FLG_ASCII, " ", " ", "\000" }, /* 44 SPC */
218
219 { FLG_ASCII, "-", "_", "\037" }, /* 45 - */
220 { FLG_ASCII, "=", "+", "+" }, /* 46 = */
221 { FLG_ASCII, "[", "{", "\033" }, /* 47 [ */
222 { FLG_ASCII, "]", "}", "\035" }, /* 48 ] */
223 { FLG_ASCII, "\\", "|", "\034" }, /* 49 \ */
224
225 { FLG_NONE, "", "", "" }, /* 50 pound */
226
227 { FLG_ASCII, ";", ":", ";" }, /* 51 ; */
228 { FLG_ASCII, "'", "\"", "'" }, /* 52 ' */
229 { FLG_ASCII, "`", "~", "`" }, /* 53 ` */
230 { FLG_ASCII, ",", "<", "<" }, /* 54 , */
231 { FLG_ASCII, ".", ">", ">" }, /* 55 . */
232 { FLG_ASCII, "/", "?", "\037" }, /* 56 / */
233 { FLG_CAPS, "", "", "" }, /* 57 CAPS */
234
235 { FLG_FKEY, "\033[M", "\033[Y", "\033[k" }, /* 58 f1 */
236 { FLG_FKEY, "\033[N", "\033[Z", "\033[l" }, /* 59 f2 */
237 { FLG_FKEY, "\033[O", "\033[a", "\033[m" }, /* 60 f3 */
238 { FLG_FKEY, "\033[P", "\033[b", "\033[n" }, /* 61 f4 */
239 { FLG_FKEY, "\033[Q", "\033[c", "\033[o" }, /* 62 f5 */
240 { FLG_FKEY, "\033[R", "\033[d", "\033[p" }, /* 63 f6 */
241 { FLG_FKEY, "\033[S", "\033[e", "\033[q" }, /* 64 f7 */
242 { FLG_FKEY, "\033[T", "\033[f", "\033[r" }, /* 65 f8 */
243 { FLG_FKEY, "\033[U", "\033[g", "\033[s" }, /* 66 f9 */
244 { FLG_FKEY, "\033[V", "\033[h", "\033[t" }, /* 67 f10 */
245 { FLG_FKEY, "\033[W", "\033[i", "\033[u" }, /* 68 f11 */
246 { FLG_FKEY, "\033[X", "\033[j", "\033[v" }, /* 69 f12 */
247
248 { FLG_NONE, "", "", "" }, /* 70 prtsc */
249 { FLG_SCROLL, "", "", "" }, /* 71 SCRLK */
250 { FLG_NONE, "", "", "" }, /* 72 pause */
251 { FLG_NONE, "", "", "" }, /* 73 KPins */
252 { FLG_NONE, "", "", "" }, /* 74 KPhome */
253 { FLG_NONE, "", "", "" }, /* 75 KPpgup */
254 { FLG_NONE, "", "", "" }, /* 76 KPdel */
255 { FLG_NONE, "", "", "" }, /* 77 KPend */
256 { FLG_NONE, "", "", "" }, /* 78 KPpgdn */
257
258 { FLG_FKEY, "\033[C", "", "" }, /* 79 KPright */
259 { FLG_FKEY, "\033[D", "", "" }, /* 80 KPleft */
260 { FLG_FKEY, "\033[B", "", "" }, /* 81 KPdown */
261 { FLG_FKEY, "\033[A", "", "" }, /* 82 KPup */
262
263 { FLG_NUM, "", "", "" }, /* 83 NUMLK */
264 { FLG_NKPD, "/", "/", "/" }, /* 84 KP/ */
265 { FLG_NKPD, "*", "*", "*" }, /* 85 KP* */
266 { FLG_NKPD, "-", "-", "-" }, /* 86 KP- */
267 { FLG_NKPD, "+", "+", "+" }, /* 87 KP+ */
268 { FLG_NKPD, "\r", "\r", "\n" }, /* 88 KPent */
269
270 { FLG_NKPD, "1", "\033[F", "1" }, /* 89 KP1 */
271 { FLG_NKPD, "2", "\033[B", "2" }, /* 90 KP2 */
272 { FLG_NKPD, "3", "\033[G", "3" }, /* 91 KP3 */
273 { FLG_NKPD, "4", "\033[D", "4" }, /* 92 KP4 */
274 { FLG_NKPD, "5", "\033[E", "5" }, /* 93 KP5 */
275 { FLG_NKPD, "6", "\033[C", "6" }, /* 94 KP6 */
276 { FLG_NKPD, "7", "\033[H", "7" }, /* 95 KP7 */
277 { FLG_NKPD, "8", "\033[A", "8" }, /* 96 KP8 */
278 { FLG_NKPD, "9", "\033[I", "9" }, /* 97 KP9 */
279 { FLG_NKPD, "0", "\033[L", "0" }, /* 98 KP0 */
280
281 { FLG_NKPD, ".", "\177", "." }, /* 99 KP. */
282
283 { FLG_NONE, "", "", "" }, /* 100 non\ */
284
285};
286
287#define usbhid_scantablesize (sizeof(usbhid_scantable)/sizeof(keycode_t))
288
289
290/* *********************************************************************
291 * usbhid_kbd_mod1(uhid)
292 *
293 * Process modifier key changes for the current USB event,
294 * which was stored in uhid_imsg. Basically all this does
295 * is update uhid_shiftflags, converting the bits into the ones
296 * we use in our keyboard table.
297 *
298 * Input parameters:
299 * uhid - the hid softc.
300 *
301 * Return value:
302 * nothing
303 ********************************************************************* */
304
305static void usbhid_kbd_mod1(usbhid_softc_t *uhid)
306{
307 uint8_t changed;
308 uint8_t mod;
309
310 /*
311 * See if anything changed.
312 */
313
314 changed = (uhid->uhid_imsg[UBR_KBD_MODS] ^ uhid->uhid_lastmsg[UBR_KBD_MODS]);
315 if (changed == 0) return;
316
317 /*
318 * Something changed. Reflect changes in our local copy of the
319 * shift state.
320 */
321
322 mod = uhid->uhid_imsg[UBR_KBD_MODS];
323
325
328 if (mod & (KBD_MOD_LALT|KBD_MOD_RALT)) uhid->uhid_shiftflags |= FLG_ALT;
329}
330
331/* *********************************************************************
332 * usbhid_kbd_scan1(uhid,scan,breakflg)
333 *
334 * Handle a single keyboard event. Using the scan code, look up
335 * the key in the table and convert it to one or more characters
336 * for the keyboard event queue.
337 *
338 * Input parameters:
339 * uhid - the hid softc
340 * scan - scan code from keyboard report
341 * breakflg - true if key is being released, false if pressed
342 *
343 * Return value:
344 * nothing
345 ********************************************************************* */
346
347static void usbhid_kbd_scan1(usbhid_softc_t *uhid,uint8_t scan,int breakflg)
348{
349 keycode_t *code = 0;
350 char *str;
351
352 /*
353 * Check scan code for reality.
354 */
355
356 if (scan >= usbhid_scantablesize) return;
357 code = &usbhid_scantable[scan];
358
359 /*
360 * If the change is a toggle, handle the toggle. These
361 * keys also deal with the LEDs on the keyboard.
362 */
363
364 if (code->kc_type & (FLG_CAPS|FLG_SCROLL|FLG_NUM)) {
365 if (!breakflg) uhid->uhid_shiftflags ^= code->kc_type;
366// if (ks->ks_setleds) {
367// (*(ks->ks_setleds))(ks,ks->ks_shiftflags & (FLG_CAPS|FLG_SCROLL|FLG_NUM));
368// }
369 }
370
371 /*
372 * Regular keys - just look up in table and
373 * queue the characters to the upper layers.
374 */
375
376 if (code->kc_type & (FLG_ASCII | FLG_FKEY | FLG_NKPD)) {
377 if (uhid->uhid_shiftflags & (FLG_SHIFT|FLG_CAPS)) str = code->kc_shifted;
378 else if (uhid->uhid_shiftflags & FLG_CTRL) str = code->kc_ctrl;
379 else str = code->kc_normal;
380 if (!breakflg) {
381#if CFG_VGACONSOLE
382 while (*str) {
383 pcconsole_enqueue(*str++);
384 }
385#else
386 printf("%s",str);
387#endif
388#ifndef _CFE_
389 fflush(stdout);
390#endif
391 }
392 }
393
394}
395
396
397/* *********************************************************************
398 * usbhid_kbd_scan(uhid)
399 *
400 * Main processing routine for keyboard report messages. Once
401 * we've determined that it is a keyboard mesage, we end up
402 * here. The work involves seeing what new keys have arrived
403 * in the list (presses), and which ones are no longer there
404 * (releases). To do this, we us the current and previous
405 * report structure.
406 *
407 * Input parameters:
408 * uhid - the hid softc
409 *
410 * Return value:
411 * nothing
412 ********************************************************************* */
413
414static void usbhid_kbd_scan(usbhid_softc_t *uhid)
415{
416 int n,o;
417
418 /*
419 * Modifier keys (shift, alt, control)
420 */
421
422 if (uhid->uhid_imsg[UBR_KBD_MODS] ^ uhid->uhid_lastmsg[UBR_KBD_MODS]) {
423 usbhid_kbd_mod1(uhid);
424 }
425
426 /*
427 * "Make" codes (keys pressed down)
428 * Look for keys in 'uhid_imsg' that are not in 'uhid_lastmsg'
429 */
430
431 for (n = UBR_KBD_KEYS; n < (UBR_KBD_KEYS + UBR_KBD_NUMKEYS); n++) {
432 if (uhid->uhid_imsg[n] == 0) break; /* no more keys */
433 for (o = UBR_KBD_KEYS; o < (UBR_KBD_KEYS + UBR_KBD_NUMKEYS); o++) {
434 if (uhid->uhid_imsg[n] == uhid->uhid_lastmsg[o]) break;
435 }
436 if (o == (UBR_KBD_KEYS + UBR_KBD_NUMKEYS)) { /* key not found, must be pressed */
437 usbhid_kbd_scan1(uhid,uhid->uhid_imsg[n],0);
438 }
439 }
440
441 /*
442 * "Break" codes (keys released)
443 * Look for keys in 'uhid_lastmsg' that are not in 'uhid_imsg'
444 */
445
446
447 for (n = UBR_KBD_KEYS; n < (UBR_KBD_KEYS + UBR_KBD_NUMKEYS); n++) {
448 if (uhid->uhid_lastmsg[n] == 0) break; /* no more keys */
449 for (o = UBR_KBD_KEYS; o < (UBR_KBD_KEYS + UBR_KBD_NUMKEYS); o++) {
450 if (uhid->uhid_lastmsg[n] == uhid->uhid_imsg[o]) break;
451 }
452 if (o == (UBR_KBD_KEYS + UBR_KBD_NUMKEYS)) { /* key not found, must be released */
453 usbhid_kbd_scan1(uhid,uhid->uhid_lastmsg[n],1);
454 }
455 }
456}
457
458
459/* *********************************************************************
460 * usbhid_ireq_callback(ur)
461 *
462 * This routine is called when our interrupt transfer completes
463 * and there is report data to be processed.
464 *
465 * Input parameters:
466 * ur - usb request
467 *
468 * Return value:
469 * 0
470 ********************************************************************* */
471
472static int usbhid_ireq_callback(usbreq_t *ur)
473{
474 usbhid_softc_t *uhid = (ur->ur_dev->ud_private);
475
476 /*
477 * If the driver is unloaded, the request will be cancelled.
478 */
479
480 if (ur->ur_status == 0xFF) {
482 return 0;
483 }
484
485 /*
486 * What we do now depends on the type of device.
487 */
488
489 switch (uhid->uhid_devtype) {
490 case HID_DEVTYPE_KBD:
491 /*
492 * Handle keyboard event
493 */
494 usbhid_kbd_scan(uhid);
495
496 /*
497 * Save old event to compare for next time.
498 */
499 memcpy(uhid->uhid_lastmsg,uhid->uhid_imsg,UBR_KBD_MAX);
500 break;
501
503#if 0
504 /*
505 * No need to handle mice, but here's the good stuff.
506 */
507 printf("Mouse: [%s %s %s] X:%d Y:%d Wheel:%d\n",
508 (ur->ur_buffer[0] & 1) ? "left" : "",
509 (ur->ur_buffer[0] & 4) ? "middle" : "",
510 (ur->ur_buffer[0] & 2) ? "right" : "",
511 (int)(signed char)ur->ur_buffer[1],
512 (int)(signed char)ur->ur_buffer[2],
513 (int)(signed char)ur->ur_buffer[3]);
514#endif
515 break;
516 }
517
518 /*
519 * Re-queue request to get next keyboard event.
520 */
521
523
524 return 0;
525}
526
527
528/* *********************************************************************
529 * usbhid_queue_intreq(dev,softc)
530 *
531 * Queue an interrupt request for this usb device. The
532 * driver will place this request on the queue that corresponds
533 * to the endpoint, and will call the callback routine when
534 * something happens.
535 *
536 * Input parameters:
537 * dev - usb device
538 * softc - the usb hid softc
539 *
540 * Return value:
541 * nothing
542 ********************************************************************* */
543
544static void usbhid_queue_intreq(usbdev_t *dev,usbhid_softc_t *softc)
545{
546 usbreq_t *ur;
547
548 ur = usb_make_request(dev,
549 softc->uhid_ipipe,
550 softc->uhid_imsg,softc->uhid_ipipemps,
551 UR_FLAG_IN);
552
553 ur->ur_callback = usbhid_ireq_callback;
554
556}
557
558
559/* *********************************************************************
560 * usbhid_attach(dev,drv)
561 *
562 * This routine is called when the bus scan stuff finds a HID
563 * device. We finish up the initialization by configuring the
564 * device and allocating our softc here.
565 *
566 * Input parameters:
567 * dev - usb device, in the "addressed" state.
568 * drv - the driver table entry that matched
569 *
570 * Return value:
571 * 0
572 ********************************************************************* */
573
574static int usbhid_attach(usbdev_t *dev,usb_driver_t *drv)
575{
576 usb_config_descr_t *cfgdscr = dev->ud_cfgdescr;
577 usb_endpoint_descr_t *epdscr;
578 usb_interface_descr_t *ifdscr;
579 usbhid_softc_t *softc;
580
581 dev->ud_drv = drv;
582
583 softc = KMALLOC(sizeof(usbhid_softc_t),0);
584 memset(softc,0,sizeof(usbhid_softc_t));
585 dev->ud_private = softc;
586
589
590 if (!epdscr || !ifdscr) {
591 /*
592 * Could not get descriptors, something is very wrong.
593 * Leave device addressed but not configured.
594 */
595 return 0;
596 }
597
598 /*
599 * Allocate a DMA buffer
600 */
601
603 if (softc->uhid_imsg == NULL) {
604 /* Could not allocate a buffer, fail. */
605 return -1;
606 }
607
608 /*
609 * Choose the standard configuration.
610 */
611
613
614 /*
615 * Set the protocol to the "boot" protocol, so we don't
616 * have to deal with fancy HID stuff.
617 */
618
620
621 /*
622 * Open the interrupt pipe.
623 */
624
625 softc->uhid_ipipe = usb_open_pipe(dev,epdscr);
626 softc->uhid_ipipemps = GETUSBFIELD(epdscr,wMaxPacketSize);
627
628 /*
629 * Figure out the device type from the protocol. Keyboards,
630 * mice use this field to distinguish themselves.
631 */
632
633 softc->uhid_devtype = ifdscr->bInterfaceProtocol;
634 if (softc->uhid_devtype > HID_DEVTYPE_MAX) {
636 }
637
638 console_log("USBHID: %s Configured.\n",
639 usbhid_devtypes[softc->uhid_devtype]);
640
641 /*
642 * Queue a transfer on the interrupt endpoint to catch
643 * our first characters.
644 */
645
646 usbhid_queue_intreq(dev,softc);
647
648 return 0;
649}
650
651/* *********************************************************************
652 * usbhid_detach(dev)
653 *
654 * This routine is called when the bus scanner notices that
655 * this device has been removed from the system. We should
656 * do any cleanup that is required. The pending requests
657 * will be cancelled automagically.
658 *
659 * Input parameters:
660 * dev - usb device
661 *
662 * Return value:
663 * 0
664 ********************************************************************* */
665
666static int usbhid_detach(usbdev_t *dev)
667{
668 return 0;
669}
670
671
672
uint8_t code
Definition: ata.h:0
#define console_log(fmt, x...)
Definition: cfe.h:18
#define NULL
Definition: def.h:47
#define KMALLOC(size, align)
Definition: lib_malloc.h:92
u32 uint32_t
Definition: libfdt_env.h:11
u8 uint8_t
Definition: libfdt_env.h:9
char kc_normal[KC_RESPLEN]
Definition: usbhid.c:160
char kc_shifted[KC_RESPLEN]
Definition: usbhid.c:161
int kc_type
Definition: usbhid.c:159
char kc_ctrl[KC_RESPLEN]
Definition: usbhid.c:162
uint8_t bConfigurationValue
Definition: usbchap9.h:216
uint8_t bInterfaceNumber
Definition: usbchap9.h:227
uint8_t bInterfaceProtocol
Definition: usbchap9.h:232
Definition: usbd.h:141
usb_config_descr_t * ud_cfgdescr
Definition: usbd.h:150
void * ud_private
Definition: usbd.h:148
usb_driver_t * ud_drv
Definition: usbd.h:142
uint32_t uhid_shiftflags
Definition: usbhid.c:118
int uhid_ipipe
Definition: usbhid.c:113
uint8_t * uhid_imsg
Definition: usbhid.c:116
int uhid_devtype
Definition: usbhid.c:115
int uhid_ipipemps
Definition: usbhid.c:114
uint8_t uhid_lastmsg[UBR_KBD_MAX]
Definition: usbhid.c:117
Definition: usbd.h:171
int(* ur_callback)(struct usbreq_s *req)
Definition: usbd.h:196
int ur_status
Definition: usbd.h:188
uint8_t * ur_buffer
Definition: usbd.h:185
usbdev_t * ur_dev
Definition: usbd.h:178
#define GETUSBFIELD(s, f)
Definition: usbchap9.h:347
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usbchap9.h:66
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usbchap9.h:65
void * usb_find_cfg_descr(usbdev_t *dev, int dtype, int idx)
Definition: usbd.c:1237
usbreq_t * usb_make_request(usbdev_t *dev, int epaddr, uint8_t *buf, int length, int flags)
Definition: usbd.c:353
void usb_free_request(usbreq_t *ur)
Definition: usbd.c:457
int usb_queue_request(usbreq_t *ur)
Definition: usbd.c:502
int usb_set_configuration(usbdev_t *dev, int config)
Definition: usbd.c:619
int usb_open_pipe(usbdev_t *dev, usb_endpoint_descr_t *epdesc)
Definition: usbd.c:165
#define UR_FLAG_IN
Definition: usbd.h:164
#define KBD_MOD_RALT
Definition: usbhid.c:90
#define UBR_KBD_KEYS
Definition: usbhid.c:79
usb_driver_t usbhid_driver
Definition: usbhid.c:121
struct keycode_s keycode_t
#define HID_DEVTYPE_KBD
Definition: usbhid.c:73
#define FLG_SCROLL
Definition: usbhid.c:143
#define FLG_NKPD
Definition: usbhid.c:148
#define HID_BOOT_PROTOCOL
Definition: usbhid.c:69
#define HID_DEVTYPE_MAX
Definition: usbhid.c:75
#define KBD_MOD_RSHIFT
Definition: usbhid.c:89
#define usb_dma_alloc(n)
Definition: usbhid.c:62
#define UBR_KBD_MAX
Definition: usbhid.c:81
#define FLG_FKEY
Definition: usbhid.c:147
#define usbhid_set_protocol(dev, protocol, ifc)
Definition: usbhid.c:97
#define FLG_CTRL
Definition: usbhid.c:145
#define FLG_SHIFT
Definition: usbhid.c:144
#define FLG_NONE
Definition: usbhid.c:150
#define FLG_ALT
Definition: usbhid.c:146
#define UBR_KBD_MODS
Definition: usbhid.c:77
#define KBD_MOD_LALT
Definition: usbhid.c:85
#define FLG_NUM
Definition: usbhid.c:141
#define FLG_CAPS
Definition: usbhid.c:142
#define usbhid_scantablesize
Definition: usbhid.c:287
#define KC_RESPLEN
Definition: usbhid.c:157
#define KBD_MOD_LCTRL
Definition: usbhid.c:83
#define HID_DEVTYPE_MOUSE
Definition: usbhid.c:74
#define HID_DEVTYPE_UNKNOWN
Definition: usbhid.c:72
#define FLG_ASCII
Definition: usbhid.c:149
#define KBD_MOD_RCTRL
Definition: usbhid.c:88
struct usbhid_softc_s usbhid_softc_t
#define UBR_KBD_NUMKEYS
Definition: usbhid.c:80
#define KBD_MOD_LSHIFT
Definition: usbhid.c:84
u8 str[13]
Definition: xenos_edid.h:0