Changeset a35b458 in mainline for uspace/lib/usbhid/src/hiddescriptor.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
r3061bc1 ra35b458 63 63 64 64 65 65 66 66 /** The new report item flag. Used to determine when the item is completly 67 67 * configured and should be added to the report structure … … 95 95 link_t *path_it = report->collection_paths.head.next; 96 96 usb_hid_report_path_t *path = NULL; 97 97 98 98 if((report == NULL) || (cmp_path == NULL)) { 99 99 return NULL; 100 100 } 101 101 102 102 while(path_it != &report->collection_paths.head) { 103 103 path = list_get_instance(path_it, usb_hid_report_path_t, 104 104 cpath_link); 105 105 106 106 if(usb_hid_report_compare_usage_path(path, cmp_path, 107 107 USB_HID_PATH_COMPARE_STRICT) == 0){ … … 184 184 usages = NULL; 185 185 } 186 186 187 187 usb_hid_report_path_t *path = report_item->usage_path; 188 188 for(i=0; i<report_item->count; i++){ … … 237 237 } 238 238 } 239 239 240 240 usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL, 241 241 field->usage_page); … … 261 261 report_des = usb_hid_report_find_description(report, 262 262 report_item->id, report_item->type); 263 263 264 264 if(report_des == NULL){ 265 265 report_des = malloc( … … 288 288 /* append this field to the end of founded report list */ 289 289 list_append(&field->ritems_link, &report_des->report_items); 290 290 291 291 /* update the sizes */ 292 292 report_des->bit_length += field->size; … … 358 358 size_t offset_output=0; 359 359 size_t offset_feature=0; 360 360 361 361 link_t *item_link; 362 362 … … 368 368 return EINVAL; 369 369 } 370 370 371 371 /*report item initialization*/ 372 372 if(!(report_item=malloc(sizeof(usb_hid_report_item_t)))){ … … 381 381 } 382 382 usb_hid_report_path_append_item(usage_path, 0, 0); 383 383 384 384 while(i<size){ 385 385 if(!USB_HID_ITEM_IS_LONG(data[i])){ … … 388 388 return EINVAL; 389 389 } 390 390 391 391 tag = USB_HID_ITEM_TAG(data[i]); 392 392 item_size = USB_HID_ITEM_SIZE(data[i]); 393 393 class = USB_HID_ITEM_TAG_CLASS(data[i]); 394 394 395 395 ret = usb_hid_report_parse_tag(tag,class,data+i+1, 396 396 item_size,report_item, usage_path); … … 402 402 */ 403 403 report_item->usage_path = usage_path; 404 404 405 405 usb_hid_report_path_set_report_id( 406 406 report_item->usage_path, report_item->id); 407 407 408 408 if(report_item->id != 0){ 409 409 report->use_report_ids = 1; 410 410 } 411 411 412 412 switch(tag) { 413 413 case USB_HID_REPORT_TAG_INPUT: … … 419 419 report_item->size; 420 420 break; 421 421 422 422 case USB_HID_REPORT_TAG_OUTPUT: 423 423 report_item->type = 424 424 USB_HID_REPORT_TYPE_OUTPUT; 425 425 426 426 report_item->offset = offset_output; 427 427 offset_output += report_item->count * 428 428 report_item->size; 429 429 break; 430 430 431 431 case USB_HID_REPORT_TAG_FEATURE: 432 432 report_item->type = … … 437 437 report_item->size; 438 438 break; 439 439 440 440 default: 441 441 usb_log_debug2( … … 443 443 break; 444 444 } 445 445 446 446 /* 447 447 * append new fields to the report structure … … 466 466 new_report_item = usb_hid_report_item_clone( 467 467 report_item); 468 468 469 469 usb_hid_report_path_t *tmp_path = 470 470 usb_hid_report_path_clone(usage_path); … … 481 481 } 482 482 free(report_item); 483 483 484 484 report_item = list_get_instance(item_link, 485 485 usb_hid_report_item_t, link); 486 486 487 487 usb_hid_report_usage_path_t *tmp_usage_path; 488 488 tmp_usage_path = list_get_instance( 489 489 report_item->usage_path->cpath_link.prev, 490 490 usb_hid_report_usage_path_t, rpath_items_link); 491 491 492 492 usb_hid_report_set_last_item(usage_path, 493 493 USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page); 494 494 495 495 usb_hid_report_set_last_item(usage_path, 496 496 USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage); … … 498 498 usb_hid_report_path_free(report_item->usage_path); 499 499 list_remove (item_link); 500 500 501 501 break; 502 502 503 503 default: 504 504 // nothing special to do … … 513 513 i += 3 + USB_HID_ITEM_SIZE(data[i+1]); 514 514 } 515 516 517 } 518 515 516 517 } 518 519 519 return EOK; 520 520 } … … 534 534 size_t item_size, usb_hid_report_item_t *report_item, 535 535 usb_hid_report_path_t *usage_path) { 536 536 537 537 int ret; 538 538 539 539 switch(class){ 540 540 case USB_HID_TAG_CLASS_MAIN: … … 559 559 report_item, usage_path); 560 560 break; 561 561 562 562 default: 563 563 return USB_HID_NO_ACTION; … … 580 580 { 581 581 usb_hid_report_usage_path_t *path_item; 582 582 583 583 switch(tag) 584 584 { … … 589 589 return 0; 590 590 break; 591 591 592 592 case USB_HID_REPORT_TAG_COLLECTION: 593 593 … … 596 596 usb_hid_report_usage_path_t, rpath_items_link); 597 597 path_item->flags = *data; 598 598 599 599 /* set last item */ 600 600 usb_hid_report_set_last_item(usage_path, … … 607 607 USB_HID_EXTENDED_USAGE(report_item->usages[ 608 608 report_item->usages_count-1])); 609 609 610 610 /* append the new one which will be set by common usage/usage 611 611 * page */ … … 617 617 return USB_HID_NO_ACTION; 618 618 break; 619 619 620 620 case USB_HID_REPORT_TAG_END_COLLECTION: 621 621 usb_hid_report_remove_last_item(usage_path); … … 642 642 size_t item_size, usb_hid_report_item_t *report_item, 643 643 usb_hid_report_path_t *usage_path) { 644 644 645 645 switch(tag) 646 646 { … … 699 699 return USB_HID_RESET_OFFSET; 700 700 break; 701 701 702 702 case USB_HID_REPORT_TAG_PUSH: 703 703 case USB_HID_REPORT_TAG_POP: … … 708 708 return tag; 709 709 break; 710 710 711 711 default: 712 712 return USB_HID_NO_ACTION; … … 730 730 { 731 731 int32_t extended_usage; 732 732 733 733 switch (tag) { 734 734 case USB_HID_REPORT_TAG_USAGE: … … 740 740 */ 741 741 break; 742 742 743 743 case START_DELIMITER_SET: 744 744 report_item->in_delimiter = INSIDE_DELIMITER_SET; … … 748 748 extended_usage += 749 749 usb_hid_report_tag_data_uint32(data, item_size); 750 750 751 751 report_item->usages[report_item->usages_count] = 752 752 extended_usage; 753 753 754 754 report_item->usages_count++; 755 755 break; 756 756 } 757 757 break; 758 758 759 759 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 760 760 if (item_size == 3) { … … 763 763 USB_HID_EXTENDED_USAGE_PAGE( 764 764 usb_hid_report_tag_data_uint32(data, item_size)); 765 766 765 766 767 767 report_item->usage_minimum = 768 768 USB_HID_EXTENDED_USAGE( … … 773 773 } 774 774 break; 775 775 776 776 case USB_HID_REPORT_TAG_USAGE_MAXIMUM: 777 777 if (item_size == 3) { … … 781 781 return USB_HID_INVALID; 782 782 } 783 783 784 784 /* Usage extended usages */ 785 785 report_item->extended_usage_page = 786 786 USB_HID_EXTENDED_USAGE_PAGE( 787 787 usb_hid_report_tag_data_uint32(data,item_size)); 788 788 789 789 report_item->usage_maximum = 790 790 USB_HID_EXTENDED_USAGE( … … 794 794 usb_hid_report_tag_data_uint32(data,item_size); 795 795 } 796 796 797 797 /* Put the records into the usages array */ 798 798 for (int32_t i = report_item->usage_minimum; 799 799 i <= report_item->usage_maximum; i++) { 800 800 801 801 if (report_item->extended_usage_page) { 802 802 report_item->usages[report_item->usages_count++] = … … 808 808 } 809 809 report_item->extended_usage_page = 0; 810 811 break; 812 810 811 break; 812 813 813 case USB_HID_REPORT_TAG_DESIGNATOR_INDEX: 814 814 report_item->designator_index = 815 815 usb_hid_report_tag_data_uint32(data, item_size); 816 816 break; 817 817 818 818 case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM: 819 819 report_item->designator_minimum = 820 820 usb_hid_report_tag_data_uint32(data, item_size); 821 821 break; 822 822 823 823 case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM: 824 824 report_item->designator_maximum = 825 825 usb_hid_report_tag_data_uint32(data, item_size); 826 826 break; 827 827 828 828 case USB_HID_REPORT_TAG_STRING_INDEX: 829 829 report_item->string_index = 830 830 usb_hid_report_tag_data_uint32(data, item_size); 831 831 break; 832 832 833 833 case USB_HID_REPORT_TAG_STRING_MINIMUM: 834 834 report_item->string_minimum = 835 835 usb_hid_report_tag_data_uint32(data, item_size); 836 836 break; 837 837 838 838 case USB_HID_REPORT_TAG_STRING_MAXIMUM: 839 839 report_item->string_maximum = 840 840 usb_hid_report_tag_data_uint32(data, item_size); 841 841 break; 842 842 843 843 case USB_HID_REPORT_TAG_DELIMITER: 844 844 report_item->in_delimiter = 845 845 usb_hid_report_tag_data_uint32(data, item_size); 846 846 break; 847 847 848 848 default: 849 849 return USB_HID_NO_ACTION; 850 850 } 851 851 852 852 return 0; 853 853 } … … 965 965 usb_hid_report_path_free(path); 966 966 } 967 967 968 968 // free report items 969 969 usb_hid_report_description_t *report_des; … … 974 974 975 975 list_remove(&report_des->reports_link); 976 976 977 977 while(!list_empty(&report_des->report_items)) { 978 978 field = list_get_instance( … … 984 984 free(field); 985 985 } 986 986 987 987 free(report_des); 988 988 } 989 989 990 990 return; 991 991 }
Note:
See TracChangeset
for help on using the changeset viewer.