Changeset 9f1362d4 in mainline for uspace/srv/hid/console/console.c


Ignore:
Timestamp:
2010-04-19T19:58:18Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
369a5f8
Parents:
caad59a
Message:

console output improvements

  • define new generic styles (STYLE_INVERTED for inverted print and STYLE_SELECTION for selections), use them primarily instead of specifying colors or RGBs
  • use console_set_style(fphone(stdout), STYLE_NORMAL) as the correct mean for reseting console settings (instead of specifying conrete hardcoded colors)
  • rename console_goto() to console_set_pos() (consistency with console_get_pos())
  • use semantically correct unsigned types for console sizes and cursor positions (instead of signed types)
  • use unsigned types for sizes and positions in libclui
  • top: nicer screen redrawing (do not use console_clear() which causes flickering, but repaint the screen properly — not entirely finished yet)
  • initialize mouse pointer coordinates (so the mouse cursor does not behave erratic after boot, unfortunatelly this does not solve ticket #223)
File:
1 edited

Legend:

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

    rcaad59a r9f1362d4  
    7171/** Information about framebuffer */
    7272struct {
    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) */
     73        int phone;           /**< Framebuffer phone */
     74        ipcarg_t cols;       /**< Framebuffer columns */
     75        ipcarg_t rows;       /**< Framebuffer rows */
     76        ipcarg_t color_cap;  /**< Color capabilities (FB_CCAP_xxx) */
    7777} fb_info;
    7878
     
    9999/** Information on row-span yet unsent to FB driver. */
    100100struct {
    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. */
     101        ipcarg_t col;  /**< Leftmost column of the span. */
     102        ipcarg_t row;  /**< Row where the span lies. */
     103        ipcarg_t cnt;  /**< Width of the span. */
    104104} fb_pending;
    105105
     
    117117}
    118118
    119 static void curs_goto(size_t x, size_t y)
     119static void curs_goto(ipcarg_t x, ipcarg_t y)
    120120{
    121121        async_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);
     
    147147}
    148148
    149 static void set_style(int style)
     149static void set_style(uint8_t style)
    150150{
    151151        async_msg_1(fb_info.phone, FB_SET_STYLE, style);
    152152}
    153153
    154 static void set_color(int fgcolor, int bgcolor, int flags)
     154static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags)
    155155{
    156156        async_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);
    157157}
    158158
    159 static void set_rgb_color(int fgcolor, int bgcolor)
     159static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor)
    160160{
    161161        async_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);
     
    178178}
    179179
    180 static int ccap_fb_to_con(int ccap_fb, int *ccap_con)
     180static int ccap_fb_to_con(ipcarg_t ccap_fb, ipcarg_t *ccap_con)
    181181{
    182182        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 
     183        case FB_CCAP_NONE:
     184                *ccap_con = CONSOLE_CCAP_NONE;
     185                break;
     186        case FB_CCAP_STYLE:
     187                *ccap_con = CONSOLE_CCAP_STYLE;
     188                break;
     189        case FB_CCAP_INDEXED:
     190                *ccap_con = CONSOLE_CCAP_INDEXED;
     191                break;
     192        case FB_CCAP_RGB:
     193                *ccap_con = CONSOLE_CCAP_RGB;
     194                break;
     195        default:
     196                return EINVAL;
     197        }
     198       
    190199        return EOK;
    191200}
     
    226235 *
    227236 */
    228 static void cell_mark_changed(size_t col, size_t row)
     237static void cell_mark_changed(ipcarg_t col, ipcarg_t row)
    229238{
    230239        if (fb_pending.cnt != 0) {
     
    253262{
    254263        bool flush_cursor = false;
    255 
     264       
    256265        switch (ch) {
    257266        case '\n':
     
    297306                        async_msg_1(fb_info.phone, FB_SCROLL, 1);
    298307        }
    299 
     308       
    300309        if (cons == active_console && flush_cursor)
    301310                curs_goto(cons->scr.position_x, cons->scr.position_y);
     
    327336       
    328337        if (cons != kernel_console) {
    329                 size_t x;
    330                 size_t y;
    331                 int rc = 0;
    332                
    333338                async_serialize_start();
    334339               
     
    344349                set_attrs(&cons->scr.attrs);
    345350                curs_visibility(false);
     351               
     352                ipcarg_t x;
     353                ipcarg_t y;
     354                int rc = 0;
     355               
    346356                if (interbuffer) {
    347357                        for (y = 0; y < cons->scr.size_y; y++) {
     
    390400        /* Ignore parameters, the connection is already opened */
    391401        while (true) {
    392                
    393402                ipc_call_t call;
    394403                ipc_callid_t callid = async_get_call(&call);
     
    433442static void mouse_events(ipc_callid_t iid, ipc_call_t *icall)
    434443{
    435         int button, press;
    436         int dx, dy;
    437         int newcon;
    438 
    439444        /* Ignore parameters, the connection is already opened */
    440445        while (true) {
    441 
    442446                ipc_call_t call;
    443447                ipc_callid_t callid = async_get_call(&call);
    444 
     448               
    445449                int retval;
    446 
     450               
    447451                switch (IPC_GET_METHOD(call)) {
    448452                case IPC_M_PHONE_HUNGUP:
     
    450454                        return;
    451455                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);
     456                        if (IPC_GET_ARG1(call) == 1) {
     457                                int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call));
    456458                                if (newcon != -1)
    457459                                        change_console(&consoles[newcon]);
     
    460462                        break;
    461463                case MEVENT_MOVE:
    462                         dx = IPC_GET_ARG1(call);
    463                         dy = IPC_GET_ARG2(call);
    464                         gcons_mouse_move(dx, dy);
     464                        gcons_mouse_move((int) IPC_GET_ARG1(call),
     465                            (int) IPC_GET_ARG2(call));
    465466                        retval = 0;
    466467                        break;
     
    520521        console_event_t ev;
    521522        fibril_mutex_lock(&input_mutex);
     523       
    522524recheck:
    523525        while ((keybuffer_pop(&cons->keybuffer, &ev)) && (pos < size)) {
     
    536538                goto recheck;
    537539        }
     540       
    538541        fibril_mutex_unlock(&input_mutex);
    539542}
     
    542545{
    543546        console_event_t ev;
    544 
     547       
    545548        fibril_mutex_lock(&input_mutex);
     549       
    546550recheck:
    547551        if (keybuffer_pop(&cons->keybuffer, &ev)) {
     
    551555                goto recheck;
    552556        }
     557       
    553558        fibril_mutex_unlock(&input_mutex);
    554559}
     
    580585        ipcarg_t arg2;
    581586        ipcarg_t arg3;
    582 
    583         int cons_ccap;
     587       
    584588        int rc;
    585589       
     
    622626                        if (cons == active_console) {
    623627                                async_req_0_0(fb_info.phone, FB_FLUSH);
    624                                
    625628                                curs_goto(cons->scr.position_x, cons->scr.position_y);
    626629                        }
     
    650653                        break;
    651654                case CONSOLE_GET_COLOR_CAP:
    652                         rc = ccap_fb_to_con(fb_info.color_cap, &cons_ccap);
     655                        rc = ccap_fb_to_con(fb_info.color_cap, &arg1);
    653656                        if (rc != EOK) {
    654657                                ipc_answer_0(callid, rc);
    655658                                continue;
    656659                        }
    657                         arg1 = cons_ccap;
    658660                        break;
    659661                case CONSOLE_SET_STYLE:
     
    714716                return false;
    715717        }
    716 
     718       
    717719        kbd_phone = fd_phone(input_fd);
    718720        if (kbd_phone < 0) {
     
    720722                return false;
    721723        }
    722 
     724       
    723725        /* NB: The callback connection is slotted for removal */
    724726        ipcarg_t phonehash;
     
    727729                return false;
    728730        }
    729 
     731       
    730732        async_new_connection(phonehash, 0, NULL, keyboard_events);
    731 
     733       
    732734        /* Connect to mouse device */
    733735        mouse_phone = -1;
    734736        int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);
    735 
     737       
    736738        if (mouse_fd < 0) {
    737739                printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");
    738740                goto skip_mouse;
    739741        }
    740 
     742       
    741743        mouse_phone = fd_phone(mouse_fd);
    742744        if (mouse_phone < 0) {
     
    744746                goto skip_mouse;
    745747        }
    746 
     748       
    747749        if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) {
    748750                printf(NAME ": Failed to create callback from mouse device\n");
     
    750752                goto skip_mouse;
    751753        }
    752 
     754       
    753755        async_new_connection(phonehash, 0, NULL, mouse_events);
    754756skip_mouse:
    755 
     757       
    756758        /* Connect to framebuffer driver */
    757759        fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VIDEO, 0, 0);
     
    760762                return -1;
    761763        }
    762 
     764       
    763765        /* Register driver */
    764766        int rc = devmap_driver_register(NAME, client_connection);
     
    772774       
    773775        /* Synchronize, the gcons could put something in queue */
    774         ipcarg_t color_cap;
    775776        async_req_0_0(fb_info.phone, FB_FLUSH);
    776777        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;
     778        async_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap);
    779779       
    780780        /* Set up shared memory buffer. */
Note: See TracChangeset for help on using the changeset viewer.