Changes in / [c9256c5:e8f826b] in mainline
- Location:
- uspace
- Files:
-
- 3 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/include/usb/hid/hid_report_items.h
rc9256c5 re8f826b 27 27 */ 28 28 29 /** @addtogroup libusb 29 /** @addtogroup libusbhid 30 30 * @{ 31 31 */ 32 32 /** @file 33 * @brief USB HID Report descriptor item tags.33 * @brief USB HID parser. 34 34 */ 35 #ifndef LIBUSB _HID_REPORT_ITEMS_H_36 #define LIBUSB _HID_REPORT_ITEMS_H_35 #ifndef LIBUSBHID_HID_REPORT_ITEMS_H_ 36 #define LIBUSBHID_HID_REPORT_ITEMS_H_ 37 37 38 38 #include <stdint.h> 39 39 40 /*---------------------------------------------------------------------------*/ 41 /* 40 /** 42 41 * Item prefix 43 42 */ 44 45 /** Returns size of item data in bytes */46 43 #define USB_HID_ITEM_SIZE(data) ((uint8_t)(data & 0x3)) 47 48 /** Returns item tag */49 44 #define USB_HID_ITEM_TAG(data) ((uint8_t)((data & 0xF0) >> 4)) 50 51 /** Returns class of item tag */52 45 #define USB_HID_ITEM_TAG_CLASS(data) ((uint8_t)((data & 0xC) >> 2)) 53 54 /** Returns if the item is the short item or long item. Long items are not55 * supported. */56 46 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 57 47 58 /*---------------------------------------------------------------------------*/ 59 /* 48 49 /** 60 50 * Extended usage macros 61 51 */ 62 63 /** Recognizes if the given usage is extended (contains also usage page). */64 52 #define USB_HID_IS_EXTENDED_USAGE(usage) ((usage & 0xFFFF0000) != 0) 65 66 /** Cuts usage page of the extended usage. */67 53 #define USB_HID_EXTENDED_USAGE_PAGE(usage) ((usage & 0xFFFF0000) >> 16) 68 69 /** Cuts usage of the extended usage */70 54 #define USB_HID_EXTENDED_USAGE(usage) (usage & 0xFFFF) 71 55 72 /*---------------------------------------------------------------------------*/ 73 /* 56 /** 74 57 * Input/Output/Feature Item flags 75 58 */ 76 /** 77 * Indicates whether the item is data (0) or a constant (1) value. Data 78 * indicates the item is defining report fields that contain modifiable device 79 * data. Constant indicates the item is a static read-only field in a report 80 * and cannot be modified (written) by the host. 81 */ 59 /** Constant (1) / Variable (0) */ 82 60 #define USB_HID_ITEM_FLAG_CONSTANT(flags) ((flags & 0x1) == 0x1) 83 84 /** 85 * Indicates whether the item creates variable (1) or array (0) data fields in 86 * reports. 87 */ 61 /** Variable (1) / Array (0) */ 88 62 #define USB_HID_ITEM_FLAG_VARIABLE(flags) ((flags & 0x2) == 0x2) 89 90 /** 91 * Indicates whether the data is absolute (0) (based on a fixed origin) or 92 * relative (1) (indicating the change in value from the last report). Mouse 93 * devices usually provide relative data, while tablets usually provide 94 * absolute data. 95 */ 63 /** Absolute / Relative*/ 96 64 #define USB_HID_ITEM_FLAG_RELATIVE(flags) ((flags & 0x4) == 0x4) 97 98 /** 99 * Indicates whether the data “rolls over” when reaching either the extreme 100 * high or low value. For example, a dial that can spin freely 360 degrees 101 * might output values from 0 to 10. If Wrap is indicated, the next value 102 * reported after passing the 10 position in the increasing direction would be 103 * 0. 104 */ 65 /** Wrap / No Wrap */ 105 66 #define USB_HID_ITEM_FLAG_WRAP(flags) ((flags & 0x8) == 0x8) 106 107 /**108 * Indicates whether the raw data from the device has been processed in some109 * way, and no longer represents a linear relationship between what is110 * measured and the data that is reported.111 */112 67 #define USB_HID_ITEM_FLAG_LINEAR(flags) ((flags & 0x10) == 0x10) 113 114 /**115 * Indicates whether the control has a preferred state to which it will return116 * when the user is not physically interacting with the control. Push buttons117 * (as opposed to toggle buttons) and self- centering joysticks are examples.118 */119 68 #define USB_HID_ITEM_FLAG_PREFERRED(flags) ((flags & 0x20) == 0x20) 120 121 /**122 * Indicates whether the control has a state in which it is not sending123 * meaningful data. One possible use of the null state is for controls that124 * require the user to physically interact with the control in order for it to125 * report useful data.126 */127 69 #define USB_HID_ITEM_FLAG_POSITION(flags) ((flags & 0x40) == 0x40) 128 129 /**130 * Indicates whether the Feature or Output control's value should be changed131 * by the host or not. Volatile output can change with or without host132 * interaction. To avoid synchronization problems, volatile controls should be133 * relative whenever possible.134 */135 70 #define USB_HID_ITEM_FLAG_VOLATILE(flags) ((flags & 0x80) == 0x80) 136 137 /**138 * Indicates that the control emits a fixed-size stream of bytes. The contents139 * of the data field are determined by the application. The contents of the140 * buffer are not interpreted as a single numeric quantity. Report data141 * defined by a Buffered Bytes item must be aligned on an 8-bit boundary.142 */143 71 #define USB_HID_ITEM_FLAG_BUFFERED(flags) ((flags & 0x100) == 0x100) 144 72 145 /*---------------------------------------------------------------------------*/146 147 73 /* MAIN ITEMS */ 148 149 /** 150 * Main items are used to either define or group certain types of data fields 151 * within a Report descriptor. 152 */ 153 #define USB_HID_TAG_CLASS_MAIN 0x0 154 155 /** 156 * An Input item describes information about the data provided by one or more 157 * physical controls. An application can use this information to interpret the 158 * data provided by the device. All data fields defined in a single item share 159 * an identical data format. 160 */ 161 #define USB_HID_REPORT_TAG_INPUT 0x8 162 163 /** 164 * The Output item is used to define an output data field in a report. This 165 * item is similar to an Input item except it describes data sent to the 166 * device—for example, LED states. 167 */ 168 #define USB_HID_REPORT_TAG_OUTPUT 0x9 169 170 /** 171 * Feature items describe device configuration information that can be sent to 172 * the device. 173 */ 174 #define USB_HID_REPORT_TAG_FEATURE 0xB 175 176 /** 177 * A Collection item identifies a relationship between two or more data 178 * (Input, Output, or Feature.) 179 */ 74 #define USB_HID_TAG_CLASS_MAIN 0x0 75 #define USB_HID_REPORT_TAG_INPUT 0x8 76 #define USB_HID_REPORT_TAG_OUTPUT 0x9 77 #define USB_HID_REPORT_TAG_FEATURE 0xB 180 78 #define USB_HID_REPORT_TAG_COLLECTION 0xA 181 182 /**183 * While the Collection item opens a collection of data, the End Collection184 * item closes a collection.185 */186 79 #define USB_HID_REPORT_TAG_END_COLLECTION 0xC 187 80 188 /*---------------------------------------------------------------------------*/ 81 /* GLOBAL ITEMS */ 82 #define USB_HID_TAG_CLASS_GLOBAL 0x1 83 #define USB_HID_REPORT_TAG_USAGE_PAGE 0x0 84 #define USB_HID_REPORT_TAG_LOGICAL_MINIMUM 0x1 85 #define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM 0x2 86 #define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3 87 #define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4 88 #define USB_HID_REPORT_TAG_UNIT_EXPONENT 0x5 89 #define USB_HID_REPORT_TAG_UNIT 0x6 90 #define USB_HID_REPORT_TAG_REPORT_SIZE 0x7 91 #define USB_HID_REPORT_TAG_REPORT_ID 0x8 92 #define USB_HID_REPORT_TAG_REPORT_COUNT 0x9 93 #define USB_HID_REPORT_TAG_PUSH 0xA 94 #define USB_HID_REPORT_TAG_POP 0xB 189 95 190 /* GLOBAL ITEMS */191 192 /**193 * Global items describe rather than define data from a control.194 */195 #define USB_HID_TAG_CLASS_GLOBAL 0x1196 197 /**198 * Unsigned integer specifying the current Usage Page. Since a usage are 32199 * bit values, Usage Page items can be used to conserve space in a report200 * descriptor by setting the high order 16 bits of a subsequent usages. Any201 * usage that follows which is defines 16 bits or less is interpreted as a202 * Usage ID and concatenated with the Usage Page to form a 32 bit Usage.203 */204 #define USB_HID_REPORT_TAG_USAGE_PAGE 0x0205 206 /**207 * Extent value in logical units. This is the minimum value that a variable208 * or array item will report. For example, a mouse reporting x position values209 * from 0 to 128 would have a Logical Minimum of 0 and a Logical Maximum of210 * 128.211 */212 #define USB_HID_REPORT_TAG_LOGICAL_MINIMUM 0x1213 214 /**215 * Extent value in logical units. This is the maximum value that a variable216 * or array item will report.217 */218 #define USB_HID_REPORT_TAG_LOGICAL_MAXIMUM 0x2219 220 /**221 * Minimum value for the physical extent of a variable item. This represents222 * the Logical Minimum with units applied to it.223 */224 #define USB_HID_REPORT_TAG_PHYSICAL_MINIMUM 0x3225 226 /**227 * Maximum value for the physical extent of a variable item.228 */229 #define USB_HID_REPORT_TAG_PHYSICAL_MAXIMUM 0x4230 231 /**232 * Value of the unit exponent in base 10. See the table later in this section233 * for more information.234 */235 #define USB_HID_REPORT_TAG_UNIT_EXPONENT 0x5236 237 /**238 * Unit values.239 */240 #define USB_HID_REPORT_TAG_UNIT 0x6241 242 /**243 * Unsigned integer specifying the size of the report fields in bits. This244 * allows the parser to build an item map for the report handler to use.245 */246 #define USB_HID_REPORT_TAG_REPORT_SIZE 0x7247 248 /**249 * Unsigned value that specifies the Report ID. If a Report ID tag is used250 * anywhere in Report descriptor, all data reports for the device are preceded251 * by a single byte ID field. All items succeeding the first Report ID tag but252 * preceding a second Report ID tag are included in a report prefixed by a253 * 1-byte ID. All items succeeding the second but preceding a third Report ID254 * tag are included in a second report prefixed by a second ID, and so on.255 */256 #define USB_HID_REPORT_TAG_REPORT_ID 0x8257 258 /**259 * Unsigned integer specifying the number of data fields for the item;260 * determines how many fields are included in the report for this particular261 * item (and consequently how many bits are added to the report).262 */263 #define USB_HID_REPORT_TAG_REPORT_COUNT 0x9264 265 /**266 * Places a copy of the global item state table on the stack.267 */268 #define USB_HID_REPORT_TAG_PUSH 0xA269 270 /**271 * Replaces the item state table with the top structure from the stack.272 */273 #define USB_HID_REPORT_TAG_POP 0xB274 275 /*---------------------------------------------------------------------------*/276 96 277 97 /* LOCAL ITEMS */ 278 279 /** 280 * Local item tags define characteristics of controls. These items do not 281 * carry over to the next Main item. If a Main item defines more than one 282 * control, it may be preceded by several similar Local item tags. For 283 * example, an Input item may have several Usage tags associated with it, one 284 * for each control. 285 */ 286 #define USB_HID_TAG_CLASS_LOCAL 0x2 287 288 /** 289 * Usage index for an item usage; represents a suggested usage for the item or 290 * collection. In the case where an item represents multiple controls, a Usage 291 * tag may suggest a usage for every variable or element in an array. 292 */ 293 #define USB_HID_REPORT_TAG_USAGE 0x0 294 295 /** 296 * Defines the starting usage associated with an array or bitmap. 297 */ 298 #define USB_HID_REPORT_TAG_USAGE_MINIMUM 0x1 299 300 /** 301 * Defines the ending usage associated with an array or bitmap. 302 */ 303 #define USB_HID_REPORT_TAG_USAGE_MAXIMUM 0x2 304 305 /** 306 * Determines the body part used for a control. Index points to a designator 307 * in the Physical descriptor. 308 */ 309 #define USB_HID_REPORT_TAG_DESIGNATOR_INDEX 0x3 310 311 /** 312 * Defines the index of the starting designator associated with an array or 313 * bitmap. 314 */ 98 #define USB_HID_TAG_CLASS_LOCAL 0x2 99 #define USB_HID_REPORT_TAG_USAGE 0x0 100 #define USB_HID_REPORT_TAG_USAGE_MINIMUM 0x1 101 #define USB_HID_REPORT_TAG_USAGE_MAXIMUM 0x2 102 #define USB_HID_REPORT_TAG_DESIGNATOR_INDEX 0x3 315 103 #define USB_HID_REPORT_TAG_DESIGNATOR_MINIMUM 0x4 316 317 /**318 * Defines the index of the ending designator associated with an array or319 * bitmap.320 */321 104 #define USB_HID_REPORT_TAG_DESIGNATOR_MAXIMUM 0x5 322 323 /** 324 * String index for a String descriptor; allows a string to be associated with 325 * a particular item or control. 326 */ 327 #define USB_HID_REPORT_TAG_STRING_INDEX 0x7 328 329 /** 330 * Specifies the first string index when assigning a group of sequential 331 * strings to controls in an array or bitmap. 332 */ 333 #define USB_HID_REPORT_TAG_STRING_MINIMUM 0x8 334 335 /** 336 * Specifies the last string index when assigning a group of sequential 337 * strings to controls in an array or bitmap. 338 */ 339 #define USB_HID_REPORT_TAG_STRING_MAXIMUM 0x9 340 341 /** 342 * Defines the beginning or end of a set of local items (1 = open set, 0 = 343 * close set). 344 * 345 * Usages other than the first (most preferred) usage defined are not 346 * accessible by system software. 347 */ 348 #define USB_HID_REPORT_TAG_DELIMITER 0xA 349 350 /*---------------------------------------------------------------------------*/ 105 #define USB_HID_REPORT_TAG_STRING_INDEX 0x7 106 #define USB_HID_REPORT_TAG_STRING_MINIMUM 0x8 107 #define USB_HID_REPORT_TAG_STRING_MAXIMUM 0x9 108 #define USB_HID_REPORT_TAG_DELIMITER 0xA 351 109 352 110 #endif -
uspace/lib/usbhid/include/usb/hid/hiddescriptor.h
rc9256c5 re8f826b 27 27 */ 28 28 29 /** @addtogroup libusb 29 /** @addtogroup libusbhid 30 30 * @{ 31 31 */ … … 33 33 * USB HID report descriptor and report data parser 34 34 */ 35 #ifndef LIBUSB _HIDDESCRIPTOR_H_36 #define LIBUSB _HIDDESCRIPTOR_H_35 #ifndef LIBUSBHID_HIDDESCRIPTOR_H_ 36 #define LIBUSBHID_HIDDESCRIPTOR_H_ 37 37 38 38 #include <stdint.h> … … 42 42 #include <usb/hid/hidtypes.h> 43 43 44 45 /* 46 * Descriptor parser functions 47 */ 48 49 /** */ 44 50 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 45 51 const uint8_t *data, size_t size); 46 52 53 /** */ 47 54 void usb_hid_free_report(usb_hid_report_t *report); 48 55 56 /** */ 49 57 void usb_hid_descriptor_print(usb_hid_report_t *report); 50 58 59 51 60 int usb_hid_report_init(usb_hid_report_t *report); 52 53 61 int usb_hid_report_append_fields(usb_hid_report_t *report, 54 62 usb_hid_report_item_t *report_item); 55 63 56 64 usb_hid_report_description_t * usb_hid_report_find_description(const usb_hid_report_t *report, uint8_t report_id, usb_hid_report_type_t type); 57 58 65 int usb_hid_report_parse_tag(uint8_t tag, uint8_t class, const uint8_t *data, size_t item_size, 59 66 usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path); 60 61 67 int usb_hid_report_parse_main_tag(uint8_t tag, const uint8_t *data, size_t item_size, 62 68 usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path); 63 64 69 int usb_hid_report_parse_global_tag(uint8_t tag, const uint8_t *data, size_t item_size, 65 70 usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path); 66 67 71 int usb_hid_report_parse_local_tag(uint8_t tag, const uint8_t *data, size_t item_size, 68 72 usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path); 69 73 70 74 void usb_hid_descriptor_print_list(link_t *head); 71 72 75 void usb_hid_report_reset_local_items(usb_hid_report_item_t *report_item); 73 74 76 void usb_hid_free_report_list(link_t *head); 75 76 77 usb_hid_report_item_t *usb_hid_report_item_clone(const usb_hid_report_item_t *item); 77 78 78 uint32_t usb_hid_report_tag_data_uint32(const uint8_t *data, size_t size); 79 79 80 80 usb_hid_report_path_t *usb_hid_report_path_try_insert(usb_hid_report_t *report, usb_hid_report_path_t *cmp_path); 81 82 83 81 #endif 84 82 /** -
uspace/lib/usbhid/include/usb/hid/hidpath.h
rc9256c5 re8f826b 27 27 */ 28 28 29 /** @addtogroup libusb 29 /** @addtogroup libusbhid 30 30 * @{ 31 31 */ … … 33 33 * USB HID report descriptor and report data parser 34 34 */ 35 #ifndef LIBUSB _HIDPATH_H_36 #define LIBUSB _HIDPATH_H_35 #ifndef LIBUSBHID_HIDPATH_H_ 36 #define LIBUSBHID_HIDPATH_H_ 37 37 38 38 #include <usb/hid/hidparser.h> … … 40 40 #include <adt/list.h> 41 41 42 43 /*---------------------------------------------------------------------------*/44 42 /** 45 * Flags of usage paths comparison modes. 46 * 43 * Description of path of usage pages and usages in report descriptor 47 44 */ 48 /** Wanted usage path must be exactly the same as the searched one. 49 * This option cannot be combined with the others. 50 */ 45 /** Wanted usage path must be exactly the same as the searched one */ 51 46 #define USB_HID_PATH_COMPARE_STRICT 0 52 53 /** 54 * Wanted usage path must be the suffix in the searched one. 55 */ 47 /** Wanted usage path must be the suffix in the searched one */ 56 48 #define USB_HID_PATH_COMPARE_END 1 57 58 /** 59 * Only usage page are compared along the usage path. 60 * This option can be combined with others. 61 */ 49 /** */ 62 50 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 2 63 64 /** 65 * Searched usage page must be prefix of the other one. 66 */ 51 /** Searched usage page must be prefix of the other one */ 67 52 #define USB_HID_PATH_COMPARE_BEGIN 4 68 69 /** 70 * Searched couple of usage page and usage can be anywhere in usage path. 71 * This option is deprecated. 72 */ 53 /** Searched couple of usage page and usage can be anywhere in usage path */ 73 54 #define USB_HID_PATH_COMPARE_ANYWHERE 8 74 55 75 /*----------------------------------------------------------------------------*/ 76 /** 77 * Item of usage path structure. Last item of linked list describes one item 78 * in report, the others describe superior Collection tags. Usage and Usage 79 * page of report item can be changed due to data in report. 80 */ 56 57 /** Collection usage path structure */ 81 58 typedef struct { 82 /** Usage page of report item. Zero when usage page can be changed.*/59 /** */ 83 60 uint32_t usage_page; 84 /** Usage of report item. Zero when usage can be changed.*/61 /** */ 85 62 uint32_t usage; 86 63 87 /** Attribute of Collection tag in report descriptor*/88 64 uint8_t flags; 89 90 /** Linked list structure*/ 65 /** */ 91 66 link_t link; 92 67 } usb_hid_report_usage_path_t; 93 68 94 95 /*---------------------------------------------------------------------------*/ 96 /** 97 * USB HID usage path structure. 98 * */ 69 /** */ 99 70 typedef struct { 100 /** Length of usage path*/71 /** */ 101 72 int depth; 102 103 /** Report id. Zero is reserved and means that report id is not used. */104 73 uint8_t report_id; 105 74 106 /** Linked list structure.*/75 /** */ 107 76 link_t link; /* list */ 108 77 109 /** Head of the list of usage path items. */ 110 link_t head; 78 link_t head; /* head of list of usage paths */ 111 79 112 80 } usb_hid_report_path_t; 113 81 114 /* ---------------------------------------------------------------------------*/82 /** */ 115 83 usb_hid_report_path_t *usb_hid_report_path(void); 116 84 85 /** */ 117 86 void usb_hid_report_path_free(usb_hid_report_path_t *path); 118 87 88 /** */ 119 89 int usb_hid_report_path_set_report_id(usb_hid_report_path_t *usage_path, 120 90 uint8_t report_id); 121 91 92 /** */ 122 93 int usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 123 94 int32_t usage_page, int32_t usage); 124 95 96 /** */ 125 97 void usb_hid_report_remove_last_item(usb_hid_report_path_t *usage_path); 126 98 99 /** */ 127 100 void usb_hid_report_null_last_item(usb_hid_report_path_t *usage_path); 128 101 102 /** */ 129 103 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 130 104 int32_t tag, int32_t data); 131 105 106 /** */ 132 107 int usb_hid_report_compare_usage_path(usb_hid_report_path_t *report_path, 133 108 usb_hid_report_path_t *path, int flags); 134 109 110 /** */ 135 111 usb_hid_report_path_t *usb_hid_report_path_clone(usb_hid_report_path_t *usage_path); 136 112 -
uspace/lib/usbhid/include/usb/hid/hidtypes.h
rc9256c5 re8f826b 27 27 */ 28 28 29 /** @addtogroup libusb 29 /** @addtogroup libusbhid 30 30 * @{ 31 31 */ 32 32 /** @file 33 * Basic data structures for USB HID Report descriptor and report parser.34 */ 35 #ifndef LIBUSB _HIDTYPES_H_36 #define LIBUSB _HIDTYPES_H_33 * USB HID report descriptor and report data parser 34 */ 35 #ifndef LIBUSBHID_HIDTYPES_H_ 36 #define LIBUSBHID_HIDTYPES_H_ 37 37 38 38 #include <stdint.h> 39 39 #include <adt/list.h> 40 40 41 /*---------------------------------------------------------------------------*/42 43 /**44 * Maximum amount of specified usages for one report item45 */46 41 #define USB_HID_MAX_USAGES 0xffff 47 42 48 /** 49 * Converts integer from unsigned two's complement format format to signed 50 * one. 51 * 52 * @param x Number to convert 53 * @param size Length of the unsigned number in bites 54 * @return signed int 55 */ 56 #define USB_HID_UINT32_TO_INT32(x, size) \ 57 ((((x) & (1 << ((size) - 1))) != 0) ? \ 58 -(~((x) - 1) & ((1 << size) - 1)) : (x)) 59 60 /** 61 * Convert integer from signed format to unsigned. If number is negative the 62 * two's complement format is used. 63 * 64 * @param x Number to convert 65 * @param size Length of result number in bites 66 * @return unsigned int 67 */ 68 #define USB_HID_INT32_TO_UINT32(x, size) \ 69 (((x) < 0 ) ? ((1 << (size)) + (x)) : (x)) 70 71 /*---------------------------------------------------------------------------*/ 72 73 /** 74 * Report type 75 */ 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 46 76 47 typedef enum { 77 48 USB_HID_REPORT_TYPE_INPUT = 1, … … 80 51 } usb_hid_report_type_t; 81 52 82 /*---------------------------------------------------------------------------*/ 83 84 /** 85 * Description of all reports described in one report descriptor. 86 */ 87 typedef struct { 88 /** Count of available reports. */ 53 54 typedef struct { 55 /** */ 89 56 int report_count; 90 91 /** Head of linked list of description of reports. */ 92 link_t reports; 93 94 /** Head of linked list of all used usage/collection paths. */ 57 link_t reports; /** list of usb_hid_report_description_t */ 58 95 59 link_t collection_paths; 96 97 /** Length of list of usage paths. */98 60 int collection_paths_count; 99 61 100 /** Flag whether report ids are used. */101 62 int use_report_ids; 102 103 /** Report id of last parsed report. */104 63 uint8_t last_report_id; 105 64 106 65 } usb_hid_report_t; 107 /*---------------------------------------------------------------------------*/ 108 109 /** 110 * Description of one concrete report 111 */ 112 typedef struct { 113 /** Report id. Zero when no report id is used. */ 66 67 typedef struct { 114 68 uint8_t report_id; 115 116 /** Type of report */117 69 usb_hid_report_type_t type; 118 70 119 /** Bit length of the report */120 71 size_t bit_length; 121 122 /** Number of items in report */123 72 size_t item_length; 124 73 125 /** Linked list of report items in report */ 126 link_t report_items; 127 128 /** Linked list of descriptions. */ 74 link_t report_items; /** list of report items (fields) */ 75 129 76 link_t link; 130 77 } usb_hid_report_description_t; 131 /*---------------------------------------------------------------------------*/ 132 133 /** 134 * Description of one field/item in report 135 */ 136 typedef struct { 137 /** Bit offset of the field */ 78 79 typedef struct { 80 138 81 int offset; 139 140 /** Bit size of the field */141 82 size_t size; 142 83 143 /** Usage page. Zero when usage page can be changed. */144 84 uint16_t usage_page; 145 146 /** Usage. Zero when usage can be changed. */147 85 uint16_t usage; 148 86 149 /** Item's attributes */150 87 uint8_t item_flags; 151 152 /** Usage/Collection path of the field. */153 88 usb_hid_report_path_t *collection_path; 154 89 155 /**156 * The lowest valid logical value (value with the device operates)157 */158 90 int32_t logical_minimum; 159 160 /**161 * The greatest valid logical value162 */163 91 int32_t logical_maximum; 164 165 /**166 * The lowest valid physical value (value with the system operates)167 */168 92 int32_t physical_minimum; 169 170 /** The greatest valid physical value */171 93 int32_t physical_maximum; 172 173 /** The lowest valid usage index */174 94 int32_t usage_minimum; 175 176 /** The greatest valid usage index */177 95 int32_t usage_maximum; 178 179 /** Unit of the value */180 96 uint32_t unit; 181 182 /** Unit exponent */183 97 uint32_t unit_exponent; 184 98 185 /** Array of possible usages */186 99 uint32_t *usages; 187 188 /** Size of the array of usages */189 100 size_t usages_count; 190 101 191 /** Parsed value */192 102 int32_t value; 193 103 194 /** List to another report items */195 104 link_t link; 196 105 } usb_hid_report_field_t; 197 106 198 /*---------------------------------------------------------------------------*/ 107 199 108 200 109 /** 201 * State table for report descriptor parsing110 * state table 202 111 */ 203 112 typedef struct { … … 205 114 int32_t id; 206 115 207 /** Extended usage page*/116 /** */ 208 117 uint16_t extended_usage_page; 209 210 /** Array of usages specified for this item */211 118 uint32_t usages[USB_HID_MAX_USAGES]; 212 213 /** Length of usages array */214 119 int usages_count; 215 120 216 /** Usage page*/121 /** */ 217 122 uint32_t usage_page; 218 123 219 /** Minimum valid usage index*/124 /** */ 220 125 int32_t usage_minimum; 221 222 /** Maximum valid usage index */ 126 /** */ 223 127 int32_t usage_maximum; 224 225 /** Minimum valid logical value */ 128 /** */ 226 129 int32_t logical_minimum; 227 228 /** Maximum valid logical value */ 130 /** */ 229 131 int32_t logical_maximum; 230 231 /** Length of the items in bits*/ 132 /** */ 232 133 int32_t size; 233 234 /** COunt of items*/ 134 /** */ 235 135 int32_t count; 236 237 /** Bit offset of the item in report */ 136 /** */ 238 137 size_t offset; 239 240 /** Unit exponent */ 138 /** */ 241 139 int32_t unit_exponent; 242 /** Unit of the value*/140 /** */ 243 141 int32_t unit; 244 142 245 /** String index*/143 /** */ 246 144 uint32_t string_index; 247 248 /** Minimum valid string index */ 145 /** */ 249 146 uint32_t string_minimum; 250 251 /** Maximum valid string index */ 147 /** */ 252 148 uint32_t string_maximum; 253 254 /** The designator index */ 149 /** */ 255 150 uint32_t designator_index; 256 257 /** Minimum valid designator value*/ 151 /** */ 258 152 uint32_t designator_minimum; 259 260 /** Maximum valid designator value*/ 153 /** */ 261 154 uint32_t designator_maximum; 262 263 /** Minimal valid physical value*/ 155 /** */ 264 156 int32_t physical_minimum; 265 266 /** Maximal valid physical value */ 157 /** */ 267 158 int32_t physical_maximum; 268 159 269 /** Items attributes*/160 /** */ 270 161 uint8_t item_flags; 271 162 272 /** Report type */273 163 usb_hid_report_type_t type; 274 164 275 165 /** current collection path*/ 276 166 usb_hid_report_path_t *usage_path; 277 278 /** Unused*/ 167 /** */ 279 168 link_t link; 280 169 281 170 int in_delimiter; 282 171 } usb_hid_report_item_t; 283 /*---------------------------------------------------------------------------*/ 284 /** 285 * Enum of the keyboard modifiers 286 */ 172 173 /** HID parser callbacks for IN items. */ 174 typedef struct { 175 /** Callback for keyboard. 176 * 177 * @param key_codes Array of pressed key (including modifiers). 178 * @param count Length of @p key_codes. 179 * @param arg Custom argument. 180 */ 181 void (*keyboard)(const uint8_t *key_codes, size_t count, const uint8_t report_id, void *arg); 182 } usb_hid_report_in_callbacks_t; 183 184 287 185 typedef enum { 288 186 USB_HID_MOD_LCTRL = 0x01, … … 308 206 USB_HID_MOD_RGUI 309 207 }; 310 /*---------------------------------------------------------------------------*/311 312 208 313 209 #endif
Note:
See TracChangeset
for help on using the changeset viewer.