Loading include/input/InputDevice.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -295,6 +295,8 @@ enum class InputDeviceConfigurationFileType : int32_t { /* /* * Gets the path of an input device configuration file, if one is available. * Gets the path of an input device configuration file, if one is available. * Considers both system provided and user installed configuration files. * Considers both system provided and user installed configuration files. * The optional suffix is appended to the end of the file name (before the * extension). * * * The device identifier is used to construct several default configuration file * The device identifier is used to construct several default configuration file * names to try based on the device name, vendor, product, and version. * names to try based on the device name, vendor, product, and version. Loading @@ -302,8 +304,8 @@ enum class InputDeviceConfigurationFileType : int32_t { * Returns an empty string if not found. * Returns an empty string if not found. */ */ extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( const InputDeviceIdentifier& deviceIdentifier, const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, InputDeviceConfigurationFileType type); const char* suffix = ""); /* /* * Gets the path of an input device configuration file, if one is available. * Gets the path of an input device configuration file, if one is available. Loading include/input/KeyLayoutMap.h +5 −1 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <stdint.h> #include <stdint.h> #include <utils/Errors.h> #include <utils/Errors.h> #include <utils/Tokenizer.h> #include <utils/Tokenizer.h> #include <set> #include <input/InputDevice.h> #include <input/InputDevice.h> Loading Loading @@ -63,7 +64,8 @@ struct AxisInfo { */ */ class KeyLayoutMap { class KeyLayoutMap { public: public: static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename); static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename, const char* contents = nullptr); static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename, static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename, const char* contents); const char* contents); Loading Loading @@ -103,6 +105,7 @@ private: std::unordered_map<int32_t, Led> mLedsByScanCode; std::unordered_map<int32_t, Led> mLedsByScanCode; std::unordered_map<int32_t, Led> mLedsByUsageCode; std::unordered_map<int32_t, Led> mLedsByUsageCode; std::unordered_map<int32_t, Sensor> mSensorsByAbsCode; std::unordered_map<int32_t, Sensor> mSensorsByAbsCode; std::set<std::string> mRequiredKernelConfigs; std::string mLoadFileName; std::string mLoadFileName; KeyLayoutMap(); KeyLayoutMap(); Loading @@ -123,6 +126,7 @@ private: status_t parseAxis(); status_t parseAxis(); status_t parseLed(); status_t parseLed(); status_t parseSensor(); status_t parseSensor(); status_t parseRequiredKernelConfig(); }; }; }; }; Loading include/input/Keyboard.h +1 −3 Original line number Original line Diff line number Diff line Loading @@ -62,8 +62,6 @@ private: status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); const std::string& name); std::string getPath(const InputDeviceIdentifier& deviceIdentifier, const std::string& name, InputDeviceConfigurationFileType type); }; }; /** /** Loading libs/input/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -62,6 +62,7 @@ cc_library { "libbase", "libbase", "liblog", "liblog", "libcutils", "libcutils", "libvintf", ], ], static_libs: [ static_libs: [ Loading libs/input/InputDevice.cpp +18 −12 Original line number Original line Diff line number Diff line Loading @@ -53,15 +53,18 @@ static void appendInputDeviceConfigurationFileRelativePath(std::string& path, } } std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( const InputDeviceIdentifier& deviceIdentifier, const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, InputDeviceConfigurationFileType type) { const char* suffix) { if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { if (deviceIdentifier.version != 0) { if (deviceIdentifier.version != 0) { // Try vendor product version. // Try vendor product version. std::string versionPath = getInputDeviceConfigurationFilePathByName( std::string versionPath = StringPrintf("Vendor_%04x_Product_%04x_Version_%04x", getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%" deviceIdentifier.vendor, deviceIdentifier.product, "04x_Version_%04x%s", deviceIdentifier.version), deviceIdentifier.vendor, deviceIdentifier.product, deviceIdentifier.version, suffix), type); type); if (!versionPath.empty()) { if (!versionPath.empty()) { return versionPath; return versionPath; Loading @@ -69,9 +72,11 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( } } // Try vendor product. // Try vendor product. std::string productPath = getInputDeviceConfigurationFilePathByName( std::string productPath = StringPrintf("Vendor_%04x_Product_%04x", getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%04x%s", deviceIdentifier.vendor, deviceIdentifier.product), deviceIdentifier.vendor, deviceIdentifier.product, suffix), type); type); if (!productPath.empty()) { if (!productPath.empty()) { return productPath; return productPath; Loading @@ -79,7 +84,8 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( } } // Try device name. // Try device name. return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName(), type); return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName() + suffix, type); } } std::string getInputDeviceConfigurationFilePathByName( std::string getInputDeviceConfigurationFilePathByName( Loading Loading
include/input/InputDevice.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -295,6 +295,8 @@ enum class InputDeviceConfigurationFileType : int32_t { /* /* * Gets the path of an input device configuration file, if one is available. * Gets the path of an input device configuration file, if one is available. * Considers both system provided and user installed configuration files. * Considers both system provided and user installed configuration files. * The optional suffix is appended to the end of the file name (before the * extension). * * * The device identifier is used to construct several default configuration file * The device identifier is used to construct several default configuration file * names to try based on the device name, vendor, product, and version. * names to try based on the device name, vendor, product, and version. Loading @@ -302,8 +304,8 @@ enum class InputDeviceConfigurationFileType : int32_t { * Returns an empty string if not found. * Returns an empty string if not found. */ */ extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( const InputDeviceIdentifier& deviceIdentifier, const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, InputDeviceConfigurationFileType type); const char* suffix = ""); /* /* * Gets the path of an input device configuration file, if one is available. * Gets the path of an input device configuration file, if one is available. Loading
include/input/KeyLayoutMap.h +5 −1 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <stdint.h> #include <stdint.h> #include <utils/Errors.h> #include <utils/Errors.h> #include <utils/Tokenizer.h> #include <utils/Tokenizer.h> #include <set> #include <input/InputDevice.h> #include <input/InputDevice.h> Loading Loading @@ -63,7 +64,8 @@ struct AxisInfo { */ */ class KeyLayoutMap { class KeyLayoutMap { public: public: static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename); static base::Result<std::shared_ptr<KeyLayoutMap>> load(const std::string& filename, const char* contents = nullptr); static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename, static base::Result<std::shared_ptr<KeyLayoutMap>> loadContents(const std::string& filename, const char* contents); const char* contents); Loading Loading @@ -103,6 +105,7 @@ private: std::unordered_map<int32_t, Led> mLedsByScanCode; std::unordered_map<int32_t, Led> mLedsByScanCode; std::unordered_map<int32_t, Led> mLedsByUsageCode; std::unordered_map<int32_t, Led> mLedsByUsageCode; std::unordered_map<int32_t, Sensor> mSensorsByAbsCode; std::unordered_map<int32_t, Sensor> mSensorsByAbsCode; std::set<std::string> mRequiredKernelConfigs; std::string mLoadFileName; std::string mLoadFileName; KeyLayoutMap(); KeyLayoutMap(); Loading @@ -123,6 +126,7 @@ private: status_t parseAxis(); status_t parseAxis(); status_t parseLed(); status_t parseLed(); status_t parseSensor(); status_t parseSensor(); status_t parseRequiredKernelConfig(); }; }; }; }; Loading
include/input/Keyboard.h +1 −3 Original line number Original line Diff line number Diff line Loading @@ -62,8 +62,6 @@ private: status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); status_t loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, status_t loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifier, const std::string& name); const std::string& name); std::string getPath(const InputDeviceIdentifier& deviceIdentifier, const std::string& name, InputDeviceConfigurationFileType type); }; }; /** /** Loading
libs/input/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -62,6 +62,7 @@ cc_library { "libbase", "libbase", "liblog", "liblog", "libcutils", "libcutils", "libvintf", ], ], static_libs: [ static_libs: [ Loading
libs/input/InputDevice.cpp +18 −12 Original line number Original line Diff line number Diff line Loading @@ -53,15 +53,18 @@ static void appendInputDeviceConfigurationFileRelativePath(std::string& path, } } std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( const InputDeviceIdentifier& deviceIdentifier, const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, InputDeviceConfigurationFileType type) { const char* suffix) { if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { if (deviceIdentifier.version != 0) { if (deviceIdentifier.version != 0) { // Try vendor product version. // Try vendor product version. std::string versionPath = getInputDeviceConfigurationFilePathByName( std::string versionPath = StringPrintf("Vendor_%04x_Product_%04x_Version_%04x", getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%" deviceIdentifier.vendor, deviceIdentifier.product, "04x_Version_%04x%s", deviceIdentifier.version), deviceIdentifier.vendor, deviceIdentifier.product, deviceIdentifier.version, suffix), type); type); if (!versionPath.empty()) { if (!versionPath.empty()) { return versionPath; return versionPath; Loading @@ -69,9 +72,11 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( } } // Try vendor product. // Try vendor product. std::string productPath = getInputDeviceConfigurationFilePathByName( std::string productPath = StringPrintf("Vendor_%04x_Product_%04x", getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%04x%s", deviceIdentifier.vendor, deviceIdentifier.product), deviceIdentifier.vendor, deviceIdentifier.product, suffix), type); type); if (!productPath.empty()) { if (!productPath.empty()) { return productPath; return productPath; Loading @@ -79,7 +84,8 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( } } // Try device name. // Try device name. return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName(), type); return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName() + suffix, type); } } std::string getInputDeviceConfigurationFilePathByName( std::string getInputDeviceConfigurationFilePathByName( Loading