locked
WM_TOUCH multitouch TOUCHEVENTF_UP event lost RRS feed

  • Question

  • For some reason when i rapidly touch the screen with multiple fingers, eventually a  finger gets "stuck". I am trying to understand  why. What i see is that a TOUCHEVENTF_UP is not sent at all neither alone not even combined with a MOVE. I give you part of my code bellow. Can anyone help me?

    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);
        }
    }

    Tuesday, December 10, 2013 3:11 PM