Changes in uspace/srv/console/console.c [9f51afc:47a350f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/console/console.c
r9f51afc r47a350f 37 37 #include <ipc/kbd.h> 38 38 #include <io/keycode.h> 39 #include <ipc/mouse.h>40 39 #include <ipc/fb.h> 41 40 #include <ipc/services.h> … … 65 64 /** Phone to the keyboard driver. */ 66 65 static int kbd_phone; 67 68 /** Phone to the mouse driver. */69 static int mouse_phone;70 66 71 67 /** Information about framebuffer */ … … 430 426 } 431 427 432 /** Handler for mouse events */433 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall)434 {435 int button, press;436 int dx, dy;437 int newcon;438 439 /* Ignore parameters, the connection is already opened */440 while (true) {441 442 ipc_call_t call;443 ipc_callid_t callid = async_get_call(&call);444 445 int retval;446 447 switch (IPC_GET_METHOD(call)) {448 case IPC_M_PHONE_HUNGUP:449 /* TODO: Handle hangup */450 return;451 case MEVENT_BUTTON:452 button = IPC_GET_ARG1(call);453 press = IPC_GET_ARG2(call);454 if (button == 1) {455 newcon = gcons_mouse_btn(press);456 if (newcon != -1)457 change_console(&consoles[newcon]);458 }459 retval = 0;460 break;461 case MEVENT_MOVE:462 dx = IPC_GET_ARG1(call);463 dy = IPC_GET_ARG2(call);464 gcons_mouse_move(dx, dy);465 retval = 0;466 break;467 default:468 retval = ENOENT;469 }470 471 ipc_answer_0(callid, retval);472 }473 }474 475 428 static void cons_write(console_t *cons, ipc_callid_t rid, ipc_call_t *request) 476 429 { … … 722 675 return false; 723 676 } 724 677 725 678 kbd_phone = fd_phone(input_fd); 726 679 if (kbd_phone < 0) { … … 728 681 return false; 729 682 } 730 683 731 684 /* NB: The callback connection is slotted for removal */ 732 685 ipcarg_t phonehash; … … 735 688 return false; 736 689 } 737 690 738 691 async_new_connection(phonehash, 0, NULL, keyboard_events); 739 740 /* Connect to mouse device */741 mouse_phone = -1;742 int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);743 744 if (mouse_fd < 0) {745 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");746 goto skip_mouse;747 }748 749 mouse_phone = fd_phone(mouse_fd);750 if (mouse_phone < 0) {751 printf(NAME ": Failed to connect to mouse device\n");752 goto skip_mouse;753 }754 755 if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {756 printf(NAME ": Failed to create callback from mouse device\n");757 mouse_phone = -1;758 goto skip_mouse;759 }760 761 async_new_connection(phonehash, 0, NULL, mouse_events);762 skip_mouse:763 692 764 693 /* Connect to framebuffer driver */ … … 768 697 return -1; 769 698 } 770 699 771 700 /* Register driver */ 772 701 int rc = devmap_driver_register(NAME, client_connection);
Note:
See TracChangeset
for help on using the changeset viewer.