Changes in uspace/lib/usbhid/src/hiddescriptor.c [a1732929:3ca4ae9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
ra1732929 r3ca4ae9 36 36 #include <errno.h> 37 37 #include <stdio.h> 38 #include <malloc.h>39 38 #include <mem.h> 40 39 #include <usb/debug.h> 41 40 #include <assert.h> 41 #include <stdlib.h> 42 42 43 43 … … 75 75 #define USB_HID_RESET_OFFSET 3 76 76 77 #define USB_HID_INVALID -98 77 78 /** Unknown tag was founded in report descriptor data*/ 78 79 #define USB_HID_UNKNOWN_TAG -99 … … 103 104 104 105 if(usb_hid_report_compare_usage_path(path, cmp_path, 105 USB_HID_PATH_COMPARE_STRICT) == EOK){106 USB_HID_PATH_COMPARE_STRICT) == 0){ 106 107 break; 107 108 } … … 175 176 176 177 if(report_item->usages_count > 0){ 177 usages = malloc(sizeof( uint32_t) * report_item->usages_count);178 usages = malloc(sizeof(int32_t) * report_item->usages_count); 178 179 memcpy(usages, report_item->usages, sizeof(int32_t) * 179 180 report_item->usages_count); … … 246 247 field->size = report_item->size; 247 248 248 field->offset = report_item->offset + (i * report_item->size); 249 if(report_item->type == USB_HID_REPORT_TYPE_INPUT) { 250 int offset = report_item->offset + report_item->size * i; 251 int field_offset = (offset/8)*8 + (offset/8 + 1) * 8 - 252 offset - report_item->size; 253 if(field_offset < 0) { 254 field->offset = 0; 255 } 256 else { 257 field->offset = field_offset; 258 } 259 } 260 else { 261 field->offset = report_item->offset + (i * report_item->size); 262 } 263 249 264 250 265 if(report->use_report_ids != 0) { … … 539 554 540 555 if((ret=usb_hid_report_parse_main_tag(tag, data, item_size, 541 report_item, usage_path)) == EOK) {556 report_item, usage_path)) == 0) { 542 557 543 558 return USB_HID_NEW_REPORT_ITEM; … … 570 585 * @param Length of data buffer 571 586 * @param Current state table 572 * @return Errorcode587 * @return 0 or USB_HID_ code 573 588 */ 574 589 … … 585 600 case USB_HID_REPORT_TAG_FEATURE: 586 601 report_item->item_flags = *data; 587 return EOK;602 return 0; 588 603 break; 589 604 … … 625 640 } 626 641 627 return EOK;642 return 0; 628 643 } 629 644 … … 635 650 * @param Length of data buffer 636 651 * @param Current state table 637 * @return Errorcode652 * @return 0 or USB_HID_ code 638 653 */ 639 654 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, … … 711 726 } 712 727 713 return EOK;728 return 0; 714 729 } 715 730 … … 721 736 * @param Length of data buffer 722 737 * @param Current state table 723 * @return Errorcode738 * @return 0 or USB_HID_ code 724 739 */ 725 740 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, … … 777 792 USB_HID_EXTENDED_USAGE_PAGE( 778 793 usb_hid_report_tag_data_uint32(data, item_size))) { 779 return EINVAL;794 return USB_HID_INVALID; 780 795 } 781 796 … … 848 863 } 849 864 850 return EOK;865 return 0; 851 866 } 852 867 … … 881 896 { 882 897 if(list == NULL || list_empty(list)) { 883 usb_log_debug("\tempty ");898 usb_log_debug("\tempty\n"); 884 899 return; 885 900 } … … 887 902 list_foreach(*list, ritems_link, usb_hid_report_field_t, 888 903 report_item) { 889 usb_log_debug("\t\tOFFSET: % u", report_item->offset);890 usb_log_debug("\t\tSIZE: %zu ", report_item->size);891 usb_log_debug("\t\tLOGMIN: %d ",904 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 905 usb_log_debug("\t\tSIZE: %zu\n", report_item->size); 906 usb_log_debug("\t\tLOGMIN: %d\n", 892 907 report_item->logical_minimum); 893 usb_log_debug("\t\tLOGMAX: %d ",908 usb_log_debug("\t\tLOGMAX: %d\n", 894 909 report_item->logical_maximum); 895 usb_log_debug("\t\tPHYMIN: %d ",910 usb_log_debug("\t\tPHYMIN: %d\n", 896 911 report_item->physical_minimum); 897 usb_log_debug("\t\tPHYMAX: %d ",912 usb_log_debug("\t\tPHYMAX: %d\n", 898 913 report_item->physical_maximum); 899 usb_log_debug("\t\ttUSAGEMIN: %X ",914 usb_log_debug("\t\ttUSAGEMIN: %X\n", 900 915 report_item->usage_minimum); 901 usb_log_debug("\t\tUSAGEMAX: %X ",916 usb_log_debug("\t\tUSAGEMAX: %X\n", 902 917 report_item->usage_maximum); 903 usb_log_debug("\t\tUSAGES COUNT: %zu ",918 usb_log_debug("\t\tUSAGES COUNT: %zu\n", 904 919 report_item->usages_count); 905 920 906 usb_log_debug("\t\tVALUE: %X ", report_item->value);907 usb_log_debug("\t\ttUSAGE: %X ", report_item->usage);908 usb_log_debug("\t\tUSAGE PAGE: %X ", report_item->usage_page);921 usb_log_debug("\t\tVALUE: %X\n", report_item->value); 922 usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage); 923 usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page); 909 924 910 925 usb_hid_print_usage_path(report_item->collection_path); 926 927 usb_log_debug("\n"); 911 928 } 912 929 } … … 926 943 list_foreach(report->reports, reports_link, 927 944 usb_hid_report_description_t, report_des) { 928 usb_log_debug("Report ID: %d ", report_des->report_id);929 usb_log_debug("\tType: %d ", report_des->type);930 usb_log_debug("\tLength: %zu ", report_des->bit_length);931 usb_log_debug("\tB Size: %zu ",945 usb_log_debug("Report ID: %d\n", report_des->report_id); 946 usb_log_debug("\tType: %d\n", report_des->type); 947 usb_log_debug("\tLength: %zu\n", report_des->bit_length); 948 usb_log_debug("\tB Size: %zu\n", 932 949 usb_hid_report_byte_size(report, 933 950 report_des->report_id, 934 951 report_des->type)); 935 usb_log_debug("\tItems: %zu ", report_des->item_length);952 usb_log_debug("\tItems: %zu\n", report_des->item_length); 936 953 937 954 usb_hid_descriptor_print_list(&report_des->report_items);
Note:
See TracChangeset
for help on using the changeset viewer.