Changes in uspace/drv/usbhid/kbd/kbddev.c [19e0560e:0d59d0e9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbd/kbddev.c
r19e0560e r0d59d0e9 72 72 static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK; 73 73 74 ///** Boot protocol report size (key part). */ 75 //static const size_t BOOTP_REPORT_SIZE = 6; 76 77 ///** Boot protocol total report size. */ 78 //static const size_t BOOTP_BUFFER_SIZE = 8; 79 80 ///** Boot protocol output report size. */ 81 //static const size_t BOOTP_BUFFER_OUT_SIZE = 1; 82 83 ///** Boot protocol error key code. */ 84 //static const uint8_t BOOTP_ERROR_ROLLOVER = 1; 74 85 static const uint8_t ERROR_ROLLOVER = 1; 75 86 … … 94 105 .flags = 0 95 106 }; 107 108 //static usb_endpoint_description_t hid_poll_endpoint_description = { 109 // .transfer_type = USB_TRANSFER_INTERRUPT, 110 // .direction = USB_DIRECTION_IN, 111 // .interface_class = USB_CLASS_HID, 112 // .flags = 0 113 //}; 114 115 ///* Array of endpoints expected on the device, NULL terminated. */ 116 //usb_endpoint_description_t 117 // *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = { 118 // &boot_poll_endpoint_description, 119 // &hid_poll_endpoint_description, 120 // NULL 121 //}; 96 122 97 123 const char *HID_KBD_FUN_NAME = "keyboard"; … … 150 176 151 177 /*----------------------------------------------------------------------------*/ 178 179 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count, 180 // uint8_t report_id, void *arg); 181 182 //static const usb_hid_report_in_callbacks_t usb_kbd_parser_callbacks = { 183 // .keyboard = usb_kbd_process_keycodes 184 //}; 185 186 /*----------------------------------------------------------------------------*/ 152 187 /* Keyboard layouts */ 153 188 /*----------------------------------------------------------------------------*/ … … 165 200 166 201 /*----------------------------------------------------------------------------*/ 202 /* Modifier constants */ 203 /*----------------------------------------------------------------------------*/ 204 /** Mapping of USB modifier key codes to generic modifier key codes. */ 205 //static const keycode_t usbhid_modifiers_keycodes[USB_HID_MOD_COUNT] = { 206 // KC_LCTRL, /* USB_HID_MOD_LCTRL */ 207 // KC_LSHIFT, /* USB_HID_MOD_LSHIFT */ 208 // KC_LALT, /* USB_HID_MOD_LALT */ 209 // 0, /* USB_HID_MOD_LGUI */ 210 // KC_RCTRL, /* USB_HID_MOD_RCTRL */ 211 // KC_RSHIFT, /* USB_HID_MOD_RSHIFT */ 212 // KC_RALT, /* USB_HID_MOD_RALT */ 213 // 0, /* USB_HID_MOD_RGUI */ 214 //}; 215 216 //typedef enum usbhid_lock_code { 217 // USB_KBD_LOCK_NUM = 0x53, 218 // USB_KBD_LOCK_CAPS = 0x39, 219 // USB_KBD_LOCK_SCROLL = 0x47, 220 // USB_KBD_LOCK_COUNT = 3 221 //} usbhid_lock_code; 222 223 //static const usbhid_lock_code usbhid_lock_codes[USB_KBD_LOCK_COUNT] = { 224 // USB_KBD_LOCK_NUM, 225 // USB_KBD_LOCK_CAPS, 226 // USB_KBD_LOCK_SCROLL 227 //}; 228 229 /*----------------------------------------------------------------------------*/ 167 230 /* IPC method handler */ 168 231 /*----------------------------------------------------------------------------*/ 169 232 170 233 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 234 //ddf_dev_ops_t keyboard_ops = { 235 // .default_handler = default_connection_handler 236 //}; 171 237 172 238 /** … … 235 301 return; 236 302 } 237 303 238 304 /* Reset the LED data. */ 239 305 memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t)); … … 429 495 */ 430 496 static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev, 431 usb_kbd_t *kbd_dev )497 usb_kbd_t *kbd_dev/*, const uint8_t *key_codes, size_t count*/) 432 498 { 433 499 unsigned int key; … … 501 567 } 502 568 569 // usb_log_debug("Old keys: "); 570 // for (i = 0; i < kbd_dev->key_count; ++i) { 571 // usb_log_debug("%d ", kbd_dev->keys_old[i]); 572 // } 573 // usb_log_debug("\n"); 574 575 576 // usb_log_debug("New keys: "); 577 // for (i = 0; i < kbd_dev->key_count; ++i) { 578 // usb_log_debug("%d ", kbd_dev->keys[i]); 579 // } 580 // usb_log_debug("\n"); 581 503 582 memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4); 504 583 … … 511 590 512 591 /*----------------------------------------------------------------------------*/ 592 /* Callbacks for parser */ 593 /*----------------------------------------------------------------------------*/ 594 /** 595 * Callback function for the HID report parser. 596 * 597 * This function is called by the HID report parser with the parsed report. 598 * The parsed report is used to check if any events occured (key was pressed or 599 * released, modifier was pressed or released). 600 * 601 * @param key_codes Parsed keyboard report - codes of currently pressed keys 602 * according to HID Usage Tables. 603 * @param count Number of key codes in report (size of the report). 604 * @param report_id 605 * @param arg User-specified argument. Expects pointer to the keyboard device 606 * structure representing the keyboard. 607 * 608 * @sa usb_kbd_check_key_changes(), usb_kbd_check_modifier_changes() 609 */ 610 //static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count, 611 // uint8_t report_id, void *arg) 612 //{ 613 // if (arg == NULL) { 614 // usb_log_warning("Missing argument in callback " 615 // "usbhid_process_keycodes().\n"); 616 // return; 617 // } 618 619 // usb_hid_dev_t *hid_dev = (usb_hid_dev_t *)arg; 620 621 // if (hid_dev->data == NULL) { 622 // usb_log_warning("Missing KBD device structure in callback.\n"); 623 // return; 624 // } 625 626 // usb_kbd_t *kbd_dev = (usb_kbd_t *)hid_dev->data; 627 628 // usb_log_debug("Got keys from parser (report id: %u): %s\n", 629 // report_id, usb_debug_str_buffer(key_codes, count, 0)); 630 631 // if (count != kbd_dev->key_count) { 632 // usb_log_warning("Number of received keycodes (%zu) differs from" 633 // " expected (%zu).\n", count, kbd_dev->key_count); 634 // return; 635 // } 636 637 // ///usb_kbd_check_modifier_changes(kbd_dev, key_codes, count); 638 // usb_kbd_check_key_changes(hid_dev, kbd_dev, key_codes, count); 639 //} 640 641 /*----------------------------------------------------------------------------*/ 513 642 /* General kbd functions */ 514 643 /*----------------------------------------------------------------------------*/ … … 539 668 "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0)); 540 669 670 // int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, 671 // callbacks, kbd_dev); 541 672 usb_hid_report_path_t *path = usb_hid_report_path(); 542 673 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 674 //usb_hid_report_path_set_report_id(path, 0); 543 675 544 676 uint8_t report_id; … … 566 698 567 699 assert(i < kbd_dev->key_count); 700 // if (i == kbd_dev->key_count) { 701 // break; 702 // } 568 703 569 704 // save the key usage 705 /* TODO: maybe it's not good to save value, nor usage 706 * as the value may be e.g. 1 for LEDs and usage may be 707 * value of the LED. On the other hand, in case of normal 708 * keys, the usage is more important and we must check 709 * that. One possible solution: distinguish between those 710 * two parts of the Report somehow. 711 */ 570 712 if (field->value != 0) { 571 713 kbd_dev->keys[i] = field->usage; … … 754 896 usb_log_warning("Error creating output report buffer.\n"); 755 897 free(kbd_dev->keys); 756 return ENOMEM; 898 return ENOMEM; /* TODO: other error code */ 757 899 } 758 900 … … 809 951 810 952 // save the KBD device structure into the HID device structure 953 //hid_dev->data = kbd_dev; 811 954 *data = kbd_dev; 812 955 … … 895 1038 896 1039 if ((*kbd_dev)->repeat_mtx != NULL) { 897 / /assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));898 while (fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)) {}1040 /* TODO: replace by some check and wait */ 1041 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); 899 1042 free((*kbd_dev)->repeat_mtx); 900 1043 }
Note:
See TracChangeset
for help on using the changeset viewer.