Changes in uspace/srv/hid/console/console.c [6d5e378:8a99c7e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r6d5e378 r8a99c7e 44 44 #include <event.h> 45 45 #include <io/keycode.h> 46 #include < io/chargrid.h>47 #include < io/console.h>48 #include <i o/output.h>46 #include <screenbuffer.h> 47 #include <fb.h> 48 #include <imgmap.h> 49 49 #include <align.h> 50 50 #include <malloc.h> 51 51 #include <as.h> 52 52 #include <fibril_synch.h> 53 #include "images.h" 53 54 #include "console.h" 54 55 … … 56 57 #define NAMESPACE "term" 57 58 58 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 59 #define CONSOLE_TOP 66 60 #define CONSOLE_MARGIN 12 61 62 #define STATE_START 100 63 #define STATE_TOP 8 64 #define STATE_SPACE 4 65 #define STATE_WIDTH 48 66 #define STATE_HEIGHT 48 67 68 typedef enum { 69 CONS_DISCONNECTED = 0, 70 CONS_DISCONNECTED_SELECTED, 71 CONS_SELECTED, 72 CONS_IDLE, 73 CONS_DATA, 74 CONS_KERNEL, 75 CONS_LAST 76 } console_state_t; 77 78 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 59 79 60 80 typedef struct { 61 atomic_t refcnt; /**< Connection reference count */ 62 prodcons_t input_pc; /**< Incoming keyboard events */ 63 64 /** 65 * Not yet sent bytes of last char event. 66 */ 67 char char_remains[UTF8_CHAR_BUFFER_SIZE]; 68 size_t char_remains_len; /**< Number of not yet sent bytes. */ 69 70 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 71 72 size_t index; /**< Console index */ 73 service_id_t dsid; /**< Service handle */ 74 75 sysarg_t cols; /**< Number of columns */ 76 sysarg_t rows; /**< Number of rows */ 77 console_caps_t ccaps; /**< Console capabilities */ 78 79 chargrid_t *frontbuf; /**< Front buffer */ 80 frontbuf_handle_t fbid; /**< Front buffer handle */ 81 atomic_t refcnt; /**< Connection reference count */ 82 prodcons_t input_pc; /**< Incoming keyboard events */ 83 char char_remains[UTF8_CHAR_BUFFER_SIZE]; /**< Not yet sent bytes of last char event. */ 84 size_t char_remains_len; /**< Number of not yet sent bytes. */ 85 86 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 87 88 size_t index; /**< Console index */ 89 console_state_t state; /**< Console state */ 90 service_id_t dsid; /**< Service handle */ 91 92 vp_handle_t state_vp; /**< State icon viewport */ 93 sysarg_t cols; /**< Number of columns */ 94 sysarg_t rows; /**< Number of rows */ 95 console_caps_t ccaps; /**< Console capabilities */ 96 97 screenbuffer_t *frontbuf; /**< Front buffer */ 98 frontbuf_handle_t fbid; /**< Front buffer handle */ 81 99 } console_t; 100 101 typedef enum { 102 GRAPHICS_NONE = 0, 103 GRAPHICS_BASIC = 1, 104 GRAPHICS_FULL = 2 105 } graphics_state_t; 106 107 /** Current console state */ 108 static graphics_state_t graphics_state = GRAPHICS_NONE; 109 110 /** State icons */ 111 static imagemap_handle_t state_icons[CONS_LAST]; 82 112 83 113 /** Session to the input server */ 84 114 static async_sess_t *input_sess; 85 115 86 /** Session to the outputserver */87 static async_sess_t * output_sess;88 89 /** Output dimensions*/90 static sysarg_t cols;91 static sysarg_t rows;116 /** Session to the framebuffer server */ 117 static async_sess_t *fb_sess; 118 119 /** Framebuffer resolution */ 120 static sysarg_t xres; 121 static sysarg_t yres; 92 122 93 123 /** Array of data for virtual consoles */ … … 101 131 static console_t *kernel_console = &consoles[KERNEL_CONSOLE]; 102 132 133 static imgmap_t *logo_img; 134 static imgmap_t *nameic_img; 135 136 static imgmap_t *anim_1_img; 137 static imgmap_t *anim_2_img; 138 static imgmap_t *anim_3_img; 139 static imgmap_t *anim_4_img; 140 141 static imagemap_handle_t anim_1; 142 static imagemap_handle_t anim_2; 143 static imagemap_handle_t anim_3; 144 static imagemap_handle_t anim_4; 145 146 static sequence_handle_t anim_seq; 147 148 static imgmap_t *cons_data_img; 149 static imgmap_t *cons_dis_img; 150 static imgmap_t *cons_dis_sel_img; 151 static imgmap_t *cons_idle_img; 152 static imgmap_t *cons_kernel_img; 153 static imgmap_t *cons_sel_img; 154 155 static vp_handle_t logo_vp; 156 static imagemap_handle_t logo_handle; 157 158 static vp_handle_t nameic_vp; 159 static imagemap_handle_t nameic_handle; 160 161 static vp_handle_t screen_vp; 162 static vp_handle_t console_vp; 163 164 struct { 165 sysarg_t x; 166 sysarg_t y; 167 168 sysarg_t btn_x; 169 sysarg_t btn_y; 170 171 bool pressed; 172 } mouse; 173 174 static void cons_redraw_state(console_t *cons) 175 { 176 if (graphics_state == GRAPHICS_FULL) { 177 fibril_mutex_lock(&cons->mtx); 178 179 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 180 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 181 182 if ((cons->state != CONS_DISCONNECTED) && 183 (cons->state != CONS_KERNEL) && 184 (cons->state != CONS_DISCONNECTED_SELECTED)) { 185 char data[5]; 186 snprintf(data, 5, "%zu", cons->index + 1); 187 188 for (size_t i = 0; data[i] != 0; i++) 189 fb_vp_putchar(fb_sess, cons->state_vp, i + 2, 1, data[i]); 190 } 191 192 fibril_mutex_unlock(&cons->mtx); 193 } 194 } 195 196 static void cons_kernel_sequence_start(console_t *cons) 197 { 198 if (graphics_state == GRAPHICS_FULL) { 199 fibril_mutex_lock(&cons->mtx); 200 201 fb_vp_sequence_start(fb_sess, cons->state_vp, anim_seq); 202 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 203 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 204 205 fibril_mutex_unlock(&cons->mtx); 206 } 207 } 208 209 static void cons_update_state(console_t *cons, console_state_t state) 210 { 211 bool update = false; 212 213 fibril_mutex_lock(&cons->mtx); 214 215 if (cons->state != state) { 216 cons->state = state; 217 update = true; 218 } 219 220 fibril_mutex_unlock(&cons->mtx); 221 222 if (update) 223 cons_redraw_state(cons); 224 } 225 226 static void cons_notify_data(console_t *cons) 227 { 228 fibril_mutex_lock(&switch_mtx); 229 230 if (cons != active_console) 231 cons_update_state(cons, CONS_DATA); 232 233 fibril_mutex_unlock(&switch_mtx); 234 } 235 236 static void cons_notify_connect(console_t *cons) 237 { 238 fibril_mutex_lock(&switch_mtx); 239 240 if (cons == active_console) 241 cons_update_state(cons, CONS_SELECTED); 242 else 243 cons_update_state(cons, CONS_IDLE); 244 245 fibril_mutex_unlock(&switch_mtx); 246 } 247 248 static void cons_notify_disconnect(console_t *cons) 249 { 250 fibril_mutex_lock(&switch_mtx); 251 252 if (cons == active_console) 253 cons_update_state(cons, CONS_DISCONNECTED_SELECTED); 254 else 255 cons_update_state(cons, CONS_DISCONNECTED); 256 257 fibril_mutex_unlock(&switch_mtx); 258 } 259 103 260 static void cons_update(console_t *cons) 104 261 { … … 107 264 108 265 if ((cons == active_console) && (active_console != kernel_console)) { 109 output_update(output_sess, cons->fbid);110 output_cursor_update(output_sess, cons->fbid);266 fb_vp_update(fb_sess, console_vp, cons->fbid); 267 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 111 268 } 112 269 … … 121 278 122 279 if ((cons == active_console) && (active_console != kernel_console)) 123 output_cursor_update(output_sess, cons->fbid);280 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 124 281 125 282 fibril_mutex_unlock(&cons->mtx); … … 130 287 { 131 288 fibril_mutex_lock(&cons->mtx); 132 chargrid_clear(cons->frontbuf);289 screenbuffer_clear(cons->frontbuf); 133 290 fibril_mutex_unlock(&cons->mtx); 134 291 … … 136 293 } 137 294 138 static void cons_damage (console_t *cons)295 static void cons_damage_all(console_t *cons) 139 296 { 140 297 fibril_mutex_lock(&switch_mtx); … … 142 299 143 300 if ((cons == active_console) && (active_console != kernel_console)) { 144 output_damage(output_sess, cons->fbid, 0, 0, cons->cols,301 fb_vp_damage(fb_sess, console_vp, cons->fbid, 0, 0, cons->cols, 145 302 cons->rows); 146 output_cursor_update(output_sess, cons->fbid);303 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 147 304 } 148 305 … … 161 318 162 319 if (cons == kernel_console) { 163 output_yield(output_sess);320 fb_yield(fb_sess); 164 321 if (!console_kcon()) { 165 output_claim(output_sess);322 fb_claim(fb_sess); 166 323 fibril_mutex_unlock(&switch_mtx); 167 324 return; … … 170 327 171 328 if (active_console == kernel_console) 172 output_claim(output_sess);329 fb_claim(fb_sess); 173 330 174 331 prev_console = active_console; 175 332 active_console = cons; 176 333 334 if (prev_console->state == CONS_DISCONNECTED_SELECTED) 335 cons_update_state(prev_console, CONS_DISCONNECTED); 336 else 337 cons_update_state(prev_console, CONS_IDLE); 338 339 if ((cons->state == CONS_DISCONNECTED) || 340 (cons->state == CONS_DISCONNECTED_SELECTED)) 341 cons_update_state(cons, CONS_DISCONNECTED_SELECTED); 342 else 343 cons_update_state(cons, CONS_SELECTED); 344 177 345 fibril_mutex_unlock(&switch_mtx); 178 346 179 cons_damage (cons);347 cons_damage_all(cons); 180 348 } 181 349 … … 183 351 { 184 352 fibril_mutex_lock(&switch_mtx); 185 353 186 354 console_t *active_uspace = active_console; 187 if (active_uspace == kernel_console) 355 if (active_uspace == kernel_console) { 188 356 active_uspace = prev_console; 189 357 } 190 358 assert(active_uspace != kernel_console); 191 359 192 360 fibril_mutex_unlock(&switch_mtx); 193 361 194 362 return active_uspace; 363 } 364 365 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi) 366 { 367 if (val > hi) 368 return hi; 369 370 if (val < lo) 371 return lo; 372 373 return val; 374 } 375 376 static void cons_mouse_move(sysarg_t dx, sysarg_t dy) 377 { 378 ssize_t sx = (ssize_t) dx; 379 ssize_t sy = (ssize_t) dy; 380 381 mouse.x = limit(mouse.x + sx, 0, xres); 382 mouse.y = limit(mouse.y + sy, 0, yres); 383 384 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 385 } 386 387 static void cons_mouse_abs_move(sysarg_t x, sysarg_t y, 388 sysarg_t max_x, sysarg_t max_y) 389 { 390 if (max_x && max_y) { 391 mouse.x = limit(x * xres / max_x, 0, xres); 392 mouse.y = limit(y * yres / max_y, 0, yres); 393 394 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 395 } 396 } 397 398 static console_t *cons_find_icon(sysarg_t x, sysarg_t y) 399 { 400 sysarg_t status_start = 401 STATE_START + (xres - 800) / 2 + CONSOLE_MARGIN; 402 403 if ((y < STATE_TOP) || (y >= STATE_TOP + STATE_HEIGHT)) 404 return NULL; 405 406 if (x < status_start) 407 return NULL; 408 409 if (x >= status_start + (STATE_WIDTH + STATE_SPACE) * CONSOLE_COUNT) 410 return NULL; 411 412 if (((x - status_start) % (STATE_WIDTH + STATE_SPACE)) >= STATE_WIDTH) 413 return NULL; 414 415 sysarg_t btn = (x - status_start) / (STATE_WIDTH + STATE_SPACE); 416 417 if (btn < CONSOLE_COUNT) 418 return consoles + btn; 419 420 return NULL; 421 } 422 423 /** Handle mouse click 424 * 425 * @param state Button state (true - pressed, false - depressed) 426 * 427 */ 428 static console_t *cons_mouse_button(bool state) 429 { 430 if (graphics_state != GRAPHICS_FULL) 431 return NULL; 432 433 if (state) { 434 console_t *cons = cons_find_icon(mouse.x, mouse.y); 435 if (cons != NULL) { 436 mouse.btn_x = mouse.x; 437 mouse.btn_y = mouse.y; 438 mouse.pressed = true; 439 } 440 441 return NULL; 442 } 443 444 if ((!state) && (!mouse.pressed)) 445 return NULL; 446 447 console_t *cons = cons_find_icon(mouse.x, mouse.y); 448 if (cons == cons_find_icon(mouse.btn_x, mouse.btn_y)) 449 return cons; 450 451 mouse.pressed = false; 452 return NULL; 195 453 } 196 454 … … 253 511 break; 254 512 case INPUT_EVENT_MOVE: 513 cons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 255 514 async_answer_0(callid, EOK); 256 515 break; 516 case INPUT_EVENT_ABS_MOVE: 517 cons_mouse_abs_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call), 518 IPC_GET_ARG3(call), IPC_GET_ARG4(call)); 519 async_answer_0(callid, EOK); 520 break; 257 521 case INPUT_EVENT_BUTTON: 522 /* Got pointer button press/release event */ 523 if (IPC_GET_ARG1(call) == 1) { 524 console_t *cons = 525 cons_mouse_button((bool) IPC_GET_ARG2(call)); 526 if (cons != NULL) 527 cons_switch(cons); 528 } 258 529 async_answer_0(callid, EOK); 259 530 break; … … 273 544 switch (ch) { 274 545 case '\n': 275 updated = chargrid_newline(cons->frontbuf);546 updated = screenbuffer_newline(cons->frontbuf); 276 547 break; 277 548 case '\r': 278 549 break; 279 550 case '\t': 280 updated = chargrid_tabstop(cons->frontbuf, 8);551 updated = screenbuffer_tabstop(cons->frontbuf, 8); 281 552 break; 282 553 case '\b': 283 updated = chargrid_backspace(cons->frontbuf);554 updated = screenbuffer_backspace(cons->frontbuf); 284 555 break; 285 556 default: 286 updated = chargrid_putchar(cons->frontbuf, ch, true);557 updated = screenbuffer_putchar(cons->frontbuf, ch, true); 287 558 } 288 559 … … 296 567 { 297 568 fibril_mutex_lock(&cons->mtx); 298 chargrid_set_cursor(cons->frontbuf, col, row);569 screenbuffer_set_cursor(cons->frontbuf, col, row); 299 570 fibril_mutex_unlock(&cons->mtx); 300 571 … … 305 576 { 306 577 fibril_mutex_lock(&cons->mtx); 307 chargrid_set_cursor_visibility(cons->frontbuf, visible);578 screenbuffer_set_cursor_visibility(cons->frontbuf, visible); 308 579 fibril_mutex_unlock(&cons->mtx); 309 580 … … 317 588 318 589 fibril_mutex_lock(&cons->mtx); 319 chargrid_get_cursor(cons->frontbuf, &col, &row);590 screenbuffer_get_cursor(cons->frontbuf, &col, &row); 320 591 fibril_mutex_unlock(&cons->mtx); 321 592 … … 340 611 async_answer_1(iid, EOK, size); 341 612 free(buf); 613 614 cons_notify_data(cons); 342 615 } 343 616 … … 403 676 { 404 677 fibril_mutex_lock(&cons->mtx); 405 chargrid_set_style(cons->frontbuf, style);678 screenbuffer_set_style(cons->frontbuf, style); 406 679 fibril_mutex_unlock(&cons->mtx); 407 680 } … … 411 684 { 412 685 fibril_mutex_lock(&cons->mtx); 413 chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr);686 screenbuffer_set_color(cons->frontbuf, bgcolor, fgcolor, attr); 414 687 fibril_mutex_unlock(&cons->mtx); 415 688 } … … 419 692 { 420 693 fibril_mutex_lock(&cons->mtx); 421 chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);694 screenbuffer_set_rgb_color(cons->frontbuf, bgcolor, fgcolor); 422 695 fibril_mutex_unlock(&cons->mtx); 423 696 } … … 451 724 } 452 725 453 if (atomic_postinc(&cons->refcnt) == 0) 726 if (atomic_postinc(&cons->refcnt) == 0) { 454 727 cons_set_cursor_visibility(cons, true); 728 cons_notify_connect(cons); 729 } 455 730 456 731 /* Accept the connection */ … … 461 736 ipc_callid_t callid = async_get_call(&call); 462 737 463 if (!IPC_GET_IMETHOD(call)) 738 if (!IPC_GET_IMETHOD(call)) { 739 if (atomic_postdec(&cons->refcnt) == 1) 740 cons_notify_disconnect(cons); 741 464 742 return; 743 } 465 744 466 745 switch (IPC_GET_IMETHOD(call)) { … … 553 832 } 554 833 555 static async_sess_t * output_connect(const char *svc)834 static async_sess_t *fb_connect(const char *svc) 556 835 { 557 836 async_sess_t *sess; … … 562 841 sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0); 563 842 if (sess == NULL) { 564 printf("%s: Unable to connect to outputservice %s\n",843 printf("%s: Unable to connect to framebuffer service %s\n", 565 844 NAME, svc); 566 845 return NULL; … … 572 851 } 573 852 574 static bool console_srv_init(char *input_svc, char *output_svc) 575 { 853 static bool console_srv_init(char *input_svc, char *fb_svc) 854 { 855 /* Avoid double initialization */ 856 if (graphics_state != GRAPHICS_NONE) 857 return false; 858 576 859 /* Connect to input service */ 577 860 input_sess = input_connect(input_svc); … … 579 862 return false; 580 863 581 /* Connect to outputservice */582 output_sess = output_connect(output_svc);583 if ( output_sess == NULL)864 /* Connect to framebuffer service */ 865 fb_sess = fb_connect(fb_svc); 866 if (fb_sess == NULL) 584 867 return false; 585 868 … … 593 876 } 594 877 595 output_get_dimensions(output_sess, &cols, &rows); 596 output_set_style(output_sess, STYLE_NORMAL); 878 fb_get_resolution(fb_sess, &xres, &yres); 879 880 /* Initialize the screen */ 881 screen_vp = fb_vp_create(fb_sess, 0, 0, xres, yres); 882 883 if ((xres >= 800) && (yres >= 600)) { 884 logo_vp = fb_vp_create(fb_sess, xres - 66, 2, 64, 60); 885 logo_img = imgmap_decode_tga((void *) helenos_tga, 886 helenos_tga_size, IMGMAP_FLAG_SHARED); 887 logo_handle = fb_imagemap_create(fb_sess, logo_img); 888 889 nameic_vp = fb_vp_create(fb_sess, 5, 17, 100, 26); 890 nameic_img = imgmap_decode_tga((void *) nameic_tga, 891 nameic_tga_size, IMGMAP_FLAG_SHARED); 892 nameic_handle = fb_imagemap_create(fb_sess, nameic_img); 893 894 cons_data_img = imgmap_decode_tga((void *) cons_data_tga, 895 cons_data_tga_size, IMGMAP_FLAG_SHARED); 896 cons_dis_img = imgmap_decode_tga((void *) cons_dis_tga, 897 cons_dis_tga_size, IMGMAP_FLAG_SHARED); 898 cons_dis_sel_img = imgmap_decode_tga((void *) cons_dis_sel_tga, 899 cons_dis_sel_tga_size, IMGMAP_FLAG_SHARED); 900 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 901 cons_idle_tga_size, IMGMAP_FLAG_SHARED); 902 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 903 cons_kernel_tga_size, IMGMAP_FLAG_SHARED); 904 cons_sel_img = imgmap_decode_tga((void *) cons_sel_tga, 905 cons_sel_tga_size, IMGMAP_FLAG_SHARED); 906 907 state_icons[CONS_DISCONNECTED] = 908 fb_imagemap_create(fb_sess, cons_dis_img); 909 state_icons[CONS_DISCONNECTED_SELECTED] = 910 fb_imagemap_create(fb_sess, cons_dis_sel_img); 911 state_icons[CONS_SELECTED] = 912 fb_imagemap_create(fb_sess, cons_sel_img); 913 state_icons[CONS_IDLE] = 914 fb_imagemap_create(fb_sess, cons_idle_img); 915 state_icons[CONS_DATA] = 916 fb_imagemap_create(fb_sess, cons_data_img); 917 state_icons[CONS_KERNEL] = 918 fb_imagemap_create(fb_sess, cons_kernel_img); 919 920 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 921 anim_1_tga_size, IMGMAP_FLAG_SHARED); 922 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 923 anim_2_tga_size, IMGMAP_FLAG_SHARED); 924 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 925 anim_3_tga_size, IMGMAP_FLAG_SHARED); 926 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 927 anim_4_tga_size, IMGMAP_FLAG_SHARED); 928 929 anim_1 = fb_imagemap_create(fb_sess, anim_1_img); 930 anim_2 = fb_imagemap_create(fb_sess, anim_2_img); 931 anim_3 = fb_imagemap_create(fb_sess, anim_3_img); 932 anim_4 = fb_imagemap_create(fb_sess, anim_4_img); 933 934 anim_seq = fb_sequence_create(fb_sess); 935 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_1); 936 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_2); 937 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_3); 938 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_4); 939 940 console_vp = fb_vp_create(fb_sess, CONSOLE_MARGIN, CONSOLE_TOP, 941 xres - 2 * CONSOLE_MARGIN, yres - (CONSOLE_TOP + CONSOLE_MARGIN)); 942 943 fb_vp_clear(fb_sess, screen_vp); 944 fb_vp_imagemap_damage(fb_sess, logo_vp, logo_handle, 945 0, 0, 64, 60); 946 fb_vp_imagemap_damage(fb_sess, nameic_vp, nameic_handle, 947 0, 0, 100, 26); 948 949 graphics_state = GRAPHICS_FULL; 950 } else { 951 console_vp = screen_vp; 952 graphics_state = GRAPHICS_BASIC; 953 } 954 955 fb_vp_set_style(fb_sess, console_vp, STYLE_NORMAL); 956 fb_vp_clear(fb_sess, console_vp); 957 958 sysarg_t cols; 959 sysarg_t rows; 960 fb_vp_get_dimensions(fb_sess, console_vp, &cols, &rows); 597 961 598 962 console_caps_t ccaps; 599 output_get_caps(output_sess, &ccaps); 963 fb_vp_get_caps(fb_sess, console_vp, &ccaps); 964 965 mouse.x = xres / 2; 966 mouse.y = yres / 2; 967 mouse.pressed = false; 600 968 601 969 /* Inititalize consoles */ … … 607 975 consoles[i].char_remains_len = 0; 608 976 609 if (i == KERNEL_CONSOLE) 977 if (graphics_state == GRAPHICS_FULL) { 978 /* Create state buttons */ 979 consoles[i].state_vp = 980 fb_vp_create(fb_sess, STATE_START + (xres - 800) / 2 + 981 CONSOLE_MARGIN + i * (STATE_WIDTH + STATE_SPACE), 982 STATE_TOP, STATE_WIDTH, STATE_HEIGHT); 983 } 984 985 if (i == KERNEL_CONSOLE) { 986 consoles[i].state = CONS_KERNEL; 987 cons_redraw_state(&consoles[i]); 988 cons_kernel_sequence_start(&consoles[i]); 610 989 continue; 990 } 991 992 if (i == 0) 993 consoles[i].state = CONS_DISCONNECTED_SELECTED; 994 else 995 consoles[i].state = CONS_DISCONNECTED; 611 996 612 997 consoles[i].cols = cols; … … 614 999 consoles[i].ccaps = ccaps; 615 1000 consoles[i].frontbuf = 616 chargrid_create(cols, rows, CHARGRID_FLAG_SHARED);1001 screenbuffer_create(cols, rows, SCREENBUFFER_FLAG_SHARED); 617 1002 618 1003 if (consoles[i].frontbuf == NULL) { … … 621 1006 } 622 1007 623 consoles[i].fbid = output_frontbuf_create(output_sess, 624 consoles[i].frontbuf); 1008 consoles[i].fbid = fb_frontbuf_create(fb_sess, consoles[i].frontbuf); 625 1009 if (consoles[i].fbid == 0) { 626 1010 printf("%s: Unable to create frontbuffer %zu\n", NAME, i); … … 628 1012 } 629 1013 1014 cons_redraw_state(&consoles[i]); 1015 630 1016 char vc[LOC_NAME_MAXLEN + 1]; 631 1017 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); … … 636 1022 } 637 1023 } 638 639 cons_damage(active_console);640 1024 641 1025 /* Receive kernel notifications */ … … 649 1033 } 650 1034 651 static void usage( char *name)652 { 653 printf("Usage: %s <input_dev> <output_dev>\n", name);1035 static void usage(void) 1036 { 1037 printf("Usage: console <input_dev> <framebuffer_dev>\n"); 654 1038 } 655 1039 … … 657 1041 { 658 1042 if (argc < 3) { 659 usage( argv[0]);1043 usage(); 660 1044 return -1; 661 1045 } … … 670 1054 async_manager(); 671 1055 672 /* Never reached */673 1056 return 0; 674 1057 }
Note:
See TracChangeset
for help on using the changeset viewer.