Changes in uspace/lib/usbhid/src/hidparser.c [07525cd:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidparser.c
r07525cd r9d58539 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 132 134 usb_hid_report_description_t *report_des; 133 135 usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT; … … 151 153 152 154 /* read data */ 153 list_foreach(report_des->report_items, ritems_link, 154 usb_hid_report_field_t, item) { 155 list_foreach(report_des->report_items, list_item) { 156 item = list_get_instance(list_item, usb_hid_report_field_t, 157 ritems_link); 155 158 156 159 if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) { … … 160 163 item->value = 161 164 usb_hid_translate_data(item, data); 162 165 163 166 item->usage = USB_HID_EXTENDED_USAGE( 164 167 item->usages[item->value - … … 181 184 /* variable item */ 182 185 item->value = usb_hid_translate_data(item, 183 data); 184 } 186 data); 187 } 185 188 } 186 189 } … … 189 192 } 190 193 191 194 /*---------------------------------------------------------------------------*/ 192 195 /** 193 196 * Translate data from the report as specified in report descriptor item … … 271 274 } 272 275 273 276 /*---------------------------------------------------------------------------*/ 274 277 /* OUTPUT API */ 275 278 … … 292 295 usb_hid_report_description_t *report_des = NULL; 293 296 294 list_foreach(report->reports, reports_link, 295 usb_hid_report_description_t, report_des) { 297 list_foreach(report->reports, report_it) { 298 report_des = list_get_instance(report_it, 299 usb_hid_report_description_t, reports_link); 300 296 301 if ((report_des->report_id == report_id) && 297 302 (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) { … … 346 351 347 352 if (report->use_report_ids != 0) { 348 buffer[0] = report_id; 353 buffer[0] = report_id; 349 354 } 350 355 … … 357 362 } 358 363 359 list_foreach(report_des->report_items, ritems_link, 360 usb_hid_report_field_t, report_item) { 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 361 370 value = usb_hid_translate_data_reverse(report_item, 362 371 report_item->value); … … 373 382 } 374 383 size_t shift = 8 - offset % 8 - length; 375 value = value << shift; 384 value = value << shift; 376 385 value = value & (((1 << length) - 1) << shift); 377 386 378 387 uint8_t mask = 0; 379 388 mask = 0xff - (((1 << length) - 1) << shift); … … 391 400 392 401 tmp_value = tmp_value << (offset % 8); 393 402 394 403 mask = ~(((1 << (8 - (offset % 8))) - 1) 395 404 << (offset % 8)); … … 404 413 value = value & ((1 << (length - 405 414 ((offset + length) % 8))) - 1); 406 415 407 416 mask = (1 << (length - 408 417 ((offset + length) % 8))) - 1; … … 422 431 } 423 432 424 433 /*---------------------------------------------------------------------------*/ 425 434 /** 426 435 * Translate given data for putting them into the outoput report … … 467 476 } 468 477 469 478 /*---------------------------------------------------------------------------*/ 470 479 /** 471 480 * Clones given state table … … 488 497 } 489 498 490 499 /*---------------------------------------------------------------------------*/ 491 500 /** 492 501 * Function for sequence walking through the report. Returns next field in the … … 543 552 } 544 553 545 554 /*---------------------------------------------------------------------------*/ 546 555 /** 547 556 * Returns next report_id of report of specified type. If zero is given than … … 591 600 } 592 601 593 602 /*---------------------------------------------------------------------------*/ 594 603 /** 595 604 * Reset all local items in given state table
Note:
See TracChangeset
for help on using the changeset viewer.