| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2012 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #define LOG_TAG "InputDevice" | 
|  | 18 |  | 
|  | 19 | #include <stdlib.h> | 
|  | 20 | #include <unistd.h> | 
|  | 21 | #include <ctype.h> | 
|  | 22 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 23 | #include <android-base/stringprintf.h> | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 24 | #include <ftl/enum.h> | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 25 | #include <input/InputDevice.h> | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 26 | #include <input/InputEventLabels.h> | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 27 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 28 | using android::base::StringPrintf; | 
|  | 29 |  | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 30 | namespace android { | 
|  | 31 |  | 
|  | 32 | static const char* CONFIGURATION_FILE_DIR[] = { | 
|  | 33 | "idc/", | 
|  | 34 | "keylayout/", | 
|  | 35 | "keychars/", | 
|  | 36 | }; | 
|  | 37 |  | 
|  | 38 | static const char* CONFIGURATION_FILE_EXTENSION[] = { | 
|  | 39 | ".idc", | 
|  | 40 | ".kl", | 
|  | 41 | ".kcm", | 
|  | 42 | }; | 
|  | 43 |  | 
|  | 44 | static bool isValidNameChar(char ch) { | 
|  | 45 | return isascii(ch) && (isdigit(ch) || isalpha(ch) || ch == '-' || ch == '_'); | 
|  | 46 | } | 
|  | 47 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 48 | static void appendInputDeviceConfigurationFileRelativePath(std::string& path, | 
|  | 49 | const std::string& name, InputDeviceConfigurationFileType type) { | 
| Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 50 | path += CONFIGURATION_FILE_DIR[static_cast<int32_t>(type)]; | 
| Siarhei Vishniakou | 409ec1a | 2019-02-20 19:36:25 -0600 | [diff] [blame] | 51 | path += name; | 
| Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 52 | path += CONFIGURATION_FILE_EXTENSION[static_cast<int32_t>(type)]; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 53 | } | 
|  | 54 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 55 | std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( | 
| Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 56 | const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, | 
|  | 57 | const char* suffix) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 58 | if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { | 
|  | 59 | if (deviceIdentifier.version != 0) { | 
|  | 60 | // Try vendor product version. | 
| Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 61 | std::string versionPath = | 
|  | 62 | getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%" | 
|  | 63 | "04x_Version_%04x%s", | 
|  | 64 | deviceIdentifier.vendor, | 
|  | 65 | deviceIdentifier.product, | 
|  | 66 | deviceIdentifier.version, | 
|  | 67 | suffix), | 
|  | 68 | type); | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 69 | if (!versionPath.empty()) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 70 | return versionPath; | 
|  | 71 | } | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | // Try vendor product. | 
| Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 75 | std::string productPath = | 
|  | 76 | getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%04x%s", | 
|  | 77 | deviceIdentifier.vendor, | 
|  | 78 | deviceIdentifier.product, | 
|  | 79 | suffix), | 
|  | 80 | type); | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 81 | if (!productPath.empty()) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 82 | return productPath; | 
|  | 83 | } | 
|  | 84 | } | 
|  | 85 |  | 
|  | 86 | // Try device name. | 
| Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 87 | return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName() + suffix, | 
|  | 88 | type); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 89 | } | 
|  | 90 |  | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 91 | std::string getInputDeviceConfigurationFilePathByName( | 
|  | 92 | const std::string& name, InputDeviceConfigurationFileType type) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 93 | // Search system repository. | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 94 | std::string path; | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 95 |  | 
| Hongguang Chen | 1438ccb | 2021-04-30 09:48:49 -0700 | [diff] [blame] | 96 | // Treblized input device config files will be located /product/usr, /system_ext/usr, | 
|  | 97 | // /odm/usr or /vendor/usr. | 
| Daniel Norman | 54283d6 | 2021-10-08 16:31:03 -0700 | [diff] [blame] | 98 | // These files may also be in the com.android.input.config APEX. | 
|  | 99 | const char* rootsForPartition[]{ | 
|  | 100 | "/product", | 
|  | 101 | "/system_ext", | 
|  | 102 | "/odm", | 
|  | 103 | "/vendor", | 
|  | 104 | "/apex/com.android.input.config/etc", | 
|  | 105 | getenv("ANDROID_ROOT"), | 
|  | 106 | }; | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 107 | for (size_t i = 0; i < size(rootsForPartition); i++) { | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 108 | if (rootsForPartition[i] == nullptr) { | 
|  | 109 | continue; | 
|  | 110 | } | 
|  | 111 | path = rootsForPartition[i]; | 
|  | 112 | path += "/usr/"; | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 113 | appendInputDeviceConfigurationFileRelativePath(path, name, type); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 114 | #if DEBUG_PROBE | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 115 | ALOGD("Probing for system provided input device configuration file: path='%s'", | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 116 | path.c_str()); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 117 | #endif | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 118 | if (!access(path.c_str(), R_OK)) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 119 | #if DEBUG_PROBE | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 120 | ALOGD("Found"); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 121 | #endif | 
| Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 122 | return path; | 
|  | 123 | } | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 124 | } | 
|  | 125 |  | 
|  | 126 | // Search user repository. | 
|  | 127 | // TODO Should only look here if not in safe mode. | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 128 | path = ""; | 
|  | 129 | char *androidData = getenv("ANDROID_DATA"); | 
|  | 130 | if (androidData != nullptr) { | 
|  | 131 | path += androidData; | 
|  | 132 | } | 
|  | 133 | path += "/system/devices/"; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 134 | appendInputDeviceConfigurationFileRelativePath(path, name, type); | 
|  | 135 | #if DEBUG_PROBE | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 136 | ALOGD("Probing for system user input device configuration file: path='%s'", path.c_str()); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 137 | #endif | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 138 | if (!access(path.c_str(), R_OK)) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 139 | #if DEBUG_PROBE | 
|  | 140 | ALOGD("Found"); | 
|  | 141 | #endif | 
|  | 142 | return path; | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | // Not found. | 
|  | 146 | #if DEBUG_PROBE | 
|  | 147 | ALOGD("Probe failed to find input device configuration file: name='%s', type=%d", | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 148 | name.c_str(), type); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 149 | #endif | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 150 | return ""; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 151 | } | 
|  | 152 |  | 
| Siarhei Vishniakou | b45635c | 2019-02-20 19:22:09 -0600 | [diff] [blame] | 153 | // --- InputDeviceIdentifier | 
|  | 154 |  | 
|  | 155 | std::string InputDeviceIdentifier::getCanonicalName() const { | 
|  | 156 | std::string replacedName = name; | 
|  | 157 | for (char& ch : replacedName) { | 
|  | 158 | if (!isValidNameChar(ch)) { | 
|  | 159 | ch = '_'; | 
|  | 160 | } | 
|  | 161 | } | 
|  | 162 | return replacedName; | 
|  | 163 | } | 
|  | 164 |  | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 165 |  | 
|  | 166 | // --- InputDeviceInfo --- | 
|  | 167 |  | 
|  | 168 | InputDeviceInfo::InputDeviceInfo() { | 
| Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 169 | initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 170 | } | 
|  | 171 |  | 
| Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 172 | InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) | 
|  | 173 | : mId(other.mId), | 
|  | 174 | mGeneration(other.mGeneration), | 
|  | 175 | mControllerNumber(other.mControllerNumber), | 
|  | 176 | mIdentifier(other.mIdentifier), | 
|  | 177 | mAlias(other.mAlias), | 
|  | 178 | mIsExternal(other.mIsExternal), | 
|  | 179 | mHasMic(other.mHasMic), | 
| Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 180 | mKeyboardLayoutInfo(other.mKeyboardLayoutInfo), | 
| Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 181 | mSources(other.mSources), | 
|  | 182 | mKeyboardType(other.mKeyboardType), | 
|  | 183 | mKeyCharacterMap(other.mKeyCharacterMap), | 
| Prabir Pradhan | 167c270 | 2022-09-14 00:37:24 +0000 | [diff] [blame] | 184 | mSupportsUsi(other.mSupportsUsi), | 
| Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 185 | mHasVibrator(other.mHasVibrator), | 
| Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 186 | mHasBattery(other.mHasBattery), | 
| Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 187 | mHasButtonUnderPad(other.mHasButtonUnderPad), | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 188 | mHasSensor(other.mHasSensor), | 
|  | 189 | mMotionRanges(other.mMotionRanges), | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 190 | mSensors(other.mSensors), | 
|  | 191 | mLights(other.mLights) {} | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 192 |  | 
|  | 193 | InputDeviceInfo::~InputDeviceInfo() { | 
|  | 194 | } | 
|  | 195 |  | 
| Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 196 | void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, | 
| Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 197 | const InputDeviceIdentifier& identifier, const std::string& alias, | 
| Vaibhav Devmurari | 7fb4113 | 2023-01-02 13:30:26 +0000 | [diff] [blame] | 198 | bool isExternal, bool hasMic) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 199 | mId = id; | 
|  | 200 | mGeneration = generation; | 
| Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 201 | mControllerNumber = controllerNumber; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 202 | mIdentifier = identifier; | 
|  | 203 | mAlias = alias; | 
|  | 204 | mIsExternal = isExternal; | 
| Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 205 | mHasMic = hasMic; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 206 | mSources = 0; | 
|  | 207 | mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE; | 
|  | 208 | mHasVibrator = false; | 
| Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 209 | mHasBattery = false; | 
| Michael Wright | 931fd6d | 2013-07-10 18:05:15 -0700 | [diff] [blame] | 210 | mHasButtonUnderPad = false; | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 211 | mHasSensor = false; | 
| Prabir Pradhan | 167c270 | 2022-09-14 00:37:24 +0000 | [diff] [blame] | 212 | mSupportsUsi = false; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 213 | mMotionRanges.clear(); | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 214 | mSensors.clear(); | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 215 | mLights.clear(); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 216 | } | 
|  | 217 |  | 
|  | 218 | const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( | 
|  | 219 | int32_t axis, uint32_t source) const { | 
| Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame] | 220 | for (const MotionRange& range : mMotionRanges) { | 
|  | 221 | if (range.axis == axis && isFromSource(range.source, source)) { | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 222 | return ⦥ | 
|  | 223 | } | 
|  | 224 | } | 
| Yi Kong | 5bed83b | 2018-07-17 12:53:47 -0700 | [diff] [blame] | 225 | return nullptr; | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 226 | } | 
|  | 227 |  | 
|  | 228 | void InputDeviceInfo::addSource(uint32_t source) { | 
|  | 229 | mSources |= source; | 
|  | 230 | } | 
|  | 231 |  | 
|  | 232 | void InputDeviceInfo::addMotionRange(int32_t axis, uint32_t source, float min, float max, | 
|  | 233 | float flat, float fuzz, float resolution) { | 
|  | 234 | MotionRange range = { axis, source, min, max, flat, fuzz, resolution }; | 
| Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 235 | mMotionRanges.push_back(range); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 236 | } | 
|  | 237 |  | 
|  | 238 | void InputDeviceInfo::addMotionRange(const MotionRange& range) { | 
| Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 239 | mMotionRanges.push_back(range); | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 240 | } | 
|  | 241 |  | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 242 | void InputDeviceInfo::addSensorInfo(const InputDeviceSensorInfo& info) { | 
|  | 243 | if (mSensors.find(info.type) != mSensors.end()) { | 
|  | 244 | ALOGW("Sensor type %s already exists, will be replaced by new sensor added.", | 
| Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 245 | ftl::enum_string(info.type).c_str()); | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 246 | } | 
|  | 247 | mSensors.insert_or_assign(info.type, info); | 
|  | 248 | } | 
|  | 249 |  | 
| Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 250 | void InputDeviceInfo::addBatteryInfo(const InputDeviceBatteryInfo& info) { | 
|  | 251 | if (mBatteries.find(info.id) != mBatteries.end()) { | 
|  | 252 | ALOGW("Battery id %d already exists, will be replaced by new battery added.", info.id); | 
|  | 253 | } | 
|  | 254 | mBatteries.insert_or_assign(info.id, info); | 
|  | 255 | } | 
|  | 256 |  | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 257 | void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) { | 
|  | 258 | if (mLights.find(info.id) != mLights.end()) { | 
|  | 259 | ALOGW("Light id %d already exists, will be replaced by new light added.", info.id); | 
|  | 260 | } | 
|  | 261 | mLights.insert_or_assign(info.id, info); | 
|  | 262 | } | 
|  | 263 |  | 
| Philip Junker | f843796 | 2022-01-25 21:20:19 +0100 | [diff] [blame] | 264 | void InputDeviceInfo::setKeyboardType(int32_t keyboardType) { | 
|  | 265 | static_assert(AINPUT_KEYBOARD_TYPE_NONE < AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC); | 
|  | 266 | static_assert(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC < AINPUT_KEYBOARD_TYPE_ALPHABETIC); | 
|  | 267 | // There can be multiple subdevices with different keyboard types, set it to the highest type | 
|  | 268 | mKeyboardType = std::max(mKeyboardType, keyboardType); | 
|  | 269 | } | 
|  | 270 |  | 
| Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 271 | void InputDeviceInfo::setKeyboardLayoutInfo(KeyboardLayoutInfo layoutInfo) { | 
|  | 272 | mKeyboardLayoutInfo = std::move(layoutInfo); | 
|  | 273 | } | 
|  | 274 |  | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 275 | std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() { | 
|  | 276 | std::vector<InputDeviceSensorInfo> infos; | 
|  | 277 | infos.reserve(mSensors.size()); | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 278 | for (const auto& [type, info] : mSensors) { | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 279 | infos.push_back(info); | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 280 | } | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 281 | return infos; | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 282 | } | 
|  | 283 |  | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 284 | std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() { | 
|  | 285 | std::vector<InputDeviceLightInfo> infos; | 
|  | 286 | infos.reserve(mLights.size()); | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 287 | for (const auto& [id, info] : mLights) { | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 288 | infos.push_back(info); | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 289 | } | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 290 | return infos; | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 291 | } | 
|  | 292 |  | 
| Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 293 | } // namespace android |