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/services/inputflinger/reader/Macros.h b/services/inputflinger/reader/Macros.h
index e107d88..d2a7ced 100644
--- a/services/inputflinger/reader/Macros.h
+++ b/services/inputflinger/reader/Macros.h
@@ -22,6 +22,8 @@
#include <log/log.h>
#include <log/log_event_list.h>
+#include <unordered_map>
+
namespace android {
/**
* Log debug messages for each raw event received from the EventHub.
@@ -113,4 +115,14 @@
return (sources & sourceMask & ~AINPUT_SOURCE_CLASS_MASK) != 0;
}
+template <typename K, typename V>
+static inline std::optional<V> getValueByKey(const std::unordered_map<K, V>& map, K key) {
+ auto it = map.find(key);
+ std::optional<V> value = std::nullopt;
+ if (it != map.end()) {
+ value = it->second;
+ }
+ return value;
+}
+
} // namespace android