Changeset 976f546 in mainline for uspace/lib/usb/include/usb/classes/hidparser.h
- Timestamp:
- 2011-03-01T22:03:37Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19a1800
- Parents:
- 2f60e57d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hidparser.h
r2f60e57d r976f546 27 27 */ 28 28 29 /** @addtogroup libusb usb29 /** @addtogroup libusb 30 30 * @{ 31 31 */ … … 37 37 38 38 #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 39 85 40 86 /** … … 42 88 */ 43 89 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; 44 100 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; 101 int32_t unit_exponent; 102 int32_t unit; 52 103 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; 53 119 } usb_hid_report_item_t; 54 120 55 121 56 122 /** HID report parser structure. */ 57 typedef struct { 58 } usb_hid_report_parser_t; 123 typedef struct { 124 link_t input; 125 link_t output; 126 link_t feature; 127 } usb_hid_report_parser_t; 59 128 60 129 … … 70 139 } usb_hid_report_in_callbacks_t; 71 140 72 #define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x0173 #define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x0274 #define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x0475 #define USB_HID_BOOT_KEYBOARD_COMPOSE 0x0876 #define USB_HID_BOOT_KEYBOARD_KANA 0x1077 78 /*79 * modifiers definitions80 */81 82 141 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 83 142 const usb_hid_report_in_callbacks_t *callbacks, void *arg); … … 85 144 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 86 145 146 147 int usb_hid_parser_init(usb_hid_report_parser_t *parser); 87 148 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 88 149 const uint8_t *data, size_t size); … … 93 154 94 155 95 intusb_hid_free_report_parser(usb_hid_report_parser_t *parser);156 void usb_hid_free_report_parser(usb_hid_report_parser_t *parser); 96 157 158 void usb_hid_descriptor_print(usb_hid_report_parser_t *parser); 97 159 #endif 98 160 /**
Note:
See TracChangeset
for help on using the changeset viewer.