Changeset 1b20da0 in mainline for uspace/lib/usbhid/src/hiddescriptor.c
- Timestamp:
- 2018-02-28T17:52:03Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3061bc1
- Parents:
- df6ded8
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hiddescriptor.c
rdf6ded8 r1b20da0 85 85 * inserts it if not. 86 86 * 87 * @param report Report structure 88 * @param cmp_path The collection path 87 * @param report Report structure 88 * @param cmp_path The collection path 89 89 * @return Pointer to the result collection path in report structure. 90 90 * @retval NULL If some error occurs … … 122 122 else { 123 123 return list_get_instance(path_it, usb_hid_report_path_t, 124 cpath_link); 124 cpath_link); 125 125 } 126 126 } … … 156 156 * @param report Report structure in which the new report items should be 157 157 * stored 158 * @param report_item Current report descriptor's parsing state table 158 * @param report_item Current report descriptor's parsing state table 159 159 * @return Error code 160 160 * @retval EOK If all fields were successfully append to report … … 179 179 usages = malloc(sizeof(uint32_t) * report_item->usages_count); 180 180 memcpy(usages, report_item->usages, sizeof(int32_t) * 181 report_item->usages_count); 181 report_item->usages_count); 182 182 } 183 183 else { … … 185 185 } 186 186 187 usb_hid_report_path_t *path = report_item->usage_path; 187 usb_hid_report_path_t *path = report_item->usage_path; 188 188 for(i=0; i<report_item->count; i++){ 189 189 … … 196 196 link_initialize(&field->ritems_link); 197 197 198 /* fill the attributes */ 198 /* fill the attributes */ 199 199 field->logical_minimum = report_item->logical_minimum; 200 200 field->logical_maximum = report_item->logical_maximum; … … 203 203 204 204 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0){ 205 /* 205 /* 206 206 Store usage array. The Correct Usage Page and Usage is 207 207 depending on data in report and will be filled later … … 223 223 else { 224 224 usage = report_item->usages[ 225 report_item->usages_count- 1]; 225 report_item->usages_count- 1]; 226 226 } 227 227 228 228 if(USB_HID_IS_EXTENDED_USAGE(usage)){ 229 229 field->usage = USB_HID_EXTENDED_USAGE(usage); 230 field->usage_page = 230 field->usage_page = 231 231 USB_HID_EXTENDED_USAGE_PAGE(usage); 232 232 } … … 324 324 usb_hid_report_description_t, report_des) { 325 325 // if report id not set, return the first of the type 326 if(((report_des->report_id == report_id) || (report_id == 0)) && 327 (report_des->type == type)) { 326 if(((report_des->report_id == report_id) || (report_id == 0)) && 327 (report_des->type == type)) { 328 328 return report_des; 329 329 } … … 343 343 * @retval EOK If report descriptor is successfully parsed 344 344 */ 345 errno_t usb_hid_parse_report_descriptor(usb_hid_report_t *report, 345 errno_t usb_hid_parse_report_descriptor(usb_hid_report_t *report, 346 346 const uint8_t *data, size_t size) 347 347 { … … 352 352 int ret; 353 353 usb_hid_report_item_t *report_item=0; 354 usb_hid_report_item_t *new_report_item; 354 usb_hid_report_item_t *new_report_item; 355 355 usb_hid_report_path_t *usage_path; 356 356 … … 380 380 return ENOMEM; 381 381 } 382 usb_hid_report_path_append_item(usage_path, 0, 0); 383 384 while(i<size){ 382 usb_hid_report_path_append_item(usage_path, 0, 0); 383 384 while(i<size){ 385 385 if(!USB_HID_ITEM_IS_LONG(data[i])){ 386 386 … … 412 412 switch(tag) { 413 413 case USB_HID_REPORT_TAG_INPUT: 414 report_item->type = 414 report_item->type = 415 415 USB_HID_REPORT_TYPE_INPUT; 416 416 417 417 report_item->offset = offset_input; 418 offset_input += report_item->count * 418 offset_input += report_item->count * 419 419 report_item->size; 420 420 break; 421 421 422 422 case USB_HID_REPORT_TAG_OUTPUT: 423 report_item->type = 423 report_item->type = 424 424 USB_HID_REPORT_TYPE_OUTPUT; 425 425 426 426 report_item->offset = offset_output; 427 offset_output += report_item->count * 427 offset_output += report_item->count * 428 428 report_item->size; 429 429 break; 430 430 431 431 case USB_HID_REPORT_TAG_FEATURE: 432 report_item->type = 432 report_item->type = 433 433 USB_HID_REPORT_TYPE_FEATURE; 434 434 435 435 report_item->offset = offset_feature; 436 offset_feature += report_item->count * 436 offset_feature += report_item->count * 437 437 report_item->size; 438 438 break; … … 444 444 } 445 445 446 /* 447 * append new fields to the report structure 446 /* 447 * append new fields to the report structure 448 448 */ 449 usb_hid_report_append_fields(report, 449 usb_hid_report_append_fields(report, 450 450 report_item); 451 451 … … 458 458 offset_output = 0; 459 459 offset_feature = 0; 460 usb_hid_report_path_set_report_id (usage_path, 460 usb_hid_report_path_set_report_id (usage_path, 461 461 report_item->id); 462 462 break; … … 467 467 report_item); 468 468 469 usb_hid_report_path_t *tmp_path = 469 usb_hid_report_path_t *tmp_path = 470 470 usb_hid_report_path_clone(usage_path); 471 471 472 new_report_item->usage_path = tmp_path; 472 new_report_item->usage_path = tmp_path; 473 473 474 474 list_prepend (&new_report_item->link, &stack); … … 490 490 usb_hid_report_usage_path_t, rpath_items_link); 491 491 492 usb_hid_report_set_last_item(usage_path, 492 usb_hid_report_set_last_item(usage_path, 493 493 USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page); 494 494 495 usb_hid_report_set_last_item(usage_path, 495 usb_hid_report_set_last_item(usage_path, 496 496 USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage); 497 497 … … 502 502 503 503 default: 504 // nothing special to do 504 // nothing special to do 505 505 break; 506 506 } … … 533 533 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, 534 534 size_t item_size, usb_hid_report_item_t *report_item, 535 usb_hid_report_path_t *usage_path) { 535 usb_hid_report_path_t *usage_path) { 536 536 537 537 int ret; … … 550 550 break; 551 551 552 case USB_HID_TAG_CLASS_GLOBAL: 552 case USB_HID_TAG_CLASS_GLOBAL: 553 553 return usb_hid_report_parse_global_tag(tag, data, item_size, 554 554 report_item, usage_path); 555 555 break; 556 556 557 case USB_HID_TAG_CLASS_LOCAL: 557 case USB_HID_TAG_CLASS_LOCAL: 558 558 return usb_hid_report_parse_local_tag(tag, data, item_size, 559 559 report_item, usage_path); … … 575 575 */ 576 576 577 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, 577 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, 578 578 size_t item_size, usb_hid_report_item_t *report_item, 579 579 usb_hid_report_path_t *usage_path) … … 586 586 case USB_HID_REPORT_TAG_OUTPUT: 587 587 case USB_HID_REPORT_TAG_FEATURE: 588 report_item->item_flags = *data; 589 return 0; 588 report_item->item_flags = *data; 589 return 0; 590 590 break; 591 591 … … 598 598 599 599 /* set last item */ 600 usb_hid_report_set_last_item(usage_path, 601 USB_HID_TAG_CLASS_GLOBAL, 600 usb_hid_report_set_last_item(usage_path, 601 USB_HID_TAG_CLASS_GLOBAL, 602 602 USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[ 603 603 report_item->usages_count-1])); 604 604 605 usb_hid_report_set_last_item(usage_path, 606 USB_HID_TAG_CLASS_LOCAL, 605 usb_hid_report_set_last_item(usage_path, 606 USB_HID_TAG_CLASS_LOCAL, 607 607 USB_HID_EXTENDED_USAGE(report_item->usages[ 608 608 report_item->usages_count-1])); … … 610 610 /* append the new one which will be set by common usage/usage 611 611 * page */ 612 usb_hid_report_path_append_item(usage_path, 613 report_item->usage_page, 612 usb_hid_report_path_append_item(usage_path, 613 report_item->usage_page, 614 614 report_item->usages[report_item->usages_count-1]); 615 615 … … 639 639 * @return 0 or USB_HID_ code 640 640 */ 641 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, 642 size_t item_size, usb_hid_report_item_t *report_item, 643 usb_hid_report_path_t *usage_path) { 641 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, 642 size_t item_size, usb_hid_report_item_t *report_item, 643 usb_hid_report_path_t *usage_path) { 644 644 645 645 switch(tag) 646 646 { 647 647 case USB_HID_REPORT_TAG_USAGE_PAGE: 648 report_item->usage_page = 648 report_item->usage_page = 649 649 usb_hid_report_tag_data_uint32(data, item_size); 650 650 break; … … 658 658 case USB_HID_REPORT_TAG_LOGICAL_MAXIMUM: 659 659 report_item->logical_maximum = USB_HID_UINT32_TO_INT32( 660 usb_hid_report_tag_data_uint32(data,item_size), 660 usb_hid_report_tag_data_uint32(data,item_size), 661 661 item_size * 8); 662 662 break; … … 664 664 case USB_HID_REPORT_TAG_PHYSICAL_MINIMUM: 665 665 report_item->physical_minimum = USB_HID_UINT32_TO_INT32( 666 usb_hid_report_tag_data_uint32(data,item_size), 666 usb_hid_report_tag_data_uint32(data,item_size), 667 667 item_size * 8); 668 break; 668 break; 669 669 670 670 case USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM: 671 671 report_item->physical_maximum = USB_HID_UINT32_TO_INT32( 672 usb_hid_report_tag_data_uint32(data,item_size), 672 usb_hid_report_tag_data_uint32(data,item_size), 673 673 item_size * 8); 674 674 break; … … 695 695 696 696 case USB_HID_REPORT_TAG_REPORT_ID: 697 report_item->id = usb_hid_report_tag_data_uint32(data, 697 report_item->id = usb_hid_report_tag_data_uint32(data, 698 698 item_size); 699 699 return USB_HID_RESET_OFFSET; … … 702 702 case USB_HID_REPORT_TAG_PUSH: 703 703 case USB_HID_REPORT_TAG_POP: 704 /* 704 /* 705 705 * stack operations are done in top level parsing 706 706 * function … … 943 943 944 944 945 /** Frees the HID report descriptor parser structure 945 /** Frees the HID report descriptor parser structure 946 946 * 947 947 * @param parser Opaque HID report parser structure
Note:
See TracChangeset
for help on using the changeset viewer.