Changeset 68b614e in mainline


Ignore:
Timestamp:
2011-05-08T16:00:58Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f50f722
Parents:
cc5908e
Message:

Correct parsing of usages in case of array items

Location:
uspace/lib/usb/src
Files:
3 edited

Legend:

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

    rcc5908e r68b614e  
    6464{
    6565        /* find or append current collection path to the list */
    66         link_t *path_it = report->collection_paths.next;
     66        //link_t *path_it = report->collection_paths.next;
     67        link_t *path_it = report->collection_paths.prev->next;
    6768        usb_hid_report_path_t *path = NULL;
     69       
     70       
    6871        while(path_it != &report->collection_paths) {
    6972                path = list_get_instance(path_it, usb_hid_report_path_t, link);
     
    115118        usb_hid_report_field_t *field;
    116119        int i;
    117 
    118         usb_log_debug("usages_count  - %zu\n", report_item->usages_count);
    119120
    120121        uint32_t *usages;
     
    147148                        */
    148149                        field->usage = 0;
    149                         field->usage_page = report_item->usage_page;
     150                        field->usage_page = 0; //report_item->usage_page;
    150151
    151152                        field->usages_count = report_item->usages_count;
     
    168169                        }
    169170                        else {
     171                                // should not occur
    170172                                field->usage = usage;
    171173                                field->usage_page = report_item->usage_page;
     
    465467                       
    466468                        // set last item
    467                         usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, report_item->usage_page);
    468                         usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, report_item->usages[report_item->usages_count-1]);
     469                        usb_hid_report_set_last_item(usage_path,
     470                                                     USB_HID_TAG_CLASS_GLOBAL,
     471                                                     USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[report_item->usages_count-1]));
     472                        usb_hid_report_set_last_item(usage_path,
     473                                                     USB_HID_TAG_CLASS_LOCAL,
     474                                                     USB_HID_EXTENDED_USAGE(report_item->usages[report_item->usages_count-1]));
    469475                       
    470476                        // append the new one which will be set by common
     
    561567                             usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path)
    562568{
     569        int32_t extended_usage;
     570       
    563571        switch(tag) {
    564572                case USB_HID_REPORT_TAG_USAGE:
     
    570578                                        report_item->in_delimiter = INSIDE_DELIMITER_SET;
    571579                                case OUTSIDE_DELIMITER_SET:
    572                                         report_item->usages[report_item->usages_count] = usb_hid_report_tag_data_uint32(data,item_size);
     580                                        extended_usage = ((report_item->usage_page) << 16);
     581                                        extended_usage += usb_hid_report_tag_data_uint32(data,item_size);
     582                                        report_item->usages[report_item->usages_count] = extended_usage;
    573583                                        report_item->usages_count++;
    574584                                        break;
     
    607617                                }
    608618                                else {
    609                                         report_item->usages[report_item->usages_count++] = i;
     619                                       
     620                                        report_item->usages[report_item->usages_count++] = (report_item->usage_page << 16) + i;
    610621                                }
    611622                        }
     
    691702                usb_log_debug("\t\ttUSAGEMIN: %X\n", report_item->usage_minimum);
    692703                usb_log_debug("\t\tUSAGEMAX: %X\n", report_item->usage_maximum);
     704                usb_log_debug("\t\tUSAGES COUNT: %zu\n", report_item->usages_count);
    693705
    694706                usb_log_debug("\t\tVALUE: %X\n", report_item->value);
     
    696708                usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page);
    697709               
    698                 //usb_hid_print_usage_path(report_item->collection_path);
     710                usb_hid_print_usage_path(report_item->collection_path);
    699711
    700712                usb_log_debug("\n");           
     
    728740                usb_hid_descriptor_print_list(&report_des->report_items);
    729741
    730 
     742/*
    731743                link_t *path_it = report->collection_paths.next;
    732744                while(path_it != &report->collection_paths) {
     
    734746                        path_it = path_it->next;
    735747                }
    736                
     748*/             
    737749                report_it = report_it->next;
    738750        }
  • uspace/lib/usb/src/hidparser.c

    rcc5908e r68b614e  
    111111        usb_hid_report_description_t *report_des;
    112112        usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
    113 
     113       
    114114        if(report == NULL) {
    115115                return EINVAL;
     
    140140               
    141141                                item->usage = USB_HID_EXTENDED_USAGE(item->usages[item->value - item->physical_minimum]);
    142                                 item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]);
    143 
     142                                item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]);                             
     143
     144                                usb_hid_report_set_last_item (item->collection_path,
     145                                                              USB_HID_TAG_CLASS_GLOBAL,
     146                                                              item->usage_page);
     147                                usb_hid_report_set_last_item (item->collection_path,
     148                                                              USB_HID_TAG_CLASS_LOCAL,
     149                                                              item->usage);
     150                               
    144151                        }
    145152                        else {
     
    150157                list_item = list_item->next;
    151158        }
    152            
     159       
    153160        return EOK;
    154161       
  • uspace/lib/usb/src/hidpath.c

    rcc5908e r68b614e  
    4242
    4343
     44#define USB_HID_SAME_USAGE(usage1, usage2)      ((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))
     45#define USB_HID_SAME_USAGE_PAGE(page1, page2)   ((page1 == page2) || (page1 == 0) || (page2 == 0))
     46
    4447/**
    4548 * Appends one item (couple of usage_path and usage) into the usage path
     
    203206                        while(report_link != &report_path->head) {
    204207                                report_item = list_get_instance(report_link, usb_hid_report_usage_path_t, link);
    205                                 if(report_item->usage_page == path_item->usage_page){
     208                                if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page)){
    206209                                        if(only_page == 0){
    207                                                 if(report_item->usage == path_item->usage) {
     210                                                if(USB_HID_SAME_USAGE(report_item->usage, path_item->usage)) {
    208211                                                        return EOK;
    209212                                                }
     
    242245                                                                      link);           
    243246
    244                                         if((report_item->usage_page != path_item->usage_page) ||
     247                                        if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) ||
    245248                                           ((only_page == 0) &&
    246                                             (report_item->usage != path_item->usage))) {
     249                                            !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
    247250                                                       
    248251                                                   return 1;
     
    282285                                                                      usb_hid_report_usage_path_t,
    283286                                                                      link);           
    284 
    285                                         if((report_item->usage_page != path_item->usage_page) ||
     287                                                 
     288                                        if(!USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page) ||
    286289                                           ((only_page == 0) &&
    287                                             (report_item->usage != path_item->usage))) {
    288                                                    return 1;
     290                                            !USB_HID_SAME_USAGE(report_item->usage, path_item->usage))) {
     291                                                        return 1;
    289292                                        } else {
    290293                                                report_link = report_link->prev;
Note: See TracChangeset for help on using the changeset viewer.