diff --git a/freeglut/freeglut/src/freeglut_callbacks.c b/freeglut/freeglut/src/freeglut_callbacks.c index 4915e19..4f6ad86 100644 --- a/freeglut/freeglut/src/freeglut_callbacks.c +++ b/freeglut/freeglut/src/freeglut_callbacks.c @@ -179,6 +179,15 @@ void FGAPIENTRY glutJoystickFunc( void (* callback) 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; diff --git a/freeglut/freeglut/src/freeglut_init.c b/freeglut/freeglut/src/freeglut_init.c index 5161c03..8b9d34d 100644 --- a/freeglut/freeglut/src/freeglut_init.c +++ b/freeglut/freeglut/src/freeglut_init.c @@ -84,6 +84,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */ GLUT_EXEC_STATE_INIT, /* ExecState */ NULL, /* ProgramName */ GL_FALSE, /* JoysticksInitialised */ + 0, /* NumActiveJoysticks */ GL_FALSE, /* InputDevsInitialised */ 1, /* AuxiliaryBufferNumber */ 4, /* SampleNumber */ diff --git a/freeglut/freeglut/src/freeglut_internal.h b/freeglut/freeglut/src/freeglut_internal.h index d8ae89f..79cb404 100644 --- a/freeglut/freeglut/src/freeglut_internal.h +++ b/freeglut/freeglut/src/freeglut_internal.h @@ -57,7 +57,7 @@ #else # error "Unrecognized target host!" -*/ + #endif #endif @@ -320,6 +320,7 @@ struct tagSFG_State fgExecutionState ExecState; /* Used for GLUT termination */ char *ProgramName; /* Name of the invoking program */ GLboolean JoysticksInitialised; /* Only initialize if application calls for them */ + int NumActiveJoysticks; /* Number of active joysticks -- if zero, don't poll joysticks */ GLboolean InputDevsInitialised; /* Only initialize if application calls for them */ int AuxiliaryBufferNumber; /* Number of auxiliary buffers */