Fixing multitouch for Windows per e-mail from Florian Echtler dated 5/3/11 10:33 AM
authorJohn F. Fay <johnffay@nettally.com>
Fri, 27 May 2011 20:17:34 +0000 (20:17 +0000)
committerJohn F. Fay <johnffay@nettally.com>
Fri, 27 May 2011 20:17:34 +0000 (20:17 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@919 7f0cb862-5218-0410-a997-914c9d46530a

src/freeglut_main.c
src/freeglut_window.c

index e31ee1a..f73953d 100644 (file)
@@ -70,6 +70,12 @@ struct GXKeyList gxKeyList;
 #    define MIN(a,b) (((a)<(b)) ? (a) : (b))
 #endif
 
 #    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:
 
 /*
  * 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);
                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 ) {
 
                        /* 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;
                free( (void*)ti );
                lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/
                break;
index 0c56fe1..41c3fe7 100644 (file)
@@ -141,6 +141,10 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShar
 
 #endif  /* TARGET_HOST_MS_WINDOWS */
 
 
 #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)
 
 /* 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
 
     /* 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)
     #endif
 
 #if defined(_WIN32_WCE)