Changes in / [3a1aa20:b8622e2] in mainline
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/conv.c
r3a1aa20 rb8622e2 36 36 #include <io/keycode.h> 37 37 #include <stdint.h> 38 #include <stdio.h>39 #include <usb/debug.h>40 38 #include "conv.h" 41 39 … … 143 141 //[0xe7] = KC_R // TODO: right GUI 144 142 145 [0x53] = KC_NUM_LOCK,146 [0x54] = KC_NSLASH,147 [0x55] = KC_NTIMES,148 [0x56] = KC_NMINUS,149 [0x57] = KC_NPLUS,150 [0x58] = KC_NENTER,151 [0x59] = KC_N1,152 [0x5a] = KC_N2,153 [0x5b] = KC_N3,154 [0x5c] = KC_N4,155 [0x5d] = KC_N5,156 [0x5e] = KC_N6,157 [0x5f] = KC_N7,158 [0x60] = KC_N8,159 [0x61] = KC_N9,160 [0x62] = KC_N0,161 [0x63] = KC_NPERIOD162 163 143 }; 164 144 … … 209 189 210 190 key = map[scancode]; 211 212 if (scancode == 0x53) {213 usb_log_debug("\n\nWe have a NUM LOCK!, sending key %u\n\n", key);214 }215 216 if (scancode == 0x47) {217 usb_log_debug("\n\nWe have a SCROLL LOCK!, sending key %u\n\n", key);218 }219 220 if (scancode == 0x39) {221 usb_log_debug("\n\nWe have a CAPS LOCK!, sending key %u\n\n", key);222 }223 224 191 // if (key != 0) 225 192 // kbd_push_ev(type, key); -
uspace/drv/usbhid/hid.h
r3a1aa20 rb8622e2 37 37 #define USBHID_HID_H_ 38 38 39 #include <stdint.h>40 41 39 #include <usb/classes/hid.h> 42 40 #include <ddf/driver.h> … … 76 74 usb_endpoint_pipe_t ctrl_pipe; 77 75 usb_endpoint_pipe_t poll_pipe; 78 79 uint8_t *keycodes;80 size_t keycode_count;81 uint8_t modifiers;82 76 } usb_hid_dev_kbd_t; 83 77 -
uspace/drv/usbhid/main.c
r3a1aa20 rb8622e2 51 51 #include <usb/descriptor.h> 52 52 #include <io/console.h> 53 #include <stdint.h>54 53 #include "hid.h" 55 54 #include "descparser.h" … … 59 58 60 59 #define BUFFER_SIZE 8 61 #define BUFFER_OUT_SIZE 162 60 #define NAME "usbhid" 63 61 64 62 #define GUESSED_POLL_ENDPOINT 1 65 #define BOOTP_REPORT_SIZE 666 63 67 64 /** Keyboard polling endpoint description for boot protocol class. */ … … 123 120 124 121 static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length) 125 { uint8_t buffer[BUFFER_SIZE];122 { 126 123 printf("%s\n", msg); 127 124 … … 140 137 */ 141 138 142 /** Currently active modifiers (locks is probably better word).139 /** Currently active modifiers. 143 140 * 144 141 * TODO: put to device? … … 162 159 static int active_layout = 0; 163 160 164 static void usbkbd_req_set_report(usb_hid_dev_kbd_t *kbd_dev, uint16_t iface, 165 usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size) 166 { 167 int rc, sess_rc; 168 169 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 170 if (sess_rc != EOK) { 171 usb_log_warning("Failed to start a session: %s.\n", 172 str_error(sess_rc)); 173 return; 174 } 175 176 usb_log_debug("Sending Set_Report request to the device.\n"); 177 178 rc = usb_control_request_set(&kbd_dev->ctrl_pipe, 179 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 180 USB_HIDREQ_SET_REPORT, type, iface, buffer, buf_size); 181 182 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 183 184 if (rc != EOK) { 185 usb_log_warning("Error sending output report to the keyboard: " 186 "%s.\n", str_error(rc)); 187 return; 188 } 189 190 if (sess_rc != EOK) { 191 usb_log_warning("Error closing session: %s.\n", 192 str_error(sess_rc)); 193 return; 194 } 195 } 196 197 static void usbkbd_req_set_protocol(usb_hid_dev_kbd_t *kbd_dev, uint16_t iface, 198 usb_hid_protocol_t protocol) 199 { 200 int rc, sess_rc; 201 202 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 203 if (sess_rc != EOK) { 204 usb_log_warning("Failed to start a session: %s.\n", 205 str_error(sess_rc)); 206 return; 207 } 208 209 usb_log_debug("Sending Set_Protocol request to the device.\n"); 210 211 rc = usb_control_request_set(&kbd_dev->ctrl_pipe, 212 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 213 USB_HIDREQ_SET_PROTOCOL, protocol, iface, NULL, 0); 214 215 sess_rc = usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 216 217 if (rc != EOK) { 218 usb_log_warning("Error sending output report to the keyboard: " 219 "%s.\n", str_error(rc)); 220 return; 221 } 222 223 if (sess_rc != EOK) { 224 usb_log_warning("Error closing session: %s.\n", 225 str_error(sess_rc)); 226 return; 227 } 228 } 229 230 static void usbkbd_set_led(unsigned mods, usb_hid_dev_kbd_t *kbd_dev) 231 { 232 uint8_t buffer[BUFFER_SIZE]; 233 int rc= 0; 234 235 uint8_t leds = 0; 236 237 if (mods & KM_NUM_LOCK) { 238 leds |= USB_HID_LED_NUM_LOCK; 239 } 240 241 if (mods & KM_CAPS_LOCK) { 242 leds |= USB_HID_LED_CAPS_LOCK; 243 } 244 245 if (mods & KM_SCROLL_LOCK) { 246 leds |= USB_HID_LED_SCROLL_LOCK; 247 } 248 249 // TODO: COMPOSE and KANA 250 251 usb_log_debug("Creating output report.\n"); 252 if ((rc = usb_hid_boot_keyboard_output_report( 253 leds, buffer, BUFFER_SIZE)) != EOK) { 254 usb_log_warning("Error composing output report to the keyboard:" 255 "%s.\n", str_error(rc)); 256 return; 257 } 258 259 // TODO: determine what interface to use!! (now set to 1) 260 usbkbd_req_set_report(kbd_dev, 1, USB_HID_REPORT_TYPE_OUTPUT, buffer, 261 BUFFER_SIZE); 262 } 263 264 static void kbd_push_ev(int type, unsigned int key, usb_hid_dev_kbd_t *kbd_dev) 161 static void kbd_push_ev(int type, unsigned int key) 265 162 { 266 163 console_event_t ev; … … 286 183 287 184 switch (key) { 288 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; usb_log_debug2("\n\nPushing CAPS LOCK! (mask: %u)\n\n", mod_mask);break;289 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; usb_log_debug2("\n\nPushing NUM LOCK! (mask: %u)\n\n", mod_mask);break;290 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; usb_log_debug2("\n\nPushing SCROLL LOCK! (mask: %u)\n\n", mod_mask);break;185 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 186 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 187 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 291 188 default: mod_mask = 0; break; 292 189 } 293 190 294 191 if (mod_mask != 0) { 295 usb_log_debug2("\n\nChanging mods and lock keys\n");296 usb_log_debug2("\nmods before: 0x%x\n", mods);297 usb_log_debug2("\nLock keys before:0x%x\n\n", lock_keys);298 299 192 if (type == KEY_PRESS) { 300 usb_log_debug2("\nKey pressed.\n");301 193 /* 302 194 * Only change lock state on transition from released … … 308 200 309 201 /* Update keyboard lock indicator lights. */ 310 usbkbd_set_led(mods, kbd_dev); 202 // TODO 203 //kbd_ctl_set_ind(mods); 311 204 } else { 312 usb_log_debug2("\nKey released.\n");313 205 lock_keys = lock_keys & ~mod_mask; 314 206 } 315 207 } 316 208 /* 317 usb_log_debug2("type: %d\n", type);318 usb_log_debug2("mods: 0x%x\n", mods);319 usb_log_debug2("keycode: %u\n", key);209 printf("type: %d\n", type); 210 printf("mods: 0x%x\n", mods); 211 printf("keycode: %u\n", key); 320 212 */ 321 usb_log_debug2("\n\nmods after: 0x%x\n", mods);322 usb_log_debug2("\nLock keys after: 0x%x\n\n", lock_keys);323 213 324 214 if (type == KEY_PRESS && (mods & KM_LCTRL) && … … 346 236 ev.key = key; 347 237 ev.mods = mods; 348 349 if (ev.mods & KM_NUM_LOCK) {350 usb_log_debug("\n\nNum Lock turned on.\n\n");351 }352 238 353 239 ev.c = layout[active_layout]->parse_ev(&ev); 354 240 355 usb_log_debug2("Sending key %d to the console\n", ev.key);241 printf("Sending key %d to the console\n", ev.key); 356 242 assert(console_callback_phone != -1); 357 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, 358 ev.mods, ev.c); 243 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); 359 244 } 360 245 /* … … 364 249 /* 365 250 * TODO: 366 * 1) key press / key release - how does the keyboard notify about 367 * release? 251 * 1) key press / key release - how does the keyboard notify about release? 368 252 * 2) layouts (use the already defined), not important now 369 253 * 3) 370 254 */ 371 255 372 static const keycode_t usb_hid_modifiers_keycodes[USB_HID_MOD_COUNT] = {373 KC_LCTRL, /* USB_HID_MOD_LCTRL */374 KC_LSHIFT, /* USB_HID_MOD_LSHIFT */375 KC_LALT, /* USB_HID_MOD_LALT */376 0, /* USB_HID_MOD_LGUI */377 KC_RCTRL, /* USB_HID_MOD_RCTRL */378 KC_RSHIFT, /* USB_HID_MOD_RSHIFT */379 KC_RALT, /* USB_HID_MOD_RALT */380 0, /* USB_HID_MOD_RGUI */381 };382 383 static void usbkbd_check_modifier_changes(usb_hid_dev_kbd_t *kbd_dev,384 uint8_t modifiers)385 {386 /*387 * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK388 * both as modifiers and as keys with their own scancodes???389 *390 * modifiers should be sent as normal keys to usbkbd_parse_scancode()!!391 * so maybe it would be better if I received it from report parser in392 * that way393 */394 395 int i;396 for (i = 0; i < USB_HID_MOD_COUNT; ++i) {397 if ((modifiers & usb_hid_modifiers_consts[i]) &&398 !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {399 // modifier pressed400 if (usb_hid_modifiers_keycodes[i] != 0) {401 kbd_push_ev(KEY_PRESS,402 usb_hid_modifiers_keycodes[i], kbd_dev);403 }404 } else if (!(modifiers & usb_hid_modifiers_consts[i]) &&405 (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) {406 // modifier released407 if (usb_hid_modifiers_keycodes[i] != 0) {408 kbd_push_ev(KEY_RELEASE,409 usb_hid_modifiers_keycodes[i], kbd_dev);410 }411 } // no change412 }413 414 kbd_dev->modifiers = modifiers;415 }416 417 static void usbkbd_check_key_changes(usb_hid_dev_kbd_t *kbd_dev,418 const uint8_t *key_codes)419 {420 // TODO: phantom state!!421 422 unsigned int key;423 unsigned int i, j;424 425 // TODO: quite dummy right now, think of better implementation426 427 // key releases428 for (j = 0; j < kbd_dev->keycode_count; ++j) {429 // try to find the old key in the new key list430 i = 0;431 while (i < kbd_dev->keycode_count432 && key_codes[i] != kbd_dev->keycodes[j]) {433 ++i;434 }435 436 if (i == kbd_dev->keycode_count) {437 // not found, i.e. the key was released438 key = usbkbd_parse_scancode(kbd_dev->keycodes[j]);439 kbd_push_ev(KEY_RELEASE, key, kbd_dev);440 usb_log_debug2("\nKey released: %d\n", key);441 } else {442 // found, nothing happens443 }444 }445 446 // key presses447 for (i = 0; i < kbd_dev->keycode_count; ++i) {448 // try to find the new key in the old key list449 j = 0;450 while (j < kbd_dev->keycode_count451 && kbd_dev->keycodes[j] != key_codes[i]) {452 ++j;453 }454 455 if (j == kbd_dev->keycode_count) {456 // not found, i.e. new key pressed457 key = usbkbd_parse_scancode(key_codes[i]);458 usb_log_debug2("\nKey pressed: %d (keycode: %d)\n", key,459 key_codes[i]);460 kbd_push_ev(KEY_PRESS, key, kbd_dev);461 } else {462 // found, nothing happens463 }464 }465 466 memcpy(kbd_dev->keycodes, key_codes, kbd_dev->keycode_count);467 468 usb_log_debug2("\nNew stored keycodes: ");469 for (i = 0; i < kbd_dev->keycode_count; ++i) {470 usb_log_debug2("%d ", kbd_dev->keycodes[i]);471 }472 }473 474 256 /* 475 257 * Callbacks for parser … … 478 260 uint8_t modifiers, void *arg) 479 261 { 480 if (arg == NULL) { 481 usb_log_warning("Missing argument in callback " 482 "usbkbd_process_keycodes().\n"); 483 return; 484 } 485 486 usb_log_debug2("Got keys from parser: "); 262 printf("Got keys: "); 487 263 unsigned i; 488 264 for (i = 0; i < count; ++i) { 489 usb_log_debug2("%d ", key_codes[i]); 490 } 491 usb_log_debug2("\n"); 492 493 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)arg; 494 495 if (count != kbd_dev->keycode_count) { 496 usb_log_warning("Number of received keycodes (%d) differs from" 497 " expected number (%d).\n", count, kbd_dev->keycode_count); 498 return; 499 } 500 501 usbkbd_check_modifier_changes(kbd_dev, modifiers); 502 usbkbd_check_key_changes(kbd_dev, key_codes); 265 printf("%d ", key_codes[i]); 266 } 267 printf("\n"); 268 269 for (i = 0; i < count; ++i) { 270 // TODO: Key press / release 271 272 // TODO: NOT WORKING 273 unsigned int key = usbkbd_parse_scancode(key_codes[i]); 274 275 if (key == 0) { 276 continue; 277 } 278 kbd_push_ev(KEY_PRESS, key); 279 } 280 printf("\n"); 503 281 } 504 282 … … 513 291 for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) { 514 292 // TODO: endianness 515 uint16_t length = kbd_dev->conf->interfaces[i].hid_desc.516 report_desc_info.length;293 uint16_t length = 294 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length; 517 295 size_t actual_size = 0; 518 296 519 297 // allocate space for the report descriptor 520 kbd_dev->conf->interfaces[i].report_desc = 521 (uint8_t *)malloc(length); 298 kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length); 522 299 523 300 // get the descriptor from the device … … 540 317 return EOK; 541 318 } 542 543 319 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 544 320 { … … 599 375 } 600 376 377 378 379 601 380 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 602 381 sizeof(usb_hid_configuration_t)); … … 609 388 free(descriptors); 610 389 if (rc != EOK) { 611 usb_log_warning("Problem with parsing standard descriptors.\n");390 printf("Problem with parsing standard descriptors.\n"); 612 391 return rc; 613 392 } … … 616 395 rc = usbkbd_get_report_descriptor(kbd_dev); 617 396 if (rc != EOK) { 618 usb_log_warning("Problem with parsingREPORT descriptor.\n");397 printf("Problem with parsing HID REPORT descriptor.\n"); 619 398 return rc; 620 399 } … … 626 405 * 1) select one configuration (lets say the first) 627 406 * 2) how many interfaces?? how to select one?? 628 * ("The default setting for an interface is always alternate 629 * setting zero.") 407 * ("The default setting for an interface is always alternate setting zero.") 630 408 * 3) find endpoint which is IN and INTERRUPT (parse), save its number 631 409 * as the endpoint for polling 632 410 */ 633 411 … … 643 421 644 422 if (kbd_dev == NULL) { 645 usb_log_fatal("No memory!\n");423 fprintf(stderr, NAME ": No memory!\n"); 646 424 return NULL; 647 425 } … … 679 457 // TODO: get descriptors, parse descriptors and save endpoints 680 458 usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 459 //usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1); 681 460 rc = usbkbd_process_descriptors(kbd_dev); 682 461 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); … … 684 463 goto error_leave; 685 464 } 686 687 // save the size of the report 688 kbd_dev->keycode_count = BOOTP_REPORT_SIZE; 689 kbd_dev->keycodes = (uint8_t *)calloc( 690 kbd_dev->keycode_count, sizeof(uint8_t)); 691 692 if (kbd_dev->keycodes == NULL) { 693 usb_log_fatal("No memory!\n"); 694 goto error_leave; 695 } 696 697 // set configuration to the first one 698 // TODO: handle case with no configurations 699 usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 700 usb_request_set_configuration(&kbd_dev->ctrl_pipe, 701 kbd_dev->conf->config_descriptor.configuration_number); 702 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); 703 704 // set boot protocol 705 usbkbd_req_set_protocol(kbd_dev, 1, USB_HID_PROTOCOL_BOOT); 706 465 707 466 return kbd_dev; 708 467 … … 717 476 usb_hid_report_in_callbacks_t *callbacks = 718 477 (usb_hid_report_in_callbacks_t *)malloc( 719 478 sizeof(usb_hid_report_in_callbacks_t)); 720 479 callbacks->keyboard = usbkbd_process_keycodes; 721 480 722 481 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 723 482 // NULL); 724 /*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size"725 " %zu\n", actual_size);*/483 printf("Calling usb_hid_boot_keyboard_input_report() with size %zu\n", 484 actual_size); 726 485 //dump_buffer("bufffer: ", buffer, actual_size); 727 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, 728 callbacks, kbd_dev); 729 730 if (rc != EOK) { 731 usb_log_warning("Error in usb_hid_boot_keyboard_input_report():" 732 "%s\n", str_error(rc)); 486 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, 487 NULL); 488 if (rc != EOK) { 489 printf("Error in usb_hid_boot_keyboard_input_report(): %d\n", rc); 733 490 } 734 491 } … … 740 497 size_t actual_size; 741 498 742 usb_log_info("Polling keyboard...\n");499 printf("Polling keyboard...\n"); 743 500 744 501 while (true) { 745 async_usleep(1000 * 10 00);502 async_usleep(1000 * 10); 746 503 747 504 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe); 748 505 if (sess_rc != EOK) { 749 usb_log_warning("Failed to start a session: %s.\n",506 printf("Failed to start a session: %s.\n", 750 507 str_error(sess_rc)); 751 508 continue; … … 757 514 758 515 if (rc != EOK) { 759 usb_log_warning("Error polling the keyboard: %s.\n",516 printf("Error polling the keyboard: %s.\n", 760 517 str_error(rc)); 761 518 continue; … … 763 520 764 521 if (sess_rc != EOK) { 765 usb_log_warning("Error closing session: %s.\n",522 printf("Error closing session: %s.\n", 766 523 str_error(sess_rc)); 767 524 continue; … … 773 530 */ 774 531 if (actual_size == 0) { 775 usb_log_debug("Keyboard returned NAK\n");532 printf("Keyboard returned NAK\n"); 776 533 continue; 777 534 } … … 780 537 * TODO: Process pressed keys. 781 538 */ 782 usb_log_debug("Calling usbkbd_process_interrupt_in()\n");539 printf("Calling usbkbd_process_interrupt_in()\n"); 783 540 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 784 541 } … … 790 547 static int usbkbd_fibril_device(void *arg) 791 548 { 549 printf("!!! USB device fibril\n"); 550 792 551 if (arg == NULL) { 793 usb_log_error("No device!\n");552 printf("No device!\n"); 794 553 return -1; 795 554 } 796 797 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)arg; 555 556 ddf_dev_t *dev = (ddf_dev_t *)arg; 557 558 // initialize device (get and process descriptors, get address, etc.) 559 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev); 560 if (kbd_dev == NULL) { 561 printf("Error while initializing device.\n"); 562 return -1; 563 } 798 564 799 565 usbkbd_poll_keyboard(kbd_dev); … … 804 570 static int usbkbd_add_device(ddf_dev_t *dev) 805 571 { 572 /* For now, fail immediately. */ 573 //return ENOTSUP; 574 575 /* 576 * When everything is okay, connect to "our" HC. 577 * 578 * Not supported yet, skip.. 579 */ 580 // int phone = usb_drv_hc_connect_auto(dev, 0); 581 // if (phone < 0) { 582 // /* 583 // * Connecting to HC failed, roll-back and announce 584 // * failure. 585 // */ 586 // return phone; 587 // } 588 589 // dev->parent_phone = phone; 590 806 591 /* 807 592 * Create default function. … … 816 601 rc = ddf_fun_add_to_class(kbd_fun, "keyboard"); 817 602 assert(rc == EOK); 818 819 /*820 * Initialize device (get and process descriptors, get address, etc.)821 */822 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev);823 if (kbd_dev == NULL) {824 usb_log_error("Error while initializing device.\n");825 return -1;826 }827 603 828 604 /* 829 605 * Create new fibril for handling this keyboard 830 606 */ 831 fid_t fid = fibril_create(usbkbd_fibril_device, kbd_dev);607 fid_t fid = fibril_create(usbkbd_fibril_device, dev); 832 608 if (fid == 0) { 833 usb_log_error("Failed to start fibril for HID device\n");609 printf("%s: failed to start fibril for HID device\n", NAME); 834 610 return ENOMEM; 835 611 } … … 858 634 int main(int argc, char *argv[]) 859 635 { 860 usb_log_enable(USB_LOG_LEVEL_ MAX, NAME);636 usb_log_enable(USB_LOG_LEVEL_INFO, "usbhid"); 861 637 return ddf_driver_main(&kbd_driver); 862 638 } -
uspace/lib/usb/include/usb/classes/hid.h
r3a1aa20 rb8622e2 51 51 } usb_hid_request_t; 52 52 53 typedef enum {54 USB_HID_REPORT_TYPE_INPUT = 1,55 USB_HID_REPORT_TYPE_OUTPUT = 2,56 USB_HID_REPORT_TYPE_FEATURE = 357 } usb_hid_report_type_t;58 59 typedef enum {60 USB_HID_PROTOCOL_BOOT = 0,61 USB_HID_PROTOCOL_REPORT = 162 } usb_hid_protocol_t;63 64 53 /** USB/HID subclass constants. */ 65 54 typedef enum { … … 73 62 USB_HID_PROTOCOL_KEYBOARD = 1, 74 63 USB_HID_PROTOCOL_MOUSE = 2 75 } usb_hid_ iface_protocol_t;64 } usb_hid_protocol_t; 76 65 77 66 /** Part of standard USB HID descriptor specifying one class descriptor. -
uspace/lib/usb/include/usb/classes/hidparser.h
r3a1aa20 rb8622e2 70 70 } usb_hid_report_in_callbacks_t; 71 71 72 73 typedef enum { 74 USB_HID_MOD_LCTRL = 0x01, 75 USB_HID_MOD_LSHIFT = 0x02, 76 USB_HID_MOD_LALT = 0x04, 77 USB_HID_MOD_LGUI = 0x08, 78 USB_HID_MOD_RCTRL = 0x10, 79 USB_HID_MOD_RSHIFT = 0x20, 80 USB_HID_MOD_RALT = 0x40, 81 USB_HID_MOD_RGUI = 0x80, 82 USB_HID_MOD_COUNT = 8 83 } usb_hid_modifiers_t; 84 85 typedef enum { 86 USB_HID_LED_NUM_LOCK = 0x1, 87 USB_HID_LED_CAPS_LOCK = 0x2, 88 USB_HID_LED_SCROLL_LOCK = 0x4, 89 USB_HID_LED_COMPOSE = 0x8, 90 USB_HID_LED_KANA = 0x10, 91 USB_HID_LED_COUNT = 5 92 } usb_hid_led_t; 93 94 static const usb_hid_modifiers_t 95 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { 96 USB_HID_MOD_LCTRL, 97 USB_HID_MOD_LSHIFT, 98 USB_HID_MOD_LALT, 99 USB_HID_MOD_LGUI, 100 USB_HID_MOD_RCTRL, 101 USB_HID_MOD_RSHIFT, 102 USB_HID_MOD_RALT, 103 USB_HID_MOD_RGUI 104 }; 105 106 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = { 107 // USB_HID_LED_NUM_LOCK, 108 // USB_HID_LED_CAPS_LOCK, 109 // USB_HID_LED_SCROLL_LOCK, 110 // USB_HID_LED_COMPOSE, 111 // USB_HID_LED_KANA 112 //}; 113 114 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 115 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 116 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 117 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 118 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10 72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 73 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 74 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 75 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 76 #define USB_HID_BOOT_KEYBOARD_KANA 0x10 119 77 120 78 /* -
uspace/lib/usb/src/hidparser.c
r3a1aa20 rb8622e2 144 144 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size) 145 145 { 146 if(size < 2){146 if(size != 1){ 147 147 return -1; 148 148 } 149 149 150 data[1] = leds; 150 /* used only first five bits, others are only padding*/ 151 *data = leds; 151 152 return EOK; 152 153 }
Note:
See TracChangeset
for help on using the changeset viewer.