Changes in uspace/lib/usb/include/usb/classes/hidparser.h [dc9f122:64dbc83] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/classes/hidparser.h
rdc9f122 r64dbc83 73 73 #define USB_HID_PATH_COMPARE_END 1 74 74 #define USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 4 75 #define USB_HID_PATH_COMPARE_COLLECTION_ONLY 2 /* porovnava jenom cestu z Kolekci */ 76 77 78 #define USB_HID_MAX_USAGES 20 79 80 typedef enum { 81 USB_HID_REPORT_TYPE_INPUT = 1, 82 USB_HID_REPORT_TYPE_OUTPUT = 2, 83 USB_HID_REPORT_TYPE_FEATURE = 3 84 } usb_hid_report_type_t; 85 86 /** Collection usage path structure */ 75 76 /** */ 87 77 typedef struct { 88 78 /** */ 89 uint32_t usage_page; 90 /** */ 91 uint32_t usage; 92 93 uint8_t flags; 79 int32_t usage_page; 80 /** */ 81 int32_t usage; 94 82 /** */ 95 83 link_t link; … … 103 91 104 92 /** */ 105 link_t link; /* list */ 106 107 link_t head; /* head of list of usage paths */ 93 link_t link; 108 94 109 95 } usb_hid_report_path_t; 110 96 111 97 /** 98 * Description of report items 99 */ 112 100 typedef struct { 101 /** */ 102 int32_t id; 103 /** */ 104 int32_t usage_minimum; 105 /** */ 106 int32_t usage_maximum; 107 /** */ 108 int32_t logical_minimum; 109 /** */ 110 int32_t logical_maximum; 111 /** */ 112 int32_t size; 113 /** */ 114 int32_t count; 115 /** */ 116 size_t offset; 117 /** */ 118 int32_t delimiter; 119 /** */ 120 int32_t unit_exponent; 121 /** */ 122 int32_t unit; 123 113 124 /** */ 114 int report_count; 115 link_t reports; /** list of usb_hid_report_description_t */ 116 117 link_t collection_paths; 118 int collection_paths_count; 119 120 int use_report_ids; 121 122 } usb_hid_report_t; 123 124 typedef struct { 125 uint8_t report_id; 126 usb_hid_report_type_t type; 127 128 size_t bit_length; 129 size_t item_length; 130 131 link_t report_items; /** list of report items (fields) */ 132 133 link_t link; 134 } usb_hid_report_description_t; 135 136 typedef struct { 137 138 int offset; 139 size_t size; 140 141 uint16_t usage_page; 142 uint16_t usage; 143 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; 136 /** */ 137 int32_t physical_minimum; 138 /** */ 139 int32_t physical_maximum; 140 141 /** */ 144 142 uint8_t item_flags; 145 usb_hid_report_path_t *collection_path; 146 147 int32_t logical_minimum; 148 int32_t logical_maximum; 149 int32_t physical_minimum; 150 int32_t physical_maximum; 151 uint32_t usage_minimum; 152 uint32_t usage_maximum; 153 uint32_t unit; 154 uint32_t unit_exponent; 155 156 157 int32_t value; 158 159 link_t link; 160 } usb_hid_report_field_t; 161 162 163 164 /** 165 * state table 166 */ 167 typedef struct { 168 /** report id */ 169 int32_t id; 170 171 /** */ 172 uint16_t extended_usage_page; 173 uint32_t usages[USB_HID_MAX_USAGES]; 174 int usages_count; 175 176 /** */ 177 uint32_t usage_page; 178 179 /** */ 180 uint32_t usage_minimum; 181 /** */ 182 uint32_t usage_maximum; 183 /** */ 184 int32_t logical_minimum; 185 /** */ 186 int32_t logical_maximum; 187 /** */ 188 int32_t size; 189 /** */ 190 int32_t count; 191 /** */ 192 size_t offset; 193 /** */ 194 int32_t unit_exponent; 195 /** */ 196 int32_t unit; 197 198 /** */ 199 uint32_t string_index; 200 /** */ 201 uint32_t string_minimum; 202 /** */ 203 uint32_t string_maximum; 204 /** */ 205 uint32_t designator_index; 206 /** */ 207 uint32_t designator_minimum; 208 /** */ 209 uint32_t designator_maximum; 210 /** */ 211 int32_t physical_minimum; 212 /** */ 213 int32_t physical_maximum; 214 215 /** */ 216 uint8_t item_flags; 217 218 usb_hid_report_type_t type; 219 220 /** current collection path*/ 143 144 /** */ 221 145 usb_hid_report_path_t *usage_path; 222 146 /** */ 223 147 link_t link; 224 148 } 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 225 166 226 167 /** HID parser callbacks for IN items. */ … … 248 189 } usb_hid_modifiers_t; 249 190 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 = 5 198 //} usb_hid_led_t; 199 250 200 static const usb_hid_modifiers_t 251 201 usb_hid_modifiers_consts[USB_HID_MOD_COUNT] = { … … 260 210 }; 261 211 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_KANA 218 //}; 219 220 //#define USB_HID_BOOT_KEYBOARD_NUM_LOCK 0x01 221 //#define USB_HID_BOOT_KEYBOARD_CAPS_LOCK 0x02 222 //#define USB_HID_BOOT_KEYBOARD_SCROLL_LOCK 0x04 223 //#define USB_HID_BOOT_KEYBOARD_COMPOSE 0x08 224 //#define USB_HID_BOOT_KEYBOARD_KANA 0x10 225 262 226 /* 263 227 * Descriptor parser functions 264 228 */ 265 266 /** */ 267 int usb_hid_parse_report_descriptor(usb_hid_report_t *report, 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, 268 234 const uint8_t *data, size_t size); 269 235 270 236 /** */ 271 void usb_hid_free_report(usb_hid_report_t *report); 272 273 /** */ 274 void usb_hid_descriptor_print(usb_hid_report_t *report); 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); 241 242 /* 243 * Boot protocol functions 244 */ 245 /** */ 246 int usb_hid_boot_keyboard_input_report(const uint8_t *data, size_t size, 247 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 248 249 /** */ 250 int usb_hid_boot_keyboard_output_report(uint8_t leds, uint8_t *data, size_t size); 275 251 276 252 … … 279 255 */ 280 256 /** */ 281 int usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, size_t size); 282 283 /** */ 284 size_t usb_hid_report_input_length(const usb_hid_report_t *report, 257 int usb_hid_parse_report(const usb_hid_report_parser_t *parser, 258 const uint8_t *data, size_t size, 259 usb_hid_report_path_t *path, int flags, 260 const usb_hid_report_in_callbacks_t *callbacks, void *arg); 261 262 /** */ 263 size_t usb_hid_report_input_length(const usb_hid_report_parser_t *parser, 285 264 usb_hid_report_path_t *path, int flags); 286 265 … … 322 301 */ 323 302 /** Allocates output report buffer*/ 324 uint8_t *usb_hid_report_output(usb_hid_report_ t *report, size_t *size, uint8_t report_id);303 uint8_t *usb_hid_report_output(usb_hid_report_parser_t *parser, size_t *size); 325 304 326 305 /** Frees output report buffer*/ … … 328 307 329 308 /** Returns size of output for given usage path */ 330 size_t usb_hid_report_output_size(usb_hid_report_ t *report,309 size_t usb_hid_report_output_size(usb_hid_report_parser_t *parser, 331 310 usb_hid_report_path_t *path, int flags); 332 311 333 /** Sets data in report structure */ 334 int usb_hid_report_output_set_data(usb_hid_report_t *report, 335 usb_hid_report_path_t *path, int flags, 336 int *data, size_t data_size); 337 338 /** Makes the output report buffer by translated given data */ 339 int usb_hid_report_output_translate(usb_hid_report_t *report, uint8_t report_id, uint8_t *buffer, size_t size); 312 /** Updates the output report buffer by translated given data */ 313 int usb_hid_report_output_translate(usb_hid_report_parser_t *parser, 314 usb_hid_report_path_t *path, int flags, 315 uint8_t *buffer, size_t size, 316 int32_t *data, size_t data_size); 340 317 #endif 341 318 /**
Note:
See TracChangeset
for help on using the changeset viewer.