MCPcopy Create free account
hub / github.com/deskflow/deskflow / getIDForKey

Method getIDForKey

src/lib/platform/MSWindowsKeyState.cpp:1296–1332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1294}
1295
1296KeyID MSWindowsKeyState::getIDForKey(
1297 deskflow::KeyMap::KeyItem &item, KeyButton button, UINT virtualKey, PBYTE keyState, HKL hkl
1298) const
1299{
1300 WCHAR unicode[2];
1301 int n = m_ToUnicodeEx(virtualKey, button, keyState, unicode, sizeof(unicode) / sizeof(unicode[0]), 0, hkl);
1302 KeyID id = static_cast<KeyID>(unicode[0]);
1303
1304 switch (n) {
1305 case -1: {
1306 // dead key. add an space to the keyboard so we exit
1307 // the dead key mode and future calls to this function
1308 // with different modifiers are not affected.
1309
1310 BYTE emptyState[256] = {};
1311 n = m_ToUnicodeEx(VK_SPACE, 0, emptyState, unicode, sizeof(unicode) / sizeof(unicode[0]), 0, hkl);
1312
1313 // as an alternative, we could use the returned
1314 // buffer in unicode to look at the dead key character
1315 // and not rely on getDeadKey to provide the mapping
1316 return deskflow::KeyMap::getDeadKey(id);
1317 }
1318 default:
1319 case 0:
1320 // unmapped
1321 return kKeyNone;
1322
1323 case 1:
1324 return id;
1325
1326 case 2:
1327 // left over dead key in buffer. this used to recurse,
1328 // but apparently this causes a stack overflow, so just
1329 // return no key instead.
1330 return kKeyNone;
1331 }
1332}
1333
1334void MSWindowsKeyState::addKeyEntry(deskflow::KeyMap &keyMap, deskflow::KeyMap::KeyItem &item)
1335{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected