From 0325de2e1216156f6d22feb5c16c3e5c2f86f95c Mon Sep 17 00:00:00 2001 From: crs Date: Wed, 16 Jul 2003 22:38:43 +0000 Subject: [PATCH] Fixed handling of some non-ASCII but directly mapped characters on win32. The o, a, and u with diaeresis in the german keyboard mapping are examples. --- lib/platform/CMSWindowsSecondaryScreen.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/platform/CMSWindowsSecondaryScreen.cpp b/lib/platform/CMSWindowsSecondaryScreen.cpp index d39e775d..7895c382 100644 --- a/lib/platform/CMSWindowsSecondaryScreen.cpp +++ b/lib/platform/CMSWindowsSecondaryScreen.cpp @@ -936,6 +936,10 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey, // from wide char to multibyte, then from multibyte to wide char // forcing conversion to composite characters, then from wide // char back to multibyte without making precomposed characters. + // + // after the first conversion to multibyte we see if we can map + // the key. if so then we don't bother trying to decompose dead + // keys. BOOL error; char multiByte[2 * MB_LEN_MAX]; wchar_t unicode[2]; @@ -949,6 +953,11 @@ CMSWindowsSecondaryScreen::mapKey(Keystrokes& keys, UINT& virtualKey, LOG((CLOG_DEBUG2 "KeyID 0x%08x not in code page", id)); return m_mask; } + virtualKey = mapCharacter(keys, multiByte[0], hkl, m_mask, mask, action); + if (virtualKey != static_cast(-1)) { + LOG((CLOG_DEBUG2 "KeyID 0x%08x maps to character %u", id, (unsigned char)multiByte[0])); + return m_mask; + } nChars = MultiByteToWideChar(codePage, MB_COMPOSITE | MB_ERR_INVALID_CHARS, multiByte, nChars, @@ -1040,6 +1049,10 @@ CMSWindowsSecondaryScreen::mapCharacter(Keystrokes& keys, // get virtual key UINT virtualKey = LOBYTE(virtualKeyAndModifierState); + if (LOBYTE(virtualKeyAndModifierState) == 0xff) { + LOG((CLOG_DEBUG2 "cannot map character %d", static_cast(c))); + return static_cast(-1); + } // get the required modifier state BYTE modifierState = HIBYTE(virtualKeyAndModifierState);