From a4db7f0005932b0d49ca511a2e06331500be5449 Mon Sep 17 00:00:00 2001 From: crs Date: Sun, 18 Aug 2002 17:35:10 +0000 Subject: [PATCH] fixed PrintScrn handling; it was being changed to keypad multiply. --- lib/client/CMSWindowsSecondaryScreen.cpp | 31 +++++++++++++++++++++--- lib/client/CMSWindowsSecondaryScreen.h | 4 +-- lib/server/CMSWindowsPrimaryScreen.cpp | 9 +++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lib/client/CMSWindowsSecondaryScreen.cpp b/lib/client/CMSWindowsSecondaryScreen.cpp index 44267977..a7301199 100644 --- a/lib/client/CMSWindowsSecondaryScreen.cpp +++ b/lib/client/CMSWindowsSecondaryScreen.cpp @@ -596,6 +596,31 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey, } } + // special handling of VK_SNAPSHOT + if ((virtualKey & 0xff) == VK_SNAPSHOT) { + // ignore key repeats on print screen + if (action != kRepeat) { + // get event flags + DWORD flags = 0; + if (isExtendedKey(virtualKey)) { + flags |= KEYEVENTF_EXTENDEDKEY; + } + if (action != kPress) { + flags |= KEYEVENTF_KEYUP; + } + + // active window or fullscreen? + BYTE scan = 0; + if ((mask & KeyModifierAlt) == 0) { + scan = 1; + } + + // send event + keybd_event(static_cast(virtualKey & 0xff), scan, flags, 0); + } + return m_mask; + } + // get output mask. default output mask carries over the current // toggle modifier states and includes desired shift, control, alt, // and meta states. @@ -992,7 +1017,7 @@ CMSWindowsSecondaryScreen::toggleKey(UINT virtualKey, KeyModifierMask mask) } UINT -CMSWindowsSecondaryScreen::virtualKeyToScanCode(UINT& virtualKey) +CMSWindowsSecondaryScreen::virtualKeyToScanCode(UINT& virtualKey) const { // try mapping given virtual key UINT code = MapVirtualKey(virtualKey & 0xff, 0); @@ -1044,7 +1069,7 @@ CMSWindowsSecondaryScreen::virtualKeyToScanCode(UINT& virtualKey) } bool -CMSWindowsSecondaryScreen::isExtendedKey(UINT virtualKey) +CMSWindowsSecondaryScreen::isExtendedKey(UINT virtualKey) const { // see if we've already encoded the extended flag if ((virtualKey & 0x100) != 0) { @@ -1079,5 +1104,5 @@ CMSWindowsSecondaryScreen::sendKeyEvent(UINT virtualKey, bool press) const UINT code = virtualKeyToScanCode(virtualKey); keybd_event(static_cast(virtualKey & 0xff), static_cast(code), flags, 0); - log((CLOG_DEBUG2 "send key %d, 0x%04x, %s%s", virtualKey & 0xff, code, ((flags & KEYEVENTF_KEYUP) ? "release" : "press"), ((flags & KEYEVENTF_EXTENDEDKEY) ? " extended" : ""))); + log((CLOG_DEBUG1 "send key %d, 0x%04x, %s%s", virtualKey & 0xff, code, ((flags & KEYEVENTF_KEYUP) ? "release" : "press"), ((flags & KEYEVENTF_EXTENDEDKEY) ? " extended" : ""))); } diff --git a/lib/client/CMSWindowsSecondaryScreen.h b/lib/client/CMSWindowsSecondaryScreen.h index a2b556c2..577413d7 100644 --- a/lib/client/CMSWindowsSecondaryScreen.h +++ b/lib/client/CMSWindowsSecondaryScreen.h @@ -97,8 +97,8 @@ private: void releaseKeys(); void toggleKey(UINT virtualKey, KeyModifierMask mask); - UINT virtualKeyToScanCode(UINT& virtualKey); - bool isExtendedKey(UINT virtualKey); + UINT virtualKeyToScanCode(UINT& virtualKey) const; + bool isExtendedKey(UINT virtualKey) const; void sendKeyEvent(UINT virtualKey, bool press); private: diff --git a/lib/server/CMSWindowsPrimaryScreen.cpp b/lib/server/CMSWindowsPrimaryScreen.cpp index c66162ee..5fe8b1b0 100644 --- a/lib/server/CMSWindowsPrimaryScreen.cpp +++ b/lib/server/CMSWindowsPrimaryScreen.cpp @@ -929,6 +929,15 @@ CMSWindowsPrimaryScreen::mapKey( vkCode2 = vkCode; } + // if the original vkCode is VK_SNAPSHOT then use it. oddly enough, + // some keyboards use the same scan code for keypad multiply and + // print screen. the difference is that the latter has the extended + // key flag set. but MapVirtualKey() doesn't seem capable of using + // that flag. + else if (vkCode == VK_SNAPSHOT) { + vkCode2 = vkCode; + } + // if MapVirtualKey failed then use original virtual key else if (vkCode2 == 0) { vkCode2 = vkCode;