Changeset 1519b91 in mainline


Ignore:
Timestamp:
2011-05-06T06:12:56Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b9d7965
Parents:
9d05599
Message:

#209 - correct usage paths for decomposed items

Location:
uspace/lib/usb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hiddescriptor.h

    r9d05599 r1519b91  
    7878uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size);
    7979
     80void usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path);
    8081#endif
    8182/**
  • uspace/lib/usb/src/hiddescriptor.c

    r9d05599 r1519b91  
    5656#define USB_HID_UNKNOWN_TAG             -99
    5757
    58 
    59 /**
    60  * Initialize the report descriptor parser structure
    61  *
    62  * @param parser Report descriptor parser structure
    63  * @return Error code
    64  */
    65 int usb_hid_report_init(usb_hid_report_t *report)
    66 {
    67         if(report == NULL) {
    68                 return EINVAL;
    69         }
    70 
    71         memset(report, 0, sizeof(usb_hid_report_t));
    72         list_initialize(&report->reports);
    73         list_initialize(&report->collection_paths);
    74 
    75         report->use_report_ids = 0;
    76     return EOK;   
    77 }
    78 
    79 int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item)
    80 {
    81         usb_hid_report_field_t *field;
    82         int i;
    83 
    84 
     58void usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path)
     59{
    8560        /* find or append current collection path to the list */
    8661        link_t *path_it = report->collection_paths.next;
     
    8964                path = list_get_instance(path_it, usb_hid_report_path_t, link);
    9065               
    91                 if(usb_hid_report_compare_usage_path(path, report_item->usage_path, USB_HID_PATH_COMPARE_STRICT) == EOK){
     66                if(usb_hid_report_compare_usage_path(path, cmp_path, USB_HID_PATH_COMPARE_STRICT) == EOK){
    9267                        break;
    9368                }                       
     
    9570        }
    9671        if(path_it == &report->collection_paths) {
    97                 path = usb_hid_report_path_clone(report_item->usage_path);                     
     72                path = usb_hid_report_path_clone(cmp_path);                     
    9873                list_append(&path->link, &report->collection_paths);                                   
    9974                report->collection_paths_count++;
    10075        }
     76}
     77
     78/**
     79 * Initialize the report descriptor parser structure
     80 *
     81 * @param parser Report descriptor parser structure
     82 * @return Error code
     83 */
     84int usb_hid_report_init(usb_hid_report_t *report)
     85{
     86        if(report == NULL) {
     87                return EINVAL;
     88        }
     89
     90        memset(report, 0, sizeof(usb_hid_report_t));
     91        list_initialize(&report->reports);
     92        list_initialize(&report->collection_paths);
     93
     94        report->use_report_ids = 0;
     95    return EOK;   
     96}
     97
     98int usb_hid_report_append_fields(usb_hid_report_t *report, usb_hid_report_item_t *report_item)
     99{
     100        usb_hid_report_field_t *field;
     101        int i;
    101102
    102103        for(i=0; i<report_item->usages_count; i++){
     
    104105        }
    105106
    106        
     107        usb_hid_report_path_t *path = report_item->usage_path; 
    107108        for(i=0; i<report_item->count; i++){
    108109
     
    168169                }
    169170               
     171                usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_GLOBAL, field->usage_page);
     172                usb_hid_report_set_last_item(path, USB_HID_TAG_CLASS_LOCAL, field->usage);
     173
     174                usb_hid_report_path_try_insert(report, path);
     175
    170176                field->size = report_item->size;
    171177                field->offset = report_item->offset + (i * report_item->size);
     
    349355                                        tmp_usage_path = list_get_instance(report_item->usage_path->link.prev, usb_hid_report_usage_path_t, link);
    350356                                       
    351                                         usb_hid_report_set_last_item(usage_path, tmp_usage_path->usage_page, tmp_usage_path->usage);
     357                                        usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, tmp_usage_path->usage_page);
     358                                        usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, tmp_usage_path->usage);
    352359
    353360                                        usb_hid_report_path_free(report_item->usage_path);
Note: See TracChangeset for help on using the changeset viewer.