diff options
author | Philip Junker <philipjunker@google.com> | 2021-12-10 18:39:42 +0100 |
---|---|---|
committer | Philip Junker <philipjunker@google.com> | 2021-12-31 10:26:15 +0100 |
commit | 90bc949048f2b91fa841cb8272381af8c301c055 (patch) | |
tree | b9496359745524c364a0241ece3bdd2da9de6b2e /include/input | |
parent | f60ade6b4c52b1f41975ed9506df1dc0b28e8857 (diff) | |
download | native-90bc949048f2b91fa841cb8272381af8c301c055.tar.gz |
Fix KeyCharacterMap overlays by reloading base overlay before applying another overlay.
Add all fields to parcel (mLoadFileName, mLayoutOverlayApplied, mKeysByScanCode, mKeysByUsageCode).
Add all fields to equality operator.
Add tests to libinput_tests.
Bug: 210090260
Test: Manually verified that layout changes correctly.
Test: atest libinput_tests
Change-Id: I1777b87e5c2ce8a0dbd42ad48748ea9e669c9139
Diffstat (limited to 'include/input')
-rw-r--r-- | include/input/KeyCharacterMap.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h index 451ca3c6cd..f6f8939b7a 100644 --- a/include/input/KeyCharacterMap.h +++ b/include/input/KeyCharacterMap.h @@ -84,7 +84,7 @@ public: const std::string getLoadFileName() const; - /* Combines this key character map with an overlay. */ + /* Combines this key character map with the provided overlay. */ void combine(const KeyCharacterMap& overlay); /* Gets the keyboard type. */ @@ -144,6 +144,8 @@ public: bool operator==(const KeyCharacterMap& other) const; + bool operator!=(const KeyCharacterMap& other) const; + KeyCharacterMap(const KeyCharacterMap& other); virtual ~KeyCharacterMap(); @@ -230,11 +232,12 @@ private: KeyedVector<int32_t, Key*> mKeys; KeyboardType mType; std::string mLoadFileName; + bool mLayoutOverlayApplied; KeyedVector<int32_t, int32_t> mKeysByScanCode; KeyedVector<int32_t, int32_t> mKeysByUsageCode; - KeyCharacterMap(); + KeyCharacterMap(const std::string& filename); bool getKey(int32_t keyCode, const Key** outKey) const; bool getKeyBehavior(int32_t keyCode, int32_t metaState, @@ -243,8 +246,6 @@ private: bool findKey(char16_t ch, int32_t* outKeyCode, int32_t* outMetaState) const; - static base::Result<std::shared_ptr<KeyCharacterMap>> load(Tokenizer* tokenizer, Format format); - static void addKey(Vector<KeyEvent>& outEvents, int32_t deviceId, int32_t keyCode, int32_t metaState, bool down, nsecs_t time); static void addMetaKeys(Vector<KeyEvent>& outEvents, @@ -264,6 +265,15 @@ private: int32_t deviceId, int32_t metaState, nsecs_t time, int32_t keyCode, int32_t keyMetaState, int32_t* currentMetaState); + + /* Clears all data stored in this key character map */ + void clear(); + + /* Loads the KeyCharacterMap provided by the tokenizer into this instance. */ + status_t load(Tokenizer* tokenizer, Format format); + + /* Reloads the data from mLoadFileName and unapplies any overlay. */ + status_t reloadBaseFromFile(); }; } // namespace android |