Fixing multitouch for Windows per e-mail from Florian Echtler dated 5/3/11 10:33 AM

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@919 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
fayjf 2011-05-27 20:17:34 +00:00
parent 7b62a4fb84
commit 409b0c9f78
2 changed files with 27 additions and 3 deletions

View File

@ -70,6 +70,12 @@ struct GXKeyList gxKeyList;
# define MIN(a,b) (((a)<(b)) ? (a) : (b)) # define MIN(a,b) (((a)<(b)) ? (a) : (b))
#endif #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 numInputs = (unsigned int)wParam;
unsigned int i = 0; unsigned int i = 0;
TOUCHINPUT* ti = (TOUCHINPUT*)malloc( sizeof(TOUCHINPUT)*numInputs); 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 */ /* Handle each contact point */
for (i = 0; i < numInputs; ++i ) { 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 ); free( (void*)ti );
lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/ lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/
break; break;

View 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 */ /* pushing attribute/value pairs into an array */
#define ATTRIB(a) attributes[where++]=(a) #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 */ /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */
#ifdef WM_TOUCH #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 #endif
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)