Changes in uspace/lib/usb/include/usb/classes/hidparser.h [976f546:d972534] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hidparser.h
r976f546 rd972534 37 37 38 38 #include <stdint.h> 39 #include <adt/list.h>40 41 #include <hid_report_items.h>42 43 /**44 * Items prefix45 */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 flags54 */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 Types68 */69 #define USB_HID_COLLECTION_TYPE_PHYSICAL 0x0070 #define USB_HID_COLLECTION_TYPE_APPLICATION 0x0171 #define USB_HID_COLLECTION_TYPE_LOGICAL 0x0272 #define USB_HID_COLLECTION_TYPE_REPORT 0x0373 #define USB_HID_COLLECTION_TYPE_NAMED_ARRAY 0x0474 #define USB_HID_COLLECTION_TYPE_USAGE_SWITCH 0x0575 76 /*77 * modifiers definitions78 */79 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x0180 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x0281 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x0482 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x0883 #define USB_HID_BOOT_KEYBOARD_KANA 0x1084 85 39 86 40 /** … … 88 42 */ 89 43 typedef 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;100 44 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; 103 52 104 /*105 * some not yet used fields106 */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;119 53 } usb_hid_report_item_t; 120 54 121 55 122 56 /** 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; 57 typedef struct { 58 } usb_hid_report_parser_t; 128 59 129 60 … … 139 70 } usb_hid_report_in_callbacks_t; 140 71 72 73 typedef 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 85 typedef 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 94 static 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 141 124 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 142 125 const usb_hid_report_in_callbacks_t *callbacks, void *arg); … … 144 127 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 145 128 146 147 int usb_hid_parser_init(usb_hid_report_parser_t *parser);148 129 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 149 130 const uint8_t *data, size_t size); … … 154 135 155 136 156 voidusb_hid_free_report_parser(usb_hid_report_parser_t *parser);137 int usb_hid_free_report_parser(usb_hid_report_parser_t *parser); 157 138 158 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser);159 139 #endif 160 140 /**
Note:
See TracChangeset
for help on using the changeset viewer.