Changeset 9b78020 in mainline
- Timestamp:
- 2011-04-22T10:21:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 308a5d5
- Parents:
- 1775ebc (diff), 7304663 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbd/kbddev.c
r1775ebc r9b78020 694 694 while (field != NULL) { 695 695 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n", 696 field, field->value, field-> value);696 field, field->value, field->usage); 697 697 698 698 assert(i < kbd_dev->key_count); … … 709 709 * two parts of the Report somehow. 710 710 */ 711 kbd_dev->keys[i] = field->value; 711 if( field->value != 0 ) { 712 kbd_dev->keys[i] = field->usage; 713 } 714 else { 715 kbd_dev->keys[i] = 0; 716 } 712 717 usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]); 713 718 -
uspace/lib/usb/src/hidparser.c
r1775ebc r9b78020 73 73 void usb_hid_print_usage_path(usb_hid_report_path_t *path); 74 74 void usb_hid_descriptor_print_list(link_t *head); 75 int usb_hid_report_reset_local_items();75 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item); 76 76 void usb_hid_free_report_list(link_t *head); 77 77 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item); … … 79 79 * Data translation private functions 80 80 */ 81 int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size);81 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size); 82 82 inline size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset); 83 83 int usb_hid_translate_data(usb_hid_report_field_t *item, const uint8_t *data); … … 85 85 int usb_pow(int a, int b); 86 86 87 #define USB_HID_UINT32_TO_INT32(x, size) ((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1))) 88 #define USB_HID_INT32_TO_UINT32(x, size) (((x) < 0 ) ? ((1 << (size)) + (x)) : (x)) 87 89 // TODO: tohle ma bejt asi jinde 88 90 int usb_pow(int a, int b) … … 144 146 } 145 147 148 for(i=0; i<report_item->usages_count; i++){ 149 usb_log_debug("usages (%d) - %x\n", i, report_item->usages[i]); 150 } 151 146 152 147 153 for(i=0; i<report_item->count; i++){ … … 168 174 169 175 if(report_item->usages_count > 0 && ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) { 170 if(i < report_item->usages_count){171 if((report_item->usages[i] & 0xFF00) != 0){172 field->usage_page = (report_item->usages[i] >> 16);173 field->usage = (report_item->usages[i] & 0xFF);176 uint32_t usage; 177 if(report_item->type == USB_HID_REPORT_TYPE_INPUT) { 178 if(i < report_item->usages_count){ 179 usage = report_item->usages[i]; 174 180 } 175 181 else { 176 field->usage = report_item->usages[i];182 usage = report_item->usages[report_item->usages_count - 1]; 177 183 } 178 184 } 179 185 else { 180 field->usage = report_item->usages[report_item->usages_count - 1]; 181 } 186 if((report_item->count - i - 1) < report_item->usages_count){ 187 usage = report_item->usages[(report_item->count - i - 1)]; 188 } 189 else { 190 usage = report_item->usages[report_item->usages_count - 1]; 191 } 192 } 193 194 195 if((usage & 0xFF00) != 0){ 196 field->usage_page = (usage >> 16); 197 field->usage = (usage & 0xFF); 198 } 199 else { 200 field->usage = usage; 201 } 202 203 182 204 } 183 205 … … 342 364 343 365 /* reset local items */ 344 while(report_item->usages_count > 0){ 345 report_item->usages[--(report_item->usages_count)] = 0; 346 } 347 348 report_item->extended_usage_page = 0; 349 report_item->usage_minimum = 0; 350 report_item->usage_maximum = 0; 351 report_item->designator_index = 0; 352 report_item->designator_minimum = 0; 353 report_item->designator_maximum = 0; 354 report_item->string_index = 0; 355 report_item->string_minimum = 0; 356 report_item->string_maximum = 0; 366 usb_hid_report_reset_local_items (report_item); 357 367 358 368 break; … … 476 486 // TODO usage_path->flags = *data; 477 487 usb_hid_report_path_append_item(usage_path, report_item->usage_page, report_item->usages[report_item->usages_count-1]); 488 usb_hid_report_reset_local_items (report_item); 478 489 return USB_HID_NO_ACTION; 479 490 break; … … 506 517 { 507 518 case USB_HID_REPORT_TAG_USAGE_PAGE: 508 report_item->usage_page = usb_hid_report_tag_data_ int32(data, item_size);519 report_item->usage_page = usb_hid_report_tag_data_uint32(data, item_size); 509 520 break; 510 521 case USB_HID_REPORT_TAG_LOGICAL_MINIMUM: 511 report_item->logical_minimum = usb_hid_report_tag_data_int32(data,item_size);522 report_item->logical_minimum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8); 512 523 break; 513 524 case USB_HID_REPORT_TAG_LOGICAL_MAXIMUM: 514 report_item->logical_maximum = usb_hid_report_tag_data_int32(data,item_size);525 report_item->logical_maximum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8); 515 526 break; 516 527 case USB_HID_REPORT_TAG_PHYSICAL_MINIMUM: 517 report_item->physical_minimum = usb_hid_report_tag_data_int32(data,item_size);528 report_item->physical_minimum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8); 518 529 break; 519 530 case USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM: 520 report_item->physical_maximum = usb_hid_report_tag_data_int32(data,item_size); 531 report_item->physical_maximum = USB_HID_UINT32_TO_INT32(usb_hid_report_tag_data_uint32(data,item_size), item_size * 8); 532 521 533 break; 522 534 case USB_HID_REPORT_TAG_UNIT_EXPONENT: 523 report_item->unit_exponent = usb_hid_report_tag_data_ int32(data,item_size);535 report_item->unit_exponent = usb_hid_report_tag_data_uint32(data,item_size); 524 536 break; 525 537 case USB_HID_REPORT_TAG_UNIT: 526 report_item->unit = usb_hid_report_tag_data_ int32(data,item_size);538 report_item->unit = usb_hid_report_tag_data_uint32(data,item_size); 527 539 break; 528 540 case USB_HID_REPORT_TAG_REPORT_SIZE: 529 report_item->size = usb_hid_report_tag_data_ int32(data,item_size);541 report_item->size = usb_hid_report_tag_data_uint32(data,item_size); 530 542 break; 531 543 case USB_HID_REPORT_TAG_REPORT_COUNT: 532 report_item->count = usb_hid_report_tag_data_ int32(data,item_size);544 report_item->count = usb_hid_report_tag_data_uint32(data,item_size); 533 545 break; 534 546 case USB_HID_REPORT_TAG_REPORT_ID: 535 report_item->id = usb_hid_report_tag_data_ int32(data,item_size);547 report_item->id = usb_hid_report_tag_data_uint32(data,item_size); 536 548 return USB_HID_RESET_OFFSET; 537 549 break; … … 548 560 return USB_HID_NO_ACTION; 549 561 } 550 562 551 563 return EOK; 552 564 } … … 567 579 { 568 580 case USB_HID_REPORT_TAG_USAGE: 569 report_item->usages[report_item->usages_count++] = usb_hid_report_tag_data_int32(data,item_size); 581 report_item->usages[report_item->usages_count] = usb_hid_report_tag_data_uint32(data,item_size); 582 report_item->usages_count++; 570 583 break; 571 584 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 572 585 if (item_size == 3) { 573 586 // usage extended usages 574 report_item->extended_usage_page = (usb_hid_report_tag_data_ int32(data,item_size) & 0xFF00) >> 16;575 report_item->usage_minimum = usb_hid_report_tag_data_ int32(data,item_size) & 0xFF;587 report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; 588 report_item->usage_minimum = usb_hid_report_tag_data_uint32(data,item_size) & 0xFF; 576 589 } 577 590 else { 578 report_item->usage_minimum = usb_hid_report_tag_data_ int32(data,item_size);591 report_item->usage_minimum = usb_hid_report_tag_data_uint32(data,item_size); 579 592 } 580 593 break; … … 582 595 if (item_size == 3) { 583 596 // usage extended usages 584 report_item->extended_usage_page = (usb_hid_report_tag_data_ int32(data,item_size) & 0xFF00) >> 16;585 report_item->usage_maximum = usb_hid_report_tag_data_ int32(data,item_size) & 0xFF;597 report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; 598 report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size) & 0xFF; 586 599 } 587 600 else { 588 report_item->usage_maximum = usb_hid_report_tag_data_ int32(data,item_size);601 report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size); 589 602 } 590 603 break; 591 604 case USB_HID_REPORT_TAG_DESIGNATOR_INDEX: 592 report_item->designator_index = usb_hid_report_tag_data_ int32(data,item_size);605 report_item->designator_index = usb_hid_report_tag_data_uint32(data,item_size); 593 606 break; 594 607 case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM: 595 report_item->designator_minimum = usb_hid_report_tag_data_ int32(data,item_size);608 report_item->designator_minimum = usb_hid_report_tag_data_uint32(data,item_size); 596 609 break; 597 610 case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM: 598 report_item->designator_maximum = usb_hid_report_tag_data_ int32(data,item_size);611 report_item->designator_maximum = usb_hid_report_tag_data_uint32(data,item_size); 599 612 break; 600 613 case USB_HID_REPORT_TAG_STRING_INDEX: 601 report_item->string_index = usb_hid_report_tag_data_ int32(data,item_size);614 report_item->string_index = usb_hid_report_tag_data_uint32(data,item_size); 602 615 break; 603 616 case USB_HID_REPORT_TAG_STRING_MINIMUM: 604 report_item->string_minimum = usb_hid_report_tag_data_ int32(data,item_size);617 report_item->string_minimum = usb_hid_report_tag_data_uint32(data,item_size); 605 618 break; 606 619 case USB_HID_REPORT_TAG_STRING_MAXIMUM: 607 report_item->string_maximum = usb_hid_report_tag_data_ int32(data,item_size);620 report_item->string_maximum = usb_hid_report_tag_data_uint32(data,item_size); 608 621 break; 609 622 case USB_HID_REPORT_TAG_DELIMITER: 610 //report_item->delimiter = usb_hid_report_tag_data_ int32(data,item_size);623 //report_item->delimiter = usb_hid_report_tag_data_uint32(data,item_size); 611 624 //TODO: 612 625 // DELIMITER STUFF … … 621 634 622 635 /** 623 * Converts raw data to int32 (thats the maximum length of short item data)636 * Converts raw data to uint32 (thats the maximum length of short item data) 624 637 * 625 638 * @param Data buffer … … 627 640 * @return Converted int32 number 628 641 */ 629 int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size)642 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size) 630 643 { 631 644 unsigned int i; 632 int32_t result;645 uint32_t result; 633 646 634 647 result = 0; … … 639 652 return result; 640 653 } 641 642 643 654 644 655 /** … … 665 676 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 666 677 usb_log_debug("\t\tSIZE: %X\n", report_item->size); 667 usb_log_debug("\t\tLOGMIN: % X\n", report_item->logical_minimum);668 usb_log_debug("\t\tLOGMAX: % X\n", report_item->logical_maximum);669 usb_log_debug("\t\tPHYMIN: % X\n", report_item->physical_minimum);670 usb_log_debug("\t\tPHYMAX: % X\n", report_item->physical_maximum);678 usb_log_debug("\t\tLOGMIN: %d\n", report_item->logical_minimum); 679 usb_log_debug("\t\tLOGMAX: %d\n", report_item->logical_maximum); 680 usb_log_debug("\t\tPHYMIN: %d\n", report_item->physical_minimum); 681 usb_log_debug("\t\tPHYMAX: %d\n", report_item->physical_maximum); 671 682 usb_log_debug("\t\ttUSAGEMIN: %X\n", report_item->usage_minimum); 672 683 usb_log_debug("\t\tUSAGEMAX: %X\n", report_item->usage_maximum); … … 918 929 } 919 930 920 if(!(item->logical_minimum >= 0 && item->logical_maximum >= 0)){ 921 value = (int32_t)value; 922 } 923 else { 924 value = (uint32_t)value; 931 if((item->logical_minimum < 0) || (item->logical_maximum < 0)){ 932 value = USB_HID_UINT32_TO_INT32(value, item->size); 925 933 } 926 934 … … 1529 1537 } 1530 1538 1531 1532 return (uint32_t)ret; 1539 if((item->logical_minimum < 0) || (item->logical_maximum < 0)){ 1540 return USB_HID_INT32_TO_UINT32(ret, item->size); 1541 } 1542 return (int32_t)ret; 1533 1543 } 1534 1544 … … 1683 1693 } 1684 1694 1685 1695 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item) 1696 { 1697 if(report_item == NULL) { 1698 return; 1699 } 1700 1701 report_item->usages_count = 0; 1702 memset(report_item->usages, 0, USB_HID_MAX_USAGES); 1703 1704 report_item->extended_usage_page = 0; 1705 report_item->usage_minimum = 0; 1706 report_item->usage_maximum = 0; 1707 report_item->designator_index = 0; 1708 report_item->designator_minimum = 0; 1709 report_item->designator_maximum = 0; 1710 report_item->string_index = 0; 1711 report_item->string_minimum = 0; 1712 report_item->string_maximum = 0; 1713 1714 return; 1715 } 1686 1716 /** 1687 1717 * @}
Note:
See TracChangeset
for help on using the changeset viewer.