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