Changes in uspace/drv/hid/usbhid/kbd/kbddev.c [e0a5d4c:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/usbhid/kbd/kbddev.c
re0a5d4c rb7fd2a0 1 1 /* 2 2 * Copyright (c) 2011 Lubos Slovak 3 * Copyright (c) 2018 Ondrej Hlavaty4 3 * All rights reserved. 5 4 * … … 186 185 if (kbd_dev->client_sess == NULL) { 187 186 kbd_dev->client_sess = sess; 188 usb_log_debug("%s: OK ", __FUNCTION__);187 usb_log_debug("%s: OK\n", __FUNCTION__); 189 188 async_answer_0(icallid, EOK); 190 189 } else { 191 usb_log_error("%s: console session already set ",190 usb_log_error("%s: console session already set\n", 192 191 __FUNCTION__); 193 192 async_answer_0(icallid, ELIMIT); … … 196 195 } 197 196 default: 198 usb_log_error("%s: Unknown method: %d. ",197 usb_log_error("%s: Unknown method: %d.\n", 199 198 __FUNCTION__, (int) method); 200 199 async_answer_0(icallid, EINVAL); … … 227 226 /* Reset the LED data. */ 228 227 memset(kbd_dev->led_data, 0, kbd_dev->led_output_size * sizeof(int32_t)); 229 usb_log_debug("Creating output report: ");228 usb_log_debug("Creating output report:\n"); 230 229 231 230 usb_hid_report_field_t *field = usb_hid_report_get_sibling( … … 267 266 } 268 267 269 usb_log_debug("Output report buffer: %s ",268 usb_log_debug("Output report buffer: %s\n", 270 269 usb_debug_str_buffer(kbd_dev->output_buffer, kbd_dev->output_size, 271 270 0)); … … 277 276 kbd_dev->output_buffer, kbd_dev->output_size); 278 277 if (rc != EOK) { 279 usb_log_warning("Failed to set kbd indicators. ");278 usb_log_warning("Failed to set kbd indicators.\n"); 280 279 } 281 280 } … … 290 289 void usb_kbd_push_ev(usb_kbd_t *kbd_dev, int type, unsigned key) 291 290 { 292 usb_log_debug2("Sending kbdev event %d/%d to the console ", type, key);291 usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key); 293 292 if (kbd_dev->client_sess == NULL) { 294 293 usb_log_warning( … … 302 301 async_exchange_end(exch); 303 302 } else { 304 usb_log_warning("Failed to send key to console. ");303 usb_log_warning("Failed to send key to console.\n"); 305 304 } 306 305 } … … 329 328 * An event is created only when key is pressed or released. Besides handling 330 329 * the events (usb_kbd_push_ev()), the auto-repeat fibril is notified about 331 * key presses and releases (see usb_kbd_repeat_start() and 330 * key presses and releases (see usb_kbd_repeat_start() and 332 331 * usb_kbd_repeat_stop()). 333 332 * 334 333 * @param kbd_dev Keyboard device structure. 335 * @param key_codes Parsed keyboard report - codes of currently pressed keys 334 * @param key_codes Parsed keyboard report - codes of currently pressed keys 336 335 * according to HID Usage Tables. 337 336 * @param count Number of key codes in report (size of the report). … … 354 353 kbd_dev->key_count); 355 354 if (i != (size_t) -1) { 356 usb_log_error("Detected phantom state. ");355 usb_log_error("Detected phantom state.\n"); 357 356 return; 358 357 } … … 404 403 ddf_dump_buffer(key_buffer, 512, 405 404 kbd_dev->keys_old, 4, kbd_dev->key_count, 0); 406 usb_log_debug2("Stored keys %s. ", key_buffer);405 usb_log_debug2("Stored keys %s.\n", key_buffer); 407 406 } 408 407 … … 432 431 usb_hid_report_path_t *path = usb_hid_report_path(); 433 432 if (path == NULL) { 434 usb_log_error("Failed to create hid/kbd report path. ");433 usb_log_error("Failed to create hid/kbd report path.\n"); 435 434 return; 436 435 } … … 439 438 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 440 439 if (ret != EOK) { 441 usb_log_error("Failed to append to hid/kbd report path. ");440 usb_log_error("Failed to append to hid/kbd report path.\n"); 442 441 return; 443 442 } … … 453 452 454 453 while (field != NULL) { 455 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u) ",454 usb_log_debug2("FIELD (%p) - VALUE(%d) USAGE(%u)\n", 456 455 field, field->value, field->usage); 457 456 … … 465 464 kbd_dev->keys[i] = 0; 466 465 } 467 usb_log_debug2("Saved %u. key usage %d ", i, kbd_dev->keys[i]);466 usb_log_debug2("Saved %u. key usage %d\n", i, kbd_dev->keys[i]); 468 467 469 468 ++i; … … 503 502 usb_hid_report_path_t *path = usb_hid_report_path(); 504 503 if (path == NULL) { 505 usb_log_error("Failed to create kbd report path. ");504 usb_log_error("Failed to create kbd report path.\n"); 506 505 usb_kbd_destroy(kbd_dev); 507 506 return ENOMEM; … … 511 510 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_KEYBOARD, 0); 512 511 if (ret != EOK) { 513 usb_log_error("Failed to append item to kbd report path. ");512 usb_log_error("Failed to append item to kbd report path.\n"); 514 513 usb_hid_report_path_free(path); 515 514 usb_kbd_destroy(kbd_dev); … … 524 523 usb_hid_report_path_free(path); 525 524 526 usb_log_debug("Size of the input report: %zu ", kbd_dev->key_count);525 usb_log_debug("Size of the input report: %zu\n", kbd_dev->key_count); 527 526 528 527 kbd_dev->keys = calloc(kbd_dev->key_count, sizeof(int32_t)); 529 528 if (kbd_dev->keys == NULL) { 530 usb_log_error("Failed to allocate key buffer. ");529 usb_log_error("Failed to allocate key buffer.\n"); 531 530 usb_kbd_destroy(kbd_dev); 532 531 return ENOMEM; … … 535 534 kbd_dev->keys_old = calloc(kbd_dev->key_count, sizeof(int32_t)); 536 535 if (kbd_dev->keys_old == NULL) { 537 usb_log_error("Failed to allocate old_key buffer. ");536 usb_log_error("Failed to allocate old_key buffer.\n"); 538 537 usb_kbd_destroy(kbd_dev); 539 538 return ENOMEM; … … 545 544 &kbd_dev->output_size, 0); 546 545 if (kbd_dev->output_buffer == NULL) { 547 usb_log_error("Error creating output report buffer. ");546 usb_log_error("Error creating output report buffer.\n"); 548 547 usb_kbd_destroy(kbd_dev); 549 548 return ENOMEM; 550 549 } 551 550 552 usb_log_debug("Output buffer size: %zu ", kbd_dev->output_size);551 usb_log_debug("Output buffer size: %zu\n", kbd_dev->output_size); 553 552 554 553 kbd_dev->led_path = usb_hid_report_path(); 555 554 if (kbd_dev->led_path == NULL) { 556 usb_log_error("Failed to create kbd led report path. ");555 usb_log_error("Failed to create kbd led report path.\n"); 557 556 usb_kbd_destroy(kbd_dev); 558 557 return ENOMEM; … … 562 561 kbd_dev->led_path, USB_HIDUT_PAGE_LED, 0); 563 562 if (ret != EOK) { 564 usb_log_error("Failed to append to kbd/led report path. ");563 usb_log_error("Failed to append to kbd/led report path.\n"); 565 564 usb_kbd_destroy(kbd_dev); 566 565 return ret; … … 570 569 &hid_dev->report, 0, USB_HID_REPORT_TYPE_OUTPUT); 571 570 572 usb_log_debug("Output report size (in items): %zu ",571 usb_log_debug("Output report size (in items): %zu\n", 573 572 kbd_dev->led_output_size); 574 573 575 574 kbd_dev->led_data = calloc(kbd_dev->led_output_size, sizeof(int32_t)); 576 575 if (kbd_dev->led_data == NULL) { 577 usb_log_error("Error creating buffer for LED output report. ");576 usb_log_error("Error creating buffer for LED output report.\n"); 578 577 usb_kbd_destroy(kbd_dev); 579 578 return ENOMEM; … … 589 588 590 589 kbd_dev->initialized = USB_KBD_STATUS_INITIALIZED; 591 usb_log_debug("HID/KBD device structure initialized. ");590 usb_log_debug("HID/KBD device structure initialized.\n"); 592 591 593 592 return EOK; … … 619 618 errno_t usb_kbd_init(usb_hid_dev_t *hid_dev, void **data) 620 619 { 621 usb_log_debug("Initializing HID/KBD structure... ");620 usb_log_debug("Initializing HID/KBD structure...\n"); 622 621 623 622 if (hid_dev == NULL) { … … 628 627 629 628 /* Create the exposed function. */ 630 usb_log_debug("Creating DDF function %s... ", HID_KBD_FUN_NAME);629 usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME); 631 630 ddf_fun_t *fun = usb_device_ddf_fun_create(hid_dev->usb_dev, 632 631 fun_exposed, HID_KBD_FUN_NAME); 633 632 if (fun == NULL) { 634 usb_log_error("Could not create DDF function node. ");633 usb_log_error("Could not create DDF function node.\n"); 635 634 return ENOMEM; 636 635 } … … 638 637 usb_kbd_t *kbd_dev = ddf_fun_data_alloc(fun, sizeof(usb_kbd_t)); 639 638 if (kbd_dev == NULL) { 640 usb_log_error("Failed to allocate KBD device structure. ");639 usb_log_error("Failed to allocate KBD device structure.\n"); 641 640 ddf_fun_destroy(fun); 642 641 return ENOMEM; … … 645 644 errno_t ret = kbd_dev_init(kbd_dev, hid_dev); 646 645 if (ret != EOK) { 647 usb_log_error("Failed to initialize KBD device structure. ");646 usb_log_error("Failed to initialize KBD device structure.\n"); 648 647 ddf_fun_destroy(fun); 649 648 return ret; … … 656 655 ret = ddf_fun_bind(fun); 657 656 if (ret != EOK) { 658 usb_log_error("Could not bind DDF function: %s. ",657 usb_log_error("Could not bind DDF function: %s.\n", 659 658 str_error(ret)); 660 659 usb_kbd_destroy(kbd_dev); … … 663 662 } 664 663 665 usb_log_debug("%s function created. Handle: %" PRIun " ",664 usb_log_debug("%s function created. Handle: %" PRIun "\n", 666 665 HID_KBD_FUN_NAME, ddf_fun_get_handle(fun)); 667 666 668 usb_log_debug("Adding DDF function to category %s... ",667 usb_log_debug("Adding DDF function to category %s...\n", 669 668 HID_KBD_CATEGORY_NAME); 670 669 ret = ddf_fun_add_to_category(fun, HID_KBD_CATEGORY_NAME); … … 710 709 usb_kbd_process_data(hid_dev, kbd_dev); 711 710 712 /* Continue polling until the device is about to be removed. */713 711 return true; 714 712 } … … 754 752 if (kbd_dev->fun) { 755 753 if (ddf_fun_unbind(kbd_dev->fun) != EOK) { 756 usb_log_warning("Failed to unbind %s. ",754 usb_log_warning("Failed to unbind %s.\n", 757 755 ddf_fun_get_name(kbd_dev->fun)); 758 756 } else { 759 usb_log_debug2("%s unbound. ",757 usb_log_debug2("%s unbound.\n", 760 758 ddf_fun_get_name(kbd_dev->fun)); 761 759 ddf_fun_destroy(kbd_dev->fun); … … 785 783 786 784 if (rc != EOK) { 787 usb_log_error("Failed to parse boot report descriptor: %s ",785 usb_log_error("Failed to parse boot report descriptor: %s\n", 788 786 str_error(rc)); 789 787 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.