Changeset 06f9d8fb in mainline for uspace/drv/usbhid/kbd/kbddev.c
- Timestamp:
- 2011-05-30T20:02:17Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c3dafe1
- Parents:
- be8d907 (diff), 63862a0 (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/kbd/kbddev.c
rbe8d907 r06f9d8fb 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;85 74 static const uint8_t ERROR_ROLLOVER = 1; 86 75 … … 105 94 .flags = 0 106 95 }; 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 = 0113 //};114 115 ///* Array of endpoints expected on the device, NULL terminated. */116 //usb_endpoint_description_t117 // *usb_kbd_endpoints[USB_KBD_POLL_EP_COUNT + 1] = {118 // &boot_poll_endpoint_description,119 // &hid_poll_endpoint_description,120 // NULL121 //};122 96 123 97 const char *HID_KBD_FUN_NAME = "keyboard"; … … 176 150 177 151 /*----------------------------------------------------------------------------*/ 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_keycodes184 //};185 186 /*----------------------------------------------------------------------------*/187 152 /* Keyboard layouts */ 188 153 /*----------------------------------------------------------------------------*/ … … 200 165 201 166 /*----------------------------------------------------------------------------*/ 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 = 3221 //} 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_SCROLL227 //};228 229 /*----------------------------------------------------------------------------*/230 167 /* IPC method handler */ 231 168 /*----------------------------------------------------------------------------*/ 232 169 233 170 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_handler236 //};237 171 238 172 /** … … 301 235 return; 302 236 } 303 237 304 238 /* Reset the LED data. */ 305 239 memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t)); … … 495 429 */ 496 430 static void usb_kbd_check_key_changes(usb_hid_dev_t *hid_dev, 497 usb_kbd_t *kbd_dev /*, const uint8_t *key_codes, size_t count*/)431 usb_kbd_t *kbd_dev) 498 432 { 499 433 unsigned int key; … … 567 501 } 568 502 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 582 503 memcpy(kbd_dev->keys_old, kbd_dev->keys, kbd_dev->key_count * 4); 583 504 … … 590 511 591 512 /*----------------------------------------------------------------------------*/ 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 or599 * released, modifier was pressed or released).600 *601 * @param key_codes Parsed keyboard report - codes of currently pressed keys602 * according to HID Usage Tables.603 * @param count Number of key codes in report (size of the report).604 * @param report_id605 * @param arg User-specified argument. Expects pointer to the keyboard device606 * 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 /*----------------------------------------------------------------------------*/642 513 /* General kbd functions */ 643 514 /*----------------------------------------------------------------------------*/ … … 668 539 "buffer %s\n", usb_debug_str_buffer(buffer, actual_size, 0)); 669 540 670 // int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size,671 // callbacks, kbd_dev);672 541 usb_hid_report_path_t *path = usb_hid_report_path(); 673 542 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 674 //usb_hid_report_path_set_report_id(path, 0);675 543 676 544 uint8_t report_id; … … 698 566 699 567 assert(i < kbd_dev->key_count); 700 // if (i == kbd_dev->key_count) {701 // break;702 // }703 568 704 569 // save the key usage 705 /* TODO: maybe it's not good to save value, nor usage706 * as the value may be e.g. 1 for LEDs and usage may be707 * value of the LED. On the other hand, in case of normal708 * keys, the usage is more important and we must check709 * that. One possible solution: distinguish between those710 * two parts of the Report somehow.711 */712 570 if (field->value != 0) { 713 571 kbd_dev->keys[i] = field->usage; … … 896 754 usb_log_warning("Error creating output report buffer.\n"); 897 755 free(kbd_dev->keys); 898 return ENOMEM; /* TODO: other error code */756 return ENOMEM; 899 757 } 900 758 … … 951 809 952 810 // save the KBD device structure into the HID device structure 953 //hid_dev->data = kbd_dev;954 811 *data = kbd_dev; 955 812 … … 1038 895 1039 896 if ((*kbd_dev)->repeat_mtx != NULL) { 1040 / * TODO: replace by some check and wait */1041 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx));897 //assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); 898 while (fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)) {} 1042 899 free((*kbd_dev)->repeat_mtx); 1043 900 }
Note:
See TracChangeset
for help on using the changeset viewer.