Having the library poll joysticks only if there is an active joystick callback enabled per e-mail exchange titled "overjoyed" on December 10-13, 2009
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@863 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
81d921ae4c
commit
726c395f33
@ -179,6 +179,15 @@ void FGAPIENTRY glutJoystickFunc( void (* callback)
|
|||||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
||||||
fgInitialiseJoysticks ();
|
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 );
|
SET_CALLBACK( Joystick );
|
||||||
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
|
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ SFG_State fgState = { { -1, -1, GL_FALSE }, /* Position */
|
|||||||
GLUT_EXEC_STATE_INIT, /* ExecState */
|
GLUT_EXEC_STATE_INIT, /* ExecState */
|
||||||
NULL, /* ProgramName */
|
NULL, /* ProgramName */
|
||||||
GL_FALSE, /* JoysticksInitialised */
|
GL_FALSE, /* JoysticksInitialised */
|
||||||
|
0, /* NumActiveJoysticks */
|
||||||
GL_FALSE, /* InputDevsInitialised */
|
GL_FALSE, /* InputDevsInitialised */
|
||||||
1, /* AuxiliaryBufferNumber */
|
1, /* AuxiliaryBufferNumber */
|
||||||
4, /* SampleNumber */
|
4, /* SampleNumber */
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
# error "Unrecognized target host!"
|
# error "Unrecognized target host!"
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -320,6 +320,7 @@ struct tagSFG_State
|
|||||||
fgExecutionState ExecState; /* Used for GLUT termination */
|
fgExecutionState ExecState; /* Used for GLUT termination */
|
||||||
char *ProgramName; /* Name of the invoking program */
|
char *ProgramName; /* Name of the invoking program */
|
||||||
GLboolean JoysticksInitialised; /* Only initialize if application calls for them */
|
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 */
|
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
|
||||||
|
|
||||||
int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
|
int AuxiliaryBufferNumber; /* Number of auxiliary buffers */
|
||||||
|
Reference in New Issue
Block a user