Changes in uspace/lib/usbhid/src/hidparser.c [1e371cf:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhid/src/hidparser.c
r1e371cf 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, rdes) { 296 if ((rdes->report_id == report_id) && 297 (rdes->type == USB_HID_REPORT_TYPE_OUTPUT)) { 298 report_des = rdes; 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)) { 299 303 break; 300 304 } … … 347 351 348 352 if (report->use_report_ids != 0) { 349 buffer[0] = report_id; 353 buffer[0] = report_id; 350 354 } 351 355 … … 358 362 } 359 363 360 list_foreach(report_des->report_items, ritems_link, 361 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 362 370 value = usb_hid_translate_data_reverse(report_item, 363 371 report_item->value); … … 374 382 } 375 383 size_t shift = 8 - offset % 8 - length; 376 value = value << shift; 384 value = value << shift; 377 385 value = value & (((1 << length) - 1) << shift); 378 386 379 387 uint8_t mask = 0; 380 388 mask = 0xff - (((1 << length) - 1) << shift); … … 392 400 393 401 tmp_value = tmp_value << (offset % 8); 394 402 395 403 mask = ~(((1 << (8 - (offset % 8))) - 1) 396 404 << (offset % 8)); … … 405 413 value = value & ((1 << (length - 406 414 ((offset + length) % 8))) - 1); 407 415 408 416 mask = (1 << (length - 409 417 ((offset + length) % 8))) - 1; … … 423 431 } 424 432 425 433 /*---------------------------------------------------------------------------*/ 426 434 /** 427 435 * Translate given data for putting them into the outoput report … … 468 476 } 469 477 470 478 /*---------------------------------------------------------------------------*/ 471 479 /** 472 480 * Clones given state table … … 489 497 } 490 498 491 499 /*---------------------------------------------------------------------------*/ 492 500 /** 493 501 * Function for sequence walking through the report. Returns next field in the … … 544 552 } 545 553 546 554 /*---------------------------------------------------------------------------*/ 547 555 /** 548 556 * Returns next report_id of report of specified type. If zero is given than … … 592 600 } 593 601 594 602 /*---------------------------------------------------------------------------*/ 595 603 /** 596 604 * Reset all local items in given state table
Note:
See TracChangeset
for help on using the changeset viewer.