Ignore:
File:
1 edited

Legend:

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

    r07525cd r9d58539  
    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
    132134        usb_hid_report_description_t *report_des;
    133135        usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
     
    151153
    152154        /* read data */
    153         list_foreach(report_des->report_items, ritems_link,
    154             usb_hid_report_field_t, item) {
     155        list_foreach(report_des->report_items, list_item) {
     156                item = list_get_instance(list_item, usb_hid_report_field_t,
     157                    ritems_link);
    155158
    156159                if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
     
    160163                                item->value =
    161164                                        usb_hid_translate_data(item, data);
    162                                
     165               
    163166                                item->usage = USB_HID_EXTENDED_USAGE(
    164167                                    item->usages[item->value -
     
    181184                                /* variable item */
    182185                                item->value = usb_hid_translate_data(item,
    183                                     data);
    184                         }
     186                                    data);                             
     187                        }                       
    185188                }
    186189        }
     
    189192}
    190193
    191 
     194/*---------------------------------------------------------------------------*/
    192195/**
    193196 * Translate data from the report as specified in report descriptor item
     
    271274}
    272275
    273 
     276/*---------------------------------------------------------------------------*/
    274277/* OUTPUT API */
    275278
     
    292295        usb_hid_report_description_t *report_des = NULL;
    293296
    294         list_foreach(report->reports, reports_link,
    295             usb_hid_report_description_t, report_des) {
     297        list_foreach(report->reports, report_it) {
     298                report_des = list_get_instance(report_it,
     299                    usb_hid_report_description_t, reports_link);
     300               
    296301                if ((report_des->report_id == report_id) &&
    297302                    (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) {
     
    346351
    347352        if (report->use_report_ids != 0) {
    348                 buffer[0] = report_id;
     353                buffer[0] = report_id;         
    349354        }
    350355
     
    357362        }
    358363
    359         list_foreach(report_des->report_items, ritems_link,
    360             usb_hid_report_field_t, report_item) {
     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
    361370                value = usb_hid_translate_data_reverse(report_item,
    362371                    report_item->value);
     
    373382                        }
    374383                        size_t shift = 8 - offset % 8 - length;
    375                         value = value << shift;
     384                        value = value << shift;                                                 
    376385                        value = value & (((1 << length) - 1) << shift);
    377                        
     386                               
    378387                        uint8_t mask = 0;
    379388                        mask = 0xff - (((1 << length) - 1) << shift);
     
    391400
    392401                                        tmp_value = tmp_value << (offset % 8);
    393                                        
     402       
    394403                                        mask = ~(((1 << (8 - (offset % 8))) - 1)
    395404                                            << (offset % 8));
     
    404413                                        value = value & ((1 << (length -
    405414                                            ((offset + length) % 8))) - 1);
    406                                        
     415                               
    407416                                        mask = (1 << (length -
    408417                                            ((offset + length) % 8))) - 1;
     
    422431}
    423432
    424 
     433/*---------------------------------------------------------------------------*/
    425434/**
    426435 * Translate given data for putting them into the outoput report
     
    467476}
    468477
    469 
     478/*---------------------------------------------------------------------------*/
    470479/**
    471480 * Clones given state table
     
    488497}
    489498
    490 
     499/*---------------------------------------------------------------------------*/
    491500/**
    492501 * Function for sequence walking through the report. Returns next field in the
     
    543552}
    544553
    545 
     554/*---------------------------------------------------------------------------*/
    546555/**
    547556 * Returns next report_id of report of specified type. If zero is given than
     
    591600}
    592601
    593 
     602/*---------------------------------------------------------------------------*/
    594603/**
    595604 * Reset all local items in given state table
Note: See TracChangeset for help on using the changeset viewer.