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


Ignore:
Timestamp:
2011-03-03T15:35:37Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b7d9606
Parents:
e259d95
Message:

report item offset

File:
1 edited

Legend:

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

    re259d95 rc7a2e7e  
    4343
    4444
    45 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, uint8_t *data, size_t item_size,
     45int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const const uint8_t *data, size_t item_size,
    4646                             usb_hid_report_item_t *report_item);
    47 int usb_hid_report_parse_main_tag(uint8_t tag, uint8_t *data, size_t item_size,
     47int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    4848                             usb_hid_report_item_t *report_item);
    49 int usb_hid_report_parse_global_tag(uint8_t tag, uint8_t *data, size_t item_size,
     49int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    5050                             usb_hid_report_item_t *report_item);
    51 int usb_hid_report_parse_local_tag(uint8_t tag, uint8_t *data, size_t item_size,
     51int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    5252                             usb_hid_report_item_t *report_item);
    5353
     
    5555int usb_hid_report_reset_local_items();
    5656void usb_hid_free_report_list(link_t *head);
    57 int32_t usb_hid_report_tag_data_int32(uint8_t *data, size_t size);
     57int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size);
     58size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset);
    5859/**
    5960 *
     
    8081 */
    8182int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
    82     const uint8_t *data, size_t size)
     83    const const uint8_t *data, size_t size)
    8384{
    8485        size_t i=0;
     
    8990        usb_hid_report_item_t *report_item=0;
    9091        usb_hid_report_item_t *new_report_item;
     92
     93        size_t offset=0;
    9194       
    9295
     
    103106                        class = USB_HID_ITEM_TAG_CLASS(data[i]);
    104107                                               
    105                         ret = usb_hid_report_parse_tag(tag,class,
    106                                                  (uint8_t *)(data + sizeof(uint8_t)*(i+1)),
     108                        ret = usb_hid_report_parse_tag(tag,class,(data + (i+1)),
    107109                                                 item_size,report_item);
    108110                        switch(ret){
     
    110112                                        // store report item to report and create the new one
    111113                                        printf("\nNEW REPORT ITEM: %X",tag);
     114
     115                                        offset = usb_hid_count_item_offset(report_item, offset);
     116                                        report_item->offset = offset;
    112117                                        switch(tag) {
    113118                                                case USB_HID_REPORT_TAG_INPUT:
     
    125130                                                        break;
    126131                                                default:
    127                                                     printf("\tjump over\n");
     132                                                    printf("\tjump over tag: %X\n", tag q);
    128133                                                    break;
    129134                                        }
     
    178183 */
    179184int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 
    180     const uint8_t *data, size_t size,
     185    const const uint8_t *data, size_t size,
    181186    const usb_hid_report_in_callbacks_t *callbacks, void *arg)
    182187{
     
    210215 * @return Error code
    211216 */
    212 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,
     217int usb_hid_boot_keyboard_input_report(const const uint8_t *data, size_t size,
    213218        const usb_hid_report_in_callbacks_t *callbacks, void *arg)
    214219{
     
    268273 * @return Code of action to be done next
    269274 */
    270 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, uint8_t *data, size_t item_size,
     275int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const const uint8_t *data, size_t item_size,
    271276                             usb_hid_report_item_t *report_item)
    272277{       
     
    305310 */
    306311
    307 int usb_hid_report_parse_main_tag(uint8_t tag, uint8_t *data, size_t item_size,
     312int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    308313                             usb_hid_report_item_t *report_item)
    309314{
     
    341346 */
    342347
    343 int usb_hid_report_parse_global_tag(uint8_t tag, uint8_t *data, size_t item_size,
     348int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    344349                             usb_hid_report_item_t *report_item)
    345350{
     
    398403 * @return Error code
    399404 */
    400 int usb_hid_report_parse_local_tag(uint8_t tag, uint8_t *data, size_t item_size,
     405int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size,
    401406                             usb_hid_report_item_t *report_item)
    402407{
     
    449454 * @return Converted int32 number
    450455 */
    451 int32_t usb_hid_report_tag_data_int32(uint8_t *data, size_t size)
     456int32_t usb_hid_report_tag_data_int32(const uint8_t *data, size_t size)
    452457{
    453458        unsigned int i;
     
    563568        return;
    564569}
     570
     571inline size_t usb_hid_count_item_offset(usb_hid_report_item_t * report_item, size_t offset)
     572{
     573        return offset += (report_item->count * report_item->size);
     574}
    565575/**
    566576 * @}
Note: See TracChangeset for help on using the changeset viewer.