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 | |
Prabir Pradhan | c08b0db | 2022-09-10 00:57:15 +0000 | [diff] [blame] | 17 | #pragma once |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 18 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 19 | #include <android/sensor.h> |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 20 | #include <ftl/flags.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 21 | #include <input/Input.h> |
| 22 | #include <input/KeyCharacterMap.h> |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 23 | #include <unordered_map> |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 24 | #include <vector> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 25 | |
Sandro Meier | d3d4060 | 2022-10-19 16:18:26 +0000 | [diff] [blame] | 26 | #include <android/os/IInputConstants.h> |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 27 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | |
| 30 | /* |
| 31 | * Identifies a device. |
| 32 | */ |
| 33 | struct InputDeviceIdentifier { |
| 34 | inline InputDeviceIdentifier() : |
| 35 | bus(0), vendor(0), product(0), version(0) { |
| 36 | } |
| 37 | |
| 38 | // Information provided by the kernel. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 39 | std::string name; |
| 40 | std::string location; |
| 41 | std::string uniqueId; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 42 | uint16_t bus; |
| 43 | uint16_t vendor; |
| 44 | uint16_t product; |
| 45 | uint16_t version; |
| 46 | |
| 47 | // A composite input device descriptor string that uniquely identifies the device |
| 48 | // even across reboots or reconnections. The value of this field is used by |
| 49 | // upper layers of the input system to associate settings with individual devices. |
| 50 | // It is hashed from whatever kernel provided information is available. |
| 51 | // Ideally, the way this value is computed should not change between Android releases |
| 52 | // because that would invalidate persistent settings that rely on it. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 53 | std::string descriptor; |
RoboErik | ec2a15a | 2013-12-19 11:54:29 -0800 | [diff] [blame] | 54 | |
| 55 | // A value added to uniquely identify a device in the absence of a unique id. This |
| 56 | // is intended to be a minimum way to distinguish from other active devices and may |
| 57 | // reuse values that are not associated with an input anymore. |
| 58 | uint16_t nonce; |
Siarhei Vishniakou | b45635c | 2019-02-20 19:22:09 -0600 | [diff] [blame] | 59 | |
Prabir Pradhan | 07525ef | 2022-10-03 21:51:26 +0000 | [diff] [blame] | 60 | // The bluetooth address of the device, if known. |
| 61 | std::optional<std::string> bluetoothAddress; |
| 62 | |
Siarhei Vishniakou | b45635c | 2019-02-20 19:22:09 -0600 | [diff] [blame] | 63 | /** |
| 64 | * Return InputDeviceIdentifier.name that has been adjusted as follows: |
| 65 | * - all characters besides alphanumerics, dash, |
| 66 | * and underscore have been replaced with underscores. |
| 67 | * This helps in situations where a file that matches the device name is needed, |
| 68 | * while conforming to the filename limitations. |
| 69 | */ |
| 70 | std::string getCanonicalName() const; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 73 | /* Types of input device sensors. Keep sync with core/java/android/hardware/Sensor.java */ |
| 74 | enum class InputDeviceSensorType : int32_t { |
| 75 | ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, |
| 76 | MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD, |
| 77 | ORIENTATION = 3, |
| 78 | GYROSCOPE = ASENSOR_TYPE_GYROSCOPE, |
| 79 | LIGHT = ASENSOR_TYPE_LIGHT, |
| 80 | PRESSURE = ASENSOR_TYPE_PRESSURE, |
| 81 | TEMPERATURE = 7, |
| 82 | PROXIMITY = ASENSOR_TYPE_PROXIMITY, |
| 83 | GRAVITY = ASENSOR_TYPE_GRAVITY, |
| 84 | LINEAR_ACCELERATION = ASENSOR_TYPE_LINEAR_ACCELERATION, |
| 85 | ROTATION_VECTOR = ASENSOR_TYPE_ROTATION_VECTOR, |
| 86 | RELATIVE_HUMIDITY = ASENSOR_TYPE_RELATIVE_HUMIDITY, |
| 87 | AMBIENT_TEMPERATURE = ASENSOR_TYPE_AMBIENT_TEMPERATURE, |
| 88 | MAGNETIC_FIELD_UNCALIBRATED = ASENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, |
| 89 | GAME_ROTATION_VECTOR = ASENSOR_TYPE_GAME_ROTATION_VECTOR, |
| 90 | GYROSCOPE_UNCALIBRATED = ASENSOR_TYPE_GYROSCOPE_UNCALIBRATED, |
| 91 | SIGNIFICANT_MOTION = ASENSOR_TYPE_SIGNIFICANT_MOTION, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 92 | |
| 93 | ftl_first = ACCELEROMETER, |
| 94 | ftl_last = SIGNIFICANT_MOTION |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | enum class InputDeviceSensorAccuracy : int32_t { |
| 98 | ACCURACY_NONE = 0, |
| 99 | ACCURACY_LOW = 1, |
| 100 | ACCURACY_MEDIUM = 2, |
| 101 | ACCURACY_HIGH = 3, |
| 102 | }; |
| 103 | |
| 104 | enum class InputDeviceSensorReportingMode : int32_t { |
| 105 | CONTINUOUS = 0, |
| 106 | ON_CHANGE = 1, |
| 107 | ONE_SHOT = 2, |
| 108 | SPECIAL_TRIGGER = 3, |
| 109 | }; |
| 110 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 111 | enum class InputDeviceLightType : int32_t { |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 112 | INPUT = 0, |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 113 | PLAYER_ID = 1, |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 114 | KEYBOARD_BACKLIGHT = 2, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 115 | |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 116 | ftl_last = KEYBOARD_BACKLIGHT |
| 117 | }; |
| 118 | |
| 119 | enum class InputDeviceLightCapability : uint32_t { |
| 120 | /** Capability to change brightness of the light */ |
| 121 | BRIGHTNESS = 0x00000001, |
| 122 | /** Capability to change color of the light */ |
| 123 | RGB = 0x00000002, |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 124 | }; |
| 125 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 126 | struct InputDeviceSensorInfo { |
| 127 | explicit InputDeviceSensorInfo(std::string name, std::string vendor, int32_t version, |
| 128 | InputDeviceSensorType type, InputDeviceSensorAccuracy accuracy, |
| 129 | float maxRange, float resolution, float power, int32_t minDelay, |
| 130 | int32_t fifoReservedEventCount, int32_t fifoMaxEventCount, |
| 131 | std::string stringType, int32_t maxDelay, int32_t flags, |
| 132 | int32_t id) |
| 133 | : name(name), |
| 134 | vendor(vendor), |
| 135 | version(version), |
| 136 | type(type), |
| 137 | accuracy(accuracy), |
| 138 | maxRange(maxRange), |
| 139 | resolution(resolution), |
| 140 | power(power), |
| 141 | minDelay(minDelay), |
| 142 | fifoReservedEventCount(fifoReservedEventCount), |
| 143 | fifoMaxEventCount(fifoMaxEventCount), |
| 144 | stringType(stringType), |
| 145 | maxDelay(maxDelay), |
| 146 | flags(flags), |
| 147 | id(id) {} |
| 148 | // Name string of the sensor. |
| 149 | std::string name; |
| 150 | // Vendor string of this sensor. |
| 151 | std::string vendor; |
| 152 | // Version of the sensor's module. |
| 153 | int32_t version; |
| 154 | // Generic type of this sensor. |
| 155 | InputDeviceSensorType type; |
| 156 | // The current accuracy of sensor event. |
| 157 | InputDeviceSensorAccuracy accuracy; |
| 158 | // Maximum range of the sensor in the sensor's unit. |
| 159 | float maxRange; |
| 160 | // Resolution of the sensor in the sensor's unit. |
| 161 | float resolution; |
| 162 | // The power in mA used by this sensor while in use. |
| 163 | float power; |
| 164 | // The minimum delay allowed between two events in microsecond or zero if this sensor only |
| 165 | // returns a value when the data it's measuring changes. |
| 166 | int32_t minDelay; |
| 167 | // Number of events reserved for this sensor in the batch mode FIFO. |
| 168 | int32_t fifoReservedEventCount; |
| 169 | // Maximum number of events of this sensor that could be batched. |
| 170 | int32_t fifoMaxEventCount; |
| 171 | // The type of this sensor as a string. |
| 172 | std::string stringType; |
| 173 | // The delay between two sensor events corresponding to the lowest frequency that this sensor |
| 174 | // supports. |
| 175 | int32_t maxDelay; |
| 176 | // Sensor flags |
| 177 | int32_t flags; |
| 178 | // Sensor id, same as the input device ID it belongs to. |
| 179 | int32_t id; |
| 180 | }; |
| 181 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 182 | struct InputDeviceLightInfo { |
| 183 | explicit InputDeviceLightInfo(std::string name, int32_t id, InputDeviceLightType type, |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 184 | ftl::Flags<InputDeviceLightCapability> capabilityFlags, |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 185 | int32_t ordinal) |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 186 | : name(name), id(id), type(type), capabilityFlags(capabilityFlags), ordinal(ordinal) {} |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 187 | // Name string of the light. |
| 188 | std::string name; |
| 189 | // Light id |
| 190 | int32_t id; |
| 191 | // Type of the light. |
| 192 | InputDeviceLightType type; |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 193 | // Light capabilities. |
| 194 | ftl::Flags<InputDeviceLightCapability> capabilityFlags; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 195 | // Ordinal of the light |
| 196 | int32_t ordinal; |
| 197 | }; |
| 198 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 199 | struct InputDeviceBatteryInfo { |
| 200 | explicit InputDeviceBatteryInfo(std::string name, int32_t id) : name(name), id(id) {} |
| 201 | // Name string of the battery. |
| 202 | std::string name; |
| 203 | // Battery id |
| 204 | int32_t id; |
| 205 | }; |
| 206 | |
Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 207 | struct KeyboardLayoutInfo { |
| 208 | explicit KeyboardLayoutInfo(std::string languageTag, std::string layoutType) |
| 209 | : languageTag(languageTag), layoutType(layoutType) {} |
| 210 | |
| 211 | // A BCP 47 conformant language tag such as "en-US". |
| 212 | std::string languageTag; |
| 213 | // The layout type such as QWERTY or AZERTY. |
| 214 | std::string layoutType; |
| 215 | }; |
| 216 | |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame^] | 217 | // The version of the Universal Stylus Initiative (USI) protocol supported by the input device. |
| 218 | struct InputDeviceUsiVersion { |
| 219 | int32_t majorVersion = -1; |
| 220 | int32_t minorVersion = -1; |
| 221 | }; |
| 222 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 223 | /* |
| 224 | * Describes the characteristics and capabilities of an input device. |
| 225 | */ |
| 226 | class InputDeviceInfo { |
| 227 | public: |
| 228 | InputDeviceInfo(); |
| 229 | InputDeviceInfo(const InputDeviceInfo& other); |
| 230 | ~InputDeviceInfo(); |
| 231 | |
| 232 | struct MotionRange { |
| 233 | int32_t axis; |
| 234 | uint32_t source; |
| 235 | float min; |
| 236 | float max; |
| 237 | float flat; |
| 238 | float fuzz; |
| 239 | float resolution; |
| 240 | }; |
| 241 | |
Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 242 | void initialize(int32_t id, int32_t generation, int32_t controllerNumber, |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 243 | const InputDeviceIdentifier& identifier, const std::string& alias, |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame^] | 244 | bool isExternal, bool hasMic, int32_t associatedDisplayId); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 245 | |
| 246 | inline int32_t getId() const { return mId; } |
Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 247 | inline int32_t getControllerNumber() const { return mControllerNumber; } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 248 | inline int32_t getGeneration() const { return mGeneration; } |
| 249 | inline const InputDeviceIdentifier& getIdentifier() const { return mIdentifier; } |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 250 | inline const std::string& getAlias() const { return mAlias; } |
| 251 | inline const std::string& getDisplayName() const { |
| 252 | return mAlias.empty() ? mIdentifier.name : mAlias; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 253 | } |
| 254 | inline bool isExternal() const { return mIsExternal; } |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 255 | inline bool hasMic() const { return mHasMic; } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 256 | inline uint32_t getSources() const { return mSources; } |
| 257 | |
| 258 | const MotionRange* getMotionRange(int32_t axis, uint32_t source) const; |
| 259 | |
| 260 | void addSource(uint32_t source); |
| 261 | void addMotionRange(int32_t axis, uint32_t source, |
| 262 | float min, float max, float flat, float fuzz, float resolution); |
| 263 | void addMotionRange(const MotionRange& range); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 264 | void addSensorInfo(const InputDeviceSensorInfo& info); |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 265 | void addBatteryInfo(const InputDeviceBatteryInfo& info); |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 266 | void addLightInfo(const InputDeviceLightInfo& info); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 267 | |
Philip Junker | f843796 | 2022-01-25 21:20:19 +0100 | [diff] [blame] | 268 | void setKeyboardType(int32_t keyboardType); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 269 | inline int32_t getKeyboardType() const { return mKeyboardType; } |
| 270 | |
Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 271 | void setKeyboardLayoutInfo(KeyboardLayoutInfo keyboardLayoutInfo); |
| 272 | inline const std::optional<KeyboardLayoutInfo>& getKeyboardLayoutInfo() const { |
| 273 | return mKeyboardLayoutInfo; |
| 274 | } |
| 275 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 276 | inline void setKeyCharacterMap(const std::shared_ptr<KeyCharacterMap> value) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 277 | mKeyCharacterMap = value; |
| 278 | } |
| 279 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 280 | inline const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap() const { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 281 | return mKeyCharacterMap; |
| 282 | } |
| 283 | |
| 284 | inline void setVibrator(bool hasVibrator) { mHasVibrator = hasVibrator; } |
| 285 | inline bool hasVibrator() const { return mHasVibrator; } |
| 286 | |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 287 | inline void setHasBattery(bool hasBattery) { mHasBattery = hasBattery; } |
| 288 | inline bool hasBattery() const { return mHasBattery; } |
| 289 | |
Michael Wright | 931fd6d | 2013-07-10 18:05:15 -0700 | [diff] [blame] | 290 | inline void setButtonUnderPad(bool hasButton) { mHasButtonUnderPad = hasButton; } |
| 291 | inline bool hasButtonUnderPad() const { return mHasButtonUnderPad; } |
| 292 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 293 | inline void setHasSensor(bool hasSensor) { mHasSensor = hasSensor; } |
| 294 | inline bool hasSensor() const { return mHasSensor; } |
| 295 | |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 296 | inline const std::vector<MotionRange>& getMotionRanges() const { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 297 | return mMotionRanges; |
| 298 | } |
| 299 | |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 300 | std::vector<InputDeviceSensorInfo> getSensors(); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 301 | |
Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 302 | std::vector<InputDeviceLightInfo> getLights(); |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 303 | |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame^] | 304 | inline void setUsiVersion(std::optional<InputDeviceUsiVersion> usiVersion) { |
| 305 | mUsiVersion = std::move(usiVersion); |
| 306 | } |
| 307 | inline std::optional<InputDeviceUsiVersion> getUsiVersion() const { return mUsiVersion; } |
| 308 | |
| 309 | inline int32_t getAssociatedDisplayId() const { return mAssociatedDisplayId; } |
Prabir Pradhan | 167c270 | 2022-09-14 00:37:24 +0000 | [diff] [blame] | 310 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 311 | private: |
| 312 | int32_t mId; |
| 313 | int32_t mGeneration; |
Michael Wright | 0415d63 | 2013-07-17 13:23:26 -0700 | [diff] [blame] | 314 | int32_t mControllerNumber; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 315 | InputDeviceIdentifier mIdentifier; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 316 | std::string mAlias; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 317 | bool mIsExternal; |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 318 | bool mHasMic; |
Zixuan Qu | fecb606 | 2022-11-12 04:44:31 +0000 | [diff] [blame] | 319 | std::optional<KeyboardLayoutInfo> mKeyboardLayoutInfo; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 320 | uint32_t mSources; |
| 321 | int32_t mKeyboardType; |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 322 | std::shared_ptr<KeyCharacterMap> mKeyCharacterMap; |
Prabir Pradhan | e04ffaa | 2022-12-13 23:04:04 +0000 | [diff] [blame^] | 323 | std::optional<InputDeviceUsiVersion> mUsiVersion; |
| 324 | int32_t mAssociatedDisplayId; |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 325 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 326 | bool mHasVibrator; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 327 | bool mHasBattery; |
Michael Wright | 931fd6d | 2013-07-10 18:05:15 -0700 | [diff] [blame] | 328 | bool mHasButtonUnderPad; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 329 | bool mHasSensor; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 330 | |
Arthur Hung | 7c3ae9c | 2019-03-11 11:23:03 +0800 | [diff] [blame] | 331 | std::vector<MotionRange> mMotionRanges; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 332 | std::unordered_map<InputDeviceSensorType, InputDeviceSensorInfo> mSensors; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 333 | /* Map from light ID to light info */ |
| 334 | std::unordered_map<int32_t, InputDeviceLightInfo> mLights; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 335 | /* Map from battery ID to battery info */ |
| 336 | std::unordered_map<int32_t, InputDeviceBatteryInfo> mBatteries; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | /* Types of input device configuration files. */ |
Chris Ye | 1d927aa | 2020-07-04 18:22:41 -0700 | [diff] [blame] | 340 | enum class InputDeviceConfigurationFileType : int32_t { |
| 341 | CONFIGURATION = 0, /* .idc file */ |
| 342 | KEY_LAYOUT = 1, /* .kl file */ |
| 343 | KEY_CHARACTER_MAP = 2, /* .kcm file */ |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | /* |
| 347 | * Gets the path of an input device configuration file, if one is available. |
| 348 | * Considers both system provided and user installed configuration files. |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 349 | * The optional suffix is appended to the end of the file name (before the |
| 350 | * extension). |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 351 | * |
| 352 | * The device identifier is used to construct several default configuration file |
| 353 | * names to try based on the device name, vendor, product, and version. |
| 354 | * |
| 355 | * Returns an empty string if not found. |
| 356 | */ |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 357 | extern std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( |
Siarhei Vishniakou | a9fd82c | 2022-05-18 09:42:52 -0700 | [diff] [blame] | 358 | const InputDeviceIdentifier& deviceIdentifier, InputDeviceConfigurationFileType type, |
| 359 | const char* suffix = ""); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 360 | |
| 361 | /* |
| 362 | * Gets the path of an input device configuration file, if one is available. |
| 363 | * Considers both system provided and user installed configuration files. |
| 364 | * |
| 365 | * The name is case-sensitive and is used to construct the filename to resolve. |
| 366 | * All characters except 'a'-'z', 'A'-'Z', '0'-'9', '-', and '_' are replaced by underscores. |
| 367 | * |
| 368 | * Returns an empty string if not found. |
| 369 | */ |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 370 | extern std::string getInputDeviceConfigurationFilePathByName( |
| 371 | const std::string& name, InputDeviceConfigurationFileType type); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 372 | |
Prabir Pradhan | cae4b3a | 2019-02-05 18:51:32 -0800 | [diff] [blame] | 373 | enum ReservedInputDeviceId : int32_t { |
Sandro Meier | d3d4060 | 2022-10-19 16:18:26 +0000 | [diff] [blame] | 374 | // Device id representing an invalid device |
| 375 | INVALID_INPUT_DEVICE_ID = android::os::IInputConstants::INVALID_INPUT_DEVICE_ID, |
Prabir Pradhan | cae4b3a | 2019-02-05 18:51:32 -0800 | [diff] [blame] | 376 | // Device id of a special "virtual" keyboard that is always present. |
| 377 | VIRTUAL_KEYBOARD_ID = -1, |
| 378 | // Device id of the "built-in" keyboard if there is one. |
| 379 | BUILT_IN_KEYBOARD_ID = 0, |
Nathaniel R. Lewis | a7b82e1 | 2020-02-12 15:40:45 -0800 | [diff] [blame] | 380 | // First device id available for dynamic devices |
| 381 | END_RESERVED_ID = 1, |
Prabir Pradhan | cae4b3a | 2019-02-05 18:51:32 -0800 | [diff] [blame] | 382 | }; |
| 383 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 384 | } // namespace android |