Gets keyboard layout info from user space when available.
The layout info consists of a BCP 47 conformant language tag and a
layout type such as "qwerty" or "azerty". They will be used to
initialize the input device.
This is currently used by uinput virtual keyboard to pass in layout
information.
Bug: 237537306
Test: atest inputflinger_tests
Change-Id: Icfc30f1afb0f88dd704d1d598d62a300a032b0f5
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index e911734..5fa9fda 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -205,6 +205,16 @@
int32_t id;
};
+struct KeyboardLayoutInfo {
+ explicit KeyboardLayoutInfo(std::string languageTag, std::string layoutType)
+ : languageTag(languageTag), layoutType(layoutType) {}
+
+ // A BCP 47 conformant language tag such as "en-US".
+ std::string languageTag;
+ // The layout type such as QWERTY or AZERTY.
+ std::string layoutType;
+};
+
/*
* Describes the characteristics and capabilities of an input device.
*/
@@ -256,6 +266,11 @@
void setKeyboardType(int32_t keyboardType);
inline int32_t getKeyboardType() const { return mKeyboardType; }
+ void setKeyboardLayoutInfo(KeyboardLayoutInfo keyboardLayoutInfo);
+ inline const std::optional<KeyboardLayoutInfo>& getKeyboardLayoutInfo() const {
+ return mKeyboardLayoutInfo;
+ }
+
inline void setKeyCharacterMap(const std::shared_ptr<KeyCharacterMap> value) {
mKeyCharacterMap = value;
}
@@ -296,6 +311,7 @@
bool mIsExternal;
bool mHasMic;
hardware::input::InputDeviceCountryCode mCountryCode;
+ std::optional<KeyboardLayoutInfo> mKeyboardLayoutInfo;
uint32_t mSources;
int32_t mKeyboardType;
std::shared_ptr<KeyCharacterMap> mKeyCharacterMap;