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


Ignore:
Timestamp:
2011-04-08T13:24:21Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6acc80f3, 85c47729
Parents:
ffc63b0 (diff), 8b74997f (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.
Message:

Development branch changes

File:
1 edited

Legend:

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

    rffc63b0 r4b39af4  
    6464int usb_hid_report_reset_local_items();
    6565void usb_hid_free_report_list(link_t *head);
    66 
     66usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item);
    6767/*
    6868 * Data translation private functions
     
    106106    list_initialize(&(parser->feature));
    107107
     108        list_initialize(&(parser->stack));
     109
     110        parser->use_report_id = 0;
    108111    return EOK;   
    109112}
     
    186189                                        tmp_usage_path = NULL;
    187190
     191                                        usb_hid_report_path_set_report_id(report_item->usage_path, report_item->id);   
     192                                        if(report_item->id != 0){
     193                                                parser->use_report_id = 1;
     194                                        }
    188195                                       
    189196                                        switch(tag) {
     
    215222                                        if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) {
    216223                                                return ENOMEM;
    217                                         }
     224                                        }                                       
    218225                                        memcpy(new_report_item,report_item, sizeof(usb_hid_report_item_t));
     226                                        link_initialize(&(new_report_item->link));
     227                                       
    219228                                        /* reset local items */
    220229                                        new_report_item->usage_minimum = 0;
    221230                                        new_report_item->usage_maximum = 0;
     231                                        new_report_item->designator_index = 0;
     232                                        new_report_item->designator_minimum = 0;
     233                                        new_report_item->designator_maximum = 0;
     234                                        new_report_item->string_index = 0;
     235                                        new_report_item->string_minimum = 0;
     236                                        new_report_item->string_maximum = 0;
     237
     238                                        /* reset usage from current usage path */
     239                                        usb_hid_report_usage_path_t *path = list_get_instance(&usage_path->link, usb_hid_report_usage_path_t, link);
     240                                        path->usage = 0;
    222241                                       
    223                                         link_initialize(&(new_report_item->link));
    224242                                        report_item = new_report_item;
    225243                                                                               
     
    227245                                case USB_HID_REPORT_TAG_PUSH:
    228246                                        // push current state to stack
    229                                         // not yet implemented
     247                                        new_report_item = usb_hid_report_item_clone(report_item);
     248                                        list_prepend (&parser->stack, &new_report_item->link);
     249                                       
    230250                                        break;
    231251                                case USB_HID_REPORT_TAG_POP:
    232252                                        // restore current state from stack
    233                                         // not yet implemented                                             
     253                                        if(list_empty (&parser->stack)) {
     254                                                return EINVAL;
     255                                        }
     256                                       
     257                                        report_item = list_get_instance(&parser->stack, usb_hid_report_item_t, link);
     258                                        list_remove (parser->stack.next);
     259                                       
    234260                                        break;
    235261                                       
     
    647673        }
    648674
     675        parser->use_report_id = 0;
     676
    649677        usb_hid_free_report_list(&parser->input);
    650678        usb_hid_free_report_list(&parser->output);
     
    676704        size_t i=0;
    677705        size_t j=0;
     706        uint8_t report_id = 0;
    678707
    679708        if(parser == NULL) {
     
    686715        if(!(keys = malloc(sizeof(uint8_t) * key_count))){
    687716                return ENOMEM;
     717        }
     718
     719        if(parser->use_report_id != 0) {
     720                report_id = data[0];
     721                usb_hid_report_path_set_report_id(path, report_id);
    688722        }
    689723
     
    693727
    694728                item = list_get_instance(list_item, usb_hid_report_item_t, link);
     729
    695730                if(!USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) &&
    696731                   (usb_hid_report_compare_usage_path(item->usage_path, path, flags) == EOK)) {
     
    715750        }
    716751
    717         callbacks->keyboard(keys, key_count, 0, arg);
     752        callbacks->keyboard(keys, key_count, report_id, arg);
    718753           
    719754        free(keys);     
     
    739774        int32_t mask;
    740775        const uint8_t *foo;
    741        
     776
    742777        // now only common numbers llowed
    743778        if(item->size > 32) {
     
    758793                (usb_pow(10,(item->unit_exponent))));
    759794        }
     795
    760796        offset = item->offset + (j * item->size);
     797        if(item->id != 0) {
     798                offset += 8;
     799                usb_log_debug("MOVED OFFSET BY 1Byte, REPORT_ID(%d)\n", item->id);
     800        }
    761801       
    762802        // FIXME
     
    942982
    943983        int only_page;
     984
     985        if(report_path->report_id != path->report_id) {
     986                return 1;
     987        }
    944988
    945989        if(path->depth == 0){
     
    10381082        else {
    10391083                path->depth = 0;
     1084                path->report_id = 0;
    10401085                list_initialize(&path->link);
    10411086                return path;
     
    11551200                return 0;
    11561201        }
    1157        
     1202
    11581203        item = parser->output.next;
    11591204        while(&parser->output != item) {
     
    11951240        int length;
    11961241        int32_t tmp_value;
     1242        size_t offset_prefix = 0;
    11971243       
    11981244        if(parser == NULL) {
    11991245                return EINVAL;
     1246        }
     1247
     1248        if(parser->use_report_id != 0) {
     1249                buffer[0] = path->report_id;
     1250                offset_prefix = 8;
    12001251        }
    12011252
     
    12181269//                              // variable item
    12191270                                value = usb_hid_translate_data_reverse(report_item, data[idx++]);
    1220                                 offset = report_item->offset + (i * report_item->size);
     1271                                offset = report_item->offset + (i * report_item->size) + offset_prefix;
    12211272                                length = report_item->size;
    12221273                        }
     
    12241275                                //bitmap
    12251276                                value += usb_hid_translate_data_reverse(report_item, data[idx++]);
    1226                                 offset = report_item->offset;
     1277                                offset = report_item->offset + offset_prefix;
    12271278                                length = report_item->size * report_item->count;
    12281279                        }
     
    13231374
    13241375
     1376int usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, uint8_t report_id)
     1377{
     1378        if(path == NULL){
     1379                return EINVAL;
     1380        }
     1381
     1382        path->report_id = report_id;
     1383        return EOK;
     1384}
     1385
     1386
     1387usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item)
     1388{
     1389        usb_hid_report_item_t *new_report_item;
     1390       
     1391        if(!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) {
     1392                return NULL;
     1393        }                                       
     1394        memcpy(new_report_item,item, sizeof(usb_hid_report_item_t));
     1395        link_initialize(&(new_report_item->link));
     1396
     1397        return new_report_item;
     1398}
     1399
    13251400/**
    13261401 * @}
Note: See TracChangeset for help on using the changeset viewer.