summaryrefslogtreecommitdiff
path: root/libs/input/KeyCharacterMap.cpp
diff options
context:
space:
mode:
author Vaibhav Devmurari <vdevmurari@google.com> 2024-09-30 15:54:41 +0000
committer Vaibhav Devmurari <vdevmurari@google.com> 2024-10-07 09:41:05 +0000
commit5a71e8857560729d165e3154c97788201e063ece (patch)
treeb17a0611d5ec856cf0369f6674fc7404c44609b9 /libs/input/KeyCharacterMap.cpp
parent9623dd5092ccddbe0a5bf817c5a6727eeda9244e (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.cpp11
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;