0

I am working on an app for Windows that supports multitouch. I have followed the guide found here

http://msdn.microsoft.com/en-us/library/windows/desktop/dd744775(v=vs.85).aspx

but i have a problem. At some point there is a stuck finger meaning that i can see that there is a TOUCHEVENTF_DOWN, a TOUCHEVENTF_MOVE but NO TOUCHEVENTF_UP for this finger although there is no fingers any more on the screen...

I have:

static int fingers = 0;
static LRESULT OnTouch(HWND hWnd, WPARAM wParam, LPARAM lParam );
static LRESULT CALLBACK winProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);

SetWindowLongPtr(handle, GWL_WNDPROC, (long)winProc);

LRESULT CALLBACK winProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam){
    switch(Msg){
    case WM_TOUCH:
        OnTouch(handle, wParam, lParam);
        break;
...
}

LRESULT OnTouch(HWND hWnd, WPARAM wParam, LPARAM lParam )
{
    BOOL bHandled = FALSE;
    UINT cInputs = LOWORD(wParam);
    PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
    if (pInputs){
        if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))){
            for (UINT i=0; i < cInputs; i++){
            TOUCHINPUT ti = pInputs[i];
            if( ti.dwFlags&TOUCHEVENTF_DOWN ) {
                        fingers+=1;
            }
            else {
                if( ti.dwFlags&TOUCHEVENTF_MOVE) {
                }
                if( ti.dwFlags&TOUCHEVENTF_UP) {
                            fingers-=1;
                }
            }
            bHandled = TRUE;
        }else{
            /* handle the error here */
        }
        delete [] pInputs;
    }else{
        /* handle the error here, probably out of memory */
    }
    if (bHandled){
        // if you handled the message, close the touch input handle and return
        CloseTouchInputHandle((HTOUCHINPUT)lParam);
        return 0;
    }else{
        // if you didn't handle the message, let DefWindowProc handle it
        printf("ERROR\n");
        return DefWindowProc(hWnd, WM_TOUCH, wParam, lParam);
    }
}

After touching the screen i end up with no actual fingers on the screen but with the variable fingers != 0....

I would appreciate some help. Thanks.

P.S. I applied the proposed change but i still get stuck fingers, no finger up received.

4

1 回答 1

2

TOUCHEVENTF_MOVE并且TOUCHEVENTF_UP可以组合在一个输入中,但是您正在测试它们,就好像它们是独占值一样。因此,如果“移动”和“上升”同时出现,您将错过“上升”。

结构的文档TOUCHINPUT指定了哪些标志组合起来有意义。

于 2013-12-05T20:32:34.433 回答