Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 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 | 4810866 | 2022-09-09 21:22:04 +0000 | [diff] [blame] | 17 | #pragma once |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 18 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 19 | #include <bitset> |
| 20 | #include <climits> |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 21 | #include <filesystem> |
Harry Cutts | ea73eaa | 2023-01-16 17:55:46 +0000 | [diff] [blame] | 22 | #include <ostream> |
| 23 | #include <string> |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 24 | #include <unordered_map> |
Prabir Pradhan | 5189478 | 2022-08-23 16:29:10 +0000 | [diff] [blame] | 25 | #include <utility> |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 26 | #include <vector> |
| 27 | |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 28 | #include <batteryservice/BatteryService.h> |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 29 | #include <ftl/flags.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 30 | #include <input/Input.h> |
| 31 | #include <input/InputDevice.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 32 | #include <input/KeyCharacterMap.h> |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 33 | #include <input/KeyLayoutMap.h> |
| 34 | #include <input/Keyboard.h> |
Siarhei Vishniakou | 32f36ae | 2020-09-02 20:17:10 -0700 | [diff] [blame] | 35 | #include <input/PropertyMap.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 36 | #include <input/VirtualKeyMap.h> |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 37 | #include <linux/input.h> |
| 38 | #include <sys/epoll.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 39 | #include <utils/BitSet.h> |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 40 | #include <utils/Errors.h> |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 41 | #include <utils/List.h> |
| 42 | #include <utils/Log.h> |
| 43 | #include <utils/Mutex.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 44 | |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 45 | #include "TouchVideoDevice.h" |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 46 | #include "VibrationElement.h" |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 47 | |
Prabir Pradhan | 952e65b | 2022-06-23 17:49:55 +0000 | [diff] [blame] | 48 | struct inotify_event; |
| 49 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 50 | namespace android { |
| 51 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 52 | /* Number of colors : {red, green, blue} */ |
| 53 | static constexpr size_t COLOR_NUM = 3; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 54 | /* |
| 55 | * A raw event as retrieved from the EventHub. |
| 56 | */ |
| 57 | struct RawEvent { |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 58 | // Time when the event happened |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 59 | nsecs_t when; |
Siarhei Vishniakou | 58ba3d1 | 2021-02-11 01:31:07 +0000 | [diff] [blame] | 60 | // Time when the event was read by EventHub. Only populated for input events. |
| 61 | // For other events (device added/removed/etc), this value is undefined and should not be read. |
| 62 | nsecs_t readTime; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 63 | int32_t deviceId; |
| 64 | int32_t type; |
| 65 | int32_t code; |
| 66 | int32_t value; |
| 67 | }; |
| 68 | |
| 69 | /* Describes an absolute axis. */ |
| 70 | struct RawAbsoluteAxisInfo { |
Prabir Pradhan | d6ccedb | 2022-09-27 21:04:06 +0000 | [diff] [blame] | 71 | bool valid{false}; // true if the information is valid, false otherwise |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 72 | |
Prabir Pradhan | d6ccedb | 2022-09-27 21:04:06 +0000 | [diff] [blame] | 73 | int32_t minValue{}; // minimum value |
| 74 | int32_t maxValue{}; // maximum value |
| 75 | int32_t flat{}; // center flat position, eg. flat == 8 means center is between -8 and 8 |
| 76 | int32_t fuzz{}; // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise |
| 77 | int32_t resolution{}; // resolution in units per mm or radians per mm |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 78 | |
Prabir Pradhan | d6ccedb | 2022-09-27 21:04:06 +0000 | [diff] [blame] | 79 | inline void clear() { *this = RawAbsoluteAxisInfo(); } |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 80 | }; |
| 81 | |
Harry Cutts | ea73eaa | 2023-01-16 17:55:46 +0000 | [diff] [blame] | 82 | std::ostream& operator<<(std::ostream& out, const RawAbsoluteAxisInfo& info); |
| 83 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 84 | /* |
| 85 | * Input device classes. |
| 86 | */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 87 | enum class InputDeviceClass : uint32_t { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 88 | /* The input device is a keyboard or has buttons. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 89 | KEYBOARD = 0x00000001, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 90 | |
| 91 | /* The input device is an alpha-numeric keyboard (not just a dial pad). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 92 | ALPHAKEY = 0x00000002, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 93 | |
| 94 | /* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 95 | TOUCH = 0x00000004, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 96 | |
| 97 | /* The input device is a cursor device such as a trackball or mouse. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 98 | CURSOR = 0x00000008, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 99 | |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 100 | /* The input device is a multi-touch touchscreen or touchpad. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 101 | TOUCH_MT = 0x00000010, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 102 | |
| 103 | /* The input device is a directional pad (implies keyboard, has DPAD keys). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 104 | DPAD = 0x00000020, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 105 | |
| 106 | /* The input device is a gamepad (implies keyboard, has BUTTON keys). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 107 | GAMEPAD = 0x00000040, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 108 | |
| 109 | /* The input device has switches. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 110 | SWITCH = 0x00000080, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 111 | |
| 112 | /* The input device is a joystick (implies gamepad, has joystick absolute axes). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 113 | JOYSTICK = 0x00000100, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 114 | |
| 115 | /* The input device has a vibrator (supports FF_RUMBLE). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 116 | VIBRATOR = 0x00000200, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 117 | |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 118 | /* The input device has a microphone. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 119 | MIC = 0x00000400, |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 120 | |
Michael Wright | 842500e | 2015-03-13 17:32:02 -0700 | [diff] [blame] | 121 | /* The input device is an external stylus (has data we want to fuse with touch data). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 122 | EXTERNAL_STYLUS = 0x00000800, |
Michael Wright | 842500e | 2015-03-13 17:32:02 -0700 | [diff] [blame] | 123 | |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 124 | /* The input device has a rotary encoder */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 125 | ROTARY_ENCODER = 0x00001000, |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 126 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 127 | /* The input device has a sensor like accelerometer, gyro, etc */ |
| 128 | SENSOR = 0x00002000, |
| 129 | |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 130 | /* The input device has a battery */ |
| 131 | BATTERY = 0x00004000, |
| 132 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 133 | /* The input device has sysfs controllable lights */ |
| 134 | LIGHT = 0x00008000, |
| 135 | |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 136 | /* The input device is a touchpad, requiring an on-screen cursor. */ |
| 137 | TOUCHPAD = 0x00010000, |
| 138 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 139 | /* The input device is virtual (not a real device, not part of UI configuration). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 140 | VIRTUAL = 0x40000000, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 141 | |
| 142 | /* The input device is external (not built-in). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 143 | EXTERNAL = 0x80000000, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 144 | }; |
| 145 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 146 | enum class SysfsClass : uint32_t { |
| 147 | POWER_SUPPLY = 0, |
| 148 | LEDS = 1, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 149 | |
| 150 | ftl_last = LEDS |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | enum class LightColor : uint32_t { |
| 154 | RED = 0, |
| 155 | GREEN = 1, |
| 156 | BLUE = 2, |
| 157 | }; |
| 158 | |
| 159 | enum class InputLightClass : uint32_t { |
| 160 | /* The input light has brightness node. */ |
| 161 | BRIGHTNESS = 0x00000001, |
| 162 | /* The input light has red name. */ |
| 163 | RED = 0x00000002, |
| 164 | /* The input light has green name. */ |
| 165 | GREEN = 0x00000004, |
| 166 | /* The input light has blue name. */ |
| 167 | BLUE = 0x00000008, |
| 168 | /* The input light has global name. */ |
| 169 | GLOBAL = 0x00000010, |
| 170 | /* The input light has multi index node. */ |
| 171 | MULTI_INDEX = 0x00000020, |
| 172 | /* The input light has multi intensity node. */ |
| 173 | MULTI_INTENSITY = 0x00000040, |
| 174 | /* The input light has max brightness node. */ |
| 175 | MAX_BRIGHTNESS = 0x00000080, |
Vaibhav Devmurari | 82b37d6 | 2022-09-12 13:36:48 +0000 | [diff] [blame] | 176 | /* The input light has kbd_backlight name */ |
| 177 | KEYBOARD_BACKLIGHT = 0x00000100, |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 178 | }; |
| 179 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 180 | enum class InputBatteryClass : uint32_t { |
| 181 | /* The input device battery has capacity node. */ |
| 182 | CAPACITY = 0x00000001, |
| 183 | /* The input device battery has capacity_level node. */ |
| 184 | CAPACITY_LEVEL = 0x00000002, |
| 185 | /* The input device battery has status node. */ |
| 186 | STATUS = 0x00000004, |
| 187 | }; |
| 188 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 189 | /* Describes a raw light. */ |
| 190 | struct RawLightInfo { |
| 191 | int32_t id; |
| 192 | std::string name; |
| 193 | std::optional<int32_t> maxBrightness; |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 194 | ftl::Flags<InputLightClass> flags; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 195 | std::array<int32_t, COLOR_NUM> rgbIndex; |
| 196 | std::filesystem::path path; |
Prabir Pradhan | edeec3b | 2022-08-26 22:33:55 +0000 | [diff] [blame] | 197 | |
| 198 | bool operator==(const RawLightInfo&) const = default; |
| 199 | bool operator!=(const RawLightInfo&) const = default; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 200 | }; |
| 201 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 202 | /* Describes a raw battery. */ |
| 203 | struct RawBatteryInfo { |
| 204 | int32_t id; |
| 205 | std::string name; |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 206 | ftl::Flags<InputBatteryClass> flags; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 207 | std::filesystem::path path; |
Prabir Pradhan | edeec3b | 2022-08-26 22:33:55 +0000 | [diff] [blame] | 208 | |
| 209 | bool operator==(const RawBatteryInfo&) const = default; |
| 210 | bool operator!=(const RawBatteryInfo&) const = default; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 211 | }; |
| 212 | |
Vaibhav Devmurari | 7fb4113 | 2023-01-02 13:30:26 +0000 | [diff] [blame] | 213 | /* Layout information associated with the device */ |
| 214 | struct RawLayoutInfo { |
| 215 | std::string languageTag; |
| 216 | std::string layoutType; |
| 217 | |
| 218 | bool operator==(const RawLayoutInfo&) const = default; |
| 219 | bool operator!=(const RawLayoutInfo&) const = default; |
| 220 | }; |
| 221 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 222 | /* |
| 223 | * Gets the class that owns an axis, in cases where multiple classes might claim |
| 224 | * the same axis for different purposes. |
| 225 | */ |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 226 | extern ftl::Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, |
| 227 | ftl::Flags<InputDeviceClass> deviceClasses); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 228 | |
| 229 | /* |
| 230 | * Grand Central Station for events. |
| 231 | * |
| 232 | * The event hub aggregates input events received across all known input |
| 233 | * devices on the system, including devices that may be emulated by the simulator |
| 234 | * environment. In addition, the event hub generates fake input events to indicate |
| 235 | * when devices are added or removed. |
| 236 | * |
| 237 | * The event hub provides a stream of input events (via the getEvent function). |
| 238 | * It also supports querying the current actual state of input devices such as identifying |
| 239 | * which keys are currently down. Finally, the event hub keeps track of the capabilities of |
| 240 | * individual input devices, such as their class and the set of key codes that they support. |
| 241 | */ |
Siarhei Vishniakou | 3bc7e09 | 2019-07-24 17:43:30 -0700 | [diff] [blame] | 242 | class EventHubInterface { |
| 243 | public: |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 244 | EventHubInterface() {} |
| 245 | virtual ~EventHubInterface() {} |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 246 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 247 | // Synthetic raw event type codes produced when devices are added or removed. |
| 248 | enum { |
| 249 | // Sent when a device is added. |
| 250 | DEVICE_ADDED = 0x10000000, |
| 251 | // Sent when a device is removed. |
| 252 | DEVICE_REMOVED = 0x20000000, |
| 253 | // Sent when all added/removed devices from the most recent scan have been reported. |
| 254 | // This event is always sent at least once. |
| 255 | FINISHED_DEVICE_SCAN = 0x30000000, |
| 256 | |
| 257 | FIRST_SYNTHETIC_EVENT = DEVICE_ADDED, |
| 258 | }; |
| 259 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 260 | virtual ftl::Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 261 | |
| 262 | virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0; |
| 263 | |
| 264 | virtual int32_t getDeviceControllerNumber(int32_t deviceId) const = 0; |
| 265 | |
Harry Cutts | c34f758 | 2023-03-07 16:23:30 +0000 | [diff] [blame] | 266 | /** |
| 267 | * Get the PropertyMap for the provided EventHub device, if available. |
| 268 | * This acquires the device lock, so a copy is returned rather than the raw pointer |
| 269 | * to the device's PropertyMap. A std::nullopt may be returned if the device could |
| 270 | * not be found, or if it doesn't have any configuration. |
| 271 | */ |
| 272 | virtual std::optional<PropertyMap> getConfiguration(int32_t deviceId) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 273 | |
| 274 | virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 275 | RawAbsoluteAxisInfo* outAxisInfo) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 276 | |
| 277 | virtual bool hasRelativeAxis(int32_t deviceId, int axis) const = 0; |
| 278 | |
| 279 | virtual bool hasInputProperty(int32_t deviceId, int property) const = 0; |
| 280 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 281 | virtual bool hasMscEvent(int32_t deviceId, int mscEvent) const = 0; |
| 282 | |
Vaibhav Devmurari | cbba14c | 2022-10-10 16:54:49 +0000 | [diff] [blame] | 283 | virtual void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode, |
| 284 | int32_t toKeyCode) const = 0; |
| 285 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 286 | virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, |
| 287 | int32_t metaState, int32_t* outKeycode, int32_t* outMetaState, |
| 288 | uint32_t* outFlags) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 289 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 290 | virtual status_t mapAxis(int32_t deviceId, int32_t scanCode, AxisInfo* outAxisInfo) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 291 | |
| 292 | // Sets devices that are excluded from opening. |
| 293 | // This can be used to ignore input devices for sensors. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 294 | virtual void setExcludedDevices(const std::vector<std::string>& devices) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 295 | |
| 296 | /* |
| 297 | * Wait for events to become available and returns them. |
| 298 | * After returning, the EventHub holds onto a wake lock until the next call to getEvent. |
| 299 | * This ensures that the device will not go to sleep while the event is being processed. |
| 300 | * If the device needs to remain awake longer than that, then the caller is responsible |
| 301 | * for taking care of it (say, by poking the power manager user activity timer). |
| 302 | * |
| 303 | * The timeout is advisory only. If the device is asleep, it will not wake just to |
| 304 | * service the timeout. |
| 305 | * |
| 306 | * Returns the number of events obtained, or 0 if the timeout expired. |
| 307 | */ |
Siarhei Vishniakou | 7b3ea0b | 2022-09-16 14:23:20 -0700 | [diff] [blame] | 308 | virtual std::vector<RawEvent> getEvents(int timeoutMillis) = 0; |
Siarhei Vishniakou | add8929 | 2018-12-13 19:23:36 -0800 | [diff] [blame] | 309 | virtual std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) = 0; |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 310 | virtual base::Result<std::pair<InputDeviceSensorType, int32_t>> mapSensor( |
| 311 | int32_t deviceId, int32_t absCode) const = 0; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 312 | // Raw batteries are sysfs power_supply nodes we found from the EventHub device sysfs node, |
| 313 | // containing the raw info of the sysfs node structure. |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 314 | virtual std::vector<int32_t> getRawBatteryIds(int32_t deviceId) const = 0; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 315 | virtual std::optional<RawBatteryInfo> getRawBatteryInfo(int32_t deviceId, |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 316 | int32_t BatteryId) const = 0; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 317 | |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 318 | // Raw lights are sysfs led light nodes we found from the EventHub device sysfs node, |
| 319 | // containing the raw info of the sysfs node structure. |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 320 | virtual std::vector<int32_t> getRawLightIds(int32_t deviceId) const = 0; |
| 321 | virtual std::optional<RawLightInfo> getRawLightInfo(int32_t deviceId, |
| 322 | int32_t lightId) const = 0; |
| 323 | virtual std::optional<int32_t> getLightBrightness(int32_t deviceId, int32_t lightId) const = 0; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 324 | virtual void setLightBrightness(int32_t deviceId, int32_t lightId, int32_t brightness) = 0; |
| 325 | virtual std::optional<std::unordered_map<LightColor, int32_t>> getLightIntensities( |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 326 | int32_t deviceId, int32_t lightId) const = 0; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 327 | virtual void setLightIntensities(int32_t deviceId, int32_t lightId, |
| 328 | std::unordered_map<LightColor, int32_t> intensities) = 0; |
Vaibhav Devmurari | 7fb4113 | 2023-01-02 13:30:26 +0000 | [diff] [blame] | 329 | /* Query Layout info associated with the input device. */ |
| 330 | virtual std::optional<RawLayoutInfo> getRawLayoutInfo(int32_t deviceId) const = 0; |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 331 | /* Query current input state. */ |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 332 | virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const = 0; |
| 333 | virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const = 0; |
| 334 | virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const = 0; |
| 335 | virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 336 | int32_t* outValue) const = 0; |
Philip Junker | 4af3b3d | 2021-12-14 10:36:55 +0100 | [diff] [blame] | 337 | virtual int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 338 | |
| 339 | /* |
| 340 | * Examine key input devices for specific framework keycode support |
| 341 | */ |
Siarhei Vishniakou | 7400794 | 2022-06-13 13:57:47 -0700 | [diff] [blame] | 342 | virtual bool markSupportedKeyCodes(int32_t deviceId, const std::vector<int32_t>& keyCodes, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 343 | uint8_t* outFlags) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 344 | |
| 345 | virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0; |
Arthur Hung | cb40a00 | 2021-08-03 14:31:01 +0000 | [diff] [blame] | 346 | virtual bool hasKeyCode(int32_t deviceId, int32_t keyCode) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 347 | |
| 348 | /* LED related functions expect Android LED constants, not scan codes or HID usages */ |
| 349 | virtual bool hasLed(int32_t deviceId, int32_t led) const = 0; |
| 350 | virtual void setLedState(int32_t deviceId, int32_t led, bool on) = 0; |
| 351 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 352 | virtual void getVirtualKeyDefinitions( |
| 353 | int32_t deviceId, std::vector<VirtualKeyDefinition>& outVirtualKeys) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 354 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 355 | virtual const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const = 0; |
| 356 | virtual bool setKeyboardLayoutOverlay(int32_t deviceId, |
| 357 | std::shared_ptr<KeyCharacterMap> map) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 358 | |
| 359 | /* Control the vibrator. */ |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 360 | virtual void vibrate(int32_t deviceId, const VibrationElement& effect) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 361 | virtual void cancelVibrate(int32_t deviceId) = 0; |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 362 | virtual std::vector<int32_t> getVibratorIds(int32_t deviceId) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 363 | |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 364 | /* Query battery level. */ |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 365 | virtual std::optional<int32_t> getBatteryCapacity(int32_t deviceId, |
| 366 | int32_t batteryId) const = 0; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 367 | |
| 368 | /* Query battery status. */ |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 369 | virtual std::optional<int32_t> getBatteryStatus(int32_t deviceId, int32_t batteryId) const = 0; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 370 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 371 | /* Requests the EventHub to reopen all input devices on the next call to getEvents(). */ |
| 372 | virtual void requestReopenDevices() = 0; |
| 373 | |
| 374 | /* Wakes up getEvents() if it is blocked on a read. */ |
| 375 | virtual void wake() = 0; |
| 376 | |
| 377 | /* Dump EventHub state to a string. */ |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 378 | virtual void dump(std::string& dump) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 379 | |
| 380 | /* Called by the heatbeat to ensures that the reader has not deadlocked. */ |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 381 | virtual void monitor() const = 0; |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 382 | |
| 383 | /* Return true if the device is enabled. */ |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 384 | virtual bool isDeviceEnabled(int32_t deviceId) const = 0; |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 385 | |
| 386 | /* Enable an input device */ |
| 387 | virtual status_t enableDevice(int32_t deviceId) = 0; |
| 388 | |
| 389 | /* Disable an input device. Closes file descriptor to that device. */ |
| 390 | virtual status_t disableDevice(int32_t deviceId) = 0; |
Vaibhav Devmurari | 5fc7d85 | 2023-03-17 18:43:33 +0000 | [diff] [blame^] | 391 | |
| 392 | /* Sysfs node changed. Reopen the Eventhub device if any new Peripheral like Light, Battery, |
| 393 | * etc. is detected. */ |
| 394 | virtual void sysfsNodeChanged(const std::string& sysfsNodePath) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 395 | }; |
| 396 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 397 | template <std::size_t BITS> |
| 398 | class BitArray { |
| 399 | /* Array element type and vector of element type. */ |
| 400 | using Element = std::uint32_t; |
| 401 | /* Number of bits in each BitArray element. */ |
| 402 | static constexpr size_t WIDTH = sizeof(Element) * CHAR_BIT; |
| 403 | /* Number of elements to represent a bit array of the specified size of bits. */ |
| 404 | static constexpr size_t COUNT = (BITS + WIDTH - 1) / WIDTH; |
| 405 | |
| 406 | public: |
| 407 | /* BUFFER type declaration for BitArray */ |
| 408 | using Buffer = std::array<Element, COUNT>; |
| 409 | /* To tell if a bit is set in array, it selects an element from the array, and test |
| 410 | * if the relevant bit set. |
| 411 | * Note the parameter "bit" is an index to the bit, 0 <= bit < BITS. |
| 412 | */ |
| 413 | inline bool test(size_t bit) const { |
| 414 | return (bit < BITS) ? mData[bit / WIDTH].test(bit % WIDTH) : false; |
| 415 | } |
| 416 | /* Returns total number of bytes needed for the array */ |
| 417 | inline size_t bytes() { return (BITS + CHAR_BIT - 1) / CHAR_BIT; } |
| 418 | /* Returns true if array contains any non-zero bit from the range defined by start and end |
| 419 | * bit index [startIndex, endIndex). |
| 420 | */ |
| 421 | bool any(size_t startIndex, size_t endIndex) { |
| 422 | if (startIndex >= endIndex || startIndex > BITS || endIndex > BITS + 1) { |
| 423 | ALOGE("Invalid start/end index. start = %zu, end = %zu, total bits = %zu", startIndex, |
| 424 | endIndex, BITS); |
| 425 | return false; |
| 426 | } |
| 427 | size_t se = startIndex / WIDTH; // Start of element |
| 428 | size_t ee = endIndex / WIDTH; // End of element |
| 429 | size_t si = startIndex % WIDTH; // Start index in start element |
| 430 | size_t ei = endIndex % WIDTH; // End index in end element |
| 431 | // Need to check first unaligned bitset for any non zero bit |
| 432 | if (si > 0) { |
| 433 | size_t nBits = se == ee ? ei - si : WIDTH - si; |
| 434 | // Generate the mask of interested bit range |
| 435 | Element mask = ((1 << nBits) - 1) << si; |
| 436 | if (mData[se++].to_ulong() & mask) { |
| 437 | return true; |
| 438 | } |
| 439 | } |
| 440 | // Check whole bitset for any bit set |
| 441 | for (; se < ee; se++) { |
| 442 | if (mData[se].any()) { |
| 443 | return true; |
| 444 | } |
| 445 | } |
| 446 | // Need to check last unaligned bitset for any non zero bit |
| 447 | if (ei > 0 && se <= ee) { |
| 448 | // Generate the mask of interested bit range |
| 449 | Element mask = (1 << ei) - 1; |
| 450 | if (mData[se].to_ulong() & mask) { |
| 451 | return true; |
| 452 | } |
| 453 | } |
| 454 | return false; |
| 455 | } |
| 456 | /* Load bit array values from buffer */ |
| 457 | void loadFromBuffer(const Buffer& buffer) { |
| 458 | for (size_t i = 0; i < COUNT; i++) { |
| 459 | mData[i] = std::bitset<WIDTH>(buffer[i]); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | private: |
| 464 | std::array<std::bitset<WIDTH>, COUNT> mData; |
| 465 | }; |
| 466 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 467 | class EventHub : public EventHubInterface { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 468 | public: |
| 469 | EventHub(); |
| 470 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 471 | ftl::Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 472 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 473 | InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 474 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 475 | int32_t getDeviceControllerNumber(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 476 | |
Harry Cutts | c34f758 | 2023-03-07 16:23:30 +0000 | [diff] [blame] | 477 | std::optional<PropertyMap> getConfiguration(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 478 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 479 | status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, |
| 480 | RawAbsoluteAxisInfo* outAxisInfo) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 481 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 482 | bool hasRelativeAxis(int32_t deviceId, int axis) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 483 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 484 | bool hasInputProperty(int32_t deviceId, int property) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 485 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 486 | bool hasMscEvent(int32_t deviceId, int mscEvent) const override final; |
| 487 | |
Vaibhav Devmurari | cbba14c | 2022-10-10 16:54:49 +0000 | [diff] [blame] | 488 | void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode, |
| 489 | int32_t toKeyCode) const override final; |
| 490 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 491 | status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, int32_t metaState, |
| 492 | int32_t* outKeycode, int32_t* outMetaState, |
| 493 | uint32_t* outFlags) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 494 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 495 | status_t mapAxis(int32_t deviceId, int32_t scanCode, |
| 496 | AxisInfo* outAxisInfo) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 497 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 498 | base::Result<std::pair<InputDeviceSensorType, int32_t>> mapSensor( |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 499 | int32_t deviceId, int32_t absCode) const override final; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 500 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 501 | std::vector<int32_t> getRawBatteryIds(int32_t deviceId) const override final; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 502 | std::optional<RawBatteryInfo> getRawBatteryInfo(int32_t deviceId, |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 503 | int32_t BatteryId) const override final; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 504 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 505 | std::vector<int32_t> getRawLightIds(int32_t deviceId) const override final; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 506 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 507 | std::optional<RawLightInfo> getRawLightInfo(int32_t deviceId, |
| 508 | int32_t lightId) const override final; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 509 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 510 | std::optional<int32_t> getLightBrightness(int32_t deviceId, |
| 511 | int32_t lightId) const override final; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 512 | void setLightBrightness(int32_t deviceId, int32_t lightId, int32_t brightness) override final; |
| 513 | std::optional<std::unordered_map<LightColor, int32_t>> getLightIntensities( |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 514 | int32_t deviceId, int32_t lightId) const override final; |
Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 515 | void setLightIntensities(int32_t deviceId, int32_t lightId, |
| 516 | std::unordered_map<LightColor, int32_t> intensities) override final; |
| 517 | |
Vaibhav Devmurari | 7fb4113 | 2023-01-02 13:30:26 +0000 | [diff] [blame] | 518 | std::optional<RawLayoutInfo> getRawLayoutInfo(int32_t deviceId) const override final; |
Vaibhav Devmurari | dd82b8e | 2022-08-16 15:34:01 +0000 | [diff] [blame] | 519 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 520 | void setExcludedDevices(const std::vector<std::string>& devices) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 521 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 522 | int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const override final; |
| 523 | int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const override final; |
| 524 | int32_t getSwitchState(int32_t deviceId, int32_t sw) const override final; |
Philip Junker | 4af3b3d | 2021-12-14 10:36:55 +0100 | [diff] [blame] | 525 | int32_t getKeyCodeForKeyLocation(int32_t deviceId, |
| 526 | int32_t locationKeyCode) const override final; |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 527 | status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, |
| 528 | int32_t* outValue) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 529 | |
Siarhei Vishniakou | 7400794 | 2022-06-13 13:57:47 -0700 | [diff] [blame] | 530 | bool markSupportedKeyCodes(int32_t deviceId, const std::vector<int32_t>& keyCodes, |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 531 | uint8_t* outFlags) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 532 | |
Siarhei Vishniakou | 7b3ea0b | 2022-09-16 14:23:20 -0700 | [diff] [blame] | 533 | std::vector<RawEvent> getEvents(int timeoutMillis) override final; |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 534 | std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 535 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 536 | bool hasScanCode(int32_t deviceId, int32_t scanCode) const override final; |
Arthur Hung | cb40a00 | 2021-08-03 14:31:01 +0000 | [diff] [blame] | 537 | bool hasKeyCode(int32_t deviceId, int32_t keyCode) const override final; |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 538 | bool hasLed(int32_t deviceId, int32_t led) const override final; |
| 539 | void setLedState(int32_t deviceId, int32_t led, bool on) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 540 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 541 | void getVirtualKeyDefinitions( |
| 542 | int32_t deviceId, |
| 543 | std::vector<VirtualKeyDefinition>& outVirtualKeys) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 544 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 545 | const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap( |
| 546 | int32_t deviceId) const override final; |
| 547 | bool setKeyboardLayoutOverlay(int32_t deviceId, |
| 548 | std::shared_ptr<KeyCharacterMap> map) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 549 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 550 | void vibrate(int32_t deviceId, const VibrationElement& effect) override final; |
| 551 | void cancelVibrate(int32_t deviceId) override final; |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 552 | std::vector<int32_t> getVibratorIds(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 553 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 554 | void requestReopenDevices() override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 555 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 556 | void wake() override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 557 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 558 | void dump(std::string& dump) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 559 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 560 | void monitor() const override final; |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 561 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 562 | std::optional<int32_t> getBatteryCapacity(int32_t deviceId, |
| 563 | int32_t batteryId) const override final; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 564 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 565 | std::optional<int32_t> getBatteryStatus(int32_t deviceId, |
| 566 | int32_t batteryId) const override final; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 567 | |
Prabir Pradhan | ae4ff28 | 2022-08-23 16:21:39 +0000 | [diff] [blame] | 568 | bool isDeviceEnabled(int32_t deviceId) const override final; |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 569 | |
| 570 | status_t enableDevice(int32_t deviceId) override final; |
| 571 | |
| 572 | status_t disableDevice(int32_t deviceId) override final; |
| 573 | |
Vaibhav Devmurari | 5fc7d85 | 2023-03-17 18:43:33 +0000 | [diff] [blame^] | 574 | void sysfsNodeChanged(const std::string& sysfsNodePath) override final; |
| 575 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 576 | ~EventHub() override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 577 | |
| 578 | private: |
Prabir Pradhan | cb42b47 | 2022-08-23 16:01:19 +0000 | [diff] [blame] | 579 | // Holds information about the sysfs device associated with the Device. |
Chris Ye | 1dd2e5c | 2021-04-04 23:12:41 -0700 | [diff] [blame] | 580 | struct AssociatedDevice { |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 581 | // The sysfs root path of the misc device. |
| 582 | std::filesystem::path sysfsRootPath; |
Prabir Pradhan | cb42b47 | 2022-08-23 16:01:19 +0000 | [diff] [blame] | 583 | std::unordered_map<int32_t /*batteryId*/, RawBatteryInfo> batteryInfos; |
| 584 | std::unordered_map<int32_t /*lightId*/, RawLightInfo> lightInfos; |
Vaibhav Devmurari | 7fb4113 | 2023-01-02 13:30:26 +0000 | [diff] [blame] | 585 | std::optional<RawLayoutInfo> layoutInfo; |
Prabir Pradhan | edeec3b | 2022-08-26 22:33:55 +0000 | [diff] [blame] | 586 | |
Vaibhav Devmurari | 5fc7d85 | 2023-03-17 18:43:33 +0000 | [diff] [blame^] | 587 | bool isChanged() const; |
Prabir Pradhan | edeec3b | 2022-08-26 22:33:55 +0000 | [diff] [blame] | 588 | bool operator==(const AssociatedDevice&) const = default; |
| 589 | bool operator!=(const AssociatedDevice&) const = default; |
| 590 | std::string dump() const; |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 591 | }; |
| 592 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 593 | struct Device { |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 594 | int fd; // may be -1 if device is closed |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 595 | const int32_t id; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 596 | const std::string path; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 597 | const InputDeviceIdentifier identifier; |
| 598 | |
Siarhei Vishniakou | ec7854a | 2018-12-14 16:52:34 -0800 | [diff] [blame] | 599 | std::unique_ptr<TouchVideoDevice> videoDevice; |
| 600 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 601 | ftl::Flags<InputDeviceClass> classes; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 602 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 603 | BitArray<KEY_MAX> keyBitmask; |
| 604 | BitArray<KEY_MAX> keyState; |
| 605 | BitArray<ABS_MAX> absBitmask; |
| 606 | BitArray<REL_MAX> relBitmask; |
| 607 | BitArray<SW_MAX> swBitmask; |
| 608 | BitArray<SW_MAX> swState; |
| 609 | BitArray<LED_MAX> ledBitmask; |
| 610 | BitArray<FF_MAX> ffBitmask; |
| 611 | BitArray<INPUT_PROP_MAX> propBitmask; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 612 | BitArray<MSC_MAX> mscBitmask; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 613 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 614 | std::string configurationFile; |
Siarhei Vishniakou | d549b25 | 2020-08-11 11:25:26 -0500 | [diff] [blame] | 615 | std::unique_ptr<PropertyMap> configuration; |
Siarhei Vishniakou | 3e78dec | 2019-02-20 16:21:46 -0600 | [diff] [blame] | 616 | std::unique_ptr<VirtualKeyMap> virtualKeyMap; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 617 | KeyMap keyMap; |
| 618 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 619 | bool ffEffectPlaying; |
| 620 | int16_t ffEffectId; // initially -1 |
| 621 | |
Chris Ye | 1dd2e5c | 2021-04-04 23:12:41 -0700 | [diff] [blame] | 622 | // A shared_ptr of a device associated with the input device. |
Prabir Pradhan | 5189478 | 2022-08-23 16:29:10 +0000 | [diff] [blame] | 623 | // The input devices that have the same sysfs path have the same associated device. |
Prabir Pradhan | edeec3b | 2022-08-26 22:33:55 +0000 | [diff] [blame] | 624 | std::shared_ptr<const AssociatedDevice> associatedDevice; |
Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 625 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 626 | int32_t controllerNumber; |
| 627 | |
Prabir Pradhan | cb42b47 | 2022-08-23 16:01:19 +0000 | [diff] [blame] | 628 | Device(int fd, int32_t id, std::string path, InputDeviceIdentifier identifier, |
| 629 | std::shared_ptr<const AssociatedDevice> assocDev); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 630 | ~Device(); |
| 631 | |
| 632 | void close(); |
| 633 | |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 634 | bool enabled; // initially true |
| 635 | status_t enable(); |
| 636 | status_t disable(); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 637 | bool hasValidFd() const; |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 638 | const bool isVirtual; // set if fd < 0 is passed to constructor |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 639 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 640 | const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap() const; |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 641 | |
| 642 | template <std::size_t N> |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 643 | status_t readDeviceBitMask(unsigned long ioctlCode, BitArray<N>& bitArray); |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 644 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 645 | void configureFd(); |
| 646 | bool hasKeycodeLocked(int keycode) const; |
| 647 | void loadConfigurationLocked(); |
| 648 | bool loadVirtualKeyMapLocked(); |
| 649 | status_t loadKeyMapLocked(); |
| 650 | bool isExternalDeviceLocked(); |
| 651 | bool deviceHasMicLocked(); |
| 652 | void setLedForControllerLocked(); |
| 653 | status_t mapLed(int32_t led, int32_t* outScanCode) const; |
| 654 | void setLedStateLocked(int32_t led, bool on); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 655 | }; |
| 656 | |
Siarhei Vishniakou | a4c502a | 2021-02-05 00:45:20 +0000 | [diff] [blame] | 657 | /** |
| 658 | * Create a new device for the provided path. |
| 659 | */ |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 660 | void openDeviceLocked(const std::string& devicePath) REQUIRES(mLock); |
| 661 | void openVideoDeviceLocked(const std::string& devicePath) REQUIRES(mLock); |
Siarhei Vishniakou | f49608d | 2020-08-20 19:18:21 -0500 | [diff] [blame] | 662 | /** |
| 663 | * Try to associate a video device with an input device. If the association succeeds, |
| 664 | * the videoDevice is moved into the input device. 'videoDevice' will become null if this |
| 665 | * happens. |
| 666 | * Return true if the association succeeds. |
| 667 | * Return false otherwise. |
| 668 | */ |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 669 | bool tryAddVideoDeviceLocked(Device& device, std::unique_ptr<TouchVideoDevice>& videoDevice) |
| 670 | REQUIRES(mLock); |
| 671 | void createVirtualKeyboardLocked() REQUIRES(mLock); |
| 672 | void addDeviceLocked(std::unique_ptr<Device> device) REQUIRES(mLock); |
| 673 | void assignDescriptorLocked(InputDeviceIdentifier& identifier) REQUIRES(mLock); |
Prabir Pradhan | cb42b47 | 2022-08-23 16:01:19 +0000 | [diff] [blame] | 674 | std::shared_ptr<const AssociatedDevice> obtainAssociatedDeviceLocked( |
| 675 | const std::filesystem::path& devicePath) const REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 676 | |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 677 | void closeDeviceByPathLocked(const std::string& devicePath) REQUIRES(mLock); |
| 678 | void closeVideoDeviceByPathLocked(const std::string& devicePath) REQUIRES(mLock); |
| 679 | void closeDeviceLocked(Device& device) REQUIRES(mLock); |
| 680 | void closeAllDevicesLocked() REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 681 | |
Siarhei Vishniakou | 2592031 | 2018-12-12 15:24:44 -0800 | [diff] [blame] | 682 | status_t registerFdForEpoll(int fd); |
| 683 | status_t unregisterFdFromEpoll(int fd); |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 684 | status_t registerDeviceForEpollLocked(Device& device) REQUIRES(mLock); |
| 685 | void registerVideoDeviceForEpollLocked(const TouchVideoDevice& videoDevice) REQUIRES(mLock); |
| 686 | status_t unregisterDeviceFromEpollLocked(Device& device) REQUIRES(mLock); |
| 687 | void unregisterVideoDeviceFromEpollLocked(const TouchVideoDevice& videoDevice) REQUIRES(mLock); |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 688 | |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 689 | status_t scanDirLocked(const std::string& dirname) REQUIRES(mLock); |
| 690 | status_t scanVideoDirLocked(const std::string& dirname) REQUIRES(mLock); |
| 691 | void scanDevicesLocked() REQUIRES(mLock); |
Prabir Pradhan | 952e65b | 2022-06-23 17:49:55 +0000 | [diff] [blame] | 692 | base::Result<void> readNotifyLocked() REQUIRES(mLock); |
| 693 | void handleNotifyEventLocked(const inotify_event&) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 694 | |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 695 | Device* getDeviceLocked(int32_t deviceId) const REQUIRES(mLock); |
| 696 | Device* getDeviceByPathLocked(const std::string& devicePath) const REQUIRES(mLock); |
Siarhei Vishniakou | 1259868 | 2018-11-02 17:19:19 -0700 | [diff] [blame] | 697 | /** |
| 698 | * Look through all available fd's (both for input devices and for video devices), |
| 699 | * and return the device pointer. |
| 700 | */ |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 701 | Device* getDeviceByFdLocked(int fd) const REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 702 | |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 703 | int32_t getNextControllerNumberLocked(const std::string& name) REQUIRES(mLock); |
Josh Bartel | 938632f | 2022-07-19 15:34:22 -0500 | [diff] [blame] | 704 | |
| 705 | bool hasDeviceWithDescriptorLocked(const std::string& descriptor) const REQUIRES(mLock); |
| 706 | |
Chris Ye | d3fef46 | 2021-03-07 17:10:08 -0800 | [diff] [blame] | 707 | void releaseControllerNumberLocked(int32_t num) REQUIRES(mLock); |
| 708 | void reportDeviceAddedForStatisticsLocked(const InputDeviceIdentifier& identifier, |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 709 | ftl::Flags<InputDeviceClass> classes) REQUIRES(mLock); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 710 | |
Chris Ye | e2b1e5c | 2021-03-10 22:45:12 -0800 | [diff] [blame] | 711 | const std::unordered_map<int32_t, RawBatteryInfo>& getBatteryInfoLocked(int32_t deviceId) const |
| 712 | REQUIRES(mLock); |
| 713 | |
| 714 | const std::unordered_map<int32_t, RawLightInfo>& getLightInfoLocked(int32_t deviceId) const |
| 715 | REQUIRES(mLock); |
| 716 | |
Usama Arif | b27c8e6 | 2021-06-03 16:44:09 +0100 | [diff] [blame] | 717 | void addDeviceInputInotify(); |
| 718 | void addDeviceInotify(); |
| 719 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 720 | // Protect all internal state. |
Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 721 | mutable std::mutex mLock; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 722 | |
| 723 | // The actual id of the built-in keyboard, or NO_BUILT_IN_KEYBOARD if none. |
| 724 | // EventHub remaps the built-in keyboard to id 0 externally as required by the API. |
| 725 | enum { |
| 726 | // Must not conflict with any other assigned device ids, including |
| 727 | // the virtual keyboard id (-1). |
| 728 | NO_BUILT_IN_KEYBOARD = -2, |
| 729 | }; |
| 730 | int32_t mBuiltInKeyboardId; |
| 731 | |
| 732 | int32_t mNextDeviceId; |
| 733 | |
| 734 | BitSet32 mControllerNumbers; |
| 735 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 736 | std::unordered_map<int32_t, std::unique_ptr<Device>> mDevices; |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 737 | /** |
| 738 | * Video devices that report touchscreen heatmap, but have not (yet) been paired |
| 739 | * with a specific input device. Video device discovery is independent from input device |
| 740 | * discovery, so the two types of devices could be found in any order. |
| 741 | * Ideally, video devices in this queue do not have an open fd, or at least aren't |
| 742 | * actively streaming. |
| 743 | */ |
| 744 | std::vector<std::unique_ptr<TouchVideoDevice>> mUnattachedVideoDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 745 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 746 | std::vector<std::unique_ptr<Device>> mOpeningDevices; |
| 747 | std::vector<std::unique_ptr<Device>> mClosingDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 748 | |
| 749 | bool mNeedToSendFinishedDeviceScan; |
| 750 | bool mNeedToReopenDevices; |
| 751 | bool mNeedToScanDevices; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 752 | std::vector<std::string> mExcludedDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 753 | |
| 754 | int mEpollFd; |
| 755 | int mINotifyFd; |
| 756 | int mWakeReadPipeFd; |
| 757 | int mWakeWritePipeFd; |
| 758 | |
Usama Arif | b27c8e6 | 2021-06-03 16:44:09 +0100 | [diff] [blame] | 759 | int mDeviceInputWd; |
| 760 | int mDeviceWd = -1; |
Siarhei Vishniakou | 951f362 | 2018-12-12 19:45:42 -0800 | [diff] [blame] | 761 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 762 | // Maximum number of signalled FDs to handle at a time. |
| 763 | static const int EPOLL_MAX_EVENTS = 16; |
| 764 | |
| 765 | // The array of pending epoll events and the index of the next event to be handled. |
| 766 | struct epoll_event mPendingEventItems[EPOLL_MAX_EVENTS]; |
| 767 | size_t mPendingEventCount; |
| 768 | size_t mPendingEventIndex; |
| 769 | bool mPendingINotify; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 770 | }; |
| 771 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 772 | } // namespace android |