From fecb60640999c4758a8967e7d7960d4530198d17 Mon Sep 17 00:00:00 2001 From: Zixuan Qu Date: Sat, 12 Nov 2022 04:44:31 +0000 Subject: 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 --- include/input/InputDevice.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/input/InputDevice.h') diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index e911734407..5fa9fda64b 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -205,6 +205,16 @@ struct InputDeviceBatteryInfo { 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 @@ public: void setKeyboardType(int32_t keyboardType); inline int32_t getKeyboardType() const { return mKeyboardType; } + void setKeyboardLayoutInfo(KeyboardLayoutInfo keyboardLayoutInfo); + inline const std::optional& getKeyboardLayoutInfo() const { + return mKeyboardLayoutInfo; + } + inline void setKeyCharacterMap(const std::shared_ptr value) { mKeyCharacterMap = value; } @@ -296,6 +311,7 @@ private: bool mIsExternal; bool mHasMic; hardware::input::InputDeviceCountryCode mCountryCode; + std::optional mKeyboardLayoutInfo; uint32_t mSources; int32_t mKeyboardType; std::shared_ptr mKeyCharacterMap; -- cgit v1.2.3-59-g8ed1b