diff options
author | 2023-04-07 10:27:19 +0000 | |
---|---|---|
committer | 2023-04-07 10:27:19 +0000 | |
commit | d618fcc6e919a86740679de024a4edc5cd69b517 (patch) | |
tree | 4b1d421a8137361b29146f2012327df82abcbe7a | |
parent | ecd41c772b9c76d6cb6f79c5b54cadc9093003d3 (diff) | |
parent | 48a440198d9830490a99bbecc8acc0b16a5e90f7 (diff) |
Merge "hasKeycodeLocked() also checks usage codes" am: 8521bfe7ad am: c224482a8a am: 48a440198d
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2514955
Change-Id: Ic0ce48b297bb9040d919e6c94d2398fdd1187ac7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | include/input/KeyLayoutMap.h | 1 | ||||
-rw-r--r-- | libs/input/KeyLayoutMap.cpp | 10 | ||||
-rw-r--r-- | services/inputflinger/reader/EventHub.cpp | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/include/input/KeyLayoutMap.h b/include/input/KeyLayoutMap.h index e203d190a6..8c3c74af20 100644 --- a/include/input/KeyLayoutMap.h +++ b/include/input/KeyLayoutMap.h @@ -72,6 +72,7 @@ public: int32_t* outKeyCode, uint32_t* outFlags) const; std::vector<int32_t> findScanCodesForKey(int32_t keyCode) const; std::optional<int32_t> findScanCodeForLed(int32_t ledCode) const; + std::vector<int32_t> findUsageCodesForKey(int32_t keyCode) const; std::optional<int32_t> findUsageCodeForLed(int32_t ledCode) const; std::optional<AxisInfo> mapAxis(int32_t scanCode) const; diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp index a2649f6f11..a194513953 100644 --- a/libs/input/KeyLayoutMap.cpp +++ b/libs/input/KeyLayoutMap.cpp @@ -247,6 +247,16 @@ std::vector<int32_t> KeyLayoutMap::findScanCodesForKey(int32_t keyCode) const { return scanCodes; } +std::vector<int32_t> KeyLayoutMap::findUsageCodesForKey(int32_t keyCode) const { + std::vector<int32_t> usageCodes; + for (const auto& [usageCode, key] : mKeysByUsageCode) { + if (keyCode == key.keyCode) { + usageCodes.push_back(usageCode); + } + } + return usageCodes; +} + std::optional<AxisInfo> KeyLayoutMap::mapAxis(int32_t scanCode) const { auto it = mAxes.find(scanCode); if (it == mAxes.end()) { diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp index ee8dde1d32..0eb4ad25ee 100644 --- a/services/inputflinger/reader/EventHub.cpp +++ b/services/inputflinger/reader/EventHub.cpp @@ -634,6 +634,11 @@ bool EventHub::Device::hasKeycodeLocked(int keycode) const { } } + std::vector<int32_t> usageCodes = keyMap.keyLayoutMap->findUsageCodesForKey(keycode); + if (usageCodes.size() > 0 && mscBitmask.test(MSC_SCAN)) { + return true; + } + return false; } |