Ignore:
File:
1 edited

Legend:

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

    r9d58539 r1e371cf  
    4141#include <assert.h>
    4242
    43 /*---------------------------------------------------------------------------*/
     43
    4444/*
    4545 * Data translation private functions
     
    5252        int32_t value);
    5353
    54 /*---------------------------------------------------------------------------*/
     54
    5555
    5656static int usb_pow(int a, int b)
     
    6868        }
    6969}
    70 /*---------------------------------------------------------------------------*/
     70
    7171
    7272/** Returns size of report of specified report id and type in items
     
    117117        }
    118118}
    119 /*---------------------------------------------------------------------------*/
     119
    120120
    121121/** Parse and act upon a HID report.
     
    130130    size_t size, uint8_t *report_id)
    131131{
    132         usb_hid_report_field_t *item;
    133 
    134132        usb_hid_report_description_t *report_des;
    135133        usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
     
    153151
    154152        /* read data */
    155         list_foreach(report_des->report_items, list_item) {
    156                 item = list_get_instance(list_item, usb_hid_report_field_t,
    157                     ritems_link);
     153        list_foreach(report_des->report_items, ritems_link,
     154            usb_hid_report_field_t, item) {
    158155
    159156                if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
     
    163160                                item->value =
    164161                                        usb_hid_translate_data(item, data);
    165                
     162                               
    166163                                item->usage = USB_HID_EXTENDED_USAGE(
    167164                                    item->usages[item->value -
     
    184181                                /* variable item */
    185182                                item->value = usb_hid_translate_data(item,
    186                                     data);                             
    187                         }                       
     183                                    data);
     184                        }
    188185                }
    189186        }
     
    192189}
    193190
    194 /*---------------------------------------------------------------------------*/
     191
    195192/**
    196193 * Translate data from the report as specified in report descriptor item
     
    274271}
    275272
    276 /*---------------------------------------------------------------------------*/
     273
    277274/* OUTPUT API */
    278275
     
    295292        usb_hid_report_description_t *report_des = NULL;
    296293
    297         list_foreach(report->reports, report_it) {
    298                 report_des = list_get_instance(report_it,
    299                     usb_hid_report_description_t, reports_link);
    300                
    301                 if ((report_des->report_id == report_id) &&
    302                     (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     294        list_foreach(report->reports, reports_link,
     295            usb_hid_report_description_t, rdes) {
     296                if ((rdes->report_id == report_id) &&
     297                    (rdes->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     298                        report_des = rdes;
    303299                        break;
    304300                }
     
    351347
    352348        if (report->use_report_ids != 0) {
    353                 buffer[0] = report_id;         
     349                buffer[0] = report_id;
    354350        }
    355351
     
    362358        }
    363359
    364         usb_hid_report_field_t *report_item;
    365 
    366         list_foreach(report_des->report_items, item) {
    367                 report_item = list_get_instance(item, usb_hid_report_field_t,
    368                     ritems_link);
    369 
     360        list_foreach(report_des->report_items, ritems_link,
     361            usb_hid_report_field_t, report_item) {
    370362                value = usb_hid_translate_data_reverse(report_item,
    371363                    report_item->value);
     
    382374                        }
    383375                        size_t shift = 8 - offset % 8 - length;
    384                         value = value << shift;                                                 
     376                        value = value << shift;
    385377                        value = value & (((1 << length) - 1) << shift);
    386                                
     378                       
    387379                        uint8_t mask = 0;
    388380                        mask = 0xff - (((1 << length) - 1) << shift);
     
    400392
    401393                                        tmp_value = tmp_value << (offset % 8);
    402        
     394                                       
    403395                                        mask = ~(((1 << (8 - (offset % 8))) - 1)
    404396                                            << (offset % 8));
     
    413405                                        value = value & ((1 << (length -
    414406                                            ((offset + length) % 8))) - 1);
    415                                
     407                                       
    416408                                        mask = (1 << (length -
    417409                                            ((offset + length) % 8))) - 1;
     
    431423}
    432424
    433 /*---------------------------------------------------------------------------*/
     425
    434426/**
    435427 * Translate given data for putting them into the outoput report
     
    476468}
    477469
    478 /*---------------------------------------------------------------------------*/
     470
    479471/**
    480472 * Clones given state table
     
    497489}
    498490
    499 /*---------------------------------------------------------------------------*/
     491
    500492/**
    501493 * Function for sequence walking through the report. Returns next field in the
     
    552544}
    553545
    554 /*---------------------------------------------------------------------------*/
     546
    555547/**
    556548 * Returns next report_id of report of specified type. If zero is given than
     
    600592}
    601593
    602 /*---------------------------------------------------------------------------*/
     594
    603595/**
    604596 * Reset all local items in given state table
Note: See TracChangeset for help on using the changeset viewer.