From: John F. Fay Date: Fri, 27 May 2011 20:17:34 +0000 (+0000) Subject: Fixing multitouch for Windows per e-mail from Florian Echtler dated 5/3/11 10:33 AM X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=d530bec66ffb40150fa3f291bba08e500e6ec988;p=freeglut Fixing multitouch for Windows per e-mail from Florian Echtler dated 5/3/11 10:33 AM git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@919 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/freeglut_main.c b/src/freeglut_main.c index e31ee1a..f73953d 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -70,6 +70,12 @@ struct GXKeyList gxKeyList; # define MIN(a,b) (((a)<(b)) ? (a) : (b)) #endif +#ifdef WM_TOUCH + typedef BOOL (*pGetTouchInputInfo)(HTOUCHINPUT,UINT,PTOUCHINPUT,int); + typedef BOOL (*pCloseTouchInputHandle)(HTOUCHINPUT); + static pGetTouchInputInfo fghGetTouchInputInfo = (pGetTouchInputInfo)0xDEADBEEF; + static pCloseTouchInputHandle fghCloseTouchInputHandle = (pCloseTouchInputHandle)0xDEADBEEF; +#endif /* * TODO BEFORE THE STABLE RELEASE: @@ -2456,7 +2462,18 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, unsigned int numInputs = (unsigned int)wParam; unsigned int i = 0; TOUCHINPUT* ti = (TOUCHINPUT*)malloc( sizeof(TOUCHINPUT)*numInputs); - if (GetTouchInputInfo( (HTOUCHINPUT)lParam, numInputs, ti, sizeof(TOUCHINPUT) )) { + + if (fghGetTouchInputInfo == (pGetTouchInputInfo)0xDEADBEEF) { + fghGetTouchInputInfo = (pGetTouchInputInfo)GetProcAddress(GetModuleHandle("user32"),"GetTouchInputInfo"); + fghCloseTouchInputHandle = (pCloseTouchInputHandle)GetProcAddress(GetModuleHandle("user32"),"CloseTouchInputHandle"); + } + + if (!fghGetTouchInputInfo) { + free( (void*)ti ); + break; + } + + if (fghGetTouchInputInfo( (HTOUCHINPUT)lParam, numInputs, ti, sizeof(TOUCHINPUT) )) { /* Handle each contact point */ for (i = 0; i < numInputs; ++i ) { @@ -2478,7 +2495,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, } } } - CloseTouchInputHandle((HTOUCHINPUT)lParam); + fghCloseTouchInputHandle((HTOUCHINPUT)lParam); free( (void*)ti ); lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/ break; diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 0c56fe1..41c3fe7 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -141,6 +141,10 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar #endif /* TARGET_HOST_MS_WINDOWS */ +#ifdef WM_TOUCH + typedef BOOL (*pRegisterTouchWindow)(HWND,ULONG); + static pRegisterTouchWindow fghRegisterTouchWindow = (pRegisterTouchWindow)0xDEADBEEF; +#endif /* pushing attribute/value pairs into an array */ #define ATTRIB(a) attributes[where++]=(a) @@ -1293,7 +1297,10 @@ void fgOpenWindow( SFG_Window* window, const char* title, /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */ #ifdef WM_TOUCH - RegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM ); + if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF) + fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow"); + if (fghRegisterTouchWindow) + fghRegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM ); #endif #if defined(_WIN32_WCE)