Changeset 1f83244 in mainline for console/gcons.c


Ignore:
Timestamp:
2006-06-16T20:00:29Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b34fab6
Parents:
d552ab9
Message:

Added console switching using mouse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • console/gcons.c

    rd552ab9 r1f83244  
    241241}
    242242
     243int mouse_x, mouse_y;
     244int btn_pressed, btn_x, btn_y;
     245
     246/** Handle mouse move
     247 *
     248 * @param dx Delta X of mouse move
     249 * @param dy Delta Y of mouse move
     250 */
    243251void gcons_mouse_move(int dx, int dy)
    244252{
    245         static int x = 0;
    246         static int y = 0;
    247 
    248         x = limit(x+dx, 0, xres);
    249         y = limit(y+dy, 0, yres);
    250 
    251         async_msg_2(fbphone, FB_POINTER_MOVE, x, y);
     253        mouse_x = limit(mouse_x+dx, 0, xres);
     254        mouse_y = limit(mouse_y+dy, 0, yres);
     255
     256        async_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);
     257}
     258
     259static int gcons_find_conbut(int x, int y)
     260{
     261        int status_start = STATUS_START + (xres-800) / 2;;
     262
     263        if (y < STATUS_TOP || y >= STATUS_TOP+STATUS_HEIGHT)
     264                return -1;
     265       
     266        if (x < status_start)
     267                return -1;
     268       
     269        if (x >= status_start + (STATUS_WIDTH+STATUS_SPACE)*CONSOLE_COUNT)
     270                return -1;
     271        if (((x - status_start) % (STATUS_WIDTH+STATUS_SPACE)) >= STATUS_WIDTH)
     272                return -1;
     273       
     274        return (x-status_start) / (STATUS_WIDTH+STATUS_SPACE);
     275}
     276
     277/** Handle mouse click
     278 *
     279 * @param state New state (1-pressed, 0-depressed)
     280 */
     281int gcons_mouse_btn(int state)
     282{
     283        int conbut;
     284
     285        if (state) {
     286                conbut = gcons_find_conbut(mouse_x, mouse_y);
     287                if (conbut != -1) {
     288                        btn_pressed = 1;
     289                        btn_x = mouse_x;
     290                        btn_y = mouse_y;
     291                }
     292                return -1;
     293        }
     294        if (!state && !btn_pressed)
     295                return -1;
     296        btn_pressed = 0;
     297
     298        conbut = gcons_find_conbut(mouse_x, mouse_y);
     299        if (conbut == gcons_find_conbut(btn_x, btn_y))
     300                return conbut;
     301        return -1;
    252302}
    253303
Note: See TracChangeset for help on using the changeset viewer.