mirror of https://github.com/debauchee/barrier.git
Reset the keyboard status after ToUnicodeEx
After getting a dead key from `ToUnicodeEx`, add an additional `VK_SPACE` to the keyboard state so we reset the dead key flag and subsequent calls with modifiers, like shift, return the right result (-1) instead of 1. This happened because without reseting the dead key status the new one was attempted to be composed with the old one, which failed and the end result was a single unicode codepoint not marked as a dead key. This opens the door to potentially use the returned unicode from the second call to `ToUnicodeEx` as the key character instead of maintaining the getDeadKey function. This should, hopefully, address issues like https://github.com/debauchee/barrier/issues/1267 or https://github.com/debauchee/barrier/issues/727 https://github.com/debauchee/barrier/issues/1143 or https://github.com/debauchee/barrier/issues/795 I have submitted the same patch to Synergy.
This commit is contained in:
parent
653e4badeb
commit
b43a831cd7
|
@ -1357,9 +1357,20 @@ MSWindowsKeyState::getIDForKey(barrier::KeyMap::KeyItem& item,
|
||||||
KeyID id = static_cast<KeyID>(unicode[0]);
|
KeyID id = static_cast<KeyID>(unicode[0]);
|
||||||
|
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case -1:
|
case -1: {
|
||||||
return barrier::KeyMap::getDeadKey(id);
|
// dead key. add an space to the keyboard so we exit
|
||||||
|
// the dead key mode and future calls to this function
|
||||||
|
// with different modifiers are not affected.
|
||||||
|
|
||||||
|
BYTE emptyState[256] = { };
|
||||||
|
n = m_ToUnicodeEx(VK_SPACE, 0, emptyState, unicode,
|
||||||
|
sizeof(unicode) / sizeof(unicode[0]), 0, hkl);
|
||||||
|
|
||||||
|
// as an alternative, we could use the returned
|
||||||
|
// buffer in unicode to look at the dead key character
|
||||||
|
// and not rely on getDeadKey to provide the mapping.
|
||||||
|
return barrier::KeyMap::getDeadKey(id);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
// unmapped
|
// unmapped
|
||||||
|
|
Loading…
Reference in New Issue