Ignore:
Timestamp:
2011-03-03T18:56:11Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e9becf6
Parents:
d3594362 (diff), e259d95 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged branch maklf - basic HID report descriptor parser

File:
1 edited

Legend:

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

    rd3594362 r0588062e  
    3737
    3838#include <stdint.h>
     39#include <adt/list.h>
     40#include <usb/classes/hid_report_items.h>
     41
     42/**
     43 * Item prefix
     44 */
     45#define USB_HID_ITEM_SIZE(data)         ((uint8_t)(data & 0x3))
     46#define USB_HID_ITEM_TAG(data)          ((uint8_t)((data & 0xF0) >> 4))
     47#define USB_HID_ITEM_TAG_CLASS(data)    ((uint8_t)((data & 0xC) >> 2))
     48#define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
     49
     50
     51/**
     52 * Input/Output/Feature Item flags
     53 */
     54#define USB_HID_ITEM_FLAG_CONSTANT(flags)       (flags & 0x1)
     55#define USB_HID_ITEM_FLAG_VARIABLE(flags)       (flags & 0x2)
     56#define USB_HID_ITEM_FLAG_RELATIVE(flags)       (flags & 0x4)
     57#define USB_HID_ITEM_FLAG_WRAP(flags)           (flags & 0x8)
     58#define USB_HID_ITEM_FLAG_LINEAR(flags)         (flags & 0x10)
     59#define USB_HID_ITEM_FLAG_PREFERRED(flags)      (flags & 0x20)
     60#define USB_HID_ITEM_FLAG_POSITION(flags)       (flags & 0x40)
     61#define USB_HID_ITEM_FLAG_VOLATILE(flags)       (flags & 0x80)
     62#define USB_HID_ITEM_FLAG_BUFFERED(flags)       (flags & 0x100)
     63
    3964
    4065/**
     
    4267 */
    4368typedef struct {
     69        int32_t id;
     70        int32_t usage_page;
     71        int32_t usage; 
     72        int32_t usage_minimum;
     73        int32_t usage_maximum;
     74        int32_t logical_minimum;
     75        int32_t logical_maximum;
     76        int32_t size;
     77        int32_t count;
     78        int32_t offset;
    4479
    45         uint8_t usage_min;
    46         uint8_t usage_max;
    47         uint8_t logical_min;
    48         uint8_t logical_max;
    49         uint8_t size;
    50         uint8_t count;
    51         uint8_t offset;
     80        int32_t unit_exponent;
     81        int32_t unit;
    5282
     83        /*
     84         * some not yet used fields
     85         */
     86        int32_t string_index;
     87        int32_t string_minimum;
     88        int32_t string_maximum;
     89        int32_t designator_index;
     90        int32_t designator_minimum;
     91        int32_t designator_maximum;
     92        int32_t physical_minimum;
     93        int32_t physical_maximum;
     94
     95        uint8_t item_flags;
     96
     97        link_t link;
    5398} usb_hid_report_item_t;
    5499
    55100
    56101/** HID report parser structure. */
    57 typedef struct {
    58 } usb_hid_report_parser_t;
     102typedef struct {       
     103        link_t input;
     104        link_t output;
     105        link_t feature;
     106} usb_hid_report_parser_t;     
     107
    59108
    60109
     
    127176int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
    128177
     178int usb_hid_parser_init(usb_hid_report_parser_t *parser);
    129179int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
    130180    const uint8_t *data, size_t size);
     
    135185
    136186
    137 int usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     187void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     188
     189void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
    138190
    139191#endif
Note: See TracChangeset for help on using the changeset viewer.