Changeset 9e7cdf8 in mainline
- Timestamp:
- 2011-02-04T14:05:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8c3c756
- Parents:
- 9097c16a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/main.c
r9097c16a r9e7cdf8 49 49 #include <usb/devreq.h> 50 50 #include <usb/descriptor.h> 51 #include <usb/debug.h> 51 52 #include <io/console.h> 52 53 #include "hid.h" … … 196 197 } 197 198 /* 198 printf("type: %d\n", type);199 printf("mods: 0x%x\n", mods);200 printf("keycode: %u\n", key);199 usb_log_debug2("type: %d\n", type); 200 usb_log_debug2("mods: 0x%x\n", mods); 201 usb_log_debug2("keycode: %u\n", key); 201 202 */ 202 203 … … 228 229 ev.c = layout[active_layout]->parse_ev(&ev); 229 230 230 printf("Sending key %d to the console\n", ev.key);231 usb_log_debug("Sending key %d to the console\n", ev.key); 231 232 assert(console_callback_phone != -1); 232 233 async_msg_4(console_callback_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); … … 249 250 uint8_t modifiers, void *arg) 250 251 { 251 printf("Got keys: ");252 usb_log_debug2("Got keys from parser: "); 252 253 unsigned i; 253 254 for (i = 0; i < count; ++i) { 254 printf("%d ", key_codes[i]);255 usb_log_debug2("%d ", key_codes[i]); 255 256 // TODO: Key press / release 256 257 // TODO: NOT WORKING258 257 unsigned int key = usbkbd_parse_scancode(key_codes[i]); 259 258 kbd_push_ev(KEY_PRESS, key); 260 259 } 261 printf("\n");260 usb_log_debug2("\n"); 262 261 } 263 262 … … 339 338 free(descriptors); 340 339 if (rc != EOK) { 341 printf("Problem with parsing standard descriptors.\n");340 usb_log_warning("Problem with parsing standard descriptors.\n"); 342 341 return rc; 343 342 } … … 346 345 rc = usbkbd_get_report_descriptor(kbd_dev); 347 346 if (rc != EOK) { 348 printf("Problem with parsing HIDREPORT descriptor.\n");347 usb_log_warning("Problem with parsing REPORT descriptor.\n"); 349 348 return rc; 350 349 } … … 356 355 * 1) select one configuration (lets say the first) 357 356 * 2) how many interfaces?? how to select one?? 358 357 * ("The default setting for an interface is always alternate setting zero.") 359 358 * 3) find endpoint which is IN and INTERRUPT (parse), save its number 360 359 * as the endpoint for polling 361 360 */ 362 361 … … 370 369 371 370 if (kbd_dev == NULL) { 372 fprintf(stderr, NAME ":No memory!\n");371 usb_log_fatal("No memory!\n"); 373 372 return NULL; 374 373 } … … 380 379 int rc = kbd_dev->device->parent_phone = usb_drv_hc_connect_auto(dev, 0); 381 380 if (rc < 0) { 382 printf("Problem setting phone to HC.\n");381 usb_log_error("Problem setting phone to HC.\n"); 383 382 goto error_leave; 384 383 } … … 386 385 rc = kbd_dev->address = usb_drv_get_my_address(dev->parent_phone, dev); 387 386 if (rc < 0) { 388 printf("Problem getting address of the device.\n");387 usb_log_error("Problem getting address of the device.\n"); 389 388 goto error_leave; 390 389 } … … 392 391 // doesn't matter now that we have no address 393 392 // if (kbd_dev->address < 0) { 394 // fprintf(stderr, NAME ":No device address!\n");393 // usb_log_error("No device address!\n"); 395 394 // free(kbd_dev); 396 395 // return NULL; … … 407 406 usbkbd_process_descriptors(kbd_dev); 408 407 409 410 411 408 /* 412 409 * Initialize the backing connection to the host controller. … … 414 411 rc = usb_device_connection_initialize_from_device(&kbd_dev->wire, dev); 415 412 if (rc != EOK) { 416 printf("Problem initializing connection to device: %s.\n",417 str_error(rc));413 usb_log_error("Problem initializing connection to device: %s." 414 "\n", str_error(rc)); 418 415 goto error_leave; 419 416 } … … 425 422 GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN); 426 423 if (rc != EOK) { 427 printf("Failed to initialize interrupt in pipe: %s.\n",424 usb_log_error("Failed to initialize interrupt in pipe: %s.\n", 428 425 str_error(rc)); 429 426 goto error_leave; … … 448 445 //usb_hid_parse_report(kbd_dev->parser, buffer, actual_size, callbacks, 449 446 // NULL); 450 printf("Calling usb_hid_boot_keyboard_input_report() with size %zu\n",451 actual_size);447 /*usb_log_debug2("Calling usb_hid_boot_keyboard_input_report() with size" 448 " %zu\n", actual_size);*/ 452 449 //dump_buffer("bufffer: ", buffer, actual_size); 453 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, callbacks, 454 NULL); 455 if (rc != EOK) { 456 printf("Error in usb_hid_boot_keyboard_input_report(): %d\n", rc); 450 int rc = usb_hid_boot_keyboard_input_report(buffer, actual_size, 451 callbacks, NULL); 452 453 if (rc != EOK) { 454 usb_log_warning("Error in usb_hid_boot_keyboard_input_report():" 455 "%s\n", str_error(rc)); 457 456 } 458 457 } … … 464 463 size_t actual_size; 465 464 466 printf("Polling keyboard...\n");465 usb_log_info("Polling keyboard...\n"); 467 466 468 467 while (true) { … … 471 470 sess_rc = usb_endpoint_pipe_start_session(&kbd_dev->poll_pipe); 472 471 if (sess_rc != EOK) { 473 printf("Failed to start a session: %s.\n",472 usb_log_warning("Failed to start a session: %s.\n", 474 473 str_error(sess_rc)); 475 474 continue; … … 481 480 482 481 if (rc != EOK) { 483 printf("Error polling the keyboard: %s.\n",482 usb_log_warning("Error polling the keyboard: %s.\n", 484 483 str_error(rc)); 485 484 continue; … … 487 486 488 487 if (sess_rc != EOK) { 489 printf("Error closing session: %s.\n",488 usb_log_warning("Error closing session: %s.\n", 490 489 str_error(sess_rc)); 491 490 continue; … … 497 496 */ 498 497 if (actual_size == 0) { 499 printf("Keyboard returned NAK\n");498 usb_log_debug("Keyboard returned NAK\n"); 500 499 continue; 501 500 } … … 504 503 * TODO: Process pressed keys. 505 504 */ 506 printf("Calling usbkbd_process_interrupt_in()\n");505 usb_log_debug("Calling usbkbd_process_interrupt_in()\n"); 507 506 usbkbd_process_interrupt_in(kbd_dev, buffer, actual_size); 508 507 } … … 514 513 static int usbkbd_fibril_device(void *arg) 515 514 { 516 printf("!!! USB device fibril\n");517 518 515 if (arg == NULL) { 519 printf("No device!\n");516 usb_log_error("No device!\n"); 520 517 return -1; 521 518 } … … 526 523 usb_hid_dev_kbd_t *kbd_dev = usbkbd_init_device(dev); 527 524 if (kbd_dev == NULL) { 528 printf("Error while initializing device.\n");525 usb_log_error("Error while initializing device.\n"); 529 526 return -1; 530 527 } … … 561 558 fid_t fid = fibril_create(usbkbd_fibril_device, dev); 562 559 if (fid == 0) { 563 printf("%s: failed to start fibril for HID device\n", NAME);560 usb_log_error("Failed to start fibril for HID device\n"); 564 561 return ENOMEM; 565 562 } … … 587 584 int main(int argc, char *argv[]) 588 585 { 586 usb_log_enable(USB_LOG_LEVEL_MAX, NAME); 589 587 return driver_main(&kbd_driver); 590 588 }
Note:
See TracChangeset
for help on using the changeset viewer.