X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffg_main_mswin.c;h=22a1d4413cc4c0a6c4c31db9cec8ad81ef9070fd;hb=25a96752f76c571c447b00e376f0002568389bad;hp=f4a4919260faa9ad74f4db00f7399529e3059f57;hpb=775071fb9c0eee0bf4b5b13a38a12176518da055;p=freeglut diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index f4a4919..22a1d44 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -277,114 +277,40 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, fgState.Modifiers = fgPlatformGetModifiers( ); /* Checking for CTRL, ALT, and SHIFT key positions: Key Down! */ - if ( !lControl && GetAsyncKeyState ( VK_LCONTROL ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_CTRL_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lControl = 1; - } - - if ( !rControl && GetAsyncKeyState ( VK_RCONTROL ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_CTRL_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rControl = 1; +#define SPECIAL_KEY_DOWN(winKey,glutKey,winProcVar)\ + if ( !winProcVar && GetAsyncKeyState ( winKey ) )\ + {\ + INVOKE_WCB ( *temp_window, Special,\ + ( glutKey, temp_window->State.MouseX, temp_window->State.MouseY )\ + );\ + winProcVar = 1;\ } - if ( !lShift && GetAsyncKeyState ( VK_LSHIFT ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_SHIFT_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lShift = 1; - } - - if ( !rShift && GetAsyncKeyState ( VK_RSHIFT ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_SHIFT_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rShift = 1; - } - - if ( !lAlt && GetAsyncKeyState ( VK_LMENU ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_ALT_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lAlt = 1; - } - - if ( !rAlt && GetAsyncKeyState ( VK_RMENU ) ) - { - INVOKE_WCB ( *temp_window, Special, - ( GLUT_KEY_ALT_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rAlt = 1; - } + SPECIAL_KEY_DOWN(VK_LCONTROL,GLUT_KEY_CTRL_L ,lControl); + SPECIAL_KEY_DOWN(VK_RCONTROL,GLUT_KEY_CTRL_R ,rControl); + SPECIAL_KEY_DOWN(VK_LSHIFT ,GLUT_KEY_SHIFT_L,lShift); + SPECIAL_KEY_DOWN(VK_RSHIFT ,GLUT_KEY_SHIFT_R,rShift); + SPECIAL_KEY_DOWN(VK_LMENU ,GLUT_KEY_ALT_L ,lAlt); + SPECIAL_KEY_DOWN(VK_RMENU ,GLUT_KEY_ALT_R ,rAlt); +#undef SPECIAL_KEY_DOWN /* Checking for CTRL, ALT, and SHIFT key positions: Key Up! */ - if ( lControl && !GetAsyncKeyState ( VK_LCONTROL ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_CTRL_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lControl = 0; - } - - if ( rControl && !GetAsyncKeyState ( VK_RCONTROL ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_CTRL_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rControl = 0; +#define SPECIAL_KEY_UP(winKey,glutKey,winProcVar)\ + if ( winProcVar && !GetAsyncKeyState ( winKey ) )\ + {\ + INVOKE_WCB ( *temp_window, SpecialUp,\ + ( glutKey, temp_window->State.MouseX, temp_window->State.MouseY )\ + );\ + winProcVar = 0;\ } - if ( lShift && !GetAsyncKeyState ( VK_LSHIFT ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_SHIFT_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lShift = 0; - } - - if ( rShift && !GetAsyncKeyState ( VK_RSHIFT ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_SHIFT_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rShift = 0; - } - - if ( lAlt && !GetAsyncKeyState ( VK_LMENU ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_ALT_L, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - lAlt = 0; - } - - if ( rAlt && !GetAsyncKeyState ( VK_RMENU ) ) - { - INVOKE_WCB ( *temp_window, SpecialUp, - ( GLUT_KEY_ALT_R, temp_window->State.MouseX, temp_window->State.MouseY ) - ); - - rAlt = 0; - } + SPECIAL_KEY_UP(VK_LCONTROL,GLUT_KEY_CTRL_L ,lControl); + SPECIAL_KEY_UP(VK_RCONTROL,GLUT_KEY_CTRL_R ,rControl); + SPECIAL_KEY_UP(VK_LSHIFT ,GLUT_KEY_SHIFT_L,lShift); + SPECIAL_KEY_UP(VK_RSHIFT ,GLUT_KEY_SHIFT_R,rShift); + SPECIAL_KEY_UP(VK_LMENU ,GLUT_KEY_ALT_L ,lAlt); + SPECIAL_KEY_UP(VK_RMENU ,GLUT_KEY_ALT_R ,rAlt); +#undef SPECIAL_KEY_UP fgState.Modifiers = INVALID_MODIFIERS; }