#5196 Korean and Japanese keyboards have same key code

This commit is contained in:
Jiwoong Yoo 2017-01-26 06:04:13 +09:00 committed by Andrew Nelless
parent adf34eba40
commit 180d3e57d2
4 changed files with 49 additions and 9 deletions

View File

@ -61,11 +61,11 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x012 */ { kKeyAlt_L }, // VK_MENU
/* 0x013 */ { kKeyPause }, // VK_PAUSE
/* 0x014 */ { kKeyCapsLock }, // VK_CAPITAL
/* 0x015 */ { kKeyHangulKana }, // VK_HANGUL, VK_KANA
/* 0x015 */ { kKeyKana }, // VK_HANGUL, VK_KANA
/* 0x016 */ { kKeyNone }, // undefined
/* 0x017 */ { kKeyNone }, // VK_JUNJA
/* 0x018 */ { kKeyNone }, // VK_FINAL
/* 0x019 */ { kKeyHanjaKanzi }, // VK_KANJI
/* 0x019 */ { kKeyKanzi }, // VK_HANJA, VK_KANJI
/* 0x01a */ { kKeyNone }, // undefined
/* 0x01b */ { kKeyEscape }, // VK_ESCAPE
/* 0x01c */ { kKeyHenkan }, // VK_CONVERT
@ -318,11 +318,11 @@ const KeyID MSWindowsKeyState::s_virtualKey[] =
/* 0x112 */ { kKeyAlt_R }, // VK_MENU
/* 0x113 */ { kKeyNone }, // VK_PAUSE
/* 0x114 */ { kKeyNone }, // VK_CAPITAL
/* 0x115 */ { kKeyNone }, // VK_KANA
/* 0x116 */ { kKeyNone }, // VK_HANGUL
/* 0x115 */ { kKeyHangul }, // VK_HANGUL
/* 0x116 */ { kKeyNone }, // undefined
/* 0x117 */ { kKeyNone }, // VK_JUNJA
/* 0x118 */ { kKeyNone }, // VK_FINAL
/* 0x119 */ { kKeyNone }, // VK_KANJI
/* 0x119 */ { kKeyHanja }, // VK_HANJA
/* 0x11a */ { kKeyNone }, // undefined
/* 0x11b */ { kKeyNone }, // VK_ESCAPE
/* 0x11c */ { kKeyNone }, // VK_CONVERT
@ -728,6 +728,10 @@ MSWindowsKeyState::mapKeyFromEvent(WPARAM charAndVirtKey,
// that so we clear it.
active &= ~s_controlAlt;
}
if (id == kKeyHangul) {
// If shift-space is used to change input mode, clear shift modifier.
active &= ~KeyModifierShift;
}
*maskOut = active;
}
@ -1334,8 +1338,20 @@ MSWindowsKeyState::setWindowGroup(SInt32 group)
}
KeyID
MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button)
MSWindowsKeyState::getKeyID(UINT virtualKey, KeyButton button) const
{
// Some virtual keycodes have same values.
// VK_HANGUL == VK_KANA, VK_HANJA == NK_KANJI
// which are used to change the input mode of IME.
// But they have different X11 keysym. So we should distinguish them.
if ((LOWORD(m_keyLayout) & 0xffffu) == 0x0412u) { // 0x0412 : Korean Locale ID
if (virtualKey == VK_HANGUL || virtualKey == VK_HANJA) {
// If shift-space is used to change the input mode,
// the extented bit is not set. So add it to get right key id.
button |= 0x100u;
}
}
if ((button & 0x100u) != 0) {
virtualKey += 0x100u;
}
@ -1387,3 +1403,4 @@ MSWindowsKeyState::addKeyEntry(synergy::KeyMap& keyMap, synergy::KeyMap::KeyItem
m_keyToVKMap[item.m_id] = static_cast<UINT>(item.m_client);
}
}

View File

@ -122,7 +122,7 @@ public:
(button should include the extended key bit), or kKeyNone if there is
no such key.
*/
static KeyID getKeyID(UINT virtualKey, KeyButton button);
KeyID getKeyID(UINT virtualKey, KeyButton button) const;
//! Map button to virtual key
/*!

View File

@ -110,10 +110,12 @@ static const KeyID kKeyScrollLock = 0xEF14;
static const KeyID kKeySysReq = 0xEF15;
static const KeyID kKeyEscape = 0xEF1B;
static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */
static const KeyID kKeyHangulKana = 0xEF26; /* Hangul, Kana */
static const KeyID kKeyKana = 0xEF26; /* Kana */
static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */
static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */
static const KeyID kKeyHanjaKanzi = 0xEF2A; /* Hanja, Kanzi */
static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */
static const KeyID kKeyHangul = 0xEF31; /* Hangul */
static const KeyID kKeyHanja = 0xEF34; /* Hanja */
static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */
// cursor control

View File

@ -121,3 +121,24 @@ TEST_F(MSWindowsKeyStateTests, saveModifiers_noModifiers_savedModifiers0)
ASSERT_EQ(0, keyState.getSavedModifiers());
delete desks;
}
TEST_F(MSWindowsKeyStateTests, testKoreanLocale_inputModeKey_resultCorrectKeyID)
{
NiceMock<MockEventQueue> eventQueue;
MSWindowsDesks* desks = newDesks(&eventQueue);
MockKeyMap keyMap;
MSWindowsKeyState keyState(desks, getEventTarget(), &eventQueue, keyMap);
keyState.setKeyLayout((HKL)0x00000412u); // for ko-KR local ID
ASSERT_EQ(0xEF31, keyState.getKeyID(0x15u, 0x1f2u)); // VK_HANGUL from Hangul key
ASSERT_EQ(0xEF34, keyState.getKeyID(0x19u, 0x1f1u)); // VK_HANJA from Hanja key
ASSERT_EQ(0xEF31, keyState.getKeyID(0x15u, 0x11du)); // VK_HANGUL from R-Alt key
ASSERT_EQ(0xEF34, keyState.getKeyID(0x19u, 0x138u)); // VK_HANJA from R-Ctrl key
keyState.setKeyLayout((HKL)0x00000411); // for ja-jp locale ID
ASSERT_EQ(0xEF26, keyState.getKeyID(0x15u, 0x1du)); // VK_KANA
ASSERT_EQ(0xEF2A, keyState.getKeyID(0x19u, 0x38u)); // VK_KANJI
delete desks;
}