Changes in uspace/srv/hid/console/gcons.c [19f857a:9f1362d4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/gcons.c
r19f857a r9f1362d4 54 54 #define STATUS_HEIGHT 48 55 55 56 #define MAIN_COLOR 0xffffff 56 #define COLOR_MAIN 0xffffff 57 #define COLOR_FOREGROUND 0x202020 58 #define COLOR_BACKGROUND 0xffffff 59 60 extern char _binary_gfx_helenos_ppm_start[0]; 61 extern int _binary_gfx_helenos_ppm_size; 62 extern char _binary_gfx_nameic_ppm_start[0]; 63 extern int _binary_gfx_nameic_ppm_size; 64 65 extern char _binary_gfx_anim_1_ppm_start[0]; 66 extern int _binary_gfx_anim_1_ppm_size; 67 extern char _binary_gfx_anim_2_ppm_start[0]; 68 extern int _binary_gfx_anim_2_ppm_size; 69 extern char _binary_gfx_anim_3_ppm_start[0]; 70 extern int _binary_gfx_anim_3_ppm_size; 71 extern char _binary_gfx_anim_4_ppm_start[0]; 72 extern int _binary_gfx_anim_4_ppm_size; 73 74 extern char _binary_gfx_cons_selected_ppm_start[0]; 75 extern int _binary_gfx_cons_selected_ppm_size; 76 extern char _binary_gfx_cons_idle_ppm_start[0]; 77 extern int _binary_gfx_cons_idle_ppm_size; 78 extern char _binary_gfx_cons_has_data_ppm_start[0]; 79 extern int _binary_gfx_cons_has_data_ppm_size; 80 extern char _binary_gfx_cons_kernel_ppm_start[0]; 81 extern int _binary_gfx_cons_kernel_ppm_size; 57 82 58 83 static bool use_gcons = false; … … 82 107 static size_t active_console = 0; 83 108 84 s ize_t mouse_x;85 s ize_t mouse_y;86 87 bool btn_pressed;88 s ize_t btn_x;89 s ize_t btn_y;109 static ipcarg_t mouse_x = 0; 110 static ipcarg_t mouse_y= 0; 111 112 static bool btn_pressed = false; 113 static ipcarg_t btn_x = 0; 114 static ipcarg_t btn_y = 0; 90 115 91 116 static void vp_switch(int vp) … … 95 120 96 121 /** Create view port */ 97 static int vp_create( size_t x, size_t y, size_t width, size_t height)122 static int vp_create(ipcarg_t x, ipcarg_t y, ipcarg_t width, ipcarg_t height) 98 123 { 99 124 return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, … … 112 137 113 138 /** Transparent putchar */ 114 static void tran_putch(wchar_t ch, size_t col, size_t row)139 static void tran_putch(wchar_t ch, ipcarg_t col, ipcarg_t row) 115 140 { 116 141 async_msg_3(fbphone, FB_PUTCHAR, ch, col, row); … … 259 284 void gcons_mouse_move(ssize_t dx, ssize_t dy) 260 285 { 261 mouse_x = limit(mouse_x + dx, 0, xres); 262 mouse_y = limit(mouse_y + dy, 0, yres); 263 286 ssize_t nx = (ssize_t) mouse_x + dx; 287 ssize_t ny = (ssize_t) mouse_y + dy; 288 289 mouse_x = (size_t) limit(nx, 0, xres); 290 mouse_y = (size_t) limit(ny, 0, yres); 291 264 292 if (active_console != KERNEL_CONSOLE) 265 293 async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); 266 294 } 267 295 268 static int gcons_find_conbut(i nt x, int y)269 { 270 i nt status_start = STATUS_START + (xres - 800) / 2;296 static int gcons_find_conbut(ipcarg_t x, ipcarg_t y) 297 { 298 ipcarg_t status_start = STATUS_START + (xres - 800) / 2; 271 299 272 300 if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT)) … … 278 306 if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT) 279 307 return -1; 308 280 309 if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE) 281 310 return -1; 282 311 283 return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); 312 ipcarg_t btn = (x - status_start) / (STATUS_WIDTH + STATUS_SPACE); 313 314 if (btn < CONSOLE_COUNT) 315 return btn; 316 317 return -1; 284 318 } 285 319 … … 287 321 * 288 322 * @param state New state (true - pressed, false - depressed) 323 * 289 324 */ 290 325 int gcons_mouse_btn(bool state) 291 326 { 292 int conbut; 327 /* Ignore mouse clicks if no buttons 328 are drawn at all */ 329 if (xres < 800) 330 return -1; 293 331 294 332 if (state) { 295 conbut = gcons_find_conbut(mouse_x, mouse_y);333 int conbut = gcons_find_conbut(mouse_x, mouse_y); 296 334 if (conbut != -1) { 297 335 btn_pressed = true; … … 307 345 btn_pressed = false; 308 346 309 conbut = gcons_find_conbut(mouse_x, mouse_y);347 int conbut = gcons_find_conbut(mouse_x, mouse_y); 310 348 if (conbut == gcons_find_conbut(btn_x, btn_y)) 311 349 return conbut; … … 313 351 return -1; 314 352 } 315 316 353 317 354 /** Draw a PPM pixmap to framebuffer … … 321 358 * @param x Coordinate of upper left corner 322 359 * @param y Coordinate of upper left corner 323 */ 324 static void draw_pixmap(char *logo, size_t size, int x, int y) 325 { 326 char *shm; 327 int rc; 328 360 * 361 */ 362 static void draw_pixmap(char *logo, size_t size, ipcarg_t x, ipcarg_t y) 363 { 329 364 /* Create area */ 330 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |365 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 331 366 MAP_ANONYMOUS, 0, 0); 332 367 if (shm == MAP_FAILED) … … 336 371 337 372 /* Send area */ 338 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);373 int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 339 374 if (rc) 340 375 goto exit; … … 356 391 } 357 392 358 extern char _binary_gfx_helenos_ppm_start[0];359 extern int _binary_gfx_helenos_ppm_size;360 extern char _binary_gfx_nameic_ppm_start[0];361 extern int _binary_gfx_nameic_ppm_size;362 363 393 /** Redraws console graphics */ 364 394 void gcons_redraw_console(void) 365 395 { 366 int i;367 368 396 if (!use_gcons) 369 397 return; 370 398 371 399 vp_switch(0); 372 set_rgb_color( MAIN_COLOR, MAIN_COLOR);400 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 373 401 clear(); 374 402 draw_pixmap(_binary_gfx_helenos_ppm_start, … … 377 405 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 378 406 407 unsigned int i; 379 408 for (i = 0; i < CONSOLE_COUNT; i++) 380 409 redraw_state(i); … … 393 422 static int make_pixmap(char *data, size_t size) 394 423 { 395 char *shm;396 int rc;397 int pxid = -1;398 399 424 /* Create area */ 400 shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |425 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 401 426 MAP_ANONYMOUS, 0, 0); 402 427 if (shm == MAP_FAILED) … … 405 430 memcpy(shm, data, size); 406 431 432 int pxid = -1; 433 407 434 /* Send area */ 408 rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);435 int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm); 409 436 if (rc) 410 437 goto exit; … … 432 459 } 433 460 434 extern char _binary_gfx_anim_1_ppm_start[0];435 extern int _binary_gfx_anim_1_ppm_size;436 extern char _binary_gfx_anim_2_ppm_start[0];437 extern int _binary_gfx_anim_2_ppm_size;438 extern char _binary_gfx_anim_3_ppm_start[0];439 extern int _binary_gfx_anim_3_ppm_size;440 extern char _binary_gfx_anim_4_ppm_start[0];441 extern int _binary_gfx_anim_4_ppm_size;442 443 461 static void make_anim(void) 444 462 { 445 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]); 463 int an = async_req_1_0(fbphone, FB_ANIM_CREATE, 464 cstatus_vp[KERNEL_CONSOLE]); 446 465 if (an < 0) 447 466 return; … … 467 486 animation = an; 468 487 } 469 470 extern char _binary_gfx_cons_selected_ppm_start[0];471 extern int _binary_gfx_cons_selected_ppm_size;472 extern char _binary_gfx_cons_idle_ppm_start[0];473 extern int _binary_gfx_cons_idle_ppm_size;474 extern char _binary_gfx_cons_has_data_ppm_start[0];475 extern int _binary_gfx_cons_has_data_ppm_size;476 extern char _binary_gfx_cons_kernel_ppm_start[0];477 extern int _binary_gfx_cons_kernel_ppm_size;478 488 479 489 /** Initialize nice graphical console environment */ … … 500 510 501 511 /* Create status buttons */ 502 size_t status_start = STATUS_START + (xres - 800) / 2;512 ipcarg_t status_start = STATUS_START + (xres - 800) / 2; 503 513 size_t i; 504 514 for (i = 0; i < CONSOLE_COUNT; i++) { … … 511 521 512 522 vp_switch(cstatus_vp[i]); 513 set_rgb_color( 0x202020, 0xffffff);523 set_rgb_color(COLOR_FOREGROUND, COLOR_BACKGROUND); 514 524 } 515 525
Note:
See TracChangeset
for help on using the changeset viewer.