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 | |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 23 | #include <android-base/logging.h> |
Jooyung Han | 70932db | 2024-02-23 14:02:45 +0900 | [diff] [blame] | 24 | #include <android-base/properties.h> |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 25 | #include <android-base/stringprintf.h> |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 26 | #include <ftl/enum.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 27 | #include <input/InputDevice.h> |
Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 28 | #include <input/InputEventLabels.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 29 | |
Jooyung Han | 70932db | 2024-02-23 14:02:45 +0900 | [diff] [blame] | 30 | using android::base::GetProperty; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 31 | using android::base::StringPrintf; |
| 32 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 33 | namespace android { |
| 34 | |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 35 | // Set to true to log detailed debugging messages about IDC file probing. |
| 36 | static constexpr bool DEBUG_PROBE = false; |
| 37 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 38 | static const char* CONFIGURATION_FILE_DIR[] = { |
| 39 | "idc/", |
| 40 | "keylayout/", |
| 41 | "keychars/", |
| 42 | }; |
| 43 | |
| 44 | static const char* CONFIGURATION_FILE_EXTENSION[] = { |
| 45 | ".idc", |
| 46 | ".kl", |
| 47 | ".kcm", |
| 48 | }; |
| 49 | |
| 50 | static bool isValidNameChar(char ch) { |
| 51 | return isascii(ch) && (isdigit(ch) || isalpha(ch) || ch == '-' || ch == '_'); |
| 52 | } |
| 53 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 54 | static void appendInputDeviceConfigurationFileRelativePath(std::string& path, |
| 55 | const std::string& name, InputDeviceConfigurationFileType type) { |
Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 56 | path += CONFIGURATION_FILE_DIR[static_cast<int32_t>(type)]; |
Siarhei Vishniakou | 409ec1a | 2019-02-20 19:36:25 -0600 | [diff] [blame] | 57 | path += name; |
Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 58 | path += CONFIGURATION_FILE_EXTENSION[static_cast<int32_t>(type)]; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 61 | std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 62 | const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, |
| 63 | const char* suffix) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 64 | if (deviceIdentifier.vendor !=0 && deviceIdentifier.product != 0) { |
| 65 | if (deviceIdentifier.version != 0) { |
| 66 | // Try vendor product version. |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 67 | std::string versionPath = |
| 68 | getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%" |
| 69 | "04x_Version_%04x%s", |
| 70 | deviceIdentifier.vendor, |
| 71 | deviceIdentifier.product, |
| 72 | deviceIdentifier.version, |
| 73 | suffix), |
| 74 | type); |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 75 | if (!versionPath.empty()) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 76 | return versionPath; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Try vendor product. |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 81 | std::string productPath = |
| 82 | getInputDeviceConfigurationFilePathByName(StringPrintf("Vendor_%04x_Product_%04x%s", |
| 83 | deviceIdentifier.vendor, |
| 84 | deviceIdentifier.product, |
| 85 | suffix), |
| 86 | type); |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 87 | if (!productPath.empty()) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 88 | return productPath; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Try device name. |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 93 | return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName() + suffix, |
| 94 | type); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 97 | std::string getInputDeviceConfigurationFilePathByName( |
| 98 | const std::string& name, InputDeviceConfigurationFileType type) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 99 | // Search system repository. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 100 | std::string path; |
Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 101 | |
Hongguang Chen | 1438ccb | 2021-04-30 09:48:49 -0700 | [diff] [blame] | 102 | // Treblized input device config files will be located /product/usr, /system_ext/usr, |
| 103 | // /odm/usr or /vendor/usr. |
Jooyung Han | 70932db | 2024-02-23 14:02:45 +0900 | [diff] [blame] | 104 | std::vector<std::string> pathPrefixes{ |
| 105 | "/product/usr/", |
| 106 | "/system_ext/usr/", |
| 107 | "/odm/usr/", |
| 108 | "/vendor/usr/", |
Daniel Norman | 54283d6 | 2021-10-08 16:31:03 -0700 | [diff] [blame] | 109 | }; |
Jooyung Han | 70932db | 2024-02-23 14:02:45 +0900 | [diff] [blame] | 110 | // These files may also be in the APEX pointed by input_device.config_file.apex sysprop. |
| 111 | if (auto apex = GetProperty("input_device.config_file.apex", ""); !apex.empty()) { |
| 112 | pathPrefixes.push_back("/apex/" + apex + "/etc/usr/"); |
| 113 | } |
| 114 | // ANDROID_ROOT may not be set on host |
| 115 | if (auto android_root = getenv("ANDROID_ROOT"); android_root != nullptr) { |
| 116 | pathPrefixes.push_back(std::string(android_root) + "/usr/"); |
| 117 | } |
| 118 | for (const auto& prefix : pathPrefixes) { |
| 119 | path = prefix; |
Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 120 | appendInputDeviceConfigurationFileRelativePath(path, name, type); |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 121 | if (!access(path.c_str(), R_OK)) { |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 122 | LOG_IF(INFO, DEBUG_PROBE) |
| 123 | << "Found system-provided input device configuration file at " << path; |
Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 124 | return path; |
Harry Cutts | b632185 | 2024-09-12 18:49:39 +0000 | [diff] [blame^] | 125 | } else if (errno != ENOENT) { |
| 126 | LOG(WARNING) << "Couldn't find a system-provided input device configuration file at " |
| 127 | << path << " due to error " << errno << " (" << strerror(errno) |
| 128 | << "); there may be an IDC file there that cannot be loaded."; |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 129 | } else { |
| 130 | LOG_IF(ERROR, DEBUG_PROBE) |
| 131 | << "Didn't find system-provided input device configuration file at " << path |
| 132 | << ": " << strerror(errno); |
Jaekyun Seok | 7ead73e | 2017-02-28 18:07:03 +0900 | [diff] [blame] | 133 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | // Search user repository. |
| 137 | // TODO Should only look here if not in safe mode. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 138 | path = ""; |
| 139 | char *androidData = getenv("ANDROID_DATA"); |
| 140 | if (androidData != nullptr) { |
| 141 | path += androidData; |
| 142 | } |
| 143 | path += "/system/devices/"; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 144 | appendInputDeviceConfigurationFileRelativePath(path, name, type); |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 145 | if (!access(path.c_str(), R_OK)) { |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 146 | LOG_IF(INFO, DEBUG_PROBE) << "Found system user input device configuration file at " |
| 147 | << path; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 148 | return path; |
Harry Cutts | b632185 | 2024-09-12 18:49:39 +0000 | [diff] [blame^] | 149 | } else if (errno != ENOENT) { |
| 150 | LOG(WARNING) << "Couldn't find a system user input device configuration file at " << path |
| 151 | << " due to error " << errno << " (" << strerror(errno) |
| 152 | << "); there may be an IDC file there that cannot be loaded."; |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 153 | } else { |
| 154 | LOG_IF(ERROR, DEBUG_PROBE) << "Didn't find system user input device configuration file at " |
| 155 | << path << ": " << strerror(errno); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | // Not found. |
Harry Cutts | f20b6ba | 2024-09-12 18:11:44 +0000 | [diff] [blame] | 159 | LOG_IF(INFO, DEBUG_PROBE) << "Probe failed to find input device configuration file with name '" |
| 160 | << name << "' and type " << ftl::enum_string(type); |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 161 | return ""; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Siarhei Vishniakou | b45635c | 2019-02-20 19:22:09 -0600 | [diff] [blame] | 164 | // --- InputDeviceIdentifier |
| 165 | |
| 166 | std::string InputDeviceIdentifier::getCanonicalName() const { |
| 167 | std::string replacedName = name; |
| 168 | for (char& ch : replacedName) { |
| 169 | if (!isValidNameChar(ch)) { |
| 170 | ch = '_'; |
| 171 | } |
| 172 | } |
| 173 | return replacedName; |
| 174 | } |
| 175 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 176 | |
| 177 | // --- InputDeviceInfo --- |
| 178 | |
| 179 | InputDeviceInfo::InputDeviceInfo() { |
Siarhei Vishniakou | cfbee53 | 2024-05-10 13:41:35 -0700 | [diff] [blame] | 180 | initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::LogicalDisplayId::INVALID); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 183 | InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) |
| 184 | : mId(other.mId), |
| 185 | mGeneration(other.mGeneration), |
| 186 | mControllerNumber(other.mControllerNumber), |
| 187 | mIdentifier(other.mIdentifier), |
| 188 | mAlias(other.mAlias), |
| 189 | mIsExternal(other.mIsExternal), |
| 190 | mHasMic(other.mHasMic), |
Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 191 | mKeyboardLayoutInfo(other.mKeyboardLayoutInfo), |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 192 | mSources(other.mSources), |
| 193 | mKeyboardType(other.mKeyboardType), |
| 194 | mKeyCharacterMap(other.mKeyCharacterMap), |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame] | 195 | mUsiVersion(other.mUsiVersion), |
| 196 | mAssociatedDisplayId(other.mAssociatedDisplayId), |
Linnan Li | 48f80da | 2024-04-22 18:38:16 +0000 | [diff] [blame] | 197 | mEnabled(other.mEnabled), |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 198 | mHasVibrator(other.mHasVibrator), |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 199 | mHasBattery(other.mHasBattery), |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 200 | mHasButtonUnderPad(other.mHasButtonUnderPad), |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 201 | mHasSensor(other.mHasSensor), |
| 202 | mMotionRanges(other.mMotionRanges), |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 203 | mSensors(other.mSensors), |
Yeabkal Wubshit | b1b96db | 2024-01-24 12:47:00 -0800 | [diff] [blame] | 204 | mLights(other.mLights), |
| 205 | mViewBehavior(other.mViewBehavior) {} |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 206 | |
| 207 | InputDeviceInfo::~InputDeviceInfo() { |
| 208 | } |
| 209 | |
Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 210 | void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 211 | const InputDeviceIdentifier& identifier, const std::string& alias, |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 212 | bool isExternal, bool hasMic, |
| 213 | ui::LogicalDisplayId associatedDisplayId, |
Linnan Li | 48f80da | 2024-04-22 18:38:16 +0000 | [diff] [blame] | 214 | InputDeviceViewBehavior viewBehavior, bool enabled) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 215 | mId = id; |
| 216 | mGeneration = generation; |
Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 217 | mControllerNumber = controllerNumber; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 218 | mIdentifier = identifier; |
| 219 | mAlias = alias; |
| 220 | mIsExternal = isExternal; |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 221 | mHasMic = hasMic; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 222 | mSources = 0; |
| 223 | mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE; |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame] | 224 | mAssociatedDisplayId = associatedDisplayId; |
Linnan Li | 48f80da | 2024-04-22 18:38:16 +0000 | [diff] [blame] | 225 | mEnabled = enabled; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 226 | mHasVibrator = false; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 227 | mHasBattery = false; |
Michael Wright | 931fd6d | 2013-07-10 18:05:15 -0700 | [diff] [blame] | 228 | mHasButtonUnderPad = false; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 229 | mHasSensor = false; |
Yeabkal Wubshit | b1b96db | 2024-01-24 12:47:00 -0800 | [diff] [blame] | 230 | mViewBehavior = viewBehavior; |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame] | 231 | mUsiVersion.reset(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 232 | mMotionRanges.clear(); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 233 | mSensors.clear(); |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 234 | mLights.clear(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | const InputDeviceInfo::MotionRange* InputDeviceInfo::getMotionRange( |
| 238 | int32_t axis, uint32_t source) const { |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame] | 239 | for (const MotionRange& range : mMotionRanges) { |
| 240 | if (range.axis == axis && isFromSource(range.source, source)) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 241 | return ⦥ |
| 242 | } |
| 243 | } |
Yi Kong | 5bed83b | 2018-07-17 12:53:47 -0700 | [diff] [blame] | 244 | return nullptr; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | void InputDeviceInfo::addSource(uint32_t source) { |
| 248 | mSources |= source; |
| 249 | } |
| 250 | |
| 251 | void InputDeviceInfo::addMotionRange(int32_t axis, uint32_t source, float min, float max, |
| 252 | float flat, float fuzz, float resolution) { |
| 253 | MotionRange range = { axis, source, min, max, flat, fuzz, resolution }; |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 254 | mMotionRanges.push_back(range); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | void InputDeviceInfo::addMotionRange(const MotionRange& range) { |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 258 | mMotionRanges.push_back(range); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 261 | void InputDeviceInfo::addSensorInfo(const InputDeviceSensorInfo& info) { |
| 262 | if (mSensors.find(info.type) != mSensors.end()) { |
| 263 | 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] | 264 | ftl::enum_string(info.type).c_str()); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 265 | } |
| 266 | mSensors.insert_or_assign(info.type, info); |
| 267 | } |
| 268 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 269 | void InputDeviceInfo::addBatteryInfo(const InputDeviceBatteryInfo& info) { |
| 270 | if (mBatteries.find(info.id) != mBatteries.end()) { |
| 271 | ALOGW("Battery id %d already exists, will be replaced by new battery added.", info.id); |
| 272 | } |
| 273 | mBatteries.insert_or_assign(info.id, info); |
| 274 | } |
| 275 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 276 | void InputDeviceInfo::addLightInfo(const InputDeviceLightInfo& info) { |
| 277 | if (mLights.find(info.id) != mLights.end()) { |
| 278 | ALOGW("Light id %d already exists, will be replaced by new light added.", info.id); |
| 279 | } |
| 280 | mLights.insert_or_assign(info.id, info); |
| 281 | } |
| 282 | |
Philip Junker | f843796 | 2022-01-25 21:20:19 +0100 | [diff] [blame] | 283 | void InputDeviceInfo::setKeyboardType(int32_t keyboardType) { |
Vaibhav Devmurari | e58ffb9 | 2024-05-22 17:38:25 +0000 | [diff] [blame] | 284 | mKeyboardType = keyboardType; |
Philip Junker | f843796 | 2022-01-25 21:20:19 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 287 | void InputDeviceInfo::setKeyboardLayoutInfo(KeyboardLayoutInfo layoutInfo) { |
| 288 | mKeyboardLayoutInfo = std::move(layoutInfo); |
| 289 | } |
| 290 | |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 291 | std::vector<InputDeviceSensorInfo> InputDeviceInfo::getSensors() { |
| 292 | std::vector<InputDeviceSensorInfo> infos; |
| 293 | infos.reserve(mSensors.size()); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 294 | for (const auto& [type, info] : mSensors) { |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 295 | infos.push_back(info); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 296 | } |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 297 | return infos; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 300 | std::vector<InputDeviceLightInfo> InputDeviceInfo::getLights() { |
| 301 | std::vector<InputDeviceLightInfo> infos; |
| 302 | infos.reserve(mLights.size()); |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 303 | for (const auto& [id, info] : mLights) { |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 304 | infos.push_back(info); |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 305 | } |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 306 | return infos; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 307 | } |
| 308 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 309 | } // namespace android |