Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhid/src/hiddescriptor.c

    r1b20da0 ra35b458  
    6363
    6464
    65        
     65
    6666/** The new report item flag. Used to determine when the item is completly
    6767 * configured and should be added to the report structure
     
    9595        link_t *path_it = report->collection_paths.head.next;
    9696        usb_hid_report_path_t *path = NULL;
    97        
     97
    9898        if((report == NULL) || (cmp_path == NULL)) {
    9999                return NULL;
    100100        }
    101        
     101
    102102        while(path_it != &report->collection_paths.head) {
    103103                path = list_get_instance(path_it, usb_hid_report_path_t,
    104104                                cpath_link);
    105                
     105
    106106                if(usb_hid_report_compare_usage_path(path, cmp_path,
    107107                                        USB_HID_PATH_COMPARE_STRICT) == 0){
     
    184184                usages = NULL;
    185185        }
    186        
     186
    187187        usb_hid_report_path_t *path = report_item->usage_path;
    188188        for(i=0; i<report_item->count; i++){
     
    237237                        }
    238238                }
    239                
     239
    240240                usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL,
    241241                                field->usage_page);
     
    261261                report_des = usb_hid_report_find_description(report,
    262262                        report_item->id, report_item->type);
    263                
     263
    264264                if(report_des == NULL){
    265265                        report_des = malloc(
     
    288288                /* append this field to the end of founded report list */
    289289                list_append(&field->ritems_link, &report_des->report_items);
    290                
     290
    291291                /* update the sizes */
    292292                report_des->bit_length += field->size;
     
    358358        size_t offset_output=0;
    359359        size_t offset_feature=0;
    360        
     360
    361361        link_t *item_link;
    362362
     
    368368                return EINVAL;
    369369        }
    370        
     370
    371371        /*report item initialization*/
    372372        if(!(report_item=malloc(sizeof(usb_hid_report_item_t)))){
     
    381381        }
    382382        usb_hid_report_path_append_item(usage_path, 0, 0);
    383        
     383
    384384        while(i<size){
    385385                if(!USB_HID_ITEM_IS_LONG(data[i])){
     
    388388                                return EINVAL;
    389389                        }
    390                        
     390
    391391                        tag = USB_HID_ITEM_TAG(data[i]);
    392392                        item_size = USB_HID_ITEM_SIZE(data[i]);
    393393                        class = USB_HID_ITEM_TAG_CLASS(data[i]);
    394                        
     394
    395395                        ret = usb_hid_report_parse_tag(tag,class,data+i+1,
    396396                                item_size,report_item, usage_path);
     
    402402                                 */
    403403                                report_item->usage_path = usage_path;
    404                                        
     404
    405405                                usb_hid_report_path_set_report_id(
    406406                                     report_item->usage_path, report_item->id);
    407                                
     407
    408408                                if(report_item->id != 0){
    409409                                        report->use_report_ids = 1;
    410410                                }
    411                                        
     411
    412412                                switch(tag) {
    413413                                case USB_HID_REPORT_TAG_INPUT:
     
    419419                                            report_item->size;
    420420                                        break;
    421        
     421
    422422                                case USB_HID_REPORT_TAG_OUTPUT:
    423423                                        report_item->type =
    424424                                            USB_HID_REPORT_TYPE_OUTPUT;
    425                                        
     425
    426426                                        report_item->offset = offset_output;
    427427                                        offset_output += report_item->count *
    428428                                            report_item->size;
    429429                                        break;
    430        
     430
    431431                                case USB_HID_REPORT_TAG_FEATURE:
    432432                                        report_item->type =
     
    437437                                                report_item->size;
    438438                                        break;
    439        
     439
    440440                                default:
    441441                                        usb_log_debug2(
     
    443443                                        break;
    444444                                }
    445                                        
     445
    446446                                /*
    447447                                 * append new fields to the report structure
     
    466466                                new_report_item = usb_hid_report_item_clone(
    467467                                    report_item);
    468                                
     468
    469469                                usb_hid_report_path_t *tmp_path =
    470470                                    usb_hid_report_path_clone(usage_path);
     
    481481                                }
    482482                                free(report_item);
    483                                
     483
    484484                                report_item = list_get_instance(item_link,
    485485                                    usb_hid_report_item_t, link);
    486                                
     486
    487487                                usb_hid_report_usage_path_t *tmp_usage_path;
    488488                                tmp_usage_path = list_get_instance(
    489489                                    report_item->usage_path->cpath_link.prev,
    490490                                    usb_hid_report_usage_path_t, rpath_items_link);
    491                                
     491
    492492                                usb_hid_report_set_last_item(usage_path,
    493493                                    USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
    494                                
     494
    495495                                usb_hid_report_set_last_item(usage_path,
    496496                                    USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage);
     
    498498                                usb_hid_report_path_free(report_item->usage_path);
    499499                                list_remove (item_link);
    500                                        
     500
    501501                                break;
    502                                        
     502
    503503                        default:
    504504                                // nothing special to do
     
    513513                        i += 3 + USB_HID_ITEM_SIZE(data[i+1]);
    514514                }
    515                
    516 
    517         }
    518        
     515
     516
     517        }
     518
    519519        return EOK;
    520520}
     
    534534        size_t item_size, usb_hid_report_item_t *report_item,
    535535        usb_hid_report_path_t *usage_path) {
    536        
     536
    537537        int ret;
    538        
     538
    539539        switch(class){
    540540        case USB_HID_TAG_CLASS_MAIN:
     
    559559                        report_item, usage_path);
    560560                break;
    561        
     561
    562562        default:
    563563                return USB_HID_NO_ACTION;
     
    580580{
    581581        usb_hid_report_usage_path_t *path_item;
    582        
     582
    583583        switch(tag)
    584584        {
     
    589589                return 0;
    590590                break;
    591                        
     591
    592592        case USB_HID_REPORT_TAG_COLLECTION:
    593593
     
    596596                        usb_hid_report_usage_path_t, rpath_items_link);
    597597                path_item->flags = *data;
    598                        
     598
    599599                /* set last item */
    600600                usb_hid_report_set_last_item(usage_path,
     
    607607                        USB_HID_EXTENDED_USAGE(report_item->usages[
    608608                                report_item->usages_count-1]));
    609                        
     609
    610610                /* append the new one which will be set by common usage/usage
    611611                 * page */
     
    617617                return USB_HID_NO_ACTION;
    618618                break;
    619                        
     619
    620620        case USB_HID_REPORT_TAG_END_COLLECTION:
    621621                usb_hid_report_remove_last_item(usage_path);
     
    642642        size_t item_size, usb_hid_report_item_t *report_item,
    643643        usb_hid_report_path_t *usage_path) {
    644        
     644
    645645        switch(tag)
    646646        {
     
    699699                return USB_HID_RESET_OFFSET;
    700700                break;
    701        
     701
    702702        case USB_HID_REPORT_TAG_PUSH:
    703703        case USB_HID_REPORT_TAG_POP:
     
    708708                return tag;
    709709                break;
    710                        
     710
    711711        default:
    712712                return USB_HID_NO_ACTION;
     
    730730{
    731731        int32_t extended_usage;
    732        
     732
    733733        switch (tag) {
    734734        case USB_HID_REPORT_TAG_USAGE:
     
    740740                         */
    741741                        break;
    742                        
     742
    743743                case START_DELIMITER_SET:
    744744                        report_item->in_delimiter = INSIDE_DELIMITER_SET;
     
    748748                        extended_usage +=
    749749                            usb_hid_report_tag_data_uint32(data, item_size);
    750                        
     750
    751751                        report_item->usages[report_item->usages_count] =
    752752                            extended_usage;
    753                        
     753
    754754                        report_item->usages_count++;
    755755                        break;
    756756                }
    757757                break;
    758                
     758
    759759        case USB_HID_REPORT_TAG_USAGE_MINIMUM:
    760760                if (item_size == 3) {
     
    763763                            USB_HID_EXTENDED_USAGE_PAGE(
    764764                            usb_hid_report_tag_data_uint32(data, item_size));
    765                        
    766                        
     765
     766
    767767                        report_item->usage_minimum =
    768768                            USB_HID_EXTENDED_USAGE(
     
    773773                }
    774774                break;
    775                
     775
    776776        case USB_HID_REPORT_TAG_USAGE_MAXIMUM:
    777777                if (item_size == 3) {
     
    781781                                return USB_HID_INVALID;
    782782                        }
    783                        
     783
    784784                        /* Usage extended usages */
    785785                        report_item->extended_usage_page =
    786786                            USB_HID_EXTENDED_USAGE_PAGE(
    787787                            usb_hid_report_tag_data_uint32(data,item_size));
    788                        
     788
    789789                        report_item->usage_maximum =
    790790                            USB_HID_EXTENDED_USAGE(
     
    794794                            usb_hid_report_tag_data_uint32(data,item_size);
    795795                }
    796                
     796
    797797                /* Put the records into the usages array */
    798798                for (int32_t i = report_item->usage_minimum;
    799799                    i <= report_item->usage_maximum; i++) {
    800                        
     800
    801801                        if (report_item->extended_usage_page) {
    802802                                report_item->usages[report_item->usages_count++] =
     
    808808                }
    809809                report_item->extended_usage_page = 0;
    810                
    811                 break;
    812                
     810
     811                break;
     812
    813813        case USB_HID_REPORT_TAG_DESIGNATOR_INDEX:
    814814                report_item->designator_index =
    815815                    usb_hid_report_tag_data_uint32(data, item_size);
    816816                break;
    817        
     817
    818818        case USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM:
    819819                report_item->designator_minimum =
    820820                    usb_hid_report_tag_data_uint32(data, item_size);
    821821                break;
    822        
     822
    823823        case USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM:
    824824                report_item->designator_maximum =
    825825                    usb_hid_report_tag_data_uint32(data, item_size);
    826826                break;
    827        
     827
    828828        case USB_HID_REPORT_TAG_STRING_INDEX:
    829829                report_item->string_index =
    830830                    usb_hid_report_tag_data_uint32(data, item_size);
    831831                break;
    832        
     832
    833833        case USB_HID_REPORT_TAG_STRING_MINIMUM:
    834834                report_item->string_minimum =
    835835                    usb_hid_report_tag_data_uint32(data, item_size);
    836836                break;
    837        
     837
    838838        case USB_HID_REPORT_TAG_STRING_MAXIMUM:
    839839                report_item->string_maximum =
    840840                    usb_hid_report_tag_data_uint32(data, item_size);
    841841                break;
    842        
     842
    843843        case USB_HID_REPORT_TAG_DELIMITER:
    844844                report_item->in_delimiter =
    845845                    usb_hid_report_tag_data_uint32(data, item_size);
    846846                break;
    847        
     847
    848848        default:
    849849                return USB_HID_NO_ACTION;
    850850        }
    851        
     851
    852852        return 0;
    853853}
     
    965965                usb_hid_report_path_free(path);
    966966        }
    967        
     967
    968968        // free report items
    969969        usb_hid_report_description_t *report_des;
     
    974974
    975975                list_remove(&report_des->reports_link);
    976                
     976
    977977                while(!list_empty(&report_des->report_items)) {
    978978                        field = list_get_instance(
     
    984984                        free(field);
    985985                }
    986                
     986
    987987                free(report_des);
    988988        }
    989        
     989
    990990        return;
    991991}
Note: See TracChangeset for help on using the changeset viewer.