X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=inline;f=src%2Fmswin%2Ffg_main_mswin.c;h=09e397fe01dab82602bdd815b25c10498d2b1db6;hb=f772f5aa7706c09712d416702b5432803d4f31a8;hp=8162a5fbe8aca5ee1dad8ddec0edb81f19da5d46;hpb=c2de6d3474dc0c697fa0d5c9fd84988896a077ef;p=freeglut diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index 8162a5f..09e397f 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -578,6 +578,18 @@ static int fgPlatformGetModifiers (void) ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 ); } +/* Check whether a button (VK_*BUTTON) is currently depressed. Returns + * non-zero (not necessarily 1) if yes. */ +static SHORT fgGetAsyncKeyState(int vKey) +{ + /* MSDN says: "If the most significant bit is set, the key is down, and if + * the least significant bit is set, the key was pressed after the previous + * call to GetAsyncKeyState." This behavior cannot be relied upon however. + * Remove this bit so that we can simply test with ! if key is up. + */ + return GetAsyncKeyState(vKey) & ~1; +} + static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean keydown, WPARAM wParam, LPARAM lParam) { static unsigned char lControl = 0, lShift = 0, lAlt = 0, @@ -629,12 +641,12 @@ static LRESULT fghWindowProcKeyPress(SFG_Window *window, UINT uMsg, GLboolean ke * so when we get an alt, shift or control keypress here, we manually check whether it was the left or the right */ #define ASYNC_KEY_EVENT(winKey,glutKey,keyStateVar)\ - if (!keyStateVar && GetAsyncKeyState ( winKey ))\ + if (!keyStateVar && fgGetAsyncKeyState ( winKey ))\ {\ keypress = glutKey;\ keyStateVar = 1;\ }\ - else if (keyStateVar && !GetAsyncKeyState ( winKey ))\ + else if (keyStateVar && !fgGetAsyncKeyState ( winKey ))\ {\ keypress = glutKey;\ keyStateVar = 0;\ @@ -1237,7 +1249,7 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR SetCapture ( window->Window.Handle ) ; setCaptureActive = 1; /* Set to false in WM_CAPTURECHANGED handler */ } - else if (!GetAsyncKeyState(VK_LBUTTON) && !GetAsyncKeyState(VK_MBUTTON) && !GetAsyncKeyState(VK_RBUTTON)) + else if (!fgGetAsyncKeyState(VK_LBUTTON) && !fgGetAsyncKeyState(VK_MBUTTON) && !fgGetAsyncKeyState(VK_RBUTTON)) /* Make sure all mouse buttons are released before releasing capture */ ReleaseCapture () ;