Changes in uspace/srv/hid/console/console.c [19f857a:369a5f8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r19f857a r369a5f8 54 54 #include <vfs/vfs.h> 55 55 #include <fibril_synch.h> 56 #include <io/style.h> 57 #include <io/screenbuffer.h> 56 58 57 59 #include "console.h" 58 60 #include "gcons.h" 59 61 #include "keybuffer.h" 60 #include "screenbuffer.h" 62 61 63 62 64 #define NAME "console" … … 71 73 /** Information about framebuffer */ 72 74 struct { 73 int phone; /**< Framebuffer phone */74 ipcarg_t cols; /**< Framebuffer columns */75 ipcarg_t rows; /**< Framebuffer rows */76 i nt color_cap; /**< Color capabilities (FB_CCAP_xxx) */75 int phone; /**< Framebuffer phone */ 76 ipcarg_t cols; /**< Framebuffer columns */ 77 ipcarg_t rows; /**< Framebuffer rows */ 78 ipcarg_t color_cap; /**< Color capabilities (FB_CCAP_xxx) */ 77 79 } fb_info; 78 80 … … 99 101 /** Information on row-span yet unsent to FB driver. */ 100 102 struct { 101 size_t col; /**< Leftmost column of the span. */102 size_t row; /**< Row where the span lies. */103 size_t cnt; /**< Width of the span. */103 ipcarg_t col; /**< Leftmost column of the span. */ 104 ipcarg_t row; /**< Row where the span lies. */ 105 ipcarg_t cnt; /**< Width of the span. */ 104 106 } fb_pending; 105 107 … … 117 119 } 118 120 119 static void curs_goto( size_t x, size_t y)121 static void curs_goto(ipcarg_t x, ipcarg_t y) 120 122 { 121 123 async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y); … … 147 149 } 148 150 149 static void set_style( int style)151 static void set_style(uint8_t style) 150 152 { 151 153 async_msg_1(fb_info.phone, FB_SET_STYLE, style); 152 154 } 153 155 154 static void set_color( int fgcolor, int bgcolor, int flags)156 static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags) 155 157 { 156 158 async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags); 157 159 } 158 160 159 static void set_rgb_color( int fgcolor, int bgcolor)161 static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor) 160 162 { 161 163 async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor); … … 178 180 } 179 181 180 static int ccap_fb_to_con(i nt ccap_fb, int *ccap_con)182 static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con) 181 183 { 182 184 switch (ccap_fb) { 183 case FB_CCAP_NONE: *ccap_con = CONSOLE_CCAP_NONE; break; 184 case FB_CCAP_STYLE: *ccap_con = CONSOLE_CCAP_STYLE; break; 185 case FB_CCAP_INDEXED: *ccap_con = CONSOLE_CCAP_INDEXED; break; 186 case FB_CCAP_RGB: *ccap_con = CONSOLE_CCAP_RGB; break; 187 default: return EINVAL; 188 } 189 185 case FB_CCAP_NONE: 186 *ccap_con = CONSOLE_CCAP_NONE; 187 break; 188 case FB_CCAP_STYLE: 189 *ccap_con = CONSOLE_CCAP_STYLE; 190 break; 191 case FB_CCAP_INDEXED: 192 *ccap_con = CONSOLE_CCAP_INDEXED; 193 break; 194 case FB_CCAP_RGB: 195 *ccap_con = CONSOLE_CCAP_RGB; 196 break; 197 default: 198 return EINVAL; 199 } 200 190 201 return EOK; 191 202 } … … 226 237 * 227 238 */ 228 static void cell_mark_changed( size_t col, size_t row)239 static void cell_mark_changed(ipcarg_t col, ipcarg_t row) 229 240 { 230 241 if (fb_pending.cnt != 0) { … … 253 264 { 254 265 bool flush_cursor = false; 255 266 256 267 switch (ch) { 257 268 case '\n': … … 297 308 async_msg_1(fb_info.phone, FB_SCROLL, 1); 298 309 } 299 310 300 311 if (cons == active_console && flush_cursor) 301 312 curs_goto(cons->scr.position_x, cons->scr.position_y); … … 327 338 328 339 if (cons != kernel_console) { 329 size_t x;330 size_t y;331 int rc = 0;332 333 340 async_serialize_start(); 334 341 … … 344 351 set_attrs(&cons->scr.attrs); 345 352 curs_visibility(false); 353 354 ipcarg_t x; 355 ipcarg_t y; 356 int rc = 0; 357 346 358 if (interbuffer) { 347 359 for (y = 0; y < cons->scr.size_y; y++) { … … 390 402 /* Ignore parameters, the connection is already opened */ 391 403 while (true) { 392 393 404 ipc_call_t call; 394 405 ipc_callid_t callid = async_get_call(&call); … … 433 444 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall) 434 445 { 435 int button, press;436 int dx, dy;437 int newcon;438 439 446 /* Ignore parameters, the connection is already opened */ 440 447 while (true) { 441 442 448 ipc_call_t call; 443 449 ipc_callid_t callid = async_get_call(&call); 444 450 445 451 int retval; 446 452 447 453 switch (IPC_GET_METHOD(call)) { 448 454 case IPC_M_PHONE_HUNGUP: … … 450 456 return; 451 457 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); 458 if (IPC_GET_ARG1(call) == 1) { 459 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); 456 460 if (newcon != -1) 457 461 change_console(&consoles[newcon]); … … 460 464 break; 461 465 case MEVENT_MOVE: 462 dx = IPC_GET_ARG1(call); 463 dy = IPC_GET_ARG2(call); 464 gcons_mouse_move(dx, dy); 466 gcons_mouse_move((int) IPC_GET_ARG1(call), 467 (int) IPC_GET_ARG2(call)); 465 468 retval = 0; 466 469 break; … … 520 523 console_event_t ev; 521 524 fibril_mutex_lock(&input_mutex); 525 522 526 recheck: 523 527 while ((keybuffer_pop(&cons->keybuffer, &ev)) && (pos < size)) { … … 536 540 goto recheck; 537 541 } 542 538 543 fibril_mutex_unlock(&input_mutex); 539 544 } … … 542 547 { 543 548 console_event_t ev; 544 549 545 550 fibril_mutex_lock(&input_mutex); 551 546 552 recheck: 547 553 if (keybuffer_pop(&cons->keybuffer, &ev)) { … … 551 557 goto recheck; 552 558 } 559 553 560 fibril_mutex_unlock(&input_mutex); 554 561 } … … 580 587 ipcarg_t arg2; 581 588 ipcarg_t arg3; 582 583 int cons_ccap; 589 584 590 int rc; 585 591 … … 622 628 if (cons == active_console) { 623 629 async_req_0_0(fb_info.phone, FB_FLUSH); 624 625 630 curs_goto(cons->scr.position_x, cons->scr.position_y); 626 631 } … … 650 655 break; 651 656 case CONSOLE_GET_COLOR_CAP: 652 rc = ccap_fb_to_con(fb_info.color_cap, & cons_ccap);657 rc = ccap_fb_to_con(fb_info.color_cap, &arg1); 653 658 if (rc != EOK) { 654 659 ipc_answer_0(callid, rc); 655 660 continue; 656 661 } 657 arg1 = cons_ccap;658 662 break; 659 663 case CONSOLE_SET_STYLE: … … 714 718 return false; 715 719 } 716 720 717 721 kbd_phone = fd_phone(input_fd); 718 722 if (kbd_phone < 0) { … … 720 724 return false; 721 725 } 722 726 723 727 /* NB: The callback connection is slotted for removal */ 724 728 ipcarg_t phonehash; … … 727 731 return false; 728 732 } 729 733 730 734 async_new_connection(phonehash, 0, NULL, keyboard_events); 731 735 732 736 /* Connect to mouse device */ 733 737 mouse_phone = -1; 734 738 int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY); 735 739 736 740 if (mouse_fd < 0) { 737 741 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse"); 738 742 goto skip_mouse; 739 743 } 740 744 741 745 mouse_phone = fd_phone(mouse_fd); 742 746 if (mouse_phone < 0) { … … 744 748 goto skip_mouse; 745 749 } 746 750 747 751 if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { 748 752 printf(NAME ": Failed to create callback from mouse device\n"); … … 750 754 goto skip_mouse; 751 755 } 752 756 753 757 async_new_connection(phonehash, 0, NULL, mouse_events); 754 758 skip_mouse: 755 759 756 760 /* Connect to framebuffer driver */ 757 761 fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0); … … 760 764 return -1; 761 765 } 762 766 763 767 /* Register driver */ 764 768 int rc = devmap_driver_register(NAME, client_connection); … … 772 776 773 777 /* Synchronize, the gcons could put something in queue */ 774 ipcarg_t color_cap;775 778 async_req_0_0(fb_info.phone, FB_FLUSH); 776 779 async_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows); 777 async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &color_cap); 778 fb_info.color_cap = color_cap; 780 async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap); 779 781 780 782 /* Set up shared memory buffer. */ … … 827 829 async_serialize_start(); 828 830 gcons_redraw_console(); 829 set_ rgb_color(DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);831 set_style(STYLE_NORMAL); 830 832 screen_clear(); 831 833 curs_goto(0, 0);
Note:
See TracChangeset
for help on using the changeset viewer.