From 2e45756a332e2bd2024bbd3cec6fcf449ef41274 Mon Sep 17 00:00:00 2001 From: dcnieho Date: Sun, 12 Oct 2014 06:21:32 +0000 Subject: [PATCH 1/2] 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 --- freeglut/freeglut/src/fg_callbacks.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/freeglut/freeglut/src/fg_callbacks.c b/freeglut/freeglut/src/fg_callbacks.c index 5ca3761..7d5fca6 100644 --- a/freeglut/freeglut/src/fg_callbacks.c +++ b/freeglut/freeglut/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; } From 977d52522ca444033e60c65500c90a6a52da0aab Mon Sep 17 00:00:00 2001 From: dcnieho Date: Sun, 12 Oct 2014 06:37:00 +0000 Subject: [PATCH 2/2] change some initializer use that some compilers choke on (even that technically may a bug in the compiler, I think) git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1711 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/mswin/fg_main_mswin.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/freeglut/freeglut/src/mswin/fg_main_mswin.c b/freeglut/freeglut/src/mswin/fg_main_mswin.c index 61caf55..137fc06 100644 --- a/freeglut/freeglut/src/mswin/fg_main_mswin.c +++ b/freeglut/freeglut/src/mswin/fg_main_mswin.c @@ -752,7 +752,9 @@ SFG_Window* fghWindowUnderCursor(SFG_Window *window) /* Get mouse position at time of message */ DWORD mouse_pos_dw = GetMessagePos(); - POINT mouse_pos = {GET_X_LPARAM(mouse_pos_dw), GET_Y_LPARAM(mouse_pos_dw)}; + POINT mouse_pos; + mouse_pos.x = GET_X_LPARAM(mouse_pos_dw); + mouse_pos.y = GET_Y_LPARAM(mouse_pos_dw); ScreenToClient( window->Window.Handle, &mouse_pos ); hwnd = ChildWindowFromPoint(window->Window.Handle, mouse_pos); @@ -947,7 +949,9 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR /* For child window, we should return relative to upper-left * of parent's client area. */ - POINT topleft = {windowRect.left,windowRect.top}; + POINT topleft; + topleft.x = windowRect.left; + topleft.y = windowRect.top; ScreenToClient(window->Parent->Window.Handle,&topleft); windowRect.left = topleft.x; @@ -1763,4 +1767,4 @@ void fgPlatformVisibilityWork(SFG_Window* window) } ShowWindow( win->Window.Handle, cmdShow ); -} \ No newline at end of file +}