Add API to get KeyCode produced by physical key location.
The physical key location is provided as a location KeyCode pointing to a location on a US keyboard layout.
Bug: 179812917
Test: atest KeyboardLayoutChangeTest
Test: atest android.hardware.input.cts.tests -m
Test: atest inputflinger_tests -m
Change-Id: Ib5ed41890cbbe393ee9ada1a04cbaaf82c9bb1fc
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 518aaa0..11c074a 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -84,6 +84,7 @@
int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
+ int32_t getKeyCodeForKeyLocation(int32_t locationKeyCode) const;
bool markSupportedKeyCodes(uint32_t sourceMask, size_t numCodes, const int32_t* keyCodes,
uint8_t* outFlags);
void vibrate(const VibrationSequence& sequence, ssize_t repeat, int32_t token);
@@ -216,7 +217,8 @@
// return the first value returned by a function over every mapper.
// if all mappers return nullopt, return nullopt.
template <typename T>
- inline std::optional<T> first_in_mappers(std::function<std::optional<T>(InputMapper&)> f) {
+ inline std::optional<T> first_in_mappers(
+ std::function<std::optional<T>(InputMapper&)> f) const {
for (auto& deviceEntry : mDevices) {
auto& devicePair = deviceEntry.second;
auto& mappers = devicePair.second;
@@ -312,6 +314,9 @@
inline int32_t getKeyCodeState(int32_t keyCode) const {
return mEventHub->getKeyCodeState(mId, keyCode);
}
+ inline int32_t getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
+ return mEventHub->getKeyCodeForKeyLocation(mId, locationKeyCode);
+ }
inline int32_t getSwitchState(int32_t sw) const { return mEventHub->getSwitchState(mId, sw); }
inline status_t getAbsoluteAxisValue(int32_t code, int32_t* outValue) const {
return mEventHub->getAbsoluteAxisValue(mId, code, outValue);