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.