summaryrefslogtreecommitdiff
path: root/libs/input/Keyboard.cpp
diff options
context:
space:
mode:
author Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2022-10-03 23:24:32 +0000
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2022-10-03 23:24:32 +0000
commit3ca328fc3a24e3772d8a72d9e317c8e778091b4e (patch)
treeffebaaf45ab249d55507d07426c68fe221f76794 /libs/input/Keyboard.cpp
parent1cf6d7f4cacfed91900c1af5d1a2872ae04dc8ff (diff)
parent293041cac77386d5a782de721a1ee63a34556965 (diff)
Snap for 9133013 from 293041cac77386d5a782de721a1ee63a34556965 to tm-qpr2-release
Change-Id: Ifb27e6503863a60f0ad1a7aa0eddb8b3e5c041b9
Diffstat (limited to 'libs/input/Keyboard.cpp')
-rw-r--r--libs/input/Keyboard.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/libs/input/Keyboard.cpp b/libs/input/Keyboard.cpp
index f0895b32ef..c3f5151fd1 100644
--- a/libs/input/Keyboard.cpp
+++ b/libs/input/Keyboard.cpp
@@ -20,16 +20,23 @@
#include <unistd.h>
#include <limits.h>
-#include <input/Keyboard.h>
+#include <input/InputDevice.h>
#include <input/InputEventLabels.h>
-#include <input/KeyLayoutMap.h>
#include <input/KeyCharacterMap.h>
-#include <input/InputDevice.h>
+#include <input/KeyLayoutMap.h>
+#include <input/Keyboard.h>
+#include <log/log.h>
#include <utils/Errors.h>
-#include <utils/Log.h>
namespace android {
+static std::string getPath(const InputDeviceIdentifier& deviceIdentifier, const std::string& name,
+ InputDeviceConfigurationFileType type) {
+ return name.empty()
+ ? getInputDeviceConfigurationFilePathByDeviceIdentifier(deviceIdentifier, type)
+ : getInputDeviceConfigurationFilePathByName(name, type);
+}
+
// --- KeyMap ---
KeyMap::KeyMap() {
@@ -111,11 +118,25 @@ status_t KeyMap::loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier,
}
base::Result<std::shared_ptr<KeyLayoutMap>> ret = KeyLayoutMap::load(path);
+ if (ret.ok()) {
+ keyLayoutMap = *ret;
+ keyLayoutFile = path;
+ return OK;
+ }
+
+ // Try to load fallback layout if the regular layout could not be loaded due to missing
+ // kernel modules
+ std::string fallbackPath(
+ getInputDeviceConfigurationFilePathByDeviceIdentifier(deviceIdentifier,
+ InputDeviceConfigurationFileType::
+ KEY_LAYOUT,
+ "_fallback"));
+ ret = KeyLayoutMap::load(fallbackPath);
if (!ret.ok()) {
return ret.error().code();
}
keyLayoutMap = *ret;
- keyLayoutFile = path;
+ keyLayoutFile = fallbackPath;
return OK;
}
@@ -137,14 +158,6 @@ status_t KeyMap::loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifi
return OK;
}
-std::string KeyMap::getPath(const InputDeviceIdentifier& deviceIdentifier,
- const std::string& name, InputDeviceConfigurationFileType type) {
- return name.empty()
- ? getInputDeviceConfigurationFilePathByDeviceIdentifier(deviceIdentifier, type)
- : getInputDeviceConfigurationFilePathByName(name, type);
-}
-
-
// --- Global functions ---
bool isKeyboardSpecialFunction(const PropertyMap* config) {