Changes in / [a82889e:f8e8738] in mainline
- Files:
-
- 17 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/amd64/Makefile.inc
ra82889e rf8e8738 50 50 usbhub \ 51 51 usbkbd \ 52 usbhid \ 52 53 usbmid \ 53 54 usbmouse \ -
uspace/Makefile
ra82889e rf8e8738 123 123 drv/usbflbk \ 124 124 drv/usbkbd \ 125 drv/usbhid \ 125 126 drv/usbhub \ 126 127 drv/usbmid \ … … 143 144 drv/usbflbk \ 144 145 drv/usbkbd \ 146 drv/usbhid \ 145 147 drv/usbhub \ 146 148 drv/usbmid \ -
uspace/drv/usbkbd/kbddev.c
ra82889e rf8e8738 265 265 static void usb_kbd_set_led(usb_kbd_t *kbd_dev) 266 266 { 267 if (kbd_dev->output_size == 0) { 268 return; 269 } 270 267 271 unsigned i = 0; 268 272 … … 288 292 289 293 int rc = usb_hid_report_output_translate(kbd_dev->parser, 290 kbd_dev->led_path, USB_HID_PATH_COMPARE_END, kbd_dev->output_buffer, 294 kbd_dev->led_path, 295 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 296 kbd_dev->output_buffer, 291 297 kbd_dev->output_size, kbd_dev->led_data, kbd_dev->led_output_size); 292 298 … … 539 545 * according to HID Usage Tables. 540 546 * @param count Number of key codes in report (size of the report). 541 * @param modifiers Bitmap of modifiers (Ctrl, Alt, Shift, GUI).547 * @param report_id 542 548 * @param arg User-specified argument. Expects pointer to the keyboard device 543 549 * structure representing the keyboard. … … 546 552 */ 547 553 static void usb_kbd_process_keycodes(const uint8_t *key_codes, size_t count, 548 uint8_t modifiers, void *arg)554 uint8_t report_id, void *arg) 549 555 { 550 556 if (arg == NULL) { … … 557 563 assert(kbd_dev != NULL); 558 564 559 usb_log_debug("Got keys from parser : %s\n",560 usb_debug_str_buffer(key_codes, count, 0));565 usb_log_debug("Got keys from parser (report id: %u): %s\n", 566 report_id, usb_debug_str_buffer(key_codes, count, 0)); 561 567 562 568 if (count != kbd_dev->key_count) { … … 608 614 usb_hid_report_path_t *path = usb_hid_report_path(); 609 615 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 616 usb_hid_report_path_set_report_id(path, 1); 610 617 611 618 int rc = usb_hid_parse_report(kbd_dev->parser, buffer, 612 actual_size, path, USB_HID_PATH_COMPARE_STRICT, callbacks, kbd_dev); 619 actual_size, path, 620 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 621 callbacks, kbd_dev); 613 622 614 623 usb_hid_report_path_free (path); … … 758 767 usb_hid_report_path_t *path = usb_hid_report_path(); 759 768 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 769 770 usb_hid_report_path_set_report_id(path, 1); 771 760 772 kbd_dev->key_count = usb_hid_report_input_length( 761 kbd_dev->parser, path, USB_HID_PATH_COMPARE_STRICT); 773 kbd_dev->parser, path, 774 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 762 775 usb_hid_report_path_free (path); 763 776 … … 777 790 kbd_dev->output_buffer = usb_hid_report_output(kbd_dev->parser, 778 791 &kbd_dev->output_size); 779 if (kbd_dev->output_buffer == NULL ) {792 if (kbd_dev->output_buffer == NULL && kbd_dev->output_size != 0) { 780 793 usb_log_warning("Error creating output report buffer.\n"); 781 794 free(kbd_dev->keys); … … 790 803 791 804 kbd_dev->led_output_size = usb_hid_report_output_size(kbd_dev->parser, 792 kbd_dev->led_path, USB_HID_PATH_COMPARE_END); 805 kbd_dev->led_path, 806 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 793 807 794 808 usb_log_debug("Output report size (in items): %zu\n", -
uspace/drv/usbkbd/main.c
ra82889e rf8e8738 33 33 /** 34 34 * @file 35 * Main routines of USB HID driver.35 * Main routines of USB KBD driver. 36 36 */ 37 37 … … 75 75 * @sa usb_kbd_fibril(), usb_kbd_repeat_fibril() 76 76 */ 77 static int usb hid_try_add_device(usb_device_t *dev)77 static int usb_kbd_try_add_device(usb_device_t *dev) 78 78 { 79 79 /* Create the function exposed under /dev/devices. */ … … 105 105 usb_kbd_free(&kbd_dev); 106 106 return rc; 107 } 107 } 108 108 109 109 usb_log_debug("USB/HID KBD device structure initialized.\n"); … … 195 195 * @retval EREFUSED if the device is not supported. 196 196 */ 197 static int usb hid_add_device(usb_device_t *dev)197 static int usb_kbd_add_device(usb_device_t *dev) 198 198 { 199 usb_log_debug("usb hid_add_device()\n");199 usb_log_debug("usb_kbd_add_device()\n"); 200 200 201 201 if (dev->interface_no < 0) { 202 202 usb_log_warning("Device is not a supported keyboard.\n"); 203 usb_log_error("Failed to add HID device: endpoint not found."204 " \n");203 usb_log_error("Failed to add USB KBD device: endpoint not " 204 "found.\n"); 205 205 return ENOTSUP; 206 206 } 207 207 208 int rc = usb hid_try_add_device(dev);208 int rc = usb_kbd_try_add_device(dev); 209 209 210 210 if (rc != EOK) { 211 211 usb_log_warning("Device is not a supported keyboard.\n"); 212 usb_log_error("Failed to add HID device: %s.\n",212 usb_log_error("Failed to add KBD device: %s.\n", 213 213 str_error(rc)); 214 214 return rc; … … 224 224 /* Currently, the framework supports only device adding. Once the framework 225 225 * supports unplug, more callbacks will be added. */ 226 static usb_driver_ops_t usb hid_driver_ops = {227 .add_device = usb hid_add_device,226 static usb_driver_ops_t usb_kbd_driver_ops = { 227 .add_device = usb_kbd_add_device, 228 228 }; 229 229 230 230 231 231 /* The driver itself. */ 232 static usb_driver_t usb hid_driver = {232 static usb_driver_t usb_kbd_driver = { 233 233 .name = NAME, 234 .ops = &usb hid_driver_ops,234 .ops = &usb_kbd_driver_ops, 235 235 .endpoints = usb_kbd_endpoints 236 236 }; … … 238 238 /*----------------------------------------------------------------------------*/ 239 239 240 //static driver_ops_t kbd_driver_ops = {241 // .add_device = usbhid_add_device,242 //};243 244 ///*----------------------------------------------------------------------------*/245 246 //static driver_t kbd_driver = {247 // .name = NAME,248 // .driver_ops = &kbd_driver_ops249 //};250 251 /*----------------------------------------------------------------------------*/252 253 240 int main(int argc, char *argv[]) 254 241 { 255 printf(NAME ": HelenOS USB HID driver.\n");242 printf(NAME ": HelenOS USB KBD driver.\n"); 256 243 257 244 usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME); 258 245 259 return usb_driver_main(&usb hid_driver);246 return usb_driver_main(&usb_kbd_driver); 260 247 } 261 248 -
uspace/drv/usbkbd/usbkbd.ma
ra82889e rf8e8738 1 100 usb&interface&class=HID&subclass=0x01&protocol=0x01 2 10 usb&interface&class=HID 1 10 usb&interface&class=HID&subclass=0x01&protocol=0x01 -
uspace/lib/usb/include/usb/classes/hidparser.h
ra82889e rf8e8738 88 88 /** */ 89 89 int depth; 90 uint8_t report_id; 90 91 91 92 /** */ … … 155 156 /** */ 156 157 link_t feature; 158 159 int use_report_id; 160 157 161 } usb_hid_report_parser_t; 158 162 … … 166 170 * @param arg Custom argument. 167 171 */ 168 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t modifiers, void *arg);172 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg); 169 173 } usb_hid_report_in_callbacks_t; 170 174 … … 269 273 270 274 /** */ 275 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id); 276 277 /** */ 271 278 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage); 272 279 -
uspace/lib/usb/src/hidparser.c
ra82889e rf8e8738 106 106 list_initialize(&(parser->feature)); 107 107 108 parser->use_report_id = 0; 108 109 return EOK; 109 110 } … … 186 187 tmp_usage_path = NULL; 187 188 189 usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id); 190 if(report_item->id != 0){ 191 parser->use_report_id = 1; 192 } 188 193 189 194 switch(tag) { … … 647 652 } 648 653 654 parser->use_report_id = 0; 655 649 656 usb_hid_free_report_list(&parser->input); 650 657 usb_hid_free_report_list(&parser->output); … … 676 683 size_t i=0; 677 684 size_t j=0; 685 uint8_t report_id = 0; 678 686 679 687 if(parser == NULL) { … … 686 694 if(!(keys = malloc(sizeof(uint8_t) * key_count))){ 687 695 return ENOMEM; 696 } 697 698 if(parser->use_report_id != 0) { 699 report_id = data[0]; 700 usb_hid_report_path_set_report_id(path, report_id); 688 701 } 689 702 … … 693 706 694 707 item = list_get_instance(list_item, usb_hid_report_item_t, link); 708 695 709 if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) && 696 710 (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) { … … 715 729 } 716 730 717 callbacks->keyboard(keys, key_count, 0, arg);731 callbacks->keyboard(keys, key_count, report_id, arg); 718 732 719 733 free(keys); … … 739 753 int32_t mask; 740 754 const uint8_t *foo; 741 755 742 756 // now only common numbers llowed 743 757 if(item->size > 32) { … … 758 772 (usb_pow(10,(item->unit_exponent)))); 759 773 } 774 760 775 offset = item->offset + (j * item->size); 776 if(item->id != 0) { 777 offset += 8; 778 usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id); 779 } 761 780 762 781 // FIXME … … 942 961 943 962 int only_page; 963 964 if(report_path->report_id != path->report_id) { 965 return 1; 966 } 944 967 945 968 if(path->depth == 0){ … … 1038 1061 else { 1039 1062 path->depth = 0; 1063 path->report_id = 0; 1040 1064 list_initialize(&path->link); 1041 1065 return path; … … 1155 1179 return 0; 1156 1180 } 1157 1181 1158 1182 item = parser->output.next; 1159 1183 while(&parser->output != item) { … … 1195 1219 int length; 1196 1220 int32_t tmp_value; 1221 size_t offset_prefix = 0; 1197 1222 1198 1223 if(parser == NULL) { 1199 1224 return EINVAL; 1225 } 1226 1227 if(parser->use_report_id != 0) { 1228 buffer[0] = path->report_id; 1229 offset_prefix = 8; 1200 1230 } 1201 1231 … … 1218 1248 // // variable item 1219 1249 value = usb_hid_translate_data_reverse(report_item, data[idx++]); 1220 offset = report_item->offset + (i * report_item->size) ;1250 offset = report_item->offset + (i * report_item->size) + offset_prefix; 1221 1251 length = report_item->size; 1222 1252 } … … 1224 1254 //bitmap 1225 1255 value += usb_hid_translate_data_reverse(report_item, data[idx++]); 1226 offset = report_item->offset ;1256 offset = report_item->offset + offset_prefix; 1227 1257 length = report_item->size * report_item->count; 1228 1258 } … … 1323 1353 1324 1354 1355 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id) 1356 { 1357 if(path == NULL){ 1358 return EINVAL; 1359 } 1360 1361 path->report_id = report_id; 1362 return EOK; 1363 } 1364 1325 1365 /** 1326 1366 * @} -
uspace/lib/usb/src/hidreport.c
ra82889e rf8e8738 80 80 d = usb_dp_get_sibling_descriptor(&parser, &parser_data, 81 81 dev->descriptors.configuration, d); 82 ++i; 82 83 } 83 84
Note:
See TracChangeset
for help on using the changeset viewer.