Changes in / [1181249:166c4752] in mainline
- Location:
- uspace/lib/usb/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hiddescriptor.c
r1181249 r166c4752 101 101 } 102 102 103 104 /* 105 * 106 * 107 */ 103 108 int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item) 104 109 { … … 134 139 if(report_item->usages_count > 0 && ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) { 135 140 uint32_t usage; 136 if(report_item->type != USB_HID_REPORT_TYPE_OUTPUT) { 137 if(i < report_item->usages_count){ 138 usage = report_item->usages[i]; 139 } 140 else { 141 usage = report_item->usages[report_item->usages_count - 1]; 142 } 141 if(i < report_item->usages_count){ 142 usage = report_item->usages[i]; 143 143 } 144 144 else { 145 if((report_item->count - i - 1) < report_item->usages_count){ 146 usage = report_item->usages[(report_item->count - i - 1)]; 147 } 148 else { 149 usage = report_item->usages[report_item->usages_count - 1]; 150 } 145 usage = report_item->usages[report_item->usages_count - 1]; 151 146 } 152 147 … … 164 159 165 160 if((USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) != 0) && (!((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0)))) { 166 if(report_item->type == USB_HID_REPORT_TYPE_INPUT) { 167 field->usage = report_item->usage_maximum - i; 168 } 169 else { 170 field->usage = report_item->usage_minimum + i; 171 } 172 161 field->usage = report_item->usage_minimum + i; 173 162 } 174 163 … … 179 168 180 169 field->size = report_item->size; 181 field->offset = report_item->offset + (i * report_item->size); 170 171 size_t offset_byte = (report_item->offset + (i * report_item->size)) / 8; 172 size_t offset_bit = 8 - ((report_item->offset + (i * report_item->size)) % 8) - report_item->size; 173 174 field->offset = 8 * offset_byte + offset_bit; 182 175 if(report_item->id != 0) { 183 176 field->offset += 8; … … 640 633 641 634 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 642 usb_log_debug("\t\tSIZE: % zu\n", report_item->size);635 usb_log_debug("\t\tSIZE: %X\n", report_item->size); 643 636 usb_log_debug("\t\tLOGMIN: %d\n", report_item->logical_minimum); 644 637 usb_log_debug("\t\tLOGMAX: %d\n", report_item->logical_maximum); … … 679 672 usb_log_debug("Report ID: %d\n", report_des->report_id); 680 673 usb_log_debug("\tType: %d\n", report_des->type); 681 usb_log_debug("\tLength: % zu\n", report_des->bit_length);682 usb_log_debug("\tItems: % zu\n", report_des->item_length);674 usb_log_debug("\tLength: %d\n", report_des->bit_length); 675 usb_log_debug("\tItems: %d\n", report_des->item_length); 683 676 684 677 usb_hid_descriptor_print_list(&report_des->report_items); -
uspace/lib/usb/src/hidparser.c
r1181249 r166c4752 405 405 } 406 406 407 size_t shift = offset%8;407 size_t shift = 8 - offset%8 - length; 408 408 409 409 value = value << shift;
Note:
See TracChangeset
for help on using the changeset viewer.