From: <fa...@us...> - 2011-03-18 02:59:28
|
Revision: 905 http://freeglut.svn.sourceforge.net/freeglut/?rev=905&view=rev Author: fayjf Date: 2011-03-18 02:59:22 +0000 (Fri, 18 Mar 2011) Log Message: ----------- Adding multitouch capability per e-mail from Florian Echtler dated 3/17/11 12:07 PM Modified Paths: -------------- trunk/freeglut/freeglut/configure.ac trunk/freeglut/freeglut/include/GL/freeglut_ext.h trunk/freeglut/freeglut/src/Makefile.am trunk/freeglut/freeglut/src/freeglut_callbacks.c trunk/freeglut/freeglut/src/freeglut_ext.c trunk/freeglut/freeglut/src/freeglut_internal.h trunk/freeglut/freeglut/src/freeglut_main.c trunk/freeglut/freeglut/src/freeglut_window.c Modified: trunk/freeglut/freeglut/configure.ac =================================================================== --- trunk/freeglut/freeglut/configure.ac 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/configure.ac 2011-03-18 02:59:22 UTC (rev 905) @@ -31,6 +31,7 @@ GL_LIBS="-lGL -lXext -lX11" AC_CHECK_LIB([Xxf86vm], [XF86VidModeSwitchToMode]) AC_CHECK_LIB([Xrandr], [XRRQueryExtension]) + AC_CHECK_LIB([Xi], [XISelectEvents]) LIBXI=-lXi VERSION_INFO="-version-info 12:0:9" EXPORT_FLAGS= @@ -50,6 +51,7 @@ AC_CHECK_HEADERS([X11/extensions/xf86vmode.h], [], [], [#include <X11/Xlib.h>]) AC_CHECK_HEADERS([X11/extensions/Xrandr.h]) AC_CHECK_HEADERS([X11/extensions/XI.h X11/extensions/XInput.h]) +AC_CHECK_HEADERS([X11/extensions/XInput2.h]) CPPFLAGS="$save_CPPFLAGS" # Checks for library functions. Modified: trunk/freeglut/freeglut/include/GL/freeglut_ext.h =================================================================== --- trunk/freeglut/freeglut/include/GL/freeglut_ext.h 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/include/GL/freeglut_ext.h 2011-03-18 02:59:22 UTC (rev 905) @@ -173,6 +173,17 @@ FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName ); /* + * Multi-touch/multi-pointer extensions + */ + +#define GLUT_HAS_MULTI 1 + +FGAPI void FGAPIENTRY glutMultiEntryFunc( void (* callback)( int, int ) ); +FGAPI void FGAPIENTRY glutMultiButtonFunc( void (* callback)( int, int, int, int, int ) ); +FGAPI void FGAPIENTRY glutMultiMotionFunc( void (* callback)( int, int, int ) ); +FGAPI void FGAPIENTRY glutMultiPassiveFunc( void (* callback)( int, int, int ) ); + +/* * Joystick functions, see freeglut_joystick.c */ /* USE OF THESE FUNCTIONS IS DEPRECATED !!!!! */ Modified: trunk/freeglut/freeglut/src/Makefile.am =================================================================== --- trunk/freeglut/freeglut/src/Makefile.am 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/Makefile.am 2011-03-18 02:59:22 UTC (rev 905) @@ -38,7 +38,8 @@ freeglut_structure.c \ freeglut_teapot.c \ freeglut_videoresize.c \ - freeglut_window.c + freeglut_window.c \ + freeglut_xinput.c # # Additional linker flags Modified: trunk/freeglut/freeglut/src/freeglut_callbacks.c =================================================================== --- trunk/freeglut/freeglut/src/freeglut_callbacks.c 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/freeglut_callbacks.c 2011-03-18 02:59:22 UTC (rev 905) @@ -373,4 +373,40 @@ SET_CALLBACK( TabletButton ); } +/* + * Sets the multi-pointer entry callback for the current window + */ +void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) ) +{ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" ); + SET_CALLBACK( MultiEntry ); +} + +/* + * Sets the multi-pointer button callback for the current window + */ +void FGAPIENTRY glutMultiButtonFunc( void (* callback)(int, int, int, int, int ) ) +{ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiButtonFunc" ); + SET_CALLBACK( MultiButton ); +} + +/* + * Sets the multi-pointer motion callback for the current window + */ +void FGAPIENTRY glutMultiMotionFunc( void (* callback)(int, int, int ) ) +{ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiMotionFunc" ); + SET_CALLBACK( MultiMotion ); +} + +/* + * Sets the multi-pointer passive motion callback for the current window + */ +void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) ) +{ + FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" ); + SET_CALLBACK( MultiPassive ); +} + /*** END OF FILE ***/ Modified: trunk/freeglut/freeglut/src/freeglut_ext.c =================================================================== --- trunk/freeglut/freeglut/src/freeglut_ext.c 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/freeglut_ext.c 2011-03-18 02:59:22 UTC (rev 905) @@ -85,6 +85,10 @@ CHECK_NAME(glutReshapeFunc); CHECK_NAME(glutKeyboardFunc); CHECK_NAME(glutMouseFunc); + CHECK_NAME(glutMultiEntryFunc); + CHECK_NAME(glutMultiMotionFunc); + CHECK_NAME(glutMultiButtonFunc); + CHECK_NAME(glutMultiPassiveFunc); CHECK_NAME(glutMotionFunc); CHECK_NAME(glutPassiveMotionFunc); CHECK_NAME(glutEntryFunc); Modified: trunk/freeglut/freeglut/src/freeglut_internal.h =================================================================== --- trunk/freeglut/freeglut/src/freeglut_internal.h 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/freeglut_internal.h 2011-03-18 02:59:22 UTC (rev 905) @@ -238,6 +238,11 @@ typedef void (* FGCBTabletButton )( int, int, int, int ); typedef void (* FGCBDestroy )( void ); +typedef void (* FGCBMultiEntry )( int, int ); +typedef void (* FGCBMultiButton )( int, int, int, int, int ); +typedef void (* FGCBMultiMotion )( int, int, int ); +typedef void (* FGCBMultiPassive )( int, int, int ); + /* The global callbacks type definitions */ typedef void (* FGCBIdle )( void ); typedef void (* FGCBTimer )( int ); @@ -587,6 +592,12 @@ CB_Joystick, CB_Destroy, + /* MPX-related */ + CB_MultiEntry, + CB_MultiButton, + CB_MultiMotion, + CB_MultiPassive, + /* Presently ignored */ CB_Select, CB_OverlayDisplay, @@ -970,8 +981,15 @@ */ #if TARGET_HOST_POSIX_X11 int fgHintPresent(Window window, Atom property, Atom hint); + +/* Handler for X extension Events */ +#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + void fgHandleExtensionEvents( XEvent * ev ); + void fgRegisterDevices( Display* dpy, Window* win ); #endif +#endif + SFG_Proc fghGetProcAddress( const char *procName ); #if TARGET_HOST_MS_WINDOWS Modified: trunk/freeglut/freeglut/src/freeglut_main.c =================================================================== --- trunk/freeglut/freeglut/src/freeglut_main.c 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/freeglut_main.c 2011-03-18 02:59:22 UTC (rev 905) @@ -512,7 +512,7 @@ /* * Returns GLUT modifier mask for the state field of an X11 event. */ -static int fghGetXModifiers( int state ) +int fghGetXModifiers( int state ) { int ret = 0; @@ -1445,7 +1445,10 @@ break; default: - fgWarning ("Unknown X event type: %d\n", event.type); + /* enter handling of Extension Events here */ + #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + fgHandleExtensionEvents( &event ); + #endif break; } } @@ -2444,6 +2447,41 @@ lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); break; +#ifdef WM_TOUCH + /* handle multi-touch messages */ + case WM_TOUCH: + { + 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) )) { + /* Handle each contact point */ + for (i = 0; i < numInputs; ++i ) { + + POINT tp; + tp.x = TOUCH_COORD_TO_PIXEL(ti[i].x); + tp.y = TOUCH_COORD_TO_PIXEL(ti[i].y); + ScreenToClient( hWnd, &tp ); + + ti[i].dwID = ti[i].dwID * 2; + + if (ti[i].dwFlags & TOUCHEVENTF_DOWN) { + INVOKE_WCB( *window, MultiEntry, ( ti[i].dwID, GLUT_ENTERED ) ); + INVOKE_WCB( *window, MultiButton, ( ti[i].dwID, tp.x, tp.y, 0, GLUT_DOWN ) ); + } else if (ti[i].dwFlags & TOUCHEVENTF_MOVE) { + INVOKE_WCB( *window, MultiMotion, ( ti[i].dwID, tp.x, tp.y ) ); + } else if (ti[i].dwFlags & TOUCHEVENTF_UP) { + INVOKE_WCB( *window, MultiButton, ( ti[i].dwID, tp.x, tp.y, 0, GLUT_UP ) ); + INVOKE_WCB( *window, MultiEntry, ( ti[i].dwID, GLUT_LEFT ) ); + } + } + } + CloseTouchInputHandle((HTOUCHINPUT)lParam); + free( (void*)ti ); + lRet = 0; /*DefWindowProc( hWnd, uMsg, wParam, lParam );*/ + break; + } +#endif default: /* Handle unhandled messages */ lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); Modified: trunk/freeglut/freeglut/src/freeglut_window.c =================================================================== --- trunk/freeglut/freeglut/src/freeglut_window.c 2011-03-17 04:22:55 UTC (rev 904) +++ trunk/freeglut/freeglut/src/freeglut_window.c 2011-03-18 02:59:22 UTC (rev 905) @@ -1120,6 +1120,11 @@ window->Window.Context ); + /* register extension events _before_ window is mapped */ + #ifdef HAVE_X11_EXTENSIONS_XINPUT2_H + fgRegisterDevices( fgDisplay.Display, &(window->Window.Handle) ); + #endif + XMapWindow( fgDisplay.Display, window->Window.Handle ); XFree(visualInfo); @@ -1286,6 +1291,10 @@ /* SetWindowPos(window->Window.Handle, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); */ + /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */ + #ifdef WM_TOUCH + RegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM ); + #endif #if defined(_WIN32_WCE) ShowWindow( window->Window.Handle, SW_SHOW ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |