Changeset dc9f122 in mainline for uspace/lib/usb/src/hidparser.c


Ignore:
Timestamp:
2011-04-17T15:37:29Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ef354b6
Parents:
681f24b3
Message:

new report structure fix

File:
1 edited

Legend:

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

    r681f24b3 rdc9f122  
    140140        if(path_it == &report->collection_paths) {
    141141                path = usb_hid_report_path_clone(report_item->usage_path);                     
    142                 list_initialize(&path->link);
    143 
    144142                list_append(&path->link, &report->collection_paths);                                   
    145                
    146                 usb_hid_print_usage_path (report_item->usage_path);
    147                 usb_hid_print_usage_path (path);
    148                 usb_hid_print_usage_path(list_get_instance(report->collection_paths.prev, usb_hid_report_path_t, link));
    149 
    150                 assert(usb_hid_report_compare_usage_path (report_item->usage_path,
    151                 list_get_instance(report->collection_paths.prev,
    152                                   usb_hid_report_path_t, link),
    153                         USB_HID_PATH_COMPARE_STRICT) == EOK);
    154 
    155143                report->collection_paths_count++;
    156144        }
     
    237225        while(report_it != &report->reports) {
    238226                report_des = list_get_instance(report_it, usb_hid_report_description_t, link);
     227
    239228                if((report_des->report_id == report_id) && (report_des->type == type)){
    240                         break;
    241                 }
     229                        return report_des;
     230                }
     231               
    242232                report_it = report_it->next;
    243233        }
    244         if(report_it ==&report->reports){
    245                 return NULL;
    246         }
    247 
    248         return report_des;
     234
     235        return NULL;
    249236}
    250237
     
    341328                                         * structure                                     
    342329                                         */
    343                                         usb_log_debug("PRED: \n");
    344                                         if(report->collection_paths.next == &report->collection_paths) {
    345                                                 usb_log_debug("PRAZDNY\n");
    346                                         }
    347                                         else {
    348                                                 usb_hid_print_usage_path (list_get_instance(report->collection_paths.prev,usb_hid_report_path_t, link));
    349                                         }
    350                                         usb_log_debug("-----------\n");
    351330                                        usb_hid_report_append_fields(report, report_item);
    352331
     
    971950                field = list_get_instance(field_it, usb_hid_report_field_t, link);
    972951                if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
    973                         if(usb_hid_report_compare_usage_path (path, field->collection_path, flags) == EOK) {
     952                       
     953                        usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
     954                        if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {
    974955                                ret++;
    975956                        }
     957                        usb_hid_report_remove_last_item (field->collection_path);
    976958                }
    977959               
     
    1006988        item->flags = 0;
    1007989       
    1008         list_append (&item->link, &usage_path->link);
     990        list_append (&item->link, &usage_path->head);
    1009991        usage_path->depth++;
    1010992        return EOK;
     
    10201002        usb_hid_report_usage_path_t *item;
    10211003       
    1022         if(!list_empty(&usage_path->link)){
    1023                 item = list_get_instance(usage_path->link.prev, usb_hid_report_usage_path_t, link);             
    1024                 list_remove(usage_path->link.prev);
     1004        if(!list_empty(&usage_path->head)){
     1005                item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);             
     1006                list_remove(usage_path->head.prev);
    10251007                usage_path->depth--;
    10261008                free(item);
     
    10381020        usb_hid_report_usage_path_t *item;
    10391021       
    1040         if(!list_empty(&usage_path->link)){     
    1041                 item = list_get_instance(usage_path->link.prev, usb_hid_report_usage_path_t, link);
     1022        if(!list_empty(&usage_path->head)){     
     1023                item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
    10421024                memset(item, 0, sizeof(usb_hid_report_usage_path_t));
    10431025        }
     
    10571039        usb_hid_report_usage_path_t *item;
    10581040       
    1059         if(!list_empty(&usage_path->link)){     
    1060                 item = list_get_instance(usage_path->link.prev, usb_hid_report_usage_path_t, link);
     1041        if(!list_empty(&usage_path->head)){     
     1042                item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link);
    10611043
    10621044                switch(tag) {
     
    10781060        usb_log_debug("\tLENGTH: %d\n", path->depth);
    10791061
    1080         link_t *item = path->link.next;
     1062        link_t *item = path->head.next;
    10811063        usb_hid_report_usage_path_t *path_item;
    1082         while(item != &path->link) {
     1064        while(item != &path->head) {
    10831065
    10841066                path_item = list_get_instance(item, usb_hid_report_usage_path_t, link);
     
    10941076 * Compares two usage paths structures
    10951077 *
     1078 * If USB_HID_PATH_COMPARE_COLLECTION_ONLY flag is given, the last item in report_path structure is forgotten
     1079 *
    10961080 * @param report_path usage path structure to compare
    10971081 * @param path usage patrh structure to compare
     
    11191103        }
    11201104
    1121         //usb_log_debug("---------- PATH COMPARISON ----------\n\n");
    1122         //usb_hid_print_usage_path(report_path);
    1123         //usb_hid_print_usage_path(path);
    1124        
    11251105
    11261106        if((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0){
     
    11521132                                }
    11531133
    1154                                 if((report_link == &report_path->head) && (path_link == &path->head)) {
     1134                                if(((report_link == &report_path->head) && (path_link == &path->head)) ||
     1135                                   (((flags & USB_HID_PATH_COMPARE_COLLECTION_ONLY) != 0) && (path_link = &path->head) && (report_link == report_path->head.prev))) {
    11551136                                        return EOK;
    11561137                                }
     
    11621143                /* compare with only the end of path*/
    11631144                case USB_HID_PATH_COMPARE_END:
    1164                                 report_link = report_path->head.prev;
     1145
     1146                                if((flags & USB_HID_PATH_COMPARE_COLLECTION_ONLY) != 0) {
     1147                                        report_link = report_path->head.prev->prev;
     1148                                }
     1149                                else {
     1150                                        report_link = report_path->head.prev;
     1151                                }
    11651152                                path_link = path->head.prev;
    11661153
     
    12171204                path->report_id = 0;
    12181205                list_initialize(&path->link);
     1206                list_initialize(&path->head);
    12191207                return path;
    12201208        }
     
    12291217void usb_hid_report_path_free(usb_hid_report_path_t *path)
    12301218{
    1231         while(!list_empty(&path->link)){
     1219        while(!list_empty(&path->head)){
    12321220                usb_hid_report_remove_last_item(path);
    12331221        }
     
    12551243        }
    12561244       
    1257         if(list_empty(&usage_path->link)){
     1245        if(list_empty(&usage_path->head)){
    12581246                return new_usage_path;
    12591247        }
    12601248
    1261         path_link = usage_path->link.next;
    1262         while(path_link != &usage_path->link) {
     1249        path_link = usage_path->head.next;
     1250        while(path_link != &usage_path->head) {
    12631251                path_item = list_get_instance(path_link, usb_hid_report_usage_path_t, link);
    12641252                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
     
    12661254                        return NULL;
    12671255                }
    1268 
    1269                 list_initialize (&new_path_item->link);
     1256               
     1257                list_initialize (&new_path_item->link);         
    12701258                new_path_item->usage_page = path_item->usage_page;
    12711259                new_path_item->usage = path_item->usage;               
    12721260                new_path_item->flags = path_item->flags;               
    12731261               
    1274                 list_append(&new_path_item->link, &new_usage_path->link);
     1262                list_append(&new_path_item->link, &new_usage_path->head);
    12751263                new_usage_path->depth++;
    12761264
     
    13031291        while(report_it != &report->reports) {
    13041292                report_des = list_get_instance(report_it, usb_hid_report_description_t, link);
    1305                 if((report_des->report_id == report_id) && (report_des->type = USB_HID_REPORT_TYPE_OUTPUT)){
     1293                if((report_des->report_id == report_id) && (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)){
    13061294                        break;
    13071295                }
     
    13571345                return 0;
    13581346        }
    1359 
     1347       
    13601348        link_t *field_it = report_des->report_items.next;
    13611349        usb_hid_report_field_t *field;
     
    13631351
    13641352                field = list_get_instance(field_it, usb_hid_report_field_t, link);
    1365                 // TODO: bacha na porovnani - posledni prvek v ceste uz jsou usage/page z inputu a ne kolekce!!!
     1353                usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
    13661354                if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) {
    13671355                        ret++;
    13681356                }
     1357                usb_hid_report_remove_last_item (field->collection_path);
    13691358               
    13701359                field_it = field_it->next;
     
    15941583                field = list_get_instance(field_it, usb_hid_report_field_t, link);             
    15951584                if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) {
    1596                         if(usb_hid_report_compare_usage_path (path, field->collection_path,
     1585                        usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage);
     1586                        if(usb_hid_report_compare_usage_path (field->collection_path, path,
    15971587                                                      flags) == EOK) {
    15981588
     
    16041594                                }
    16051595                        }
     1596                        usb_hid_report_remove_last_item (field->collection_path);
    16061597                }
    16071598               
Note: See TracChangeset for help on using the changeset viewer.