Changeset 16dc887 in mainline for uspace/srv/hid/input/generic/input.c
- Timestamp:
- 2011-08-16T14:00:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 278ac72, b112055
- Parents:
- 3751a08 (diff), cc574511 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/generic/input.c
r3751a08 r16dc887 38 38 39 39 #include <adt/list.h> 40 #include <bool.h> 40 41 #include <ipc/services.h> 41 42 #include <ipc/input.h> … … 53 54 #include <io/console.h> 54 55 #include <io/keycode.h> 55 #include < devmap.h>56 #include <loc.h> 56 57 #include <input.h> 57 58 #include <kbd.h> … … 275 276 kdev->port_ops = port; 276 277 kdev->ctl_ops = ctl; 277 kdev-> dev_path = NULL;278 kdev->service_id = 0; 278 279 279 280 /* Initialize port driver. */ … … 303 304 mdev->port_ops = port; 304 305 mdev->proto_ops = proto; 305 mdev-> dev_path = NULL;306 mdev->service_id = 0; 306 307 307 308 /* Initialize port driver. */ … … 324 325 /** Add new kbdev device. 325 326 * 326 * @param dev_path Filesystem path to the device (/dev/class/...)327 * @param service_id Service ID of the keyboard device 327 328 * 328 329 */ 329 static int kbd_add_kbdev( const char *dev_path)330 static int kbd_add_kbdev(service_id_t service_id) 330 331 { 331 332 kbd_dev_t *kdev = kbd_dev_new(); … … 333 334 return -1; 334 335 335 kdev-> dev_path = dev_path;336 kdev->service_id = service_id; 336 337 kdev->port_ops = NULL; 337 338 kdev->ctl_ops = &kbdev_ctl; … … 352 353 /** Add new mousedev device. 353 354 * 354 * @param dev_path Filesystem path to the device (/dev/class/...)355 * @param service_id Service ID of the mouse device 355 356 * 356 357 */ 357 static int mouse_add_mousedev( const char *dev_path)358 static int mouse_add_mousedev(service_id_t service_id) 358 359 { 359 360 mouse_dev_t *mdev = mouse_dev_new(); … … 361 362 return -1; 362 363 363 mdev-> dev_path = dev_path;364 mdev->service_id = service_id; 364 365 mdev->port_ops = NULL; 365 366 mdev->proto_ops = &mousedev_proto; … … 482 483 /** Periodically check for new input devices. 483 484 * 484 * Looks under / dev/class/keyboard and /dev/class/mouse.485 * Looks under /loc/class/keyboard and /loc/class/mouse. 485 486 * 486 487 * @param arg Ignored 487 488 * 488 489 */ 490 #include <sys/typefmt.h> 489 491 static int dev_discovery_fibril(void *arg) 490 492 { 491 char *dev_path; 492 size_t kbd_id = 1; 493 size_t mouse_id = 1; 493 category_id_t keyboard_cat, mouse_cat; 494 service_id_t *svcs; 495 size_t count, i; 496 bool already_known; 497 const char *dev_name = "todo"; 494 498 int rc; 499 500 rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING); 501 if (rc != EOK) { 502 printf("%s: Failed resolving category 'keyboard'.\n", NAME); 503 return ENOENT; 504 } 505 506 rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING); 507 if (rc != EOK) { 508 printf("%s: Failed resolving category 'mouse'.\n", NAME); 509 return ENOENT; 510 } 495 511 496 512 while (true) { … … 498 514 499 515 /* 500 * Check for new keyboard device 516 * Check for new keyboard devices 501 517 */ 502 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id); 503 if (rc < 0) 518 rc = loc_category_get_svcs(keyboard_cat, &svcs, &count); 519 if (rc != EOK) { 520 printf("%s: Failed getting list of keyboard devices.\n", 521 NAME); 504 522 continue; 505 506 if (kbd_add_kbdev(dev_path) == EOK) { 507 printf("%s: Connected keyboard device '%s'\n",508 NAME, dev_path);523 } 524 525 for (i = 0; i < count; i++) { 526 already_known = false; 509 527 510 /* XXX Handle device removal */ 511 ++kbd_id; 528 /* Determine whether we already know this device. */ 529 list_foreach(kbd_devs, kdev_link) { 530 kbd_dev_t *kdev = list_get_instance(kdev_link, 531 kbd_dev_t, kbd_devs); 532 if (kdev->service_id == svcs[i]) { 533 already_known = true; 534 break; 535 } 536 } 537 538 if (!already_known) { 539 if (kbd_add_kbdev(svcs[i]) == EOK) { 540 printf("%s: Connected keyboard device '%s'\n", 541 NAME, dev_name); 542 } 543 } 512 544 } 513 545 514 free(dev_path);546 /* XXX Handle device removal */ 515 547 516 548 /* 517 * Check for new mouse device 549 * Check for new mouse devices 518 550 */ 519 rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id); 520 if (rc < 0) 551 rc = loc_category_get_svcs(mouse_cat, &svcs, &count); 552 if (rc != EOK) { 553 printf("%s: Failed getting list of mouse devices.\n", 554 NAME); 521 555 continue; 522 523 if (mouse_add_mousedev(dev_path) == EOK) { 524 printf("%s: Connected mouse device '%s'\n",525 NAME, dev_path);556 } 557 558 for (i = 0; i < count; i++) { 559 already_known = false; 526 560 527 /* XXX Handle device removal */ 528 ++mouse_id; 561 /* Determine whether we already know this device. */ 562 list_foreach(mouse_devs, mdev_link) { 563 mouse_dev_t *mdev = list_get_instance(mdev_link, 564 mouse_dev_t, mouse_devs); 565 if (mdev->service_id == svcs[i]) { 566 already_known = true; 567 break; 568 } 569 } 570 571 if (!already_known) { 572 if (mouse_add_mousedev(svcs[i]) == EOK) { 573 printf("%s: Connected mouse device '%s'\n", 574 NAME, dev_name); 575 } 576 } 529 577 } 530 578 531 free(dev_path);579 /* XXX Handle device removal */ 532 580 } 533 581 … … 567 615 /* Add legacy keyboard devices. */ 568 616 kbd_add_legacy_devs(); 569 617 570 618 /* Add legacy mouse devices. */ 571 619 mouse_add_legacy_devs(); 572 620 573 621 /* Register driver */ 574 int rc = devmap_driver_register(NAME, client_connection);622 int rc = loc_server_register(NAME, client_connection); 575 623 if (rc < 0) { 576 printf("%s: Unable to register driver (%d)\n", NAME, rc);624 printf("%s: Unable to register server (%d)\n", NAME, rc); 577 625 return -1; 578 626 } 579 627 580 char kbd[ DEVMAP_NAME_MAXLEN + 1];581 snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);582 583 devmap_handle_t devmap_handle;584 if ( devmap_device_register(kbd, &devmap_handle) != EOK) {585 printf("%s: Unable to register device %s\n", NAME, kbd);628 char kbd[LOC_NAME_MAXLEN + 1]; 629 snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 630 631 service_id_t service_id; 632 if (loc_service_register(kbd, &service_id) != EOK) { 633 printf("%s: Unable to register service %s\n", NAME, kbd); 586 634 return -1; 587 635 }
Note:
See TracChangeset
for help on using the changeset viewer.