Changes in / [d59d0bb:9e195e2c] in mainline
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbd/kbddev.c
rd59d0bb r9e195e2c 313 313 usb_hid_report_field_t *field = usb_hid_report_get_sibling( 314 314 hid_dev->report, NULL, kbd_dev->led_path, 315 USB_HID_PATH_COMPARE_ END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY,315 USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY | USB_HID_PATH_COMPARE_END, 316 316 USB_HID_REPORT_TYPE_OUTPUT); 317 317 318 while (field != NULL) { 319 318 while (field != NULL) { 319 320 320 if ((field->usage == USB_HID_LED_NUM_LOCK) 321 321 && (kbd_dev->mods & KM_NUM_LOCK)){ … … 334 334 335 335 field = usb_hid_report_get_sibling(hid_dev->report, field, 336 kbd_dev->led_path, 337 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 338 USB_HID_REPORT_TYPE_OUTPUT); 336 kbd_dev->led_path, USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY 337 | USB_HID_PATH_COMPARE_END, USB_HID_REPORT_TYPE_OUTPUT); 339 338 } 340 339 … … 866 865 usb_hid_report_path_set_report_id(path, 0); 867 866 868 kbd_dev->key_count = usb_hid_report_size( 869 hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT); 867 kbd_dev->key_count = usb_hid_report_input_length( 868 hid_dev->report, path, 869 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 870 870 usb_hid_report_path_free(path); 871 871 … … 908 908 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 909 909 910 kbd_dev->led_output_size = usb_hid_report_size(hid_dev->report, 911 0, USB_HID_REPORT_TYPE_OUTPUT); 910 kbd_dev->led_output_size = usb_hid_report_output_size(hid_dev->report, 911 kbd_dev->led_path, 912 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 912 913 913 914 usb_log_debug("Output report size (in items): %zu\n", -
uspace/drv/usbhid/multimedia/multimedia.c
rd59d0bb r9e195e2c 252 252 usb_hid_report_path_set_report_id(path, 1); 253 253 254 multim_dev->key_count = usb_hid_report_ size(255 hid_dev->report, 0, USB_HID_REPORT_TYPE_INPUT);256 254 multim_dev->key_count = usb_hid_report_input_length( 255 hid_dev->report, path, 256 USB_HID_PATH_COMPARE_END | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY); 257 257 usb_hid_report_path_free(path); 258 258 … … 347 347 USB_HID_REPORT_TYPE_INPUT); 348 348 349 //unsigned int key;349 unsigned int key; 350 350 351 351 /*! @todo Is this iterating OK if done multiple times? … … 353 353 */ 354 354 while (field != NULL) { 355 if(field->value != 0) { 356 usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", field->value, 357 field->usage); 358 key = usb_multimedia_map_usage(field->usage); 359 const char *key_str = 360 usb_multimedia_usage_to_str(field->usage); 361 usb_log_info("Pressed key: %s\n", key_str); 362 usb_multimedia_push_ev(hid_dev, KEY_PRESS, key); 363 } 355 usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", field->value, 356 field->usage); 357 358 key = usb_multimedia_map_usage(field->usage); 359 const char *key_str = usb_multimedia_usage_to_str(field->usage); 360 usb_log_info("Pressed key: %s\n", key_str); 361 usb_multimedia_push_ev(hid_dev, KEY_PRESS, key); 364 362 365 363 field = usb_hid_report_get_sibling( -
uspace/drv/usbhid/usbhid.c
rd59d0bb r9e195e2c 203 203 204 204 usb_log_debug("Compare flags: %d\n", mapping->compare); 205 // size_t size = usb_hid_report_size(hid_dev->report, 0, 206 // USB_HID_REPORT_TYPE_INPUT); 207 size_t size = 0; 208 usb_hid_report_field_t *field = usb_hid_report_get_sibling (hid_dev->report, 209 NULL, usage_path, mapping->compare, USB_HID_REPORT_TYPE_INPUT); 210 while(field != NULL) { 211 size++; 212 field = usb_hid_report_get_sibling (hid_dev->report, 213 field, usage_path, mapping->compare, 214 USB_HID_REPORT_TYPE_INPUT); 215 } 216 205 size_t size = usb_hid_report_input_length(hid_dev->report, usage_path, 206 mapping->compare); 217 207 usb_log_debug("Size of the input report: %zuB\n", size); 208 218 209 usb_hid_report_path_free(usage_path); 219 210 -
uspace/lib/usbhid/include/usb/classes/hid_report_items.h
rd59d0bb r9e195e2c 46 46 #define USB_HID_ITEM_IS_LONG(data) (data == 0xFE) 47 47 48 49 /**50 * Extended usage macros51 */52 #define USB_HID_IS_EXTENDED_USAGE(usage) ((usage & 0xFFFF0000) != 0)53 #define USB_HID_EXTENDED_USAGE_PAGE(usage) ((usage & 0xFFFF0000) >> 16)54 #define USB_HID_EXTENDED_USAGE(usage) (usage & 0xFFFF)55 48 56 49 /** -
uspace/lib/usbhid/include/usb/classes/hidparser.h
rd59d0bb r9e195e2c 51 51 size_t size, uint8_t *report_id); 52 52 53 /** */ 54 size_t usb_hid_report_input_length(const usb_hid_report_t *report, 55 usb_hid_report_path_t *path, int flags); 56 53 57 /* 54 58 * Output report parser functions … … 61 65 void usb_hid_report_output_free(uint8_t *output); 62 66 63 /** Returns size of report in items*/64 size_t usb_hid_report_ size(usb_hid_report_t *report, uint8_t report_id,65 usb_hid_report_type_t type);67 /** Returns size of output for given usage path */ 68 size_t usb_hid_report_output_size(usb_hid_report_t *report, 69 usb_hid_report_path_t *path, int flags); 66 70 67 71 /** Makes the output report buffer by translated given data */ -
uspace/lib/usbhid/include/usb/classes/hidtypes.h
rd59d0bb r9e195e2c 39 39 #include <adt/list.h> 40 40 41 #define USB_HID_MAX_USAGES 0xffff41 #define USB_HID_MAX_USAGES 20 42 42 43 43 #define USB_HID_UINT32_TO_INT32(x, size) ((((x) & (1 << ((size) - 1))) != 0) ? -(~(x - 1) & ((1 << size) - 1)) : (x)) //(-(~((x) - 1))) … … 92 92 int32_t physical_minimum; 93 93 int32_t physical_maximum; 94 int32_t usage_minimum;95 int32_t usage_maximum;94 uint32_t usage_minimum; 95 uint32_t usage_maximum; 96 96 uint32_t unit; 97 97 uint32_t unit_exponent; 98 99 uint32_t *usages; 100 size_t usages_count; 98 101 99 102 100 int32_t value; … … 123 121 124 122 /** */ 125 int32_t usage_minimum;126 /** */ 127 int32_t usage_maximum;123 uint32_t usage_minimum; 124 /** */ 125 uint32_t usage_maximum; 128 126 /** */ 129 127 int32_t logical_minimum; -
uspace/lib/usbhid/src/hiddescriptor.c
rd59d0bb r9e195e2c 64 64 { 65 65 /* find or append current collection path to the list */ 66 //link_t *path_it = report->collection_paths.next; 67 link_t *path_it = report->collection_paths.prev->next; 66 link_t *path_it = report->collection_paths.next; 68 67 usb_hid_report_path_t *path = NULL; 69 70 71 68 while(path_it != &report->collection_paths) { 72 69 path = list_get_instance(path_it, usb_hid_report_path_t, link); … … 119 116 int i; 120 117 121 uint32_t *usages; 122 int usages_used=0; 123 if(report_item->usages_count > 0){ 124 usages = malloc(sizeof(int32_t) * report_item->usages_count); 125 memcpy(usages, report_item->usages, sizeof(int32_t) * report_item->usages_count); 126 } 127 else { 128 usages = NULL; 129 } 130 118 for(i=0; i<report_item->usages_count; i++){ 119 usb_log_debug("usages (%d) - %x\n", i, report_item->usages[i]); 120 } 121 131 122 usb_hid_report_path_t *path = report_item->usage_path; 132 123 for(i=0; i<report_item->count; i++){ … … 142 133 field->physical_maximum = report_item->physical_maximum; 143 134 144 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0){ 145 /* 146 Store usage array. The Correct Usage Page and Usage is depending 147 on data in report and will be filled later 148 */ 149 field->usage = 0; 150 field->usage_page = 0; //report_item->usage_page; 151 152 field->usages_count = report_item->usages_count; 153 field->usages = usages; 154 usages_used = 1; 135 field->usage_minimum = report_item->usage_minimum; 136 field->usage_maximum = report_item->usage_maximum; 137 if(report_item->extended_usage_page != 0){ 138 field->usage_page = report_item->extended_usage_page; 155 139 } 156 140 else { 157 158 /* Fill the correct Usage and Usage Page */ 159 int32_t usage; 160 if(i < report_item->usages_count) { 141 field->usage_page = report_item->usage_page; 142 } 143 144 if(report_item->usages_count > 0 && ((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0))) { 145 uint32_t usage; 146 if(i < report_item->usages_count){ 161 147 usage = report_item->usages[i]; 162 148 } … … 165 151 } 166 152 167 if(USB_HID_IS_EXTENDED_USAGE(usage)){ 168 field->usage = USB_HID_EXTENDED_USAGE(usage); 169 field->usage_page = USB_HID_EXTENDED_USAGE_PAGE(usage); 153 154 if((usage & 0xFFFF0000) != 0){ 155 field->usage_page = (usage >> 16); 156 field->usage = (usage & 0xFFFF); 170 157 } 171 158 else { 172 // should not occur173 159 field->usage = usage; 174 field->usage_page = report_item->usage_page; 175 } 160 } 161 162 163 } 164 165 if((USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) != 0) && (!((report_item->usage_minimum == 0) && (report_item->usage_maximum == 0)))) { 166 field->usage = report_item->usage_minimum + i; 176 167 } 177 168 … … 218 209 } 219 210 220 // free only when not used!!!221 if(usages && usages_used == 0) {222 free(usages);223 }224 211 225 212 return EOK; … … 463 450 464 451 case USB_HID_REPORT_TAG_COLLECTION: 465 466 452 // store collection atributes 467 453 path_item = list_get_instance(usage_path->head.prev, usb_hid_report_usage_path_t, link); … … 469 455 470 456 // set last item 471 usb_hid_report_set_last_item(usage_path, 472 USB_HID_TAG_CLASS_GLOBAL, 473 USB_HID_EXTENDED_USAGE_PAGE(report_item->usages[report_item->usages_count-1])); 474 usb_hid_report_set_last_item(usage_path, 475 USB_HID_TAG_CLASS_LOCAL, 476 USB_HID_EXTENDED_USAGE(report_item->usages[report_item->usages_count-1])); 457 usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_GLOBAL, report_item->usage_page); 458 usb_hid_report_set_last_item(usage_path, USB_HID_TAG_CLASS_LOCAL, report_item->usages[report_item->usages_count-1]); 477 459 478 460 // append the new one which will be set by common … … 569 551 usb_hid_report_item_t *report_item, usb_hid_report_path_t *usage_path) 570 552 { 571 int32_t extended_usage;572 573 553 switch(tag) { 574 554 case USB_HID_REPORT_TAG_USAGE: … … 580 560 report_item->in_delimiter = INSIDE_DELIMITER_SET; 581 561 case OUTSIDE_DELIMITER_SET: 582 extended_usage = ((report_item->usage_page) << 16); 583 extended_usage += usb_hid_report_tag_data_uint32(data,item_size); 584 report_item->usages[report_item->usages_count] = extended_usage; 562 report_item->usages[report_item->usages_count] = usb_hid_report_tag_data_uint32(data,item_size); 585 563 report_item->usages_count++; 586 564 break; 587 565 } 588 566 break; 589 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 567 case USB_HID_REPORT_TAG_USAGE_MINIMUM: 590 568 if (item_size == 3) { 591 569 // usage extended usages … … 599 577 case USB_HID_REPORT_TAG_USAGE_MAXIMUM: 600 578 if (item_size == 3) { 601 602 if(report_item->extended_usage_page != ((usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16)) {603 return EINVAL;604 }605 606 579 // usage extended usages 607 580 report_item->extended_usage_page = (usb_hid_report_tag_data_uint32(data,item_size) & 0xFF00) >> 16; … … 611 584 report_item->usage_maximum = usb_hid_report_tag_data_uint32(data,item_size); 612 585 } 613 614 // vlozit zaznamy do pole usages615 int32_t i;616 for(i=report_item->usage_minimum; i<=report_item->usage_maximum; i++) {617 if(report_item->extended_usage_page) {618 report_item->usages[report_item->usages_count++] = (report_item->extended_usage_page << 16) + i;619 }620 else {621 622 report_item->usages[report_item->usages_count++] = (report_item->usage_page << 16) + i;623 }624 }625 report_item->extended_usage_page = 0;626 627 586 break; 628 587 case USB_HID_REPORT_TAG_DESIGNATOR_INDEX: … … 704 663 usb_log_debug("\t\ttUSAGEMIN: %X\n", report_item->usage_minimum); 705 664 usb_log_debug("\t\tUSAGEMAX: %X\n", report_item->usage_maximum); 706 usb_log_debug("\t\tUSAGES COUNT: %zu\n", report_item->usages_count);707 665 708 666 usb_log_debug("\t\tVALUE: %X\n", report_item->value); … … 710 668 usb_log_debug("\t\tUSAGE PAGE: %X\n", report_item->usage_page); 711 669 712 usb_hid_print_usage_path(report_item->collection_path);670 //usb_hid_print_usage_path(report_item->collection_path); 713 671 714 672 usb_log_debug("\n"); … … 742 700 usb_hid_descriptor_print_list(&report_des->report_items); 743 701 744 /* 702 745 703 link_t *path_it = report->collection_paths.next; 746 704 while(path_it != &report->collection_paths) { … … 748 706 path_it = path_it->next; 749 707 } 750 */708 751 709 report_it = report_it->next; 752 710 } -
uspace/lib/usbhid/src/hidparser.c
rd59d0bb r9e195e2c 69 69 70 70 71 /** Returns size of report of specified report id and type in items72 *73 * @param parser Opaque report parser structure74 * @param report_id75 * @param type76 * @return Number of items in specified report77 */78 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id,79 usb_hid_report_type_t type)80 {81 usb_hid_report_description_t *report_des;82 83 if(report == NULL) {84 return 0;85 }86 87 report_des = usb_hid_report_find_description (report, report_id, type);88 if(report_des == NULL){89 return 0;90 }91 else {92 return report_des->item_length;93 }94 }95 71 96 72 … … 111 87 usb_hid_report_description_t *report_des; 112 88 usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT; 113 89 114 90 if(report == NULL) { 115 91 return EINVAL; … … 138 114 // array 139 115 item->value = usb_hid_translate_data(item, data); 140 141 item->usage = USB_HID_EXTENDED_USAGE(item->usages[item->value - item->physical_minimum]); 142 item->usage_page = USB_HID_EXTENDED_USAGE_PAGE(item->usages[item->value - item->physical_minimum]); 143 144 usb_hid_report_set_last_item (item->collection_path, 145 USB_HID_TAG_CLASS_GLOBAL, 146 item->usage_page); 147 usb_hid_report_set_last_item (item->collection_path, 148 USB_HID_TAG_CLASS_LOCAL, 149 item->usage); 150 116 item->usage = (item->value - item->physical_minimum) + item->usage_minimum; 151 117 } 152 118 else { … … 157 123 list_item = list_item->next; 158 124 } 159 125 160 126 return EOK; 161 127 … … 240 206 } 241 207 208 /** 209 * Returns number of items in input report which are accessible by given usage path 210 * 211 * @param parser Opaque report descriptor structure 212 * @param path Usage path specification 213 * @param flags Usage path comparison flags 214 * @return Number of items in input report 215 */ 216 size_t usb_hid_report_input_length(const usb_hid_report_t *report, 217 usb_hid_report_path_t *path, int flags) 218 { 219 220 size_t ret = 0; 221 222 if(report == NULL) { 223 return 0; 224 } 225 226 usb_hid_report_description_t *report_des; 227 report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_INPUT); 228 if(report_des == NULL) { 229 return 0; 230 } 231 232 link_t *field_it = report_des->report_items.next; 233 usb_hid_report_field_t *field; 234 while(field_it != &report_des->report_items) { 235 236 field = list_get_instance(field_it, usb_hid_report_field_t, link); 237 if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0) { 238 239 usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage); 240 if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) { 241 ret++; 242 } 243 usb_hid_report_remove_last_item (field->collection_path); 244 } 245 246 field_it = field_it->next; 247 } 248 249 return ret; 250 } 251 242 252 /*** OUTPUT API **/ 243 253 … … 294 304 } 295 305 306 /** Returns size of output for given usage path 307 * 308 * @param parser Opaque report parser structure 309 * @param path Usage path specified which items will be thought for the output 310 * @param flags Flags of usage path structure comparison 311 * @return Number of items matching the given usage path 312 */ 313 size_t usb_hid_report_output_size(usb_hid_report_t *report, 314 usb_hid_report_path_t *path, int flags) 315 { 316 size_t ret = 0; 317 usb_hid_report_description_t *report_des; 318 319 if(report == NULL) { 320 return 0; 321 } 322 323 report_des = usb_hid_report_find_description (report, path->report_id, USB_HID_REPORT_TYPE_OUTPUT); 324 if(report_des == NULL){ 325 return 0; 326 } 327 328 link_t *field_it = report_des->report_items.next; 329 usb_hid_report_field_t *field; 330 while(field_it != &report_des->report_items) { 331 332 field = list_get_instance(field_it, usb_hid_report_field_t, link); 333 if(USB_HID_ITEM_FLAG_CONSTANT(field->item_flags) == 0){ 334 usb_hid_report_path_append_item (field->collection_path, field->usage_page, field->usage); 335 if(usb_hid_report_compare_usage_path (field->collection_path, path, flags) == EOK) { 336 ret++; 337 } 338 usb_hid_report_remove_last_item (field->collection_path); 339 } 340 341 field_it = field_it->next; 342 } 343 344 return ret; 345 346 } 347 296 348 /** Makes the output report buffer for data given in the report structure 297 349 * … … 333 385 report_item = list_get_instance(item, usb_hid_report_field_t, link); 334 386 335 usb_log_debug("OUTPUT ITEM usage(%x), value(%x)\n", report_item->usage, report_item->value); 336 337 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) { 387 if(USB_HID_ITEM_FLAG_VARIABLE(report_item->item_flags) == 0) { 338 388 339 // array340 value = usb_hid_translate_data_reverse(report_item, report_item->value);341 offset = report_item->offset;342 length = report_item->size;343 }344 else {345 // variable item346 value = usb_hid_translate_data_reverse(report_item, report_item->value);347 offset = report_item->offset;348 length = report_item->size;349 }350 351 usb_log_debug("\ttranslated value: %x\n", value);352 353 if((offset/8) == ((offset+length-1)/8)) {354 // je to v jednom bytu355 if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) {356 break; // TODO ErrorCode 357 }358 size_t shift = 8 - offset%8 - length; 359 value = value << shift;360 value = value & (((1 << length)-1) << shift);389 // array 390 value = usb_hid_translate_data_reverse(report_item, report_item->value); 391 offset = report_item->offset; 392 length = report_item->size; 393 } 394 else { 395 // variable item 396 value = usb_hid_translate_data_reverse(report_item, report_item->value); 397 offset = report_item->offset; 398 length = report_item->size; 399 } 400 401 if((offset/8) == ((offset+length-1)/8)) { 402 // je to v jednom bytu 403 if(((size_t)(offset/8) >= size) || ((size_t)(offset+length-1)/8) >= size) { 404 break; // TODO ErrorCode 405 } 406 407 size_t shift = 8 - offset%8 - length; 408 409 value = value << shift; 410 value = value & (((1 << length)-1) << shift); 361 411 362 uint8_t mask = 0; 363 mask = 0xff - (((1 << length) - 1) << shift); 364 buffer[offset/8] = (buffer[offset/8] & mask) | value; 365 } 366 else { 367 int i = 0; 368 uint8_t mask = 0; 369 for(i = (offset/8); i <= ((offset+length-1)/8); i++) { 370 if(i == (offset/8)) { 371 tmp_value = value; 372 tmp_value = tmp_value & ((1 << (8-(offset%8)))-1); 373 tmp_value = tmp_value << (offset%8); 374 375 mask = ~(((1 << (8-(offset%8)))-1) << (offset%8)); 376 buffer[i] = (buffer[i] & mask) | tmp_value; 412 uint8_t mask = 0; 413 mask = 0xff - (((1 << length) - 1) << shift); 414 buffer[offset/8] = (buffer[offset/8] & mask) | value; 415 } 416 else { 417 int i = 0; 418 uint8_t mask = 0; 419 for(i = (offset/8); i <= ((offset+length-1)/8); i++) { 420 if(i == (offset/8)) { 421 tmp_value = value; 422 tmp_value = tmp_value & ((1 << (8-(offset%8)))-1); 423 tmp_value = tmp_value << (offset%8); 424 425 mask = ~(((1 << (8-(offset%8)))-1) << (offset%8)); 426 buffer[i] = (buffer[i] & mask) | tmp_value; 427 } 428 else if (i == ((offset + length -1)/8)) { 429 430 value = value >> (length - ((offset + length) % 8)); 431 value = value & ((1 << (length - ((offset + length) % 8))) - 1); 432 433 mask = (1 << (length - ((offset + length) % 8))) - 1; 434 buffer[i] = (buffer[i] & mask) | value; 435 } 436 else { 437 buffer[i] = value & (0xFF << i); 438 } 377 439 } 378 else if (i == ((offset + length -1)/8)) { 379 380 value = value >> (length - ((offset + length) % 8)); 381 value = value & ((1 << (length - ((offset + length) % 8))) - 1); 382 383 mask = (1 << (length - ((offset + length) % 8))) - 1; 384 buffer[i] = (buffer[i] & mask) | value; 385 } 386 else { 387 buffer[i] = value & (0xFF << i); 388 } 389 } 390 } 440 } 441 391 442 392 443 // reset value … … 421 472 } 422 473 423 // variable item 424 if(item->physical_maximum == item->physical_minimum){ 425 resolution = 1; 474 475 if((USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0)) { 476 477 // variable item 478 if(item->physical_maximum == item->physical_minimum){ 479 resolution = 1; 480 } 481 else { 482 resolution = (item->logical_maximum - item->logical_minimum) / 483 ((item->physical_maximum - item->physical_minimum) * 484 (usb_pow(10,(item->unit_exponent)))); 485 } 486 487 ret = ((value - item->physical_minimum) * resolution) + item->logical_minimum; 426 488 } 427 489 else { 428 resolution = (item->logical_maximum - item->logical_minimum) / 429 ((item->physical_maximum - item->physical_minimum) * 430 (usb_pow(10,(item->unit_exponent)))); 431 } 432 433 ret = ((value - item->physical_minimum) * resolution) + item->logical_minimum; 434 usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), ret(%x)\n", value, resolution, item->physical_minimum, item->logical_minimum, ret); 435 490 // bitmapa 491 if(value == 0) { 492 ret = 0; 493 } 494 else { 495 size_t bitmap_idx = (value - item->usage_minimum); 496 ret = 1 << bitmap_idx; 497 } 498 } 499 436 500 if((item->logical_minimum < 0) || (item->logical_maximum < 0)){ 437 501 return USB_HID_INT32_TO_UINT32(ret, item->size); 438 502 } 439 return (int32_t) 0 +ret;503 return (int32_t)ret; 440 504 } 441 505 -
uspace/lib/usbhid/src/hidpath.c
rd59d0bb r9e195e2c 42 42 43 43 44 #define USB_HID_SAME_USAGE(usage1, usage2) ((usage1 == usage2) || (usage1 == 0) || (usage2 == 0))45 #define USB_HID_SAME_USAGE_PAGE(page1, page2) ((page1 == page2) || (page1 == 0) || (page2 == 0))46 47 44 /** 48 45 * Appends one item (couple of usage_path and usage) into the usage path … … 206 203 while(report_link != &report_path->head) { 207 204 report_item = list_get_instance(report_link, usb_hid_report_usage_path_t, link); 208 if( USB_HID_SAME_USAGE_PAGE(report_item->usage_page, path_item->usage_page)){205 if(report_item->usage_page == path_item->usage_page){ 209 206 if(only_page == 0){ 210 if( USB_HID_SAME_USAGE(report_item->usage, path_item->usage)) {207 if(report_item->usage == path_item->usage) { 211 208 return EOK; 212 209 } … … 245 242 link); 246 243 247 if( !USB_HID_SAME_USAGE_PAGE(report_item->usage_page,path_item->usage_page) ||244 if((report_item->usage_page != path_item->usage_page) || 248 245 ((only_page == 0) && 249 !USB_HID_SAME_USAGE(report_item->usage,path_item->usage))) {246 (report_item->usage != path_item->usage))) { 250 247 251 248 return 1; … … 285 282 usb_hid_report_usage_path_t, 286 283 link); 287 288 if( !USB_HID_SAME_USAGE_PAGE(report_item->usage_page,path_item->usage_page) ||284 285 if((report_item->usage_page != path_item->usage_page) || 289 286 ((only_page == 0) && 290 !USB_HID_SAME_USAGE(report_item->usage,path_item->usage))) {291 287 (report_item->usage != path_item->usage))) { 288 return 1; 292 289 } else { 293 290 report_link = report_link->prev;
Note:
See TracChangeset
for help on using the changeset viewer.