Changeset a81a1d09 in mainline for uspace/lib/usbhid/include/usb/classes
- Timestamp:
- 2011-05-11T16:49:28Z (15 years ago)
- 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. - Location:
- uspace/lib/usbhid/include/usb/classes
- Files:
-
- 3 added
- 9 moved
-
hid.h (moved) (moved from uspace/app/virtusbkbd/kbdconfig.h ) (1 diff)
-
hid/iface.h (moved) (moved from uspace/lib/usb/include/usb/classes/hid/iface.h )
-
hid/utled.h (moved) (moved from uspace/lib/usb/include/usb/classes/hid/utled.h )
-
hid_report_items.h (moved) (moved from uspace/lib/usb/include/usb/classes/hid_report_items.h ) (2 diffs)
-
hiddescriptor.h (added)
-
hidparser.h (added)
-
hidpath.h (added)
-
hidreport.h (moved) (moved from uspace/lib/usb/include/usb/classes/hidreport.h )
-
hidreq.h (moved) (moved from uspace/lib/usb/include/usb/classes/hidreq.h )
-
hidtypes.h (moved) (moved from uspace/lib/usb/include/usb/classes/hidparser.h ) (5 diffs)
-
hidut.h (moved) (moved from uspace/lib/usb/include/usb/classes/hidut.h ) (1 diff)
-
hidutkbd.h (moved) (moved from uspace/lib/usb/include/usb/classes/hidutkbd.h )
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/include/usb/classes/hid.h
re1dbcbc ra81a1d09 27 27 */ 28 28 29 /** @addtogroup usbvirtkbd29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief USB keyboard configuration.33 * @brief USB HID device related types. 34 34 */ 35 #ifndef VUK_KBDCONFIG_H_36 #define VUK_KBDCONFIG_H_35 #ifndef LIBUSB_HID_H_ 36 #define LIBUSB_HID_H_ 37 37 38 #include <usb/usb.h> 39 #include <usb/classes/hidparser.h> 38 40 #include <usb/descriptor.h> 39 #include "report.h"40 #include "descriptor.h"41 41 42 extern usb_standard_device_descriptor_t std_device_descriptor; 42 /** USB/HID device requests. */ 43 typedef enum { 44 USB_HIDREQ_GET_REPORT = 1, 45 USB_HIDREQ_GET_IDLE = 2, 46 USB_HIDREQ_GET_PROTOCOL = 3, 47 /* Values 4 to 8 are reserved. */ 48 USB_HIDREQ_SET_REPORT = 9, 49 USB_HIDREQ_SET_IDLE = 10, 50 USB_HIDREQ_SET_PROTOCOL = 11 51 } usb_hid_request_t; 43 52 44 extern usb_standard_configuration_descriptor_t std_configuration_descriptor; 53 typedef enum { 54 USB_HID_PROTOCOL_BOOT = 0, 55 USB_HID_PROTOCOL_REPORT = 1 56 } usb_hid_protocol_t; 45 57 46 extern usb_standard_interface_descriptor_t std_interface_descriptor; 58 /** USB/HID subclass constants. */ 59 typedef enum { 60 USB_HID_SUBCLASS_NONE = 0, 61 USB_HID_SUBCLASS_BOOT = 1 62 } usb_hid_subclass_t; 47 63 48 extern usb_standard_endpoint_descriptor_t endpoint_descriptor; 49 50 51 extern hid_descriptor_t hid_descriptor; 52 53 extern report_descriptor_data_t report_descriptor; 54 extern size_t report_descriptor_size; 64 /** USB/HID interface protocols. */ 65 typedef enum { 66 USB_HID_PROTOCOL_NONE = 0, 67 USB_HID_PROTOCOL_KEYBOARD = 1, 68 USB_HID_PROTOCOL_MOUSE = 2 69 } usb_hid_iface_protocol_t; 55 70 56 71 -
uspace/lib/usbhid/include/usb/classes/hid_report_items.h
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0 Vojtech Horky2 * Copyright (c) 2011 Matej Klonfar 3 3 * All rights reserved. 4 4 * … … 37 37 38 38 #include <stdint.h> 39 40 /** 41 * Item prefix 42 */ 43 #define USB_HID_ITEM_SIZE(data) ((uint8_t)(data & 0x3)) 44 #define USB_HID_ITEM_TAG(data) ((uint8_t)((data & 0xF0) >> 4)) 45 #define USB_HID_ITEM_TAG_CLASS(data) ((uint8_t)((data & 0xC) >> 2)) 46 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 47 48 49 /** 50 * Input/Output/Feature Item flags 51 */ 52 /** Constant (1) / Variable (0) */ 53 #define USB_HID_ITEM_FLAG_CONSTANT(flags) ((flags & 0x1) == 0x1) 54 /** Variable (1) / Array (0) */ 55 #define USB_HID_ITEM_FLAG_VARIABLE(flags) ((flags & 0x2) == 0x2) 56 /** Absolute / Relative*/ 57 #define USB_HID_ITEM_FLAG_RELATIVE(flags) ((flags & 0x4) == 0x4) 58 /** Wrap / No Wrap */ 59 #define USB_HID_ITEM_FLAG_WRAP(flags) ((flags & 0x8) == 0x8) 60 #define USB_HID_ITEM_FLAG_LINEAR(flags) ((flags & 0x10) == 0x10) 61 #define USB_HID_ITEM_FLAG_PREFERRED(flags) ((flags & 0x20) == 0x20) 62 #define USB_HID_ITEM_FLAG_POSITION(flags) ((flags & 0x40) == 0x40) 63 #define USB_HID_ITEM_FLAG_VOLATILE(flags) ((flags & 0x80) == 0x80) 64 #define USB_HID_ITEM_FLAG_BUFFERED(flags) ((flags & 0x100) == 0x100) 39 65 40 66 /* MAIN ITEMS */ -
uspace/lib/usbhid/include/usb/classes/hidtypes.h
re1dbcbc ra81a1d09 1 1 /* 2 * Copyright (c) 201 0 Vojtech Horky2 * Copyright (c) 2011 Matej Klonfar 3 3 * All rights reserved. 4 4 * … … 33 33 * USB HID report descriptor and report data parser 34 34 */ 35 #ifndef LIBUSB_HID PARSER_H_36 #define LIBUSB_HID PARSER_H_35 #ifndef LIBUSB_HIDTYPES_H_ 36 #define LIBUSB_HIDTYPES_H_ 37 37 38 38 #include <stdint.h> 39 39 #include <adt/list.h> 40 #include <usb/classes/hid_report_items.h>41 42 /**43 * Item prefix44 */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 flags53 */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 descriptor71 */72 #define USB_HID_PATH_COMPARE_STRICT 073 #define USB_HID_PATH_COMPARE_END 174 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 475 #define USB_HID_PATH_COMPARE_COLLECTION_ONLY 2 /* porovnava jenom cestu z Kolekci */76 77 40 78 41 #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 79 46 80 47 typedef enum { … … 83 50 USB_HID_REPORT_TYPE_FEATURE = 3 84 51 } 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;110 52 111 53 … … 223 165 /** */ 224 166 link_t link; 167 168 int in_delimiter; 225 169 } usb_hid_report_item_t; 226 170 … … 261 205 }; 262 206 263 /*264 * Descriptor parser functions265 */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 functions280 */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 functions292 */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 functions327 */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);345 207 #endif 346 208 /** -
uspace/lib/usbhid/include/usb/classes/hidut.h
re1dbcbc ra81a1d09 59 59 USB_HIDUT_USAGE_GENERIC_DESKTOP_GAMEPAD = 5, 60 60 USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYBOARD = 6, 61 USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7 61 USB_HIDUT_USAGE_GENERIC_DESKTOP_KEYPAD = 7, 62 USB_HIDUT_USAGE_GENERIC_DESKTOP_X = 0x30, 63 USB_HIDUT_USAGE_GENERIC_DESKTOP_Y = 0x31, 64 USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL = 0x38 62 65 /* USB_HIDUT_USAGE_GENERIC_DESKTOP_ = , */ 63 66
Note:
See TracChangeset
for help on using the changeset viewer.
