Changeset d8e61b0d in mainline for uspace/drv/usbhid/kbddev.c
- Timestamp:
- 2011-03-18T16:03:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4fec9ee, 98637224
- Parents:
- 11ac272 (diff), fc5ed5d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbddev.c
r11ac272 rd8e61b0d 51 51 #include <usb/classes/hidparser.h> 52 52 #include <usb/classes/classes.h> 53 #include <usb/classes/hidut.h> 53 54 54 55 #include "kbddev.h" … … 122 123 KC_RALT, /* USB_HID_MOD_RALT */ 123 124 0, /* USB_HID_MOD_RGUI */ 125 }; 126 127 typedef enum usbhid_lock_code { 128 USBHID_LOCK_NUM = 0x53, 129 USBHID_LOCK_CAPS = 0x39, 130 USBHID_LOCK_SCROLL = 0x47, 131 USBHID_LOCK_COUNT = 3 132 } usbhid_lock_code; 133 134 static const usbhid_lock_code usbhid_lock_codes[USBHID_LOCK_COUNT] = { 135 USBHID_LOCK_NUM, 136 USBHID_LOCK_CAPS, 137 USBHID_LOCK_SCROLL 124 138 }; 125 139 … … 346 360 * @sa usbhid_kbd_push_ev() 347 361 */ 348 static void usbhid_kbd_check_modifier_changes(usbhid_kbd_t *kbd_dev, 349 uint8_t modifiers) 350 { 351 /* 352 * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK 353 * both as modifiers and as keys with their own scancodes??? 354 * 355 * modifiers should be sent as normal keys to usbhid_parse_scancode()!! 356 * so maybe it would be better if I received it from report parser in 357 * that way 358 */ 359 360 int i; 361 for (i = 0; i < USB_HID_MOD_COUNT; ++i) { 362 if ((modifiers & usb_hid_modifiers_consts[i]) && 363 !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) { 364 // modifier pressed 365 if (usbhid_modifiers_keycodes[i] != 0) { 366 usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, 367 usbhid_modifiers_keycodes[i]); 368 } 369 } else if (!(modifiers & usb_hid_modifiers_consts[i]) && 370 (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) { 371 // modifier released 372 if (usbhid_modifiers_keycodes[i] != 0) { 373 usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, 374 usbhid_modifiers_keycodes[i]); 375 } 376 } // no change 377 } 378 379 kbd_dev->modifiers = modifiers; 362 //static void usbhid_kbd_check_modifier_changes(usbhid_kbd_t *kbd_dev, 363 // const uint8_t *key_codes, size_t count) 364 //{ 365 // /* 366 // * TODO: why the USB keyboard has NUM_, SCROLL_ and CAPS_LOCK 367 // * both as modifiers and as keyUSB_HID_LOCK_COUNTs with their own scancodes??? 368 // * 369 // * modifiers should be sent as normal keys to usbhid_parse_scancode()!! 370 // * so maybe it would be better if I received it from report parser in 371 // * that way 372 // */ 373 374 // int i; 375 // for (i = 0; i < count; ++i) { 376 // if ((modifiers & usb_hid_modifiers_consts[i]) && 377 // !(kbd_dev->modifiers & usb_hid_modifiers_consts[i])) { 378 // // modifier pressed 379 // if (usbhid_modifiers_keycodes[i] != 0) { 380 // usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, 381 // usbhid_modifiers_keycodes[i]); 382 // } 383 // } else if (!(modifiers & usb_hid_modifiers_consts[i]) && 384 // (kbd_dev->modifiers & usb_hid_modifiers_consts[i])) { 385 // // modifier released 386 // if (usbhid_modifiers_keycodes[i] != 0) { 387 // usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, 388 // usbhid_modifiers_keycodes[i]); 389 // } 390 // } // no change 391 // } 392 393 // kbd_dev->modifiers = modifiers; 394 //} 395 396 /*----------------------------------------------------------------------------*/ 397 398 static inline int usbhid_kbd_is_lock(unsigned int key_code) 399 { 400 return (key_code == KC_NUM_LOCK 401 || key_code == KC_SCROLL_LOCK 402 || key_code == KC_CAPS_LOCK); 380 403 } 381 404 … … 404 427 /* 405 428 * First of all, check if the kbd have reported phantom state. 429 * 430 * TODO: this must be changed as we don't know which keys are modifiers 431 * and which are regular keys. 406 432 */ 407 433 i = 0; … … 434 460 // not found, i.e. the key was released 435 461 key = usbhid_parse_scancode(kbd_dev->keys[j]); 436 usbhid_kbd_repeat_stop(kbd_dev, key); 462 if (!usbhid_kbd_is_lock(key)) { 463 usbhid_kbd_repeat_stop(kbd_dev, key); 464 } 437 465 usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, key); 438 466 usb_log_debug2("Key released: %d\n", key); … … 458 486 key_codes[i]); 459 487 usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key); 460 usbhid_kbd_repeat_start(kbd_dev, key); 488 if (!usbhid_kbd_is_lock(key)) { 489 usbhid_kbd_repeat_start(kbd_dev, key); 490 } 461 491 } else { 462 492 // found, nothing happens … … 502 532 503 533 usb_log_debug("Got keys from parser: %s\n", 504 usb_debug_str_buffer(key_codes, kbd_dev->key_count, 0));534 usb_debug_str_buffer(key_codes, count, 0)); 505 535 506 536 if (count != kbd_dev->key_count) { … … 510 540 } 511 541 512 usbhid_kbd_check_modifier_changes(kbd_dev, modifiers);542 ///usbhid_kbd_check_modifier_changes(kbd_dev, key_codes, count); 513 543 usbhid_kbd_check_key_changes(kbd_dev, key_codes, count); 514 544 } … … 535 565 uint8_t *buffer, size_t actual_size) 536 566 { 567 assert(kbd_dev->initialized); 568 assert(kbd_dev->hid_dev->parser != NULL); 569 537 570 usb_hid_report_in_callbacks_t *callbacks = 538 571 (usb_hid_report_in_callbacks_t *)malloc( … … 541 574 callbacks->keyboard = usbhid_kbd_process_keycodes; 542 575 543 usb_log_debug("Calling usb_hid_ boot_keyboard_input_report() with "576 usb_log_debug("Calling usb_hid_parse_report() with " 544 577 "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0)); 545 578 546 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, 547 callbacks, kbd_dev); 579 // int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, 580 // callbacks, kbd_dev); 581 int rc = usb_hid_parse_report(kbd_dev->hid_dev->parser, buffer, 582 actual_size, callbacks, kbd_dev); 548 583 549 584 if (rc != EOK) { … … 614 649 free((*kbd_dev)->repeat_mtx); 615 650 } 616 651 617 652 free(*kbd_dev); 618 653 *kbd_dev = NULL; … … 674 709 675 710 // save the size of the report (boot protocol report by default) 676 kbd_dev->key_count = BOOTP_REPORT_SIZE; 711 // kbd_dev->key_count = BOOTP_REPORT_SIZE; 712 713 usb_hid_report_path_t path; 714 path.usage_page = USB_HIDUT_PAGE_KEYBOARD; 715 kbd_dev->key_count = usb_hid_report_input_length( 716 kbd_dev->hid_dev->parser, &path); 717 718 usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count); 719 677 720 kbd_dev->keys = (uint8_t *)calloc( 678 721 kbd_dev->key_count, sizeof(uint8_t)); … … 709 752 assert(kbd_dev->hid_dev != NULL); 710 753 assert(kbd_dev->hid_dev->initialized); 711 usbhid_req_set_protocol(kbd_dev->hid_dev, USB_HID_PROTOCOL_BOOT);754 //usbhid_req_set_protocol(kbd_dev->hid_dev, USB_HID_PROTOCOL_BOOT); 712 755 713 756 usbhid_kbd_set_led(kbd_dev);
Note:
See TracChangeset
for help on using the changeset viewer.