Skip to content

Commit

Permalink
Mask low bit of key state for all keys.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1445 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Apr 27, 2001
1 parent ff3295f commit c761594
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_win32.cxx,v 1.33.2.34 2001/04/27 14:39:27 easysw Exp $"
// "$Id: Fl_win32.cxx,v 1.33.2.35 2001/04/27 14:55:33 easysw Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -515,17 +515,16 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
if (!wParam)
{
ulong state = 0;
if (GetAsyncKeyState(VK_CAPITAL)) state |= FL_CAPS_LOCK;
if (GetAsyncKeyState(VK_NUMLOCK)) state |= FL_NUM_LOCK;
if (GetAsyncKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
if (GetAsyncKeyState(VK_CONTROL)) state |= FL_CTRL;
if (GetAsyncKeyState(VK_SHIFT)) state |= FL_SHIFT;
if (GetAsyncKeyState(VK_MENU)) state |= FL_ALT;
if (GetAsyncKeyState(VK_LWIN) ||
GetAsyncKeyState(VK_RWIN)) state |= FL_META;
if (GetAsyncKeyState(VK_LBUTTON)) state |= FL_BUTTON1;
if (GetAsyncKeyState(VK_MBUTTON)) state |= FL_BUTTON2;
if (GetAsyncKeyState(VK_RBUTTON)) state |= FL_BUTTON3;
if (GetAsyncKeyState(VK_CAPITAL)&~1) state |= FL_CAPS_LOCK;
if (GetAsyncKeyState(VK_NUMLOCK)&~1) state |= FL_NUM_LOCK;
if (GetAsyncKeyState(VK_SCROLL)&~1) state |= FL_SCROLL_LOCK;
if (GetAsyncKeyState(VK_CONTROL)&~1) state |= FL_CTRL;
if (GetAsyncKeyState(VK_SHIFT)&~1) state |= FL_SHIFT;
if (GetAsyncKeyState(VK_MENU)&~1) state |= FL_ALT;
if ((GetAsyncKeyState(VK_LWIN)|GetAsyncKeyState(VK_RWIN))&~1) state |= FL_META;
if (GetAsyncKeyState(VK_LBUTTON)&~1) state |= FL_BUTTON1;
if (GetAsyncKeyState(VK_MBUTTON)&~1) state |= FL_BUTTON2;
if (GetAsyncKeyState(VK_RBUTTON)&~1) state |= FL_BUTTON3;
Fl::e_state = state;
return 0;
}
Expand All @@ -550,20 +549,20 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
ulong state = Fl::e_state & 0xff000000; // keep the mouse button state
// if GetKeyState is expensive we might want to comment some of these out:
if (GetKeyState(VK_SHIFT)&~1) state |= FL_SHIFT;
if (GetKeyState(VK_CAPITAL)) state |= FL_CAPS_LOCK;
if (GetKeyState(VK_CAPITAL)&~1) state |= FL_CAPS_LOCK;
if (GetKeyState(VK_CONTROL)&~1) state |= FL_CTRL;
// Alt gets reported for the Alt-GR switch on foreign keyboards.
// so we need to check the event as well to get it right:
if ((lParam&(1<<29)) //same as GetKeyState(VK_MENU)
&& uMsg != WM_CHAR) state |= FL_ALT;
if (GetKeyState(VK_NUMLOCK)) state |= FL_NUM_LOCK;
if (GetKeyState(VK_NUMLOCK)&~1) state |= FL_NUM_LOCK;
if (GetKeyState(VK_LWIN)&~1 || GetKeyState(VK_RWIN)&~1) {
// WIN32 bug? GetKeyState returns garbage if the user hit the
// meta key to pop up start menu. Sigh.
if ((GetAsyncKeyState(VK_LWIN)|GetAsyncKeyState(VK_RWIN))&~1)
state |= FL_META;
}
if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
if (GetKeyState(VK_SCROLL)&~1) state |= FL_SCROLL_LOCK;
Fl::e_state = state;
if (lParam & (1<<31)) goto DEFAULT; // ignore up events after fixing shift
static char buffer[2];
Expand Down Expand Up @@ -976,5 +975,5 @@ void Fl_Window::make_current() {
}

//
// End of "$Id: Fl_win32.cxx,v 1.33.2.34 2001/04/27 14:39:27 easysw Exp $".
// End of "$Id: Fl_win32.cxx,v 1.33.2.35 2001/04/27 14:55:33 easysw Exp $".
//

0 comments on commit c761594

Please sign in to comment.