diff options
author | 2024-09-30 15:54:41 +0000 | |
---|---|---|
committer | 2024-10-07 09:41:05 +0000 | |
commit | 5a71e8857560729d165e3154c97788201e063ece (patch) | |
tree | b17a0611d5ec856cf0369f6674fc7404c44609b9 /libs/input/KeyCharacterMap.cpp | |
parent | 9623dd5092ccddbe0a5bf817c5a6727eeda9244e (diff) |
hasKeycode API should take into account key remapping
Keyboards can generate certain keycodes even if the keys are not
present in the device HID descriptor, by using key remapping APIs
Test: atest ModifierKeyRemappingTest
Bug: 368397939
Flag: EXEMPT bugfix
Change-Id: I30afda89f289eddc2b05fb124555aebfb182852e
Diffstat (limited to 'libs/input/KeyCharacterMap.cpp')
-rw-r--r-- | libs/input/KeyCharacterMap.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/input/KeyCharacterMap.cpp b/libs/input/KeyCharacterMap.cpp index b0563abaf7..d775327a80 100644 --- a/libs/input/KeyCharacterMap.cpp +++ b/libs/input/KeyCharacterMap.cpp @@ -365,6 +365,17 @@ int32_t KeyCharacterMap::applyKeyRemapping(int32_t fromKeyCode) const { return toKeyCode; } +std::vector<int32_t> KeyCharacterMap::findKeyCodesMappedToKeyCode(int32_t toKeyCode) const { + std::vector<int32_t> fromKeyCodes; + + for (const auto& [from, to] : mKeyRemapping) { + if (toKeyCode == to) { + fromKeyCodes.push_back(from); + } + } + return fromKeyCodes; +} + std::pair<int32_t, int32_t> KeyCharacterMap::applyKeyBehavior(int32_t fromKeyCode, int32_t fromMetaState) const { int32_t toKeyCode = fromKeyCode; |