Fixed warnings on Linux where GCC under padantic complained ISO C casting wasn't...
[freeglut] / src / fg_callbacks.c
index b3e2917..182fe2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * freeglut_callbacks.c
+ * fg_callbacks.c
  *
  * The callbacks setting methods.
  *
 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
 
 /*
- * All of the callbacks setting methods can be generalized to this:
+ * Global callbacks.
  */
-#define SET_CALLBACK(a)                                         \
-do                                                              \
-{                                                               \
-    if( fgStructure.CurrentWindow == NULL )                     \
-        return;                                                 \
-    SET_WCB( ( *( fgStructure.CurrentWindow ) ), a, callback ); \
-} while( 0 )
 
-/*
- * Sets the Display callback for the current window
- */
-void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
-    if( !callback )
-        fgError( "Fatal error in program.  NULL display callback not "
-                 "permitted in GLUT 3.0+ or freeglut 2.0.1+" );
-    SET_CALLBACK( Display );
-}
-
-/*
- * Sets the Reshape callback for the current window
- */
-void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
+/* Sets the global idle callback */
+void FGAPIENTRY glutIdleFuncUcall( FGCBIdleUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
-    SET_CALLBACK( Reshape );
-}
-
-/*
- * Sets the Keyboard callback for the current window
- */
-void FGAPIENTRY glutKeyboardFunc( void (* callback)
-                                  ( unsigned char, int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
-    SET_CALLBACK( Keyboard );
-}
-
-/*
- * Sets the Special callback for the current window
- */
-void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
-    SET_CALLBACK( Special );
-}
-
-/*
- * Sets the global idle callback
- */
-void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFuncUcall" );
     fgState.IdleCallback = callback;
+    fgState.IdleCallbackData = userData;
 }
 
-/*
- * Sets the Timer callback for the current window
- */
-void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
-                               int timerID )
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0(Idle)
+
+/* Creates a timer and sets its callback */
+void FGAPIENTRY glutTimerFuncUcall( unsigned int timeOut, FGCBTimerUC callback, int timerID, FGCBUserData userData )
 {
     SFG_Timer *timer, *node;
 
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFuncUcall" );
 
     if( (timer = fgState.FreeTimers.Last) )
     {
@@ -111,10 +62,12 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
                      "Memory allocation failure in glutTimerFunc()" );
     }
 
-    timer->Callback  = callback;
-    timer->ID        = timerID;
-    timer->TriggerTime = fgElapsedTime() + timeOut;
+    timer->Callback     = callback;
+    timer->CallbackData = userData;
+    timer->ID           = timerID;
+    timer->TriggerTime  = fgElapsedTime() + timeOut;
 
+    /* Insert such that timers are sorted by end-time */
     for( node = fgState.Timers.First; node; node = node->Node.Next )
     {
         if( node->TriggerTime > timer->TriggerTime )
@@ -124,316 +77,255 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
     fgListInsert( &fgState.Timers, &node->Node, &timer->Node );
 }
 
-/*
- * Sets the Visibility callback for the current window.
- */
-static void fghVisibility( int status )
-{
-    int glut_status = GLUT_VISIBLE;
-
-    FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" );
-    freeglut_return_if_fail( fgStructure.CurrentWindow );
-
-    if( ( GLUT_HIDDEN == status )  || ( GLUT_FULLY_COVERED == status ) )
-        glut_status = GLUT_NOT_VISIBLE;
-    INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( glut_status ) );
-}
+IMPLEMENT_CALLBACK_FUNC_CB_ARG1(Timer, Timer)
 
-void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
+void FGAPIENTRY glutTimerFunc( unsigned int timeOut, FGCBTimer callback, int timerID )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
-    SET_CALLBACK( Visibility );
-
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
     if( callback )
-        glutWindowStatusFunc( fghVisibility );
+    {
+        FGCBTimer* reference = &callback;
+        glutTimerFuncUcall( timeOut, fghTimerFuncCallback, timerID, *((FGCBUserData*)reference) );
+    }
     else
-        glutWindowStatusFunc( NULL );
+        glutTimerFuncUcall( timeOut, NULL, timerID, NULL );
 }
 
-/*
- * Sets the keyboard key release callback for the current window
- */
-void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
-                                    ( unsigned char, int, int ) )
+/* Deprecated version of glutMenuStatusFunc callback setting method */
+void FGAPIENTRY glutMenuStateFunc( FGCBMenuState callback )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
-    SET_CALLBACK( KeyboardUp );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
+    fgState.MenuStateCallback = callback;
 }
 
-/*
- * Sets the special key release callback for the current window
- */
-void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
+/* Sets the global menu status callback for the current window */
+void FGAPIENTRY glutMenuStatusFuncUcall( FGCBMenuStatusUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
-    SET_CALLBACK( SpecialUp );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFuncUcall" );
+    fgState.MenuStatusCallback = callback;
+    fgState.MenuStatusCallbackData = userData;
 }
 
-/*
- * Sets the joystick callback and polling rate for the current window
- */
-void FGAPIENTRY glutJoystickFunc( void (* callback)
-                                  ( unsigned int, int, int, int ),
-                                  int pollInterval )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
-    fgInitialiseJoysticks ();
-
-    if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate < 0 ) ||
-           !FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) &&  /* Joystick callback was disabled */
-         ( callback && ( pollInterval >= 0 ) ) )               /* but is now enabled */
-        ++fgState.NumActiveJoysticks;
-    else if ( ( ( fgStructure.CurrentWindow->State.JoystickPollRate >= 0 ) &&
-                FETCH_WCB(*fgStructure.CurrentWindow,Joystick) ) &&  /* Joystick callback was enabled */
-              ( !callback || ( pollInterval < 0 ) ) )              /* but is now disabled */
-        --fgState.NumActiveJoysticks;
-
-    SET_CALLBACK( Joystick );
-    fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
-
-    fgStructure.CurrentWindow->State.JoystickLastPoll =
-        fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
-
-    if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
-        fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3(MenuStatus)
 
 /*
- * Sets the mouse callback for the current window
+ * Menu specific callbacks.
  */
-void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
+/* Callback upon menu destruction */
+void FGAPIENTRY glutMenuDestroyFuncUcall( FGCBDestroyUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
-    SET_CALLBACK( Mouse );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFuncUcall" );
+    if( fgStructure.CurrentMenu )
+    {
+        fgStructure.CurrentMenu->Destroy = callback;
+        fgStructure.CurrentMenu->DestroyData = userData;
+    }
 }
 
-/*
- * Sets the mouse wheel callback for the current window
- */
-void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
-    SET_CALLBACK( MouseWheel );
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0_2NAME(MenuDestroy, Destroy)
+
+/* Implement all these callback setter functions... */
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(Position)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3_USER(Keyboard,unsigned char,int,int)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3_USER(KeyboardUp,unsigned char,int,int)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(Special)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(SpecialUp)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(Mouse)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(MouseWheel)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(Motion)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2_2NAME(PassiveMotion,Passive)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(Entry)
+/* glutWMCloseFunc is an alias for glutCloseFunc; both set the window's Destroy callback */
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG0_2NAME(Close,Destroy)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG0_2NAME(WMClose,Destroy)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG0(OverlayDisplay)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(WindowStatus)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(ButtonBox)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(Dials)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(TabletMotion)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(TabletButton)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(MultiEntry)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG5(MultiButton)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(MultiMotion)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(MultiPassive)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG0(InitContext)
+IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(AppStatus)
 
 /*
- * Sets the mouse motion callback for the current window (one or more buttons
- * are pressed)
+ * Sets the Display callback for the current window
  */
-void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutDisplayFuncUcall( FGCBDisplayUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
-    SET_CALLBACK( Motion );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFuncUcall" );
+    if( !callback )
+        fgError( "Fatal error in program.  NULL display callback not "
+                 "permitted in GLUT 3.0+ or freeglut 2.0.1+" );
+    SET_CURRENT_WINDOW_CALLBACK( Display );
 }
 
-/*
- * Sets the passive mouse motion callback for the current window (no mouse
- * buttons are pressed)
- */
-void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
-    SET_CALLBACK( Passive );
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0(Display)
 
-/*
- * Window mouse entry/leave callback
- */
-void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
+void fghDefaultReshape( int width, int height, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
-    SET_CALLBACK( Entry );
+    glViewport( 0, 0, width, height );
 }
 
-/*
- * Window destruction callbacks
- */
-void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
+void FGAPIENTRY glutReshapeFuncUcall( FGCBReshapeUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
-    SET_CALLBACK( Destroy );
-}
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFuncUcall" );
+    
+    if( !callback )
+    {
+        callback = fghDefaultReshape;
+        userData = NULL;
+    }
 
-void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
-    glutCloseFunc( callback );
+    SET_CURRENT_WINDOW_CALLBACK( Reshape );
 }
 
-/* A. Donev: Destruction callback for menus */
-void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
-    if( fgStructure.CurrentMenu )
-        fgStructure.CurrentMenu->Destroy = callback;
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2(Reshape)
 
 /*
- * Deprecated version of glutMenuStatusFunc callback setting method
- */
-void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
-    fgState.MenuStateCallback = callback;
-}
+ * Sets the Visibility callback for the current window.
+ * NB: the Visibility func is deprecated in favor of the WindowStatus func,
+ * which provides more detail. The visibility func callback is implemented
+ * as a translation step from the windowStatus func. When the user sets the
+ * windowStatus func, any visibility func is overwritten.
+ * DEVELOPER NOTE: in the library, only invoke the window status func, this
+ * gets automatically translated to the visibility func if thats what the
+ * user has set.
+ * window status is kind of anemic on win32 as there are no window messages
+ * to notify us that the window is covered by other windows or not.
+ * Should one want to query this, see
+ * http://stackoverflow.com/questions/5445889/get-which-process-window-is-actually-visible-in-c-sharp
+ * for an implementation outline (but it would be polling based, not push based).
+ */
+static void fghVisibility( int status, FGCBUserData userData )
+{
+    int vis_status;
 
-/*
- * Sets the global menu status callback for the current window
- */
-void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
-    fgState.MenuStatusCallback = callback;
-}
+    FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Visibility Callback" );
+    freeglut_return_if_fail( fgStructure.CurrentWindow );
 
-/*
- * Sets the overlay display callback for the current window
- */
-void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
-    SET_CALLBACK( OverlayDisplay );
-}
+    /* Translate window status func states to visibility states */
+    if( ( status == GLUT_HIDDEN)  || ( status == GLUT_FULLY_COVERED) )
+        vis_status = GLUT_NOT_VISIBLE;
+    else    /* GLUT_FULLY_RETAINED, GLUT_PARTIALLY_RETAINED */
+        vis_status = GLUT_VISIBLE;
 
-/*
- * Sets the window status callback for the current window
- */
-void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
-    SET_CALLBACK( WindowStatus );
+    INVOKE_WCB( *( fgStructure.CurrentWindow ), Visibility, ( vis_status ) );
 }
 
-/*
- * Sets the spaceball motion callback for the current window
- */
-void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
+void FGAPIENTRY glutVisibilityFuncUcall( FGCBVisibilityUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
-    fgInitialiseSpaceball();
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFuncUcall" );
 
-    SET_CALLBACK( SpaceMotion );
-}
+    if ( !callback )
+    {
+        userData = NULL;
+    }
 
-/*
- * Sets the spaceball rotate callback for the current window
- */
-void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
-    fgInitialiseSpaceball();
+    SET_CURRENT_WINDOW_CALLBACK( Visibility );
 
-    SET_CALLBACK( SpaceRotation );
+    if( callback )
+        glutWindowStatusFuncUcall( fghVisibility, NULL );
+    else
+        glutWindowStatusFuncUcall( NULL, NULL );
 }
 
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG1(Visibility)
+
 /*
- * Sets the spaceball button callback for the current window
+ * Sets the joystick callback and polling rate for the current window
  */
-void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
+void FGAPIENTRY glutJoystickFuncUcall( FGCBJoystickUC callback, int pollInterval, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
-    fgInitialiseSpaceball();
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFuncUcall" );
+    fgInitialiseJoysticks ();
 
-    SET_CALLBACK( SpaceButton );
-}
+    if ( (
+           fgStructure.CurrentWindow->State.JoystickPollRate <= 0 ||        /* Joystick callback was disabled */
+           !FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
+         ) &&
+         ( 
+           callback && ( pollInterval > 0 )                                 /* but is now enabled */
+         ) )
+        ++fgState.NumActiveJoysticks;
+    else if ( ( 
+                fgStructure.CurrentWindow->State.JoystickPollRate > 0 &&    /* Joystick callback was enabled */
+                FETCH_WCB(*fgStructure.CurrentWindow,Joystick)
+              ) &&  
+              ( 
+                !callback || ( pollInterval <= 0 )                          /* but is now disabled */
+              ) )
+        --fgState.NumActiveJoysticks;
 
-/*
- * Sets the button box callback for the current window
- */
-void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
-    SET_CALLBACK( ButtonBox );
-}
+    SET_CURRENT_WINDOW_CALLBACK( Joystick );
+    fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
 
-/*
- * Sets the dials box callback for the current window
- */
-void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
-    SET_CALLBACK( Dials );
+    /* set last poll time such that joystick will be polled asap */
+    fgStructure.CurrentWindow->State.JoystickLastPoll = fgElapsedTime();
+    if (fgStructure.CurrentWindow->State.JoystickLastPoll < pollInterval)
+        fgStructure.CurrentWindow->State.JoystickLastPoll = 0;
+    else
+        fgStructure.CurrentWindow->State.JoystickLastPoll -= pollInterval;
 }
 
-/*
- * Sets the tablet motion callback for the current window
- */
-void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
+static void fghJoystickFuncCallback( unsigned int buttons, int axis0, int axis1, int axis2, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
-    SET_CALLBACK( TabletMotion );
+    FGCBJoystick* callback = (FGCBJoystick*)&userData;
+    (*callback)( buttons, axis0, axis1, axis2 );
 }
 
-/*
- * Sets the tablet buttons callback for the current window
- */
-void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
+void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
-    SET_CALLBACK( TabletButton );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
+    if( callback )
+    {
+        FGCBJoystick* reference = &callback;
+        glutJoystickFuncUcall( fghJoystickFuncCallback, pollInterval, *((FGCBUserData*)reference) );
+    }
+    else
+        glutJoystickFuncUcall( NULL, pollInterval, NULL );
 }
 
 /*
- * Sets the multi-pointer entry callback for the current window
+ * Sets the spaceball motion callback for the current window
  */
-void FGAPIENTRY glutMultiEntryFunc( void (* callback)(int, int ) )
+void FGAPIENTRY glutSpaceballMotionFuncUcall( FGCBSpaceMotionUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiEntryFunc" );
-    SET_CALLBACK( MultiEntry );
-}
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFuncUcall" );
+    fgInitialiseSpaceball();
 
-/*
- * 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 );
+    SET_CURRENT_WINDOW_CALLBACK( SpaceMotion );
 }
 
-/*
- * 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 );
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3_2NAME(SpaceballMotion, SpaceMotion)
 
 /*
- * Sets the multi-pointer passive motion callback for the current window
+ * Sets the spaceball rotate callback for the current window
  */
-void FGAPIENTRY glutMultiPassiveFunc( void (* callback)(int, int, int ) )
+void FGAPIENTRY glutSpaceballRotateFuncUcall( FGCBSpaceRotationUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMultiPassiveFunc" );
-    SET_CALLBACK( MultiPassive );
-}
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFuncUcall" );
+    fgInitialiseSpaceball();
 
-/*
- * Sets the context reload callback for the current window
- */
-void FGAPIENTRY glutFixMyNameInitContextFunc( void (* callback)() )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNameInitContextFunc" );
-    SET_CALLBACK( FixMyNameInitContext );
+    SET_CURRENT_WINDOW_CALLBACK( SpaceRotation );
 }
 
-/*
- * Sets the pause callback for the current window
- */
-void FGAPIENTRY glutFixMyNamePauseFunc( void (* callback)() )
-{
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNamePauseFunc" );
-    SET_CALLBACK( FixMyNamePause );
-}
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3_2NAME(SpaceballRotate, SpaceRotation)
 
 /*
- * Sets the resume callback for the current window
+ * Sets the spaceball button callback for the current window
  */
-void FGAPIENTRY glutFixMyNameResumeFunc( void (* callback)() )
+void FGAPIENTRY glutSpaceballButtonFuncUcall( FGCBSpaceButtonUC callback, FGCBUserData userData )
 {
-    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFixMyNameResumeFunc" );
-    SET_CALLBACK( FixMyNameResume );
+    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFuncUcall" );
+    fgInitialiseSpaceball();
+
+    SET_CURRENT_WINDOW_CALLBACK( SpaceButton );
 }
 
+IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2_2NAME(SpaceballButton, SpaceButton)
+
 /*** END OF FILE ***/