Exemple #1
0
void GrMouseWarp(int x, int y)
{
    POINT point;

    MOUINFO->xpos = imax(MOUINFO->xmin, imin(MOUINFO->xmax, x));
    MOUINFO->ypos = imax(MOUINFO->ymin, imin(MOUINFO->ymax, y));
    GrMouseUpdateCursor();
    point.x = MOUINFO->xpos;
    point.y = MOUINFO->ypos;
    ClientToScreen(hGRXWnd, &point);
    SetCursorPos(point.x, point.y);
}
Exemple #2
0
int _GrReadInputs(void)
{
    GrEvent ev;
    W32Event evaux;
    int key;
    int nev = 0;

    while (_W32EventQueueLength > 0) {
        EnterCriticalSection(&_csEventQueue);
        evaux = _W32EventQueue[_W32EventQueueRead];
        if (++_W32EventQueueRead == _W32EventQueueSize)
            _W32EventQueueRead = 0;
        _W32EventQueueLength--;
        LeaveCriticalSection(&_csEventQueue);

        switch (evaux.uMsg) {
        case WM_CHAR:
            ev.type = GREV_PREKEY;
            ev.kbstat = evaux.kbstat;
            ev.p1 = evaux.wParam;
            ev.p2 = 1;
            ev.p3 = 0;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_SYSCHAR:
            key = 0;
            if (evaux.wParam >= 'a' && evaux.wParam <= 'z')
                key = altletters[evaux.wParam - 'a'];
            if (evaux.wParam >= 'A' && evaux.wParam <= 'Z')
                key = altletters[evaux.wParam - 'A'];
            if (evaux.wParam >= '0' && evaux.wParam <= '9')
                key = altnumbers[evaux.wParam - '0'];
            if (key == 0)
                break;
            ev.type = GREV_PREKEY;
            ev.kbstat = evaux.kbstat;
            ev.p1 = key;
            ev.p2 = GRKEY_KEYCODE;
            ev.p3 = 0;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
            key = StdKeyTranslate(evaux.wParam, evaux.kbstat);
            if (key == 0)
                break;
            ev.type = GREV_PREKEY;
            ev.kbstat = evaux.kbstat;
            ev.p1 = key;
            ev.p2 = GRKEY_KEYCODE;
            ev.p3 = 0;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_MOUSEMOVE:
            MOUINFO->xpos = LOWORD(evaux.lParam);
            MOUINFO->ypos = HIWORD(evaux.lParam);
            MOUINFO->moved = TRUE;
            GrMouseUpdateCursor();
            if ((MOUINFO->genmmove == GR_GEN_MMOVE_ALWAYS) ||
                ((MOUINFO->genmmove == GR_GEN_MMOVE_IFBUT) &&
                 (MOUINFO->bstatus != 0))) {
                ev.type = GREV_MMOVE;
                ev.kbstat = kbd_lastmod;
                ev.p1 = MOUINFO->bstatus;
                ev.p2 = MOUINFO->xpos;
                ev.p3 = MOUINFO->ypos;
                GrEventEnqueue(&ev);
                MOUINFO->moved = FALSE;
                nev++;
            }
            break;
        case WM_LBUTTONDOWN:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_LB_PRESSED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus |= GRMOUSE_LB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_MBUTTONDOWN:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_MB_PRESSED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus |= GRMOUSE_MB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_RBUTTONDOWN:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_RB_PRESSED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus |= GRMOUSE_RB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_LBUTTONUP:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_LB_RELEASED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus &= ~GRMOUSE_LB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_MBUTTONUP:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_MB_RELEASED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus &= ~GRMOUSE_MB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_RBUTTONUP:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p1 = GRMOUSE_RB_RELEASED;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            MOUINFO->bstatus &= ~GRMOUSE_RB_STATUS;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev++;
            break;
        case WM_MOUSEWHEEL:
//            MOUINFO->xpos = LOWORD(evaux.lParam);
//            MOUINFO->ypos = HIWORD(evaux.lParam);
//            GrMouseUpdateCursor();
            ev.type = GREV_MOUSE;
            ev.kbstat = evaux.kbstat;
            ev.p2 = MOUINFO->xpos;
            ev.p3 = MOUINFO->ypos;
            if (HIWORD(evaux.wParam) > 0)
            ev.p1 = ((short)HIWORD(evaux.wParam) > 0) ?
                    GRMOUSE_B4_PRESSED : GRMOUSE_B5_PRESSED;
            GrEventEnqueue(&ev);
            ev.p1 = ((short)HIWORD(evaux.wParam) > 0) ?
                    GRMOUSE_B4_RELEASED : GRMOUSE_B5_RELEASED;
            GrEventEnqueue(&ev);
            MOUINFO->moved = FALSE;
            kbd_lastmod = evaux.kbstat;
            nev += 2;
            break;
        }
    }
    if (nev == 0) Sleep(1); /* yield */
    return nev;
}
Exemple #3
0
int _GrReadInputs(void)
{
    GrEvent evaux;
    int nev = 0;
    int mb = 0, mx = 0, my = 0;

    if (_lnxfb_waiting_to_switch_console)
        _LnxfbSwitchConsoleAndWait();

    if (MOUINFO->msstatus == 2) {
        if (_ReadPS2MouseData(&mb, &mx, &my)) {
            update_coord(x, mx);
            update_coord(y, my);
            /** NOTE we know PS2_LEFTBUTTON == GRMOUSE_LB_STATUS, etc */
            MOUINFO->bstatus = mb;
            GrMouseUpdateCursor();
            MOUINFO->moved  = TRUE;
            if (mb != mou_buttons) {
                evaux.type = GREV_MOUSE;
                evaux.kbstat = kbd_lastmod;
                evaux.p2 = MOUINFO->xpos;
                evaux.p3 = MOUINFO->ypos;
                if ((mb & PS2_LEFTBUTTON) != (mou_buttons & PS2_LEFTBUTTON)) {
                    if (mb & PS2_LEFTBUTTON)
                        evaux.p1 = GRMOUSE_LB_PRESSED;
                    else
                        evaux.p1 = GRMOUSE_LB_RELEASED;
                    GrEventEnqueue(&evaux);
                    nev++;
                }
                if ((mb & PS2_MIDDLEBUTTON) != (mou_buttons & PS2_MIDDLEBUTTON)) {
                    if (mb & PS2_MIDDLEBUTTON)
                        evaux.p1 = GRMOUSE_MB_PRESSED;
                    else
                        evaux.p1 = GRMOUSE_MB_RELEASED;
                    GrEventEnqueue(&evaux);
                    nev++;
                }
                if ((mb & PS2_RIGHTBUTTON) != (mou_buttons & PS2_RIGHTBUTTON)) {
                    if (mb & PS2_RIGHTBUTTON)
                        evaux.p1 = GRMOUSE_RB_PRESSED;
                    else
                        evaux.p1 = GRMOUSE_RB_RELEASED;
                    GrEventEnqueue(&evaux);
                    nev++;
                }
                mou_buttons = mb;
                MOUINFO->moved = FALSE;
            }
            else if ((MOUINFO->genmmove == GR_GEN_MMOVE_ALWAYS) ||
                     ((MOUINFO->genmmove == GR_GEN_MMOVE_IFBUT) &&
                     (MOUINFO->bstatus != 0))) {
                evaux.type = GREV_MMOVE;
                evaux.kbstat = kbd_lastmod;
                evaux.p1 = MOUINFO->bstatus;
                evaux.p2 = MOUINFO->xpos;
                evaux.p3 = MOUINFO->ypos;
                GrEventEnqueue(&evaux);
                MOUINFO->moved = FALSE;
                nev++;
           }
        }
    }

    if (kbd_isatty && _CheckKeyboardHit()) {
        unsigned int key = _ReadCharFromKeyboard();
        evaux.type = GREV_PREKEY;
        evaux.kbstat = kbd_lastmod;
        evaux.p3 = 0;
        if (key > 0xff) {
            evaux.p1 = key;
            evaux.p2 = GRKEY_KEYCODE;
        }
        else if ((key >= 0x80) && (kbsysencoding == GRENC_UTF_8)) {
            evaux.p1 = 0;
            if ((key & 0xe0) == 0xc0) {  /* two bytes */
                evaux.cp1[0] = key;
                evaux.cp1[1] = _ReadCharFromKeyboard();
                evaux.p2 = 2;
            }
            else if ((key & 0xf0) == 0xe0) {  /* three bytes */
                evaux.cp1[0] = key;
                evaux.cp1[1] = _ReadCharFromKeyboard();
                evaux.cp1[2] = _ReadCharFromKeyboard();
                evaux.p2 = 3;
            }
            else {  /* four bytes */
                evaux.cp1[0] = key;
                evaux.cp1[1] = _ReadCharFromKeyboard();
                evaux.cp1[2] = _ReadCharFromKeyboard();
                evaux.cp1[3] = _ReadCharFromKeyboard();
                evaux.p2 = 3;
            }
        }
        else {
            evaux.p1 = key;
            evaux.p2 = 1;
        }
        GrEventEnqueue(&evaux);
        MOUINFO->moved = FALSE;
        nev++;
    }

    if (nev == 0) {
        usleep(1000L);   // wait 1 ms to not eat 100% cpu
    }

    return nev;
}
Exemple #4
0
void GrMouseWarp(int x, int y)
{
    MOUINFO->xpos = imax(MOUINFO->xmin, imin(MOUINFO->xmax, x));
    MOUINFO->ypos = imax(MOUINFO->ymin, imin(MOUINFO->ymax, y));
    GrMouseUpdateCursor();
}
Exemple #5
0
/* Reinit mouse colors (if palette is new) */
void ws_resetmousecolors(void) {
    GrMouseEraseCursor();
    GrMouseSetColors( w_makecolor(255, 255, 255), w_makecolor(0, 0, 0) );
    GrMouseUpdateCursor();
    GrMouseDisplayCursor();
}