Пример #1
0
void
readmouse(Vnc *v)
{
    int cursorfd, len, n;
    char buf[10*EventSize], *start, *end;
    uchar curs[2*4+2*2*16];
    Cursor *cs;
    Mouse m;

    cs = &dotcursor;

    snprint(buf, sizeof buf, "%s/cursor", display->devdir);
    if((cursorfd = open(buf, OWRITE)) < 0)
        sysfatal("open %s: %r", buf);

    BPLONG(curs+0*4, cs->offset.x);
    BPLONG(curs+1*4, cs->offset.y);
    memmove(curs+2*4, cs->clr, 2*2*16);
    write(cursorfd, curs, sizeof curs);

    resize(v, 1);
    requestupdate(vnc, 0);
    start = end = buf;
    len = 0;
    for(;;) {
        if((n = read(mousefd, end, sizeof(buf) - (end - buf))) < 0)
            sysfatal("read mouse failed");

        len += n;
        end += n;
        while(len >= EventSize) {
            if(*start == 'm') {
                m.xy.x = atoi(start+1);
                m.xy.y = atoi(start+1+12);
                m.buttons = atoi(start+1+2*12) & 0x1F;
                m.xy = subpt(m.xy, screen->r.min);
                if(ptinrect(m.xy, Rpt(ZP, v->dim))) {
                    mouseevent(v, m);
                    /* send wheel button *release* */
                    if ((m.buttons & 0x7) != m.buttons) {
                        m.buttons &= 0x7;
                        mouseevent(v, m);
                    }
                }
            } else
                eresized();

            start += EventSize;
            len -= EventSize;
        }
        if(start - buf > sizeof(buf) - EventSize) {
            memmove(buf, start, len);
            start = buf;
            end = start+len;
        }
    }
}
Пример #2
0
static EVENT MouseEventProc( void )
{
    ORD stat = 0;
    int row;
    int col;
    
    if( RdosGetLeftButton() )
        stat |= MOUSE_PRESS;

    if( RdosGetRightButton() )
        stat |= MOUSE_PRESS_RIGHT;

    RdosGetMousePosition(  &col, &row );

    if( stat != currMouseStatus ) {
        if( !(stat & MOUSE_PRESS) && (currMouseStatus & MOUSE_PRESS) )
            RdosGetLeftButtonReleasePosition( &col, &row );
    
        if( !(stat & MOUSE_PRESS_RIGHT) && (currMouseStatus & MOUSE_PRESS_RIGHT) )
            RdosGetRightButtonReleasePosition( &col, &row );
    
        if( (stat & MOUSE_PRESS) && !(currMouseStatus & MOUSE_PRESS) )
            RdosGetLeftButtonPressPosition( &col, &row );
    
        if( (stat & MOUSE_PRESS_RIGHT) && !(currMouseStatus & MOUSE_PRESS_RIGHT) )
            RdosGetRightButtonPressPosition( &col, &row );
    }
    currMouseRow = row;
    currMouseCol = col;
    currMouseStatus = stat;
    
    return mouseevent();        
}
Пример #3
0
EVENT intern getanyevent( void )
{
    INPUT_RECORD        ir;
    DWORD               rd,ss;
    WORD                vk;
    EVENT               ascii;
    BOOL                has_alt, has_shift, has_ctrl;
    map                 *ev,what;
    EVENT               evnt;

    for( ;; ) {
        PeekConsoleInput( InputHandle, &ir, 1, &rd );
        if( rd == 0 ) return( EV_NO_EVENT );
        ReadConsoleInput( InputHandle, &ir, 1, &rd );
        if( eventWeWant( &ir ) ) {
            if( ir.EventType != MOUSE_EVENT ) break;
            evnt = mouseevent();
            if( evnt > EV_NO_EVENT ) return( evnt );
        }
    }

    vk = ir.Event.KeyEvent.wVirtualKeyCode;
    ascii = ir.Event.KeyEvent.uChar.AsciiChar;
    ss = ir.Event.KeyEvent.dwControlKeyState;
    has_shift = ss & SHIFT_PRESSED;
    has_ctrl = ss & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED);
    has_alt = ss & (RIGHT_ALT_PRESSED | LEFT_ALT_PRESSED);
    setshiftstate( has_shift, has_ctrl, has_alt );
    what.vk = vk;

    ev = bsearch( &what, events, sizeof( events )/sizeof( map ),
                    sizeof( what ), CompareEvents );
    if( ev != NULL ) {
        if( has_shift ) {
            ascii = ev->shift;
        } else if( has_ctrl ) {
            ascii = ev->ctrl;
        } else if( has_alt ) {
            ascii = ev->alt;
        } else {
            ascii = ev->reg;
        }
    } else if( ascii == 0 ) {
        ascii = EV_NO_EVENT;
    }
    if( ascii > EV_NO_EVENT ) {
        uihidemouse();
    }
    return( ascii );

} /* getanyevent */
Пример #4
0
EVENT td_event( void )
{
    EVENT       ev;

    ev = td_sizeevent();
    if( ev > EV_NO_EVENT ) return( ev );
    /* In a terminal environment we have to go for the keyboard first,
       since that's how the mouse events are coming in */
    ev = tk_keyboardevent();
    if( ev > EV_NO_EVENT ) {
         uihidemouse();
         return( ev );
    }
    return( mouseevent() );
}
Пример #5
0
EVENT cd_event( void )
{
    EVENT       ev;

    ev = cd_sizeevent();
    if( ev > EV_NO_EVENT )
        return( ev );
    ev = mouseevent();
    if( ev > EV_NO_EVENT )
        return( ev );
    ev = ck_keyboardevent();
    if( ev == EV_NO_EVENT )
        return( ev );
    uihidemouse();
    return( ev );
}