Ignore:
File:
1 edited

Legend:

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

    r9d58539 r07525cd  
    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                
     294        list_foreach(report->reports, reports_link,
     295            usb_hid_report_description_t, report_des) {
    301296                if ((report_des->report_id == report_id) &&
    302297                    (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     
    351346
    352347        if (report->use_report_ids != 0) {
    353                 buffer[0] = report_id;         
     348                buffer[0] = report_id;
    354349        }
    355350
     
    362357        }
    363358
    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 
     359        list_foreach(report_des->report_items, ritems_link,
     360            usb_hid_report_field_t, report_item) {
    370361                value = usb_hid_translate_data_reverse(report_item,
    371362                    report_item->value);
     
    382373                        }
    383374                        size_t shift = 8 - offset % 8 - length;
    384                         value = value << shift;                                                 
     375                        value = value << shift;
    385376                        value = value & (((1 << length) - 1) << shift);
    386                                
     377                       
    387378                        uint8_t mask = 0;
    388379                        mask = 0xff - (((1 << length) - 1) << shift);
     
    400391
    401392                                        tmp_value = tmp_value << (offset % 8);
    402        
     393                                       
    403394                                        mask = ~(((1 << (8 - (offset % 8))) - 1)
    404395                                            << (offset % 8));
     
    413404                                        value = value & ((1 << (length -
    414405                                            ((offset + length) % 8))) - 1);
    415                                
     406                                       
    416407                                        mask = (1 << (length -
    417408                                            ((offset + length) % 8))) - 1;
     
    431422}
    432423
    433 /*---------------------------------------------------------------------------*/
     424
    434425/**
    435426 * Translate given data for putting them into the outoput report
     
    476467}
    477468
    478 /*---------------------------------------------------------------------------*/
     469
    479470/**
    480471 * Clones given state table
     
    497488}
    498489
    499 /*---------------------------------------------------------------------------*/
     490
    500491/**
    501492 * Function for sequence walking through the report. Returns next field in the
     
    552543}
    553544
    554 /*---------------------------------------------------------------------------*/
     545
    555546/**
    556547 * Returns next report_id of report of specified type. If zero is given than
     
    600591}
    601592
    602 /*---------------------------------------------------------------------------*/
     593
    603594/**
    604595 * Reset all local items in given state table
Note: See TracChangeset for help on using the changeset viewer.