Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/gcons.c

    r9f1362d4 r19f857a  
    5454#define STATUS_HEIGHT  48
    5555
    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;
     56#define MAIN_COLOR  0xffffff
    8257
    8358static bool use_gcons = false;
     
    10782static size_t active_console = 0;
    10883
    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;
     84size_t mouse_x;
     85size_t mouse_y;
     86
     87bool btn_pressed;
     88size_t btn_x;
     89size_t btn_y;
    11590
    11691static void vp_switch(int vp)
     
    12095
    12196/** Create view port */
    122 static int vp_create(ipcarg_t x, ipcarg_t y, ipcarg_t width, ipcarg_t height)
     97static int vp_create(size_t x, size_t y, size_t width, size_t height)
    12398{
    12499        return async_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,
     
    137112
    138113/** Transparent putchar */
    139 static void tran_putch(wchar_t ch, ipcarg_t col, ipcarg_t row)
     114static void tran_putch(wchar_t ch, size_t col, size_t row)
    140115{
    141116        async_msg_3(fbphone, FB_PUTCHAR, ch, col, row);
     
    284259void gcons_mouse_move(ssize_t dx, ssize_t dy)
    285260{
    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        
     261        mouse_x = limit(mouse_x + dx, 0, xres);
     262        mouse_y = limit(mouse_y + dy, 0, yres);
     263
    292264        if (active_console != KERNEL_CONSOLE)
    293265                async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
    294266}
    295267
    296 static int gcons_find_conbut(ipcarg_t x, ipcarg_t y)
    297 {
    298         ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
     268static int gcons_find_conbut(int x, int y)
     269{
     270        int status_start = STATUS_START + (xres - 800) / 2;
    299271       
    300272        if ((y < STATUS_TOP) || (y >= STATUS_TOP + STATUS_HEIGHT))
     
    306278        if (x >= status_start + (STATUS_WIDTH + STATUS_SPACE) * CONSOLE_COUNT)
    307279                return -1;
    308        
    309280        if (((x - status_start) % (STATUS_WIDTH + STATUS_SPACE)) < STATUS_SPACE)
    310281                return -1;
    311282       
    312         ipcarg_t btn = (x - status_start) / (STATUS_WIDTH + STATUS_SPACE);
    313        
    314         if (btn < CONSOLE_COUNT)
    315                 return btn;
    316        
    317         return -1;
     283        return (x - status_start) / (STATUS_WIDTH + STATUS_SPACE);
    318284}
    319285
     
    321287 *
    322288 * @param state New state (true - pressed, false - depressed)
    323  *
    324289 */
    325290int gcons_mouse_btn(bool state)
    326291{
    327         /* Ignore mouse clicks if no buttons
    328            are drawn at all */
    329         if (xres < 800)
    330                 return -1;
     292        int conbut;
    331293       
    332294        if (state) {
    333                 int conbut = gcons_find_conbut(mouse_x, mouse_y);
     295                conbut = gcons_find_conbut(mouse_x, mouse_y);
    334296                if (conbut != -1) {
    335297                        btn_pressed = true;
     
    345307        btn_pressed = false;
    346308       
    347         int conbut = gcons_find_conbut(mouse_x, mouse_y);
     309        conbut = gcons_find_conbut(mouse_x, mouse_y);
    348310        if (conbut == gcons_find_conbut(btn_x, btn_y))
    349311                return conbut;
     
    351313        return -1;
    352314}
     315
    353316
    354317/** Draw a PPM pixmap to framebuffer
     
    358321 * @param x Coordinate of upper left corner
    359322 * @param y Coordinate of upper left corner
    360  *
    361  */
    362 static void draw_pixmap(char *logo, size_t size, ipcarg_t x, ipcarg_t y)
    363 {
     323 */
     324static void draw_pixmap(char *logo, size_t size, int x, int y)
     325{
     326        char *shm;
     327        int rc;
     328       
    364329        /* Create area */
    365         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     330        shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    366331            MAP_ANONYMOUS, 0, 0);
    367332        if (shm == MAP_FAILED)
     
    371336       
    372337        /* Send area */
    373         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
     338        rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
    374339        if (rc)
    375340                goto exit;
     
    391356}
    392357
     358extern char _binary_gfx_helenos_ppm_start[0];
     359extern int _binary_gfx_helenos_ppm_size;
     360extern char _binary_gfx_nameic_ppm_start[0];
     361extern int _binary_gfx_nameic_ppm_size;
     362
    393363/** Redraws console graphics */
    394364void gcons_redraw_console(void)
    395365{
     366        int i;
     367       
    396368        if (!use_gcons)
    397369                return;
    398370       
    399371        vp_switch(0);
    400         set_rgb_color(COLOR_MAIN, COLOR_MAIN);
     372        set_rgb_color(MAIN_COLOR, MAIN_COLOR);
    401373        clear();
    402374        draw_pixmap(_binary_gfx_helenos_ppm_start,
     
    405377            (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
    406378       
    407         unsigned int i;
    408379        for (i = 0; i < CONSOLE_COUNT; i++)
    409380                redraw_state(i);
     
    422393static int make_pixmap(char *data, size_t size)
    423394{
     395        char *shm;
     396        int rc;
     397        int pxid = -1;
     398       
    424399        /* Create area */
    425         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     400        shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    426401            MAP_ANONYMOUS, 0, 0);
    427402        if (shm == MAP_FAILED)
     
    430405        memcpy(shm, data, size);
    431406       
    432         int pxid = -1;
    433        
    434407        /* Send area */
    435         int rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
     408        rc = async_req_1_0(fbphone, FB_PREPARE_SHM, (ipcarg_t) shm);
    436409        if (rc)
    437410                goto exit;
     
    459432}
    460433
     434extern char _binary_gfx_anim_1_ppm_start[0];
     435extern int _binary_gfx_anim_1_ppm_size;
     436extern char _binary_gfx_anim_2_ppm_start[0];
     437extern int _binary_gfx_anim_2_ppm_size;
     438extern char _binary_gfx_anim_3_ppm_start[0];
     439extern int _binary_gfx_anim_3_ppm_size;
     440extern char _binary_gfx_anim_4_ppm_start[0];
     441extern int _binary_gfx_anim_4_ppm_size;
     442
    461443static void make_anim(void)
    462444{
    463         int an = async_req_1_0(fbphone, FB_ANIM_CREATE,
    464             cstatus_vp[KERNEL_CONSOLE]);
     445        int an = async_req_1_0(fbphone, FB_ANIM_CREATE, cstatus_vp[KERNEL_CONSOLE]);
    465446        if (an < 0)
    466447                return;
     
    486467        animation = an;
    487468}
     469
     470extern char _binary_gfx_cons_selected_ppm_start[0];
     471extern int _binary_gfx_cons_selected_ppm_size;
     472extern char _binary_gfx_cons_idle_ppm_start[0];
     473extern int _binary_gfx_cons_idle_ppm_size;
     474extern char _binary_gfx_cons_has_data_ppm_start[0];
     475extern int _binary_gfx_cons_has_data_ppm_size;
     476extern char _binary_gfx_cons_kernel_ppm_start[0];
     477extern int _binary_gfx_cons_kernel_ppm_size;
    488478
    489479/** Initialize nice graphical console environment */
     
    510500       
    511501        /* Create status buttons */
    512         ipcarg_t status_start = STATUS_START + (xres - 800) / 2;
     502        size_t status_start = STATUS_START + (xres - 800) / 2;
    513503        size_t i;
    514504        for (i = 0; i < CONSOLE_COUNT; i++) {
     
    521511               
    522512                vp_switch(cstatus_vp[i]);
    523                 set_rgb_color(COLOR_FOREGROUND, COLOR_BACKGROUND);
     513                set_rgb_color(0x202020, 0xffffff);
    524514        }
    525515       
Note: See TracChangeset for help on using the changeset viewer.