Changeset 175ad13e in mainline for uspace/lib/usb/include
- Timestamp:
- 2011-04-15T15:19:34Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 681f24b3
- Parents:
- 9698695
- Location:
- uspace/lib/usb/include/usb/classes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hid.h
r9698695 r175ad13e 50 50 USB_HIDREQ_SET_PROTOCOL = 11 51 51 } usb_hid_request_t; 52 53 typedef enum {54 USB_HID_REPORT_TYPE_INPUT = 1,55 USB_HID_REPORT_TYPE_OUTPUT = 2,56 USB_HID_REPORT_TYPE_FEATURE = 357 } usb_hid_report_type_t;58 52 59 53 typedef enum { -
uspace/lib/usb/include/usb/classes/hidparser.h
r9698695 r175ad13e 74 74 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 4 75 75 76 /** */ 77 typedef struct { 78 /** */ 79 int32_t usage_page; 80 /** */ 81 int32_t usage; 76 77 #define USB_HID_MAX_USAGES 20 78 79 typedef enum { 80 USB_HID_REPORT_TYPE_INPUT = 1, 81 USB_HID_REPORT_TYPE_OUTPUT = 2, 82 USB_HID_REPORT_TYPE_FEATURE = 3 83 } usb_hid_report_type_t; 84 85 /** Collection usage path structure */ 86 typedef struct { 87 /** */ 88 uint32_t usage_page; 89 /** */ 90 uint32_t usage; 91 92 uint8_t flags; 82 93 /** */ 83 94 link_t link; … … 95 106 } usb_hid_report_path_t; 96 107 97 /** 98 * Description of report items 99 */ 100 typedef struct { 101 /** */ 108 109 typedef struct { 110 /** */ 111 int report_count; 112 link_t reports; /** list of usb_hid_report_description_t */ 113 114 link_t collection_paths; 115 int collection_paths_count; 116 117 int use_report_ids; 118 119 } usb_hid_report_t; 120 121 typedef struct { 122 uint8_t report_id; 123 usb_hid_report_type_t type; 124 125 size_t bit_length; 126 size_t item_length; 127 128 link_t report_items; /** list of report items (fields) */ 129 130 link_t link; 131 } usb_hid_report_description_t; 132 133 typedef struct { 134 135 int offset; 136 size_t size; 137 138 uint16_t usage_page; 139 uint16_t usage; 140 141 uint8_t item_flags; 142 usb_hid_report_path_t *collection_path; 143 144 int32_t logical_minimum; 145 int32_t logical_maximum; 146 int32_t physical_minimum; 147 int32_t physical_maximum; 148 uint32_t usage_minimum; 149 uint32_t usage_maximum; 150 uint32_t unit; 151 uint32_t unit_exponent; 152 153 154 int32_t value; 155 156 link_t link; 157 } usb_hid_report_field_t; 158 159 160 161 /** 162 * state table 163 */ 164 typedef struct { 165 /** report id */ 102 166 int32_t id; 103 /** */ 104 int32_t usage_minimum; 105 /** */ 106 int32_t usage_maximum; 167 168 /** */ 169 uint16_t extended_usage_page; 170 uint32_t usages[USB_HID_MAX_USAGES]; 171 int usages_count; 172 173 /** */ 174 uint32_t usage_page; 175 176 /** */ 177 uint32_t usage_minimum; 178 /** */ 179 uint32_t usage_maximum; 107 180 /** */ 108 181 int32_t logical_minimum; … … 116 189 size_t offset; 117 190 /** */ 118 int32_t delimiter;119 /** */120 191 int32_t unit_exponent; 121 192 /** */ … … 123 194 124 195 /** */ 125 int32_t string_index;126 /** */ 127 int32_t string_minimum;128 /** */ 129 int32_t string_maximum;130 /** */ 131 int32_t designator_index;132 /** */ 133 int32_t designator_minimum;134 /** */ 135 int32_t designator_maximum;196 uint32_t string_index; 197 /** */ 198 uint32_t string_minimum; 199 /** */ 200 uint32_t string_maximum; 201 /** */ 202 uint32_t designator_index; 203 /** */ 204 uint32_t designator_minimum; 205 /** */ 206 uint32_t designator_maximum; 136 207 /** */ 137 208 int32_t physical_minimum; … … 142 213 uint8_t item_flags; 143 214 144 /** */ 215 usb_hid_report_type_t type; 216 217 /** current collection path*/ 145 218 usb_hid_report_path_t *usage_path; 146 219 /** */ 147 220 link_t link; 148 221 } usb_hid_report_item_t; 149 150 151 /** HID report parser structure. */152 typedef struct {153 /** */154 link_t input;155 /** */156 link_t output;157 /** */158 link_t feature;159 160 int use_report_id;161 162 /** */163 link_t stack;164 } usb_hid_report_parser_t;165 166 222 167 223 /** HID parser callbacks for IN items. */ … … 189 245 } usb_hid_modifiers_t; 190 246 191 //typedef enum {192 // USB_HID_LED_NUM_LOCK = 0x1,193 // USB_HID_LED_CAPS_LOCK = 0x2,194 // USB_HID_LED_SCROLL_LOCK = 0x4,195 // USB_HID_LED_COMPOSE = 0x8,196 // USB_HID_LED_KANA = 0x10,197 // USB_HID_LED_COUNT = 5198 //} usb_hid_led_t;199 200 247 static const usb_hid_modifiers_t 201 248 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { … … 210 257 }; 211 258 212 //static const usb_hid_led_t usb_hid_led_consts[USB_HID_LED_COUNT] = {213 // USB_HID_LED_NUM_LOCK,214 // USB_HID_LED_CAPS_LOCK,215 // USB_HID_LED_SCROLL_LOCK,216 // USB_HID_LED_COMPOSE,217 // USB_HID_LED_KANA218 //};219 220 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01221 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02222 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04223 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08224 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10225 226 259 /* 227 260 * Descriptor parser functions 228 261 */ 229 /** */ 230 int usb_hid_parser_init(usb_hid_report_parser_t *parser); 231 232 /** */ 233 int usb_hid_parse_report_descriptor(usb_hid_report_parser_t *parser, 262 263 /** */ 264 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 234 265 const uint8_t *data, size_t size); 235 266 236 267 /** */ 237 void usb_hid_free_report _parser(usb_hid_report_parser_t *parser);238 239 /** */ 240 void usb_hid_descriptor_print(usb_hid_report_ parser_t *parser);268 void usb_hid_free_report(usb_hid_report_t *report); 269 270 /** */ 271 void usb_hid_descriptor_print(usb_hid_report_t *report); 241 272 242 273 … … 245 276 */ 246 277 /** */ 247 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 248 const uint8_t *data, size_t size, 249 usb_hid_report_path_t *path, int flags, 250 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 251 252 /** */ 253 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser, 278 int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size); 279 280 /** */ 281 size_t usb_hid_report_input_length(const usb_hid_report_t *report, 254 282 usb_hid_report_path_t *path, int flags); 255 283 … … 291 319 */ 292 320 /** Allocates output report buffer*/ 293 uint8_t *usb_hid_report_output(usb_hid_report_ parser_t *parser, size_t *size, uint8_t report_id);321 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, uint8_t report_id); 294 322 295 323 /** Frees output report buffer*/ … … 297 325 298 326 /** Returns size of output for given usage path */ 299 size_t usb_hid_report_output_size(usb_hid_report_ parser_t *parser,327 size_t usb_hid_report_output_size(usb_hid_report_t *report, 300 328 usb_hid_report_path_t *path, int flags); 301 329 302 /** Updates the output report buffer by translated given data */ 303 int usb_hid_report_output_translate(usb_hid_report_parser_t *parser, 304 usb_hid_report_path_t *path, int flags, 305 uint8_t *buffer, size_t size, 306 int32_t *data, size_t data_size); 330 /** Sets data in report structure */ 331 int usb_hid_report_output_set_data(usb_hid_report_t *report, 332 usb_hid_report_path_t *path, int flags, 333 int *data, size_t data_size); 334 335 /** Makes the output report buffer by translated given data */ 336 int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size); 307 337 #endif 308 338 /** -
uspace/lib/usb/include/usb/classes/hidreport.h
r9698695 r175ad13e 57 57 */ 58 58 int usb_hid_process_report_descriptor(usb_device_t *dev, 59 usb_hid_report_ parser_t *parser);59 usb_hid_report_t *report); 60 60 61 61 #endif /* LIBUSB_HIDREPORT_H_ */
Note:
See TracChangeset
for help on using the changeset viewer.