Fixed bug identified by Kevin. If pollrate is larger than elapsedtime, we'd wrap, and joystick would never get polled

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1710 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2014-10-12 06:21:32 +00:00
parent 635ca451cb
commit 2e45756a33

View File

@ -247,11 +247,12 @@ void FGAPIENTRY glutJoystickFunc( FGCBJoystick callback, int pollInterval )
SET_CALLBACK( Joystick );
fgStructure.CurrentWindow->State.JoystickPollRate = pollInterval;
fgStructure.CurrentWindow->State.JoystickLastPoll =
fgElapsedTime() - fgStructure.CurrentWindow->State.JoystickPollRate;
if( fgStructure.CurrentWindow->State.JoystickLastPoll < 0 )
/* 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;
}