Changes in uspace/lib/usbhid/src/hidparser.c [9d58539:1e371cf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidparser.c
r9d58539 r1e371cf 41 41 #include <assert.h> 42 42 43 /*---------------------------------------------------------------------------*/ 43 44 44 /* 45 45 * Data translation private functions … … 52 52 int32_t value); 53 53 54 /*---------------------------------------------------------------------------*/ 54 55 55 56 56 static int usb_pow(int a, int b) … … 68 68 } 69 69 } 70 /*---------------------------------------------------------------------------*/ 70 71 71 72 72 /** Returns size of report of specified report id and type in items … … 117 117 } 118 118 } 119 /*---------------------------------------------------------------------------*/ 119 120 120 121 121 /** Parse and act upon a HID report. … … 130 130 size_t size, uint8_t *report_id) 131 131 { 132 usb_hid_report_field_t *item;133 134 132 usb_hid_report_description_t *report_des; 135 133 usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT; … … 153 151 154 152 /* read data */ 155 list_foreach(report_des->report_items, list_item) { 156 item = list_get_instance(list_item, usb_hid_report_field_t, 157 ritems_link); 153 list_foreach(report_des->report_items, ritems_link, 154 usb_hid_report_field_t, item) { 158 155 159 156 if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) { … … 163 160 item->value = 164 161 usb_hid_translate_data(item, data); 165 162 166 163 item->usage = USB_HID_EXTENDED_USAGE( 167 164 item->usages[item->value - … … 184 181 /* variable item */ 185 182 item->value = usb_hid_translate_data(item, 186 data); 187 } 183 data); 184 } 188 185 } 189 186 } … … 192 189 } 193 190 194 /*---------------------------------------------------------------------------*/ 191 195 192 /** 196 193 * Translate data from the report as specified in report descriptor item … … 274 271 } 275 272 276 /*---------------------------------------------------------------------------*/ 273 277 274 /* OUTPUT API */ 278 275 … … 295 292 usb_hid_report_description_t *report_des = NULL; 296 293 297 list_foreach(report->reports, report_it) { 298 report_des = list_get_instance(report_it, 299 usb_hid_report_description_t, reports_link); 300 301 if ((report_des->report_id == report_id) && 302 (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) { 294 list_foreach(report->reports, reports_link, 295 usb_hid_report_description_t, rdes) { 296 if ((rdes->report_id == report_id) && 297 (rdes->type == USB_HID_REPORT_TYPE_OUTPUT)) { 298 report_des = rdes; 303 299 break; 304 300 } … … 351 347 352 348 if (report->use_report_ids != 0) { 353 buffer[0] = report_id; 349 buffer[0] = report_id; 354 350 } 355 351 … … 362 358 } 363 359 364 usb_hid_report_field_t *report_item; 365 366 list_foreach(report_des->report_items, item) { 367 report_item = list_get_instance(item, usb_hid_report_field_t, 368 ritems_link); 369 360 list_foreach(report_des->report_items, ritems_link, 361 usb_hid_report_field_t, report_item) { 370 362 value = usb_hid_translate_data_reverse(report_item, 371 363 report_item->value); … … 382 374 } 383 375 size_t shift = 8 - offset % 8 - length; 384 value = value << shift; 376 value = value << shift; 385 377 value = value & (((1 << length) - 1) << shift); 386 378 387 379 uint8_t mask = 0; 388 380 mask = 0xff - (((1 << length) - 1) << shift); … … 400 392 401 393 tmp_value = tmp_value << (offset % 8); 402 394 403 395 mask = ~(((1 << (8 - (offset % 8))) - 1) 404 396 << (offset % 8)); … … 413 405 value = value & ((1 << (length - 414 406 ((offset + length) % 8))) - 1); 415 407 416 408 mask = (1 << (length - 417 409 ((offset + length) % 8))) - 1; … … 431 423 } 432 424 433 /*---------------------------------------------------------------------------*/ 425 434 426 /** 435 427 * Translate given data for putting them into the outoput report … … 476 468 } 477 469 478 /*---------------------------------------------------------------------------*/ 470 479 471 /** 480 472 * Clones given state table … … 497 489 } 498 490 499 /*---------------------------------------------------------------------------*/ 491 500 492 /** 501 493 * Function for sequence walking through the report. Returns next field in the … … 552 544 } 553 545 554 /*---------------------------------------------------------------------------*/ 546 555 547 /** 556 548 * Returns next report_id of report of specified type. If zero is given than … … 600 592 } 601 593 602 /*---------------------------------------------------------------------------*/ 594 603 595 /** 604 596 * Reset all local items in given state table
Note:
See TracChangeset
for help on using the changeset viewer.