Ignore:
File:
1 edited

Legend:

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

    r976f546 rd972534  
    3737
    3838#include <stdint.h>
    39 #include <adt/list.h>
    40 
    41 #include <hid_report_items.h>
    42 
    43 /**
    44  * Items prefix
    45  */
    46 #define USB_HID_ITEM_SIZE(data)         ((uint8_t)(data & 0x3))
    47 #define USB_HID_ITEM_TAG(data)          ((uint8_t)((data & 0xF0) >> 4))
    48 #define USB_HID_ITEM_TAG_CLASS(data)    ((uint8_t)((data & 0xC) >> 2))
    49 #define USB_HID_ITEM_IS_LONG(data)      (data == 0xFE)
    50 
    51 
    52 /**
    53  * Input/Output/Feature Item flags
    54  */
    55 #define USB_HID_ITEM_FLAG_CONSTANT(flags)       (flags & 0x1)
    56 #define USB_HID_ITEM_FLAG_VARIABLE(flags)       (flags & 0x2)
    57 #define USB_HID_ITEM_FLAG_RELATIVE(flags)       (flags & 0x4)
    58 #define USB_HID_ITEM_FLAG_WRAP(flags)           (flags & 0x8)
    59 #define USB_HID_ITEM_FLAG_LINEAR(flags)         (flags & 0x10)
    60 #define USB_HID_ITEM_FLAG_PREFERRED(flags)      (flags & 0x20)
    61 #define USB_HID_ITEM_FLAG_POSITION(flags)       (flags & 0x40)
    62 #define USB_HID_ITEM_FLAG_VOLATILE(flags)       (flags & 0x80)
    63 #define USB_HID_ITEM_FLAG_BUFFERED(flags)       (flags & 0x100)
    64 
    65 
    66 /**
    67  * Collection Item Types
    68  */
    69 #define USB_HID_COLLECTION_TYPE_PHYSICAL                0x00
    70 #define USB_HID_COLLECTION_TYPE_APPLICATION             0x01
    71 #define USB_HID_COLLECTION_TYPE_LOGICAL                 0x02
    72 #define USB_HID_COLLECTION_TYPE_REPORT                  0x03
    73 #define USB_HID_COLLECTION_TYPE_NAMED_ARRAY             0x04
    74 #define USB_HID_COLLECTION_TYPE_USAGE_SWITCH    0x05
    75 
    76 /*
    77  * modifiers definitions
    78  */
    79 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK          0x01
    80 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK         0x02
    81 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK       0x04
    82 #define USB_HID_BOOT_KEYBOARD_COMPOSE           0x08
    83 #define USB_HID_BOOT_KEYBOARD_KANA                      0x10
    84 
    8539
    8640/**
     
    8842 */
    8943typedef struct {
    90         int32_t id;
    91         int32_t usage_page;
    92         int32_t usage; 
    93         int32_t usage_minimum;
    94         int32_t usage_maximum;
    95         int32_t logical_minimum;
    96         int32_t logical_maximum;
    97         int32_t size;
    98         int32_t count;
    99         int32_t offset;
    10044
    101         int32_t unit_exponent;
    102         int32_t unit;
     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;
    10352
    104         /*
    105          * some not yet used fields
    106          */
    107         int32_t string_index;
    108         int32_t string_minimum;
    109         int32_t string_maximum;
    110         int32_t designator_index;
    111         int32_t designator_minimum;
    112         int32_t designator_maximum;
    113         int32_t physical_minimum;
    114         int32_t physical_maximum;
    115 
    116         uint8_t item_flags;
    117 
    118         link_t link;
    11953} usb_hid_report_item_t;
    12054
    12155
    12256/** HID report parser structure. */
    123 typedef struct {       
    124         link_t input;
    125         link_t output;
    126         link_t feature;
    127 } usb_hid_report_parser_t;     
     57typedef struct {
     58} usb_hid_report_parser_t;
    12859
    12960
     
    13970} usb_hid_report_in_callbacks_t;
    14071
     72
     73typedef enum {
     74        USB_HID_MOD_LCTRL = 0x01,
     75        USB_HID_MOD_LSHIFT = 0x02,
     76        USB_HID_MOD_LALT = 0x04,
     77        USB_HID_MOD_LGUI = 0x08,
     78        USB_HID_MOD_RCTRL = 0x10,
     79        USB_HID_MOD_RSHIFT = 0x20,
     80        USB_HID_MOD_RALT = 0x40,
     81        USB_HID_MOD_RGUI = 0x80,
     82        USB_HID_MOD_COUNT = 8
     83} usb_hid_modifiers_t;
     84
     85typedef enum {
     86        USB_HID_LED_NUM_LOCK = 0x1,
     87        USB_HID_LED_CAPS_LOCK = 0x2,
     88        USB_HID_LED_SCROLL_LOCK = 0x4,
     89        USB_HID_LED_COMPOSE = 0x8,
     90        USB_HID_LED_KANA = 0x10,
     91        USB_HID_LED_COUNT = 5
     92} usb_hid_led_t;
     93
     94static const usb_hid_modifiers_t
     95    usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = {
     96        USB_HID_MOD_LCTRL,
     97        USB_HID_MOD_LSHIFT,
     98        USB_HID_MOD_LALT,
     99        USB_HID_MOD_LGUI,
     100        USB_HID_MOD_RCTRL,
     101        USB_HID_MOD_RSHIFT,
     102        USB_HID_MOD_RALT,
     103        USB_HID_MOD_RGUI
     104};
     105
     106//static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = {
     107//      USB_HID_LED_NUM_LOCK,
     108//      USB_HID_LED_CAPS_LOCK,
     109//      USB_HID_LED_SCROLL_LOCK,
     110//      USB_HID_LED_COMPOSE,
     111//      USB_HID_LED_KANA
     112//};
     113
     114//#define USB_HID_BOOT_KEYBOARD_NUM_LOCK                0x01
     115//#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK               0x02
     116//#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK     0x04
     117//#define USB_HID_BOOT_KEYBOARD_COMPOSE         0x08
     118//#define USB_HID_BOOT_KEYBOARD_KANA                    0x10
     119
     120/*
     121 * modifiers definitions
     122 */
     123
    141124int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size,
    142125        const usb_hid_report_in_callbacks_t *callbacks, void *arg);
     
    144127int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size);
    145128
    146 
    147 int usb_hid_parser_init(usb_hid_report_parser_t *parser);
    148129int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser,
    149130    const uint8_t *data, size_t size);
     
    154135
    155136
    156 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
     137int usb_hid_free_report_parser(usb_hid_report_parser_t *parser);
    157138
    158 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);
    159139#endif
    160140/**
Note: See TracChangeset for help on using the changeset viewer.