diff options
author | 2022-06-22 15:27:58 +0000 | |
---|---|---|
committer | 2022-06-22 15:27:58 +0000 | |
commit | 332a29a57f332773e6eb44e404f0c55d1888f2eb (patch) | |
tree | 2693bb281d7575f6a7324606833b852b5a8ec329 /libs/input/Keyboard.cpp | |
parent | bdaf9ec7a99402f10f430676bde882d0fc612256 (diff) | |
parent | ec70ee2c604b82f9261513dbd3110ecdc9bc1f13 (diff) |
Merge "Do not load keylayout if required kernel module is missing"
Diffstat (limited to 'libs/input/Keyboard.cpp')
-rw-r--r-- | libs/input/Keyboard.cpp | 39 |
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) { |