diff options
author | 2023-03-30 13:34:54 +0800 | |
---|---|---|
committer | 2023-03-31 08:45:11 +0800 | |
commit | aadf8d5cc088c6dbe063de5da651a83466992512 (patch) | |
tree | d33cdb1974f3d1053f62d91f5e413ddb2beb2e4f /libs/input/KeyLayoutMap.cpp | |
parent | c4a353c0ad052e95bfce5958f2de25307fa32106 (diff) |
hasKeycodeLocked() also checks usage codes
Key map can use both scan code and usage code.
Adding usage code check to avoid misjudgment.
Bug: 275526611
Test:
In Android TV, pairing a BT RCU with keylayout which
has usage page/id for DPAD. In PlayStore app search
box, make sure user can move focus to search result
by pressing dpad DOWN key.
Change-Id: I70687d308899537e457192458176b1553c350f14
Diffstat (limited to 'libs/input/KeyLayoutMap.cpp')
-rw-r--r-- | libs/input/KeyLayoutMap.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/input/KeyLayoutMap.cpp b/libs/input/KeyLayoutMap.cpp index d6b4579a94..250c0dd9a9 100644 --- a/libs/input/KeyLayoutMap.cpp +++ b/libs/input/KeyLayoutMap.cpp @@ -230,6 +230,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()) { |