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