Ignore:
Timestamp:
2011-05-11T16:49:28Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
19387b61
Parents:
e1dbcbc (diff), 9212f8a (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:

Merge development/ changes

File:
1 moved

Legend:

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

    re1dbcbc ra81a1d09  
    11/*
    2  * Copyright (c) 2010 Vojtech Horky
     2 * Copyright (c) 2011 Matej Klonfar
    33 * All rights reserved.
    44 *
     
    3333 * USB HID report descriptor and report data parser
    3434 */
    35 #ifndef LIBUSB_HIDPARSER_H_
    36 #define LIBUSB_HIDPARSER_H_
     35#ifndef LIBUSB_HIDTYPES_H_
     36#define LIBUSB_HIDTYPES_H_
    3737
    3838#include <stdint.h>
    3939#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 /** Constant (1) / Variable (0) */
    55 #define USB_HID_ITEM_FLAG_CONSTANT(flags)       ((flags & 0x1) == 0x1)
    56 /** Variable (1) / Array (0) */
    57 #define USB_HID_ITEM_FLAG_VARIABLE(flags)       ((flags & 0x2) == 0x2)
    58 /** Absolute / Relative*/
    59 #define USB_HID_ITEM_FLAG_RELATIVE(flags)       ((flags & 0x4) == 0x4)
    60 /** Wrap / No Wrap */
    61 #define USB_HID_ITEM_FLAG_WRAP(flags)           ((flags & 0x8) == 0x8)
    62 #define USB_HID_ITEM_FLAG_LINEAR(flags)         ((flags & 0x10) == 0x10)
    63 #define USB_HID_ITEM_FLAG_PREFERRED(flags)      ((flags & 0x20) == 0x20)
    64 #define USB_HID_ITEM_FLAG_POSITION(flags)       ((flags & 0x40) == 0x40)
    65 #define USB_HID_ITEM_FLAG_VOLATILE(flags)       ((flags & 0x80) == 0x80)
    66 #define USB_HID_ITEM_FLAG_BUFFERED(flags)       ((flags & 0x100) == 0x100)
    67 
    68 
    69 /**
    70  * Description of path of usage pages and usages in report descriptor
    71  */
    72 #define USB_HID_PATH_COMPARE_STRICT                             0
    73 #define USB_HID_PATH_COMPARE_END                                1
    74 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY    4
    75 #define USB_HID_PATH_COMPARE_COLLECTION_ONLY    2 /* porovnava jenom cestu z Kolekci */
    76 
    7740
    7841#define USB_HID_MAX_USAGES      20
     42
     43#define USB_HID_UINT32_TO_INT32(x, size)        ((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1)))
     44#define USB_HID_INT32_TO_UINT32(x, size)        (((x) < 0 ) ? ((1 << (size)) + (x)) : (x))
     45
    7946
    8047typedef enum {
     
    8350        USB_HID_REPORT_TYPE_FEATURE = 3
    8451} usb_hid_report_type_t;
    85 
    86 /** Collection usage path structure */
    87 typedef struct {
    88         /** */
    89         uint32_t usage_page;
    90         /** */ 
    91         uint32_t usage;
    92 
    93         uint8_t flags;
    94         /** */
    95         link_t link;
    96 } usb_hid_report_usage_path_t;
    97 
    98 /** */
    99 typedef struct {
    100         /** */ 
    101         int depth;     
    102         uint8_t report_id;
    103        
    104         /** */ 
    105         link_t link; /* list */
    106 
    107         link_t head; /* head of list of usage paths */
    108 
    109 } usb_hid_report_path_t;
    11052
    11153
     
    223165        /** */ 
    224166        link_t link;
     167
     168        int in_delimiter;
    225169} usb_hid_report_item_t;
    226170
     
    261205};
    262206
    263 /*
    264  * Descriptor parser functions
    265  */
    266 
    267 /** */
    268 int usb_hid_parse_report_descriptor(usb_hid_report_t *report,
    269     const uint8_t *data, size_t size);
    270 
    271 /** */
    272 void usb_hid_free_report(usb_hid_report_t *report);
    273 
    274 /** */
    275 void usb_hid_descriptor_print(usb_hid_report_t *report);
    276 
    277 
    278 /*
    279  * Input report parser functions
    280  */
    281 /** */
    282 int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size, uint8_t *report_id);
    283 
    284 /** */
    285 size_t usb_hid_report_input_length(const usb_hid_report_t *report,
    286         usb_hid_report_path_t *path, int flags);
    287 
    288 
    289 
    290 /*
    291  * usage path functions
    292  */
    293 /** */
    294 usb_hid_report_path_t *usb_hid_report_path(void);
    295 
    296 /** */
    297 void usb_hid_report_path_free(usb_hid_report_path_t *path);
    298 
    299 /** */
    300 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, uint8_t report_id);
    301 
    302 /** */
    303 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, int32_t usage_page, int32_t usage);
    304 
    305 /** */
    306 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path);
    307 
    308 /** */
    309 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path);
    310 
    311 /** */
    312 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, int32_t tag, int32_t data);
    313 
    314 /** */
    315 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, usb_hid_report_path_t *path, int flags);
    316 
    317 /** */
    318 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path);
    319 
    320 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, usb_hid_report_type_t type);
    321 
    322 uint8_t usb_hid_report_get_report_id(usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type);
    323 
    324 
    325 /*
    326  * Output report parser functions
    327  */
    328 /** Allocates output report buffer*/
    329 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id);
    330 
    331 /** Frees output report buffer*/
    332 void usb_hid_report_output_free(uint8_t *output);
    333 
    334 /** Returns size of output for given usage path */
    335 size_t usb_hid_report_output_size(usb_hid_report_t *report,
    336                                   usb_hid_report_path_t *path, int flags);
    337 
    338 /** Sets data in report structure */
    339 int usb_hid_report_output_set_data(usb_hid_report_t *report,
    340                                    usb_hid_report_path_t *path, int flags,
    341                                   int *data, size_t data_size);
    342 
    343 /** Makes the output report buffer by translated given data */
    344 int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size);
    345207#endif
    346208/**
Note: See TracChangeset for help on using the changeset viewer.