From d72fef26d44e649f39a56730830148d48d77ee9e Mon Sep 17 00:00:00 2001 From: Alexander Gottwald Date: Tue, 5 Jul 2005 17:52:35 +0000 Subject: Fix simultanious presses of Left and Right Control and Shift keys. https://bugs.freedesktop.org/show_bug.cgi?id=3677 --- hw/xwin/ChangeLog | 8 ++++++++ hw/xwin/winkeybd.c | 36 ++++++++++++++++++++++++++++++++++++ hw/xwin/winkeybd.h | 2 +- hw/xwin/winwndproc.c | 31 ++++++++++++++++++++++++++----- 4 files changed, 71 insertions(+), 6 deletions(-) (limited to 'hw/xwin') diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index 8ae8e54ae..6d06412d2 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,11 @@ +2005-07-05 Alexander Gottwald + + * winkeybd.c: + * winkeybd.h: + * winwndproc.c: + Fix simultanious presses of Left and Right Control and Shift keys. + https://bugs.freedesktop.org/show_bug.cgi?id=3677 + 2005-07-05 Alexander Gottwald * winmultiwindowwm.c: diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index e52337956..3756a4432 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -612,3 +612,39 @@ winSendKeyEvent (DWORD dwKey, Bool fDown) xCurrentEvent.u.u.detail = dwKey + MIN_KEYCODE; mieqEnqueue (&xCurrentEvent); } + +BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam) +{ + switch (wParam) + { + case VK_CONTROL: + if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl]) + return TRUE; + if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl]) + return TRUE; + break; + case VK_SHIFT: + if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR]) + return TRUE; + if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL]) + return TRUE; + break; + default: + return TRUE; + } + return FALSE; +} + +/* Only on shift release message is sent even if both are pressed. + * Fix this here + */ +void winFixShiftKeys (int iScanCode) +{ + if (GetKeyState (VK_SHIFT) & 0x8000) + return; + + if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR]) + winSendKeyEvent (KEY_ShiftR, FALSE); + if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL]) + winSendKeyEvent (KEY_ShiftL, FALSE); +} diff --git a/hw/xwin/winkeybd.h b/hw/xwin/winkeybd.h index 31c0cbc23..f42e09fd7 100644 --- a/hw/xwin/winkeybd.h +++ b/hw/xwin/winkeybd.h @@ -65,7 +65,7 @@ g_iKeyMap [] = { /* 13 */ VK_RETURN, 0, KEY_KP_Enter, /* 14 */ 0, 0, 0, /* 15 */ 0, 0, 0, - /* 16 */ VK_SHIFT, KEY_ShiftL, KEY_ShiftR, + /* 16 */ VK_SHIFT, 0, 0, /* 17 */ VK_CONTROL, 0, KEY_RCtrl, /* 18 */ VK_MENU, 0, KEY_AltLang, /* 19 */ VK_PAUSE, KEY_Pause, 0, diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index 5d9fe14c9..0864fc638 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -42,6 +42,12 @@ #include "winconfig.h" #include "winmsg.h" +#ifdef XKB +extern BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam); +#endif +extern void winFixShiftKeys (int iScanCode); + + /* * Global variables */ @@ -1014,11 +1020,22 @@ winWindowProc (HWND hwnd, UINT message, * Discard presses generated from Windows auto-repeat * ago: Only discard them if XKB is not disabled */ - if (!g_winInfo.xkb.disable) - { - if (lParam & (1<<30)) - return 0; - } + if (!g_winInfo.xkb.disable && (lParam & (1<<30))) + { + switch (wParam) + { + /* ago: Pressing LControl while RControl is pressed is + * Indicated as repeat. Fix this! + */ + case VK_CONTROL: + case VK_SHIFT: + if (winCheckKeyPressed(wParam, lParam)) + return 0; + break; + default: + return 0; + } + } #endif /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */ @@ -1057,6 +1074,10 @@ winWindowProc (HWND hwnd, UINT message, /* Enqueue a keyup event */ winTranslateKey (wParam, lParam, &iScanCode); winSendKeyEvent (iScanCode, FALSE); + + /* Release all pressed shift keys */ + if (wParam == VK_SHIFT) + winFixShiftKeys (iScanCode); return 0; case WM_HOTKEY: -- cgit v1.2.3