Changes in uspace/lib/usb/src/hiddescriptor.c [b9d7965:0a494fe] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hiddescriptor.c
rb9d7965 r0a494fe 56 56 #define USB_HID_UNKNOWN_TAG -99 57 57 58 usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path) 59 { 58 59 /** 60 * Initialize the report descriptor parser structure 61 * 62 * @param parser Report descriptor parser structure 63 * @return Error code 64 */ 65 int usb_hid_report_init(usb_hid_report_t *report) 66 { 67 if(report == NULL) { 68 return EINVAL; 69 } 70 71 memset(report, 0, sizeof(usb_hid_report_t)); 72 list_initialize(&report->reports); 73 list_initialize(&report->collection_paths); 74 75 report->use_report_ids = 0; 76 return EOK; 77 } 78 79 int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item) 80 { 81 usb_hid_report_field_t *field; 82 int i; 83 84 60 85 /* find or append current collection path to the list */ 61 86 link_t *path_it = report->collection_paths.next; … … 64 89 path = list_get_instance(path_it, usb_hid_report_path_t, link); 65 90 66 if(usb_hid_report_compare_usage_path(path, cmp_path, USB_HID_PATH_COMPARE_STRICT) == EOK){91 if(usb_hid_report_compare_usage_path(path, report_item->usage_path, USB_HID_PATH_COMPARE_STRICT) == EOK){ 67 92 break; 68 93 } … … 70 95 } 71 96 if(path_it == &report->collection_paths) { 72 path = usb_hid_report_path_clone( cmp_path);97 path = usb_hid_report_path_clone(report_item->usage_path); 73 98 list_append(&path->link, &report->collection_paths); 74 99 report->collection_paths_count++; 75 76 return path; 77 } 78 else { 79 return list_get_instance(path_it, usb_hid_report_path_t, link); 80 } 81 } 82 83 /** 84 * Initialize the report descriptor parser structure 85 * 86 * @param parser Report descriptor parser structure 87 * @return Error code 88 */ 89 int usb_hid_report_init(usb_hid_report_t *report) 90 { 91 if(report == NULL) { 92 return EINVAL; 93 } 94 95 memset(report, 0, sizeof(usb_hid_report_t)); 96 list_initialize(&report->reports); 97 list_initialize(&report->collection_paths); 98 99 report->use_report_ids = 0; 100 return EOK; 101 } 102 103 int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item) 104 { 105 usb_hid_report_field_t *field; 106 int i; 100 } 107 101 108 102 for(i=0; i<report_item->usages_count; i++){ … … 110 104 } 111 105 112 usb_hid_report_path_t *path = report_item->usage_path;106 113 107 for(i=0; i<report_item->count; i++){ 114 108 … … 118 112 119 113 /* fill the attributes */ 114 field->collection_path = path; 120 115 field->logical_minimum = report_item->logical_minimum; 121 116 field->logical_maximum = report_item->logical_maximum; … … 173 168 } 174 169 175 usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL, field->usage_page);176 usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_LOCAL, field->usage);177 178 field->collection_path = usb_hid_report_path_try_insert(report, path);179 180 170 field->size = report_item->size; 181 171 field->offset = report_item->offset + (i * report_item->size); … … 359 349 tmp_usage_path = list_get_instance(report_item->usage_path->link.prev, usb_hid_report_usage_path_t, link); 360 350 361 usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page); 362 usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage); 351 usb_hid_report_set_last_item(usage_path, tmp_usage_path->usage_page, tmp_usage_path->usage); 363 352 364 353 usb_hid_report_path_free(report_item->usage_path); … … 640 629 641 630 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 642 usb_log_debug("\t\tSIZE: % X\n", report_item->size);631 usb_log_debug("\t\tSIZE: %zu\n", report_item->size); 643 632 usb_log_debug("\t\tLOGMIN: %d\n", report_item->logical_minimum); 644 633 usb_log_debug("\t\tLOGMAX: %d\n", report_item->logical_maximum); … … 651 640 usb_log_debug("\t\ttUSAGE: %X\n", report_item->usage); 652 641 usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page); 653 654 //usb_hid_print_usage_path(report_item->collection_path); 655 656 usb_log_debug("\n"); 642 643 // usb_log_debug("\n"); 657 644 658 645 } … … 679 666 usb_log_debug("Report ID: %d\n", report_des->report_id); 680 667 usb_log_debug("\tType: %d\n", report_des->type); 681 usb_log_debug("\tLength: % d\n", report_des->bit_length);682 usb_log_debug("\tItems: % d\n", report_des->item_length);668 usb_log_debug("\tLength: %zu\n", report_des->bit_length); 669 usb_log_debug("\tItems: %zu\n", report_des->item_length); 683 670 684 671 usb_hid_descriptor_print_list(&report_des->report_items);
Note:
See TracChangeset
for help on using the changeset viewer.