{
va_list ap;
- va_start( ap, fmt );
+ if (fgState.ErrorFunc) {
- fprintf( stderr, "freeglut ");
- if( fgState.ProgramName )
- fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
- fprintf( stderr, "\n" );
+ va_start( ap, fmt );
- va_end( ap );
+ /* call user set error handler here */
+ fgState.ErrorFunc(fmt, ap);
- if ( fgState.Initialised )
- fgDeinitialize ();
+ va_end( ap );
- exit( 1 );
+ } else {
+
+ va_start( ap, fmt );
+
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf( stderr, "(%s): ", fgState.ProgramName );
+ VFPRINTF( stderr, fmt, ap );
+ fprintf( stderr, "\n" );
+
+ va_end( ap );
+
+ if ( fgState.Initialised )
+ fgDeinitialize ();
+
+ exit( 1 );
+ }
}
void fgWarning( const char *fmt, ... )
{
va_list ap;
- va_start( ap, fmt );
+ if (fgState.WarningFunc) {
+
+ va_start( ap, fmt );
+
+ /* call user set warning handler here */
+ fgState.WarningFunc(fmt, ap);
- fprintf( stderr, "freeglut ");
- if( fgState.ProgramName )
- fprintf( stderr, "(%s): ", fgState.ProgramName );
- VFPRINTF( stderr, fmt, ap );
- fprintf( stderr, "\n" );
+ va_end( ap );
- va_end( ap );
+ } else {
+
+ va_start( ap, fmt );
+
+ fprintf( stderr, "freeglut ");
+ if( fgState.ProgramName )
+ fprintf( stderr, "(%s): ", fgState.ProgramName );
+ VFPRINTF( stderr, fmt, ap );
+ fprintf( stderr, "\n" );
+
+ va_end( ap );
+ }
}
+
/*
* Indicates whether Joystick events are being used by ANY window.
*
/*
* Returns GLUT modifier mask for the state field of an X11 event.
*/
-static int fghGetXModifiers( int state )
+int fghGetXModifiers( int state )
{
int ret = 0;
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;
}
}
/* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
uMsg, wParam, lParam ); */
- /* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */
- if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) )
- {
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
- );
-
- lControl = 1;
- }
-
- if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) )
- {
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
- );
-
- rControl = 1;
- }
-
- if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) )
- {
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
- );
-
- lShift = 1;
- }
-
- if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) )
- {
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
- );
-
- rShift = 1;
- }
-
- if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) )
+ if ( window )
{
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
- );
-
- lAlt = 1;
+ /* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */
+ if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lControl = 1;
+ }
+
+ if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rControl = 1;
+ }
+
+ if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lShift = 1;
+ }
+
+ if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rShift = 1;
+ }
+
+ if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lAlt = 1;
+ }
+
+ if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) )
+ {
+ INVOKE_WCB ( *window, Special,
+ ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rAlt = 1;
+ }
+
+ /* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */
+ if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lControl = 0;
+ }
+
+ if ( rControl && !GetAsyncKeyState ( VK_RCONTROL ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rControl = 0;
+ }
+
+ if ( lShift && !GetAsyncKeyState ( VK_LSHIFT ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lShift = 0;
+ }
+
+ if ( rShift && !GetAsyncKeyState ( VK_RSHIFT ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rShift = 0;
+ }
+
+ if ( lAlt && !GetAsyncKeyState ( VK_LMENU ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
+ );
+
+ lAlt = 0;
+ }
+
+ if ( rAlt && !GetAsyncKeyState ( VK_RMENU ) )
+ {
+ INVOKE_WCB ( *window, SpecialUp,
+ ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
+ );
+
+ rAlt = 0;
+ }
}
- if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) )
- {
- INVOKE_WCB ( *window, Special,
- ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
- );
-
- rAlt = 1;
- }
-
- /* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */
- if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_CTRL_L, window->State.MouseX, window->State.MouseY )
- );
-
- lControl = 0;
- }
-
- if ( rControl && !GetAsyncKeyState ( VK_RCONTROL ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_CTRL_R, window->State.MouseX, window->State.MouseY )
- );
-
- rControl = 0;
- }
-
- if ( lShift && !GetAsyncKeyState ( VK_LSHIFT ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_SHIFT_L, window->State.MouseX, window->State.MouseY )
- );
-
- lShift = 0;
- }
-
- if ( rShift && !GetAsyncKeyState ( VK_RSHIFT ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_SHIFT_R, window->State.MouseX, window->State.MouseY )
- );
-
- rShift = 0;
- }
-
- if ( lAlt && !GetAsyncKeyState ( VK_LMENU ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_ALT_L, window->State.MouseX, window->State.MouseY )
- );
-
- lAlt = 0;
- }
-
- if ( rAlt && !GetAsyncKeyState ( VK_RMENU ) )
- {
- INVOKE_WCB ( *window, SpecialUp,
- ( GLUT_KEY_ALT_R, window->State.MouseX, window->State.MouseY )
- );
-
- rAlt = 0;
- }
-
-
switch( uMsg )
{
case WM_CREATE:
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 );