Changes in / [b8622e2:3a1aa20] in mainline
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/conv.c
rb8622e2 r3a1aa20 36 36 #include <io/keycode.h> 37 37 #include <stdint.h> 38 #include <stdio.h> 39 #include <usb/debug.h> 38 40 #include "conv.h" 39 41 … … 141 143 //[0xe7] = KC_R // TODO: right GUI 142 144 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_NPERIOD 162 143 163 }; 144 164 … … 189 209 190 210 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 191 224 // if (key != 0) 192 225 // kbd_push_ev(type, key); -
uspace/drv/usbhid/hid.h
rb8622e2 r3a1aa20 37 37 #define USBHID_HID_H_ 38 38 39 #include <stdint.h> 40 39 41 #include <usb/classes/hid.h> 40 42 #include <ddf/driver.h> … … 74 76 usb_endpoint_pipe_t ctrl_pipe; 75 77 usb_endpoint_pipe_t poll_pipe; 78 79 uint8_t *keycodes; 80 size_t keycode_count; 81 uint8_t modifiers; 76 82 } usb_hid_dev_kbd_t; 77 83 -
uspace/drv/usbhid/main.c
rb8622e2 r3a1aa20 51 51 #include <usb/descriptor.h> 52 52 #include <io/console.h> 53 #include <stdint.h> 53 54 #include "hid.h" 54 55 #include "descparser.h" … … 58 59 59 60 #define BUFFER_SIZE 8 61 #define BUFFER_OUT_SIZE 1 60 62 #define NAME "usbhid" 61 63 62 64 #define GUESSED_POLL_ENDPOINT 1 65 #define BOOTP_REPORT_SIZE 6 63 66 64 67 /** Keyboard polling endpoint description for boot protocol class. */ … … 120 123 121 124 static void dump_buffer(const char *msg, const uint8_t *buffer, size_t length) 122 { 125 {uint8_t buffer[BUFFER_SIZE]; 123 126 printf("%s\n", msg); 124 127 … … 137 140 */ 138 141 139 /** Currently active modifiers .142 /** Currently active modifiers (locks is probably better word). 140 143 * 141 144 * TODO: put to device? … … 159 162 static int active_layout = 0; 160 163 161 static void kbd_push_ev(int type, unsigned int key) 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) 162 265 { 163 266 console_event_t ev; … … 183 286 184 287 switch (key) { 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;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; 188 291 default: mod_mask = 0; break; 189 292 } 190 293 191 294 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 192 299 if (type == KEY_PRESS) { 300 usb_log_debug2("\nKey pressed.\n"); 193 301 /* 194 302 * Only change lock state on transition from released … … 200 308 201 309 /* Update keyboard lock indicator lights. */ 202 // TODO 203 //kbd_ctl_set_ind(mods); 310 usbkbd_set_led(mods, kbd_dev); 204 311 } else { 312 usb_log_debug2("\nKey released.\n"); 205 313 lock_keys = lock_keys & ~mod_mask; 206 314 } 207 315 } 208 316 /* 209 printf("type: %d\n", type);210 printf("mods: 0x%x\n", mods);211 printf("keycode: %u\n", key);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); 212 320 */ 321 usb_log_debug2("\n\nmods after: 0x%x\n", mods); 322 usb_log_debug2("\nLock keys after: 0x%x\n\n", lock_keys); 213 323 214 324 if (type == KEY_PRESS && (mods & KM_LCTRL) && … … 236 346 ev.key = key; 237 347 ev.mods = mods; 348 349 if (ev.mods & KM_NUM_LOCK) { 350 usb_log_debug("\n\nNum Lock turned on.\n\n"); 351 } 238 352 239 353 ev.c = layout[active_layout]->parse_ev(&ev); 240 354 241 printf("Sending key %d to the console\n", ev.key);355 usb_log_debug2("Sending key %d to the console\n", ev.key); 242 356 assert(console_callback_phone != -1); 243 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); 357 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, 358 ev.mods, ev.c); 244 359 } 245 360 /* … … 249 364 /* 250 365 * TODO: 251 * 1) key press / key release - how does the keyboard notify about release? 366 * 1) key press / key release - how does the keyboard notify about 367 * release? 252 368 * 2) layouts (use the already defined), not important now 253 369 * 3) 254 370 */ 255 371 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_LOCK 388 * 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 in 392 * that way 393 */ 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 pressed 400 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 released 407 if (usb_hid_modifiers_keycodes[i] != 0) { 408 kbd_push_ev(KEY_RELEASE, 409 usb_hid_modifiers_keycodes[i], kbd_dev); 410 } 411 } // no change 412 } 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 implementation 426 427 // key releases 428 for (j = 0; j < kbd_dev->keycode_count; ++j) { 429 // try to find the old key in the new key list 430 i = 0; 431 while (i < kbd_dev->keycode_count 432 && 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 released 438 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 happens 443 } 444 } 445 446 // key presses 447 for (i = 0; i < kbd_dev->keycode_count; ++i) { 448 // try to find the new key in the old key list 449 j = 0; 450 while (j < kbd_dev->keycode_count 451 && 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 pressed 457 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 happens 463 } 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 256 474 /* 257 475 * Callbacks for parser … … 260 478 uint8_t modifiers, void *arg) 261 479 { 262 printf("Got keys: "); 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: "); 263 487 unsigned i; 264 488 for (i = 0; i < count; ++i) { 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"); 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); 281 503 } 282 504 … … 291 513 for (i = 0; i < kbd_dev->conf->config_descriptor.interface_count; ++i) { 292 514 // TODO: endianness 293 uint16_t length = 294 kbd_dev->conf->interfaces[i].hid_desc.report_desc_info.length;515 uint16_t length = kbd_dev->conf->interfaces[i].hid_desc. 516 report_desc_info.length; 295 517 size_t actual_size = 0; 296 518 297 519 // allocate space for the report descriptor 298 kbd_dev->conf->interfaces[i].report_desc = (uint8_t *)malloc(length); 520 kbd_dev->conf->interfaces[i].report_desc = 521 (uint8_t *)malloc(length); 299 522 300 523 // get the descriptor from the device … … 317 540 return EOK; 318 541 } 542 319 543 static int usbkbd_process_descriptors(usb_hid_dev_kbd_t *kbd_dev) 320 544 { … … 375 599 } 376 600 377 378 379 380 601 kbd_dev->conf = (usb_hid_configuration_t *)calloc(1, 381 602 sizeof(usb_hid_configuration_t)); … … 388 609 free(descriptors); 389 610 if (rc != EOK) { 390 printf("Problem with parsing standard descriptors.\n");611 usb_log_warning("Problem with parsing standard descriptors.\n"); 391 612 return rc; 392 613 } … … 395 616 rc = usbkbd_get_report_descriptor(kbd_dev); 396 617 if (rc != EOK) { 397 printf("Problem with parsing HIDREPORT descriptor.\n");618 usb_log_warning("Problem with parsing REPORT descriptor.\n"); 398 619 return rc; 399 620 } … … 405 626 * 1) select one configuration (lets say the first) 406 627 * 2) how many interfaces?? how to select one?? 407 * ("The default setting for an interface is always alternate setting zero.") 628 * ("The default setting for an interface is always alternate 629 * setting zero.") 408 630 * 3) find endpoint which is IN and INTERRUPT (parse), save its number 409 631 * as the endpoint for polling 410 632 */ 411 633 … … 421 643 422 644 if (kbd_dev == NULL) { 423 fprintf(stderr, NAME ":No memory!\n");645 usb_log_fatal("No memory!\n"); 424 646 return NULL; 425 647 } … … 457 679 // TODO: get descriptors, parse descriptors and save endpoints 458 680 usb_endpoint_pipe_start_session(&kbd_dev->ctrl_pipe); 459 //usb_request_set_configuration(&kbd_dev->ctrl_pipe, 1);460 681 rc = usbkbd_process_descriptors(kbd_dev); 461 682 usb_endpoint_pipe_end_session(&kbd_dev->ctrl_pipe); … … 463 684 goto error_leave; 464 685 } 465 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 466 707 return kbd_dev; 467 708 … … 476 717 usb_hid_report_in_callbacks_t *callbacks = 477 718 (usb_hid_report_in_callbacks_t *)malloc( 478 719 sizeof(usb_hid_report_in_callbacks_t)); 479 720 callbacks->keyboard = usbkbd_process_keycodes; 480 721 481 722 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 482 723 // NULL); 483 printf("Calling usb_hid_boot_keyboard_input_report() with size %zu\n",484 actual_size);724 /*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size" 725 " %zu\n", actual_size);*/ 485 726 //dump_buffer("bufffer: ", buffer, actual_size); 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); 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)); 490 733 } 491 734 } … … 497 740 size_t actual_size; 498 741 499 printf("Polling keyboard...\n");742 usb_log_info("Polling keyboard...\n"); 500 743 501 744 while (true) { 502 async_usleep(1000 * 10 );745 async_usleep(1000 * 1000); 503 746 504 747 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe); 505 748 if (sess_rc != EOK) { 506 printf("Failed to start a session: %s.\n",749 usb_log_warning("Failed to start a session: %s.\n", 507 750 str_error(sess_rc)); 508 751 continue; … … 514 757 515 758 if (rc != EOK) { 516 printf("Error polling the keyboard: %s.\n",759 usb_log_warning("Error polling the keyboard: %s.\n", 517 760 str_error(rc)); 518 761 continue; … … 520 763 521 764 if (sess_rc != EOK) { 522 printf("Error closing session: %s.\n",765 usb_log_warning("Error closing session: %s.\n", 523 766 str_error(sess_rc)); 524 767 continue; … … 530 773 */ 531 774 if (actual_size == 0) { 532 printf("Keyboard returned NAK\n");775 usb_log_debug("Keyboard returned NAK\n"); 533 776 continue; 534 777 } … … 537 780 * TODO: Process pressed keys. 538 781 */ 539 printf("Calling usbkbd_process_interrupt_in()\n");782 usb_log_debug("Calling usbkbd_process_interrupt_in()\n"); 540 783 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 541 784 } … … 547 790 static int usbkbd_fibril_device(void *arg) 548 791 { 549 printf("!!! USB device fibril\n");550 551 792 if (arg == NULL) { 552 printf("No device!\n");793 usb_log_error("No device!\n"); 553 794 return -1; 554 795 } 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 } 796 797 usb_hid_dev_kbd_t *kbd_dev = (usb_hid_dev_kbd_t *)arg; 564 798 565 799 usbkbd_poll_keyboard(kbd_dev); … … 570 804 static int usbkbd_add_device(ddf_dev_t *dev) 571 805 { 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 announce584 // * failure.585 // */586 // return phone;587 // }588 589 // dev->parent_phone = phone;590 591 806 /* 592 807 * Create default function. … … 601 816 rc = ddf_fun_add_to_class(kbd_fun, "keyboard"); 602 817 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 } 603 827 604 828 /* 605 829 * Create new fibril for handling this keyboard 606 830 */ 607 fid_t fid = fibril_create(usbkbd_fibril_device, dev);831 fid_t fid = fibril_create(usbkbd_fibril_device, kbd_dev); 608 832 if (fid == 0) { 609 printf("%s: failed to start fibril for HID device\n", NAME);833 usb_log_error("Failed to start fibril for HID device\n"); 610 834 return ENOMEM; 611 835 } … … 634 858 int main(int argc, char *argv[]) 635 859 { 636 usb_log_enable(USB_LOG_LEVEL_ INFO, "usbhid");860 usb_log_enable(USB_LOG_LEVEL_MAX, NAME); 637 861 return ddf_driver_main(&kbd_driver); 638 862 } -
uspace/lib/usb/include/usb/classes/hid.h
rb8622e2 r3a1aa20 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 = 3 57 } usb_hid_report_type_t; 58 59 typedef enum { 60 USB_HID_PROTOCOL_BOOT = 0, 61 USB_HID_PROTOCOL_REPORT = 1 62 } usb_hid_protocol_t; 63 53 64 /** USB/HID subclass constants. */ 54 65 typedef enum { … … 62 73 USB_HID_PROTOCOL_KEYBOARD = 1, 63 74 USB_HID_PROTOCOL_MOUSE = 2 64 } usb_hid_ protocol_t;75 } usb_hid_iface_protocol_t; 65 76 66 77 /** Part of standard USB HID descriptor specifying one class descriptor. -
uspace/lib/usb/include/usb/classes/hidparser.h
rb8622e2 r3a1aa20 70 70 } usb_hid_report_in_callbacks_t; 71 71 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 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 77 119 78 120 /* -
uspace/lib/usb/src/hidparser.c
rb8622e2 r3a1aa20 144 144 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size) 145 145 { 146 if(size != 1){146 if(size < 2){ 147 147 return -1; 148 148 } 149 149 150 /* used only first five bits, others are only padding*/ 151 *data = leds; 150 data[1] = leds; 152 151 return EOK; 153 152 }
Note:
See TracChangeset
for help on using the changeset viewer.