Changeset 60a228f in mainline for uspace/lib/usb/src/hidparser.c
- Timestamp:
- 2011-03-10T17:14:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7351dc3, 9d9ffdd
- Parents:
- 8bec4d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hidparser.c
r8bec4d1 r60a228f 112 112 usb_hid_report_item_t *new_report_item; 113 113 114 size_t offset=0; 114 size_t offset_input=0; 115 size_t offset_output=0; 116 size_t offset_feature=0; 115 117 116 118 … … 118 120 return ENOMEM; 119 121 } 122 memset(report_item, 0, sizeof(usb_hid_report_item_t)); 123 120 124 link_initialize(&(report_item->link)); 121 125 … … 143 147 // store report item to report and create the new one 144 148 usb_log_debug("\nNEW REPORT ITEM: %X",tag); 145 146 report_item->offset = offset;147 offset += report_item->count * report_item->size;148 149 149 150 switch(tag) { 150 151 case USB_HID_REPORT_TAG_INPUT: 152 report_item->offset = offset_input; 153 offset_input += report_item->count * report_item->size; 151 154 usb_log_debug(" - INPUT\n"); 152 155 list_append(&(report_item->link), &(parser->input)); 153 156 break; 154 157 case USB_HID_REPORT_TAG_OUTPUT: 158 report_item->offset = offset_output; 159 offset_output += report_item->count * report_item->size; 155 160 usb_log_debug(" - OUTPUT\n"); 156 161 list_append(&(report_item->link), &(parser->output)); … … 158 163 break; 159 164 case USB_HID_REPORT_TAG_FEATURE: 165 report_item->offset = offset_feature; 166 offset_feature += report_item->count * report_item->size; 160 167 usb_log_debug(" - FEATURE\n"); 161 168 list_append(&(report_item->link), &(parser->feature)); … … 483 490 484 491 if(head == NULL || list_empty(head)) { 485 printf("\tempty\n");492 usb_log_debug("\tempty\n"); 486 493 return; 487 494 } … … 491 498 report_item = list_get_instance(item, usb_hid_report_item_t, link); 492 499 493 printf("\tOFFSET: %X\n", report_item->offset);494 printf("\tCOUNT: %X\n", report_item->count);495 printf("\tSIZE: %X\n", report_item->size);496 printf("\tCONSTANT: %X\n", USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags));497 printf("\tUSAGE: %X\n", report_item->usage);498 printf("\tUSAGE PAGE: %X\n", report_item->usage_page);499 printf("\tLOGMIN: %X\n", report_item->logical_minimum);500 printf("\tLOGMAX: %X\n", report_item->logical_maximum);501 printf("\tPHYMIN: %X\n", report_item->physical_minimum);502 printf("\tPHYMAX: %X\n", report_item->physical_maximum);503 printf("\n");500 usb_log_debug("\tOFFSET: %X\n", report_item->offset); 501 usb_log_debug("\tCOUNT: %X\n", report_item->count); 502 usb_log_debug("\tSIZE: %X\n", report_item->size); 503 usb_log_debug("\tCONSTANT: %X\n", USB_HID_ITEM_FLAG_CONSTANT(report_item->item_flags)); 504 usb_log_debug("\tUSAGE: %X\n", report_item->usage); 505 usb_log_debug("\tUSAGE PAGE: %X\n", report_item->usage_page); 506 usb_log_debug("\tLOGMIN: %X\n", report_item->logical_minimum); 507 usb_log_debug("\tLOGMAX: %X\n", report_item->logical_maximum); 508 usb_log_debug("\tPHYMIN: %X\n", report_item->physical_minimum); 509 usb_log_debug("\tPHYMAX: %X\n", report_item->physical_maximum); 510 usb_log_debug("\n"); 504 511 505 512 } … … 515 522 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser) 516 523 { 517 printf("INPUT:\n");524 usb_log_debug("INPUT:\n"); 518 525 usb_hid_descriptor_print_list(&parser->input); 519 526 520 printf("OUTPUT: \n");527 usb_log_debug("OUTPUT: \n"); 521 528 usb_hid_descriptor_print_list(&parser->output); 522 529 523 printf("FEATURE:\n");530 usb_log_debug("FEATURE:\n"); 524 531 usb_hid_descriptor_print_list(&parser->feature); 525 532 … … 652 659 } 653 660 654 if((item->physical_minimum == 0) && (item->physical_maximum == 0)) {661 if((item->physical_minimum == 0) && (item->physical_maximum == 0)) { 655 662 item->physical_minimum = item->logical_minimum; 656 663 item->physical_maximum = item->logical_maximum; 657 664 } 658 665 659 resolution = (item->logical_maximum - item->logical_minimum) / ((item->physical_maximum - item->physical_minimum) * (usb_pow(10,(item->unit_exponent)))); 666 if(item->physical_maximum == item->physical_minimum){ 667 resolution = 1; 668 } 669 else { 670 resolution = (item->logical_maximum - item->logical_minimum) / 671 ((item->physical_maximum - item->physical_minimum) * 672 (usb_pow(10,(item->unit_exponent)))); 673 } 660 674 offset = item->offset + (j * item->size); 661 675 … … 694 708 695 709 usb_log_debug2("offset %d\n", offset); 710 696 711 usb_log_debug2("foo %x\n", *foo); 697 712 usb_log_debug2("maska %x\n", mask); … … 699 714 } 700 715 701 usb_log_debug2("---\n\n"); 716 usb_log_debug2("---\n\n"); 702 717 703 718 return (int)(((value - item->logical_minimum) / resolution) + item->physical_minimum);
Note:
See TracChangeset
for help on using the changeset viewer.