From: Diederick Niehorster Date: Sun, 12 Oct 2014 06:21:32 +0000 (+0000) Subject: Fixed bug identified by Kevin. If pollrate is larger than elapsedtime, we'd wrap... X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=1fb03dfe7f548056ebebe5208943199f0b163283;p=freeglut Fixed bug identified by Kevin. If pollrate is larger than elapsedtime, we'd wrap, and joystick would never get polled git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1710 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/src/fg_callbacks.c b/src/fg_callbacks.c index 5ca3761..7d5fca6 100644 --- a/src/fg_callbacks.c +++ b/src/fg_callbacks.c @@ -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; }