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 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 17 | #ifndef _RUNTIME_EVENT_HUB_H |
| 18 | #define _RUNTIME_EVENT_HUB_H |
| 19 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 20 | #include <bitset> |
| 21 | #include <climits> |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 22 | #include <unordered_map> |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 23 | #include <vector> |
| 24 | |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 25 | #include <input/Flags.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 26 | #include <input/Input.h> |
| 27 | #include <input/InputDevice.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 28 | #include <input/KeyCharacterMap.h> |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 29 | #include <input/KeyLayoutMap.h> |
| 30 | #include <input/Keyboard.h> |
Siarhei Vishniakou | 32f36ae | 2020-09-02 20:17:10 -0700 | [diff] [blame] | 31 | #include <input/PropertyMap.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 32 | #include <input/VirtualKeyMap.h> |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 33 | #include <linux/input.h> |
| 34 | #include <sys/epoll.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 35 | #include <utils/BitSet.h> |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 36 | #include <utils/Errors.h> |
| 37 | #include <utils/KeyedVector.h> |
| 38 | #include <utils/List.h> |
| 39 | #include <utils/Log.h> |
| 40 | #include <utils/Mutex.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 41 | |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 42 | #include "TouchVideoDevice.h" |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 43 | #include "VibrationElement.h" |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 44 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 45 | namespace android { |
| 46 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 47 | /* |
| 48 | * A raw event as retrieved from the EventHub. |
| 49 | */ |
| 50 | struct RawEvent { |
| 51 | nsecs_t when; |
| 52 | int32_t deviceId; |
| 53 | int32_t type; |
| 54 | int32_t code; |
| 55 | int32_t value; |
| 56 | }; |
| 57 | |
| 58 | /* Describes an absolute axis. */ |
| 59 | struct RawAbsoluteAxisInfo { |
| 60 | bool valid; // true if the information is valid, false otherwise |
| 61 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 62 | int32_t minValue; // minimum value |
| 63 | int32_t maxValue; // maximum value |
| 64 | int32_t flat; // center flat position, eg. flat == 8 means center is between -8 and 8 |
| 65 | int32_t fuzz; // error tolerance, eg. fuzz == 4 means value is +/- 4 due to noise |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 66 | int32_t resolution; // resolution in units per mm or radians per mm |
| 67 | |
| 68 | inline void clear() { |
| 69 | valid = false; |
| 70 | minValue = 0; |
| 71 | maxValue = 0; |
| 72 | flat = 0; |
| 73 | fuzz = 0; |
| 74 | resolution = 0; |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | /* |
| 79 | * Input device classes. |
| 80 | */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 81 | enum class InputDeviceClass : uint32_t { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 82 | /* The input device is a keyboard or has buttons. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 83 | KEYBOARD = 0x00000001, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 84 | |
| 85 | /* 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] | 86 | ALPHAKEY = 0x00000002, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 87 | |
| 88 | /* 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] | 89 | TOUCH = 0x00000004, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 90 | |
| 91 | /* 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] | 92 | CURSOR = 0x00000008, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 93 | |
| 94 | /* The input device is a multi-touch touchscreen. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 95 | TOUCH_MT = 0x00000010, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 96 | |
| 97 | /* The input device is a directional pad (implies keyboard, has DPAD keys). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 98 | DPAD = 0x00000020, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 99 | |
| 100 | /* The input device is a gamepad (implies keyboard, has BUTTON keys). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 101 | GAMEPAD = 0x00000040, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 102 | |
| 103 | /* The input device has switches. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 104 | SWITCH = 0x00000080, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 105 | |
| 106 | /* The input device is a joystick (implies gamepad, has joystick absolute axes). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 107 | JOYSTICK = 0x00000100, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 108 | |
| 109 | /* The input device has a vibrator (supports FF_RUMBLE). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 110 | VIBRATOR = 0x00000200, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 111 | |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 112 | /* The input device has a microphone. */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 113 | MIC = 0x00000400, |
Tim Kilbourn | 063ff53 | 2015-04-08 10:26:18 -0700 | [diff] [blame] | 114 | |
Michael Wright | 842500e | 2015-03-13 17:32:02 -0700 | [diff] [blame] | 115 | /* 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] | 116 | EXTERNAL_STYLUS = 0x00000800, |
Michael Wright | 842500e | 2015-03-13 17:32:02 -0700 | [diff] [blame] | 117 | |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 118 | /* The input device has a rotary encoder */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 119 | ROTARY_ENCODER = 0x00001000, |
Prashant Malani | 1941ff5 | 2015-08-11 18:29:28 -0700 | [diff] [blame] | 120 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 121 | /* The input device has a sensor like accelerometer, gyro, etc */ |
| 122 | SENSOR = 0x00002000, |
| 123 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 124 | /* 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] | 125 | VIRTUAL = 0x40000000, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 126 | |
| 127 | /* The input device is external (not built-in). */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 128 | EXTERNAL = 0x80000000, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | /* |
| 132 | * Gets the class that owns an axis, in cases where multiple classes might claim |
| 133 | * the same axis for different purposes. |
| 134 | */ |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 135 | extern Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 136 | |
| 137 | /* |
| 138 | * Grand Central Station for events. |
| 139 | * |
| 140 | * The event hub aggregates input events received across all known input |
| 141 | * devices on the system, including devices that may be emulated by the simulator |
| 142 | * environment. In addition, the event hub generates fake input events to indicate |
| 143 | * when devices are added or removed. |
| 144 | * |
| 145 | * The event hub provides a stream of input events (via the getEvent function). |
| 146 | * It also supports querying the current actual state of input devices such as identifying |
| 147 | * which keys are currently down. Finally, the event hub keeps track of the capabilities of |
| 148 | * individual input devices, such as their class and the set of key codes that they support. |
| 149 | */ |
Siarhei Vishniakou | 3bc7e09 | 2019-07-24 17:43:30 -0700 | [diff] [blame] | 150 | class EventHubInterface { |
| 151 | public: |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 152 | EventHubInterface() {} |
| 153 | virtual ~EventHubInterface() {} |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 154 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 155 | // Synthetic raw event type codes produced when devices are added or removed. |
| 156 | enum { |
| 157 | // Sent when a device is added. |
| 158 | DEVICE_ADDED = 0x10000000, |
| 159 | // Sent when a device is removed. |
| 160 | DEVICE_REMOVED = 0x20000000, |
| 161 | // Sent when all added/removed devices from the most recent scan have been reported. |
| 162 | // This event is always sent at least once. |
| 163 | FINISHED_DEVICE_SCAN = 0x30000000, |
| 164 | |
| 165 | FIRST_SYNTHETIC_EVENT = DEVICE_ADDED, |
| 166 | }; |
| 167 | |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 168 | virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 169 | |
| 170 | virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0; |
| 171 | |
| 172 | virtual int32_t getDeviceControllerNumber(int32_t deviceId) const = 0; |
| 173 | |
| 174 | virtual void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const = 0; |
| 175 | |
| 176 | virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 177 | RawAbsoluteAxisInfo* outAxisInfo) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 178 | |
| 179 | virtual bool hasRelativeAxis(int32_t deviceId, int axis) const = 0; |
| 180 | |
| 181 | virtual bool hasInputProperty(int32_t deviceId, int property) const = 0; |
| 182 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 183 | virtual bool hasMscEvent(int32_t deviceId, int mscEvent) const = 0; |
| 184 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 185 | virtual status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, |
| 186 | int32_t metaState, int32_t* outKeycode, int32_t* outMetaState, |
| 187 | uint32_t* outFlags) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 188 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 189 | 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] | 190 | |
| 191 | // Sets devices that are excluded from opening. |
| 192 | // This can be used to ignore input devices for sensors. |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 193 | virtual void setExcludedDevices(const std::vector<std::string>& devices) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 194 | |
| 195 | /* |
| 196 | * Wait for events to become available and returns them. |
| 197 | * After returning, the EventHub holds onto a wake lock until the next call to getEvent. |
| 198 | * This ensures that the device will not go to sleep while the event is being processed. |
| 199 | * If the device needs to remain awake longer than that, then the caller is responsible |
| 200 | * for taking care of it (say, by poking the power manager user activity timer). |
| 201 | * |
| 202 | * The timeout is advisory only. If the device is asleep, it will not wake just to |
| 203 | * service the timeout. |
| 204 | * |
| 205 | * Returns the number of events obtained, or 0 if the timeout expired. |
| 206 | */ |
| 207 | virtual size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) = 0; |
Siarhei Vishniakou | add8929 | 2018-12-13 19:23:36 -0800 | [diff] [blame] | 208 | virtual std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) = 0; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 209 | virtual base::Result<std::pair<InputDeviceSensorType, int32_t>> mapSensor(int32_t deviceId, |
| 210 | int32_t absCode) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 211 | |
| 212 | /* |
| 213 | * Query current input state. |
| 214 | */ |
| 215 | virtual int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const = 0; |
| 216 | virtual int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const = 0; |
| 217 | virtual int32_t getSwitchState(int32_t deviceId, int32_t sw) const = 0; |
| 218 | virtual status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 219 | int32_t* outValue) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 220 | |
| 221 | /* |
| 222 | * Examine key input devices for specific framework keycode support |
| 223 | */ |
| 224 | virtual bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 225 | uint8_t* outFlags) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 226 | |
| 227 | virtual bool hasScanCode(int32_t deviceId, int32_t scanCode) const = 0; |
| 228 | |
| 229 | /* LED related functions expect Android LED constants, not scan codes or HID usages */ |
| 230 | virtual bool hasLed(int32_t deviceId, int32_t led) const = 0; |
| 231 | virtual void setLedState(int32_t deviceId, int32_t led, bool on) = 0; |
| 232 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 233 | virtual void getVirtualKeyDefinitions( |
| 234 | int32_t deviceId, std::vector<VirtualKeyDefinition>& outVirtualKeys) const = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 235 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 236 | virtual const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap(int32_t deviceId) const = 0; |
| 237 | virtual bool setKeyboardLayoutOverlay(int32_t deviceId, |
| 238 | std::shared_ptr<KeyCharacterMap> map) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 239 | |
| 240 | /* Control the vibrator. */ |
Nathaniel R. Lewis | cacd69a | 2019-08-12 22:07:00 +0000 | [diff] [blame] | 241 | virtual void vibrate(int32_t deviceId, const VibrationElement& effect) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 242 | virtual void cancelVibrate(int32_t deviceId) = 0; |
Chris Ye | 8714371 | 2020-11-10 05:05:58 +0000 | [diff] [blame] | 243 | virtual std::vector<int32_t> getVibratorIds(int32_t deviceId) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 244 | |
| 245 | /* Requests the EventHub to reopen all input devices on the next call to getEvents(). */ |
| 246 | virtual void requestReopenDevices() = 0; |
| 247 | |
| 248 | /* Wakes up getEvents() if it is blocked on a read. */ |
| 249 | virtual void wake() = 0; |
| 250 | |
| 251 | /* Dump EventHub state to a string. */ |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 252 | virtual void dump(std::string& dump) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 253 | |
| 254 | /* Called by the heatbeat to ensures that the reader has not deadlocked. */ |
| 255 | virtual void monitor() = 0; |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 256 | |
| 257 | /* Return true if the device is enabled. */ |
| 258 | virtual bool isDeviceEnabled(int32_t deviceId) = 0; |
| 259 | |
| 260 | /* Enable an input device */ |
| 261 | virtual status_t enableDevice(int32_t deviceId) = 0; |
| 262 | |
| 263 | /* Disable an input device. Closes file descriptor to that device. */ |
| 264 | virtual status_t disableDevice(int32_t deviceId) = 0; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 265 | }; |
| 266 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 267 | template <std::size_t BITS> |
| 268 | class BitArray { |
| 269 | /* Array element type and vector of element type. */ |
| 270 | using Element = std::uint32_t; |
| 271 | /* Number of bits in each BitArray element. */ |
| 272 | static constexpr size_t WIDTH = sizeof(Element) * CHAR_BIT; |
| 273 | /* Number of elements to represent a bit array of the specified size of bits. */ |
| 274 | static constexpr size_t COUNT = (BITS + WIDTH - 1) / WIDTH; |
| 275 | |
| 276 | public: |
| 277 | /* BUFFER type declaration for BitArray */ |
| 278 | using Buffer = std::array<Element, COUNT>; |
| 279 | /* To tell if a bit is set in array, it selects an element from the array, and test |
| 280 | * if the relevant bit set. |
| 281 | * Note the parameter "bit" is an index to the bit, 0 <= bit < BITS. |
| 282 | */ |
| 283 | inline bool test(size_t bit) const { |
| 284 | return (bit < BITS) ? mData[bit / WIDTH].test(bit % WIDTH) : false; |
| 285 | } |
| 286 | /* Returns total number of bytes needed for the array */ |
| 287 | inline size_t bytes() { return (BITS + CHAR_BIT - 1) / CHAR_BIT; } |
| 288 | /* Returns true if array contains any non-zero bit from the range defined by start and end |
| 289 | * bit index [startIndex, endIndex). |
| 290 | */ |
| 291 | bool any(size_t startIndex, size_t endIndex) { |
| 292 | if (startIndex >= endIndex || startIndex > BITS || endIndex > BITS + 1) { |
| 293 | ALOGE("Invalid start/end index. start = %zu, end = %zu, total bits = %zu", startIndex, |
| 294 | endIndex, BITS); |
| 295 | return false; |
| 296 | } |
| 297 | size_t se = startIndex / WIDTH; // Start of element |
| 298 | size_t ee = endIndex / WIDTH; // End of element |
| 299 | size_t si = startIndex % WIDTH; // Start index in start element |
| 300 | size_t ei = endIndex % WIDTH; // End index in end element |
| 301 | // Need to check first unaligned bitset for any non zero bit |
| 302 | if (si > 0) { |
| 303 | size_t nBits = se == ee ? ei - si : WIDTH - si; |
| 304 | // Generate the mask of interested bit range |
| 305 | Element mask = ((1 << nBits) - 1) << si; |
| 306 | if (mData[se++].to_ulong() & mask) { |
| 307 | return true; |
| 308 | } |
| 309 | } |
| 310 | // Check whole bitset for any bit set |
| 311 | for (; se < ee; se++) { |
| 312 | if (mData[se].any()) { |
| 313 | return true; |
| 314 | } |
| 315 | } |
| 316 | // Need to check last unaligned bitset for any non zero bit |
| 317 | if (ei > 0 && se <= ee) { |
| 318 | // Generate the mask of interested bit range |
| 319 | Element mask = (1 << ei) - 1; |
| 320 | if (mData[se].to_ulong() & mask) { |
| 321 | return true; |
| 322 | } |
| 323 | } |
| 324 | return false; |
| 325 | } |
| 326 | /* Load bit array values from buffer */ |
| 327 | void loadFromBuffer(const Buffer& buffer) { |
| 328 | for (size_t i = 0; i < COUNT; i++) { |
| 329 | mData[i] = std::bitset<WIDTH>(buffer[i]); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | private: |
| 334 | std::array<std::bitset<WIDTH>, COUNT> mData; |
| 335 | }; |
| 336 | |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 337 | class EventHub : public EventHubInterface { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 338 | public: |
| 339 | EventHub(); |
| 340 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 341 | Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 342 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 343 | InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 344 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 345 | int32_t getDeviceControllerNumber(int32_t deviceId) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 346 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 347 | void getConfiguration(int32_t deviceId, PropertyMap* outConfiguration) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 348 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 349 | status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, |
| 350 | RawAbsoluteAxisInfo* outAxisInfo) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 351 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 352 | bool hasRelativeAxis(int32_t deviceId, int axis) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 353 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 354 | bool hasInputProperty(int32_t deviceId, int property) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 355 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 356 | bool hasMscEvent(int32_t deviceId, int mscEvent) const override final; |
| 357 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 358 | status_t mapKey(int32_t deviceId, int32_t scanCode, int32_t usageCode, int32_t metaState, |
| 359 | int32_t* outKeycode, int32_t* outMetaState, |
| 360 | uint32_t* outFlags) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 361 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 362 | status_t mapAxis(int32_t deviceId, int32_t scanCode, |
| 363 | AxisInfo* outAxisInfo) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 364 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 365 | base::Result<std::pair<InputDeviceSensorType, int32_t>> mapSensor( |
| 366 | int32_t deviceId, int32_t absCode) override final; |
| 367 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 368 | void setExcludedDevices(const std::vector<std::string>& devices) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 369 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 370 | int32_t getScanCodeState(int32_t deviceId, int32_t scanCode) const override final; |
| 371 | int32_t getKeyCodeState(int32_t deviceId, int32_t keyCode) const override final; |
| 372 | int32_t getSwitchState(int32_t deviceId, int32_t sw) const override final; |
| 373 | status_t getAbsoluteAxisValue(int32_t deviceId, int32_t axis, |
| 374 | int32_t* outValue) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 375 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 376 | bool markSupportedKeyCodes(int32_t deviceId, size_t numCodes, const int32_t* keyCodes, |
| 377 | uint8_t* outFlags) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 378 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 379 | size_t getEvents(int timeoutMillis, RawEvent* buffer, size_t bufferSize) override final; |
| 380 | std::vector<TouchVideoFrame> getVideoFrames(int32_t deviceId) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 381 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 382 | bool hasScanCode(int32_t deviceId, int32_t scanCode) const override final; |
| 383 | bool hasLed(int32_t deviceId, int32_t led) const override final; |
| 384 | void setLedState(int32_t deviceId, int32_t led, bool on) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 385 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 386 | void getVirtualKeyDefinitions( |
| 387 | int32_t deviceId, |
| 388 | std::vector<VirtualKeyDefinition>& outVirtualKeys) const override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 389 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 390 | const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap( |
| 391 | int32_t deviceId) const override final; |
| 392 | bool setKeyboardLayoutOverlay(int32_t deviceId, |
| 393 | std::shared_ptr<KeyCharacterMap> map) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 394 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 395 | void vibrate(int32_t deviceId, const VibrationElement& effect) override final; |
| 396 | void cancelVibrate(int32_t deviceId) override final; |
Chris Ye | 8714371 | 2020-11-10 05:05:58 +0000 | [diff] [blame] | 397 | std::vector<int32_t> getVibratorIds(int32_t deviceId) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 398 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 399 | void requestReopenDevices() override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 400 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 401 | void wake() override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 402 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 403 | void dump(std::string& dump) override final; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 404 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 405 | void monitor() override final; |
| 406 | |
| 407 | bool isDeviceEnabled(int32_t deviceId) override final; |
| 408 | |
| 409 | status_t enableDevice(int32_t deviceId) override final; |
| 410 | |
| 411 | status_t disableDevice(int32_t deviceId) override final; |
| 412 | |
| 413 | ~EventHub() override; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 414 | |
| 415 | private: |
| 416 | struct Device { |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 417 | int fd; // may be -1 if device is closed |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 418 | const int32_t id; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 419 | const std::string path; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 420 | const InputDeviceIdentifier identifier; |
| 421 | |
Siarhei Vishniakou | ec7854a | 2018-12-14 16:52:34 -0800 | [diff] [blame] | 422 | std::unique_ptr<TouchVideoDevice> videoDevice; |
| 423 | |
Chris Ye | 1b0c734 | 2020-07-28 21:57:03 -0700 | [diff] [blame] | 424 | Flags<InputDeviceClass> classes; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 425 | |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 426 | BitArray<KEY_MAX> keyBitmask; |
| 427 | BitArray<KEY_MAX> keyState; |
| 428 | BitArray<ABS_MAX> absBitmask; |
| 429 | BitArray<REL_MAX> relBitmask; |
| 430 | BitArray<SW_MAX> swBitmask; |
| 431 | BitArray<SW_MAX> swState; |
| 432 | BitArray<LED_MAX> ledBitmask; |
| 433 | BitArray<FF_MAX> ffBitmask; |
| 434 | BitArray<INPUT_PROP_MAX> propBitmask; |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame^] | 435 | BitArray<MSC_MAX> mscBitmask; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 436 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 437 | std::string configurationFile; |
Siarhei Vishniakou | d549b25 | 2020-08-11 11:25:26 -0500 | [diff] [blame] | 438 | std::unique_ptr<PropertyMap> configuration; |
Siarhei Vishniakou | 3e78dec | 2019-02-20 16:21:46 -0600 | [diff] [blame] | 439 | std::unique_ptr<VirtualKeyMap> virtualKeyMap; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 440 | KeyMap keyMap; |
| 441 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 442 | bool ffEffectPlaying; |
| 443 | int16_t ffEffectId; // initially -1 |
| 444 | |
| 445 | int32_t controllerNumber; |
| 446 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 447 | Device(int fd, int32_t id, const std::string& path, |
Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 448 | const InputDeviceIdentifier& identifier); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 449 | ~Device(); |
| 450 | |
| 451 | void close(); |
| 452 | |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 453 | bool enabled; // initially true |
| 454 | status_t enable(); |
| 455 | status_t disable(); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 456 | bool hasValidFd() const; |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 457 | const bool isVirtual; // set if fd < 0 is passed to constructor |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 458 | |
Chris Ye | 3a1e446 | 2020-08-12 10:13:15 -0700 | [diff] [blame] | 459 | const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap() const; |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 460 | |
| 461 | template <std::size_t N> |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 462 | status_t readDeviceBitMask(unsigned long ioctlCode, BitArray<N>& bitArray); |
Chris Ye | 66fbac3 | 2020-07-06 20:36:43 -0700 | [diff] [blame] | 463 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 464 | void configureFd(); |
| 465 | bool hasKeycodeLocked(int keycode) const; |
| 466 | void loadConfigurationLocked(); |
| 467 | bool loadVirtualKeyMapLocked(); |
| 468 | status_t loadKeyMapLocked(); |
| 469 | bool isExternalDeviceLocked(); |
| 470 | bool deviceHasMicLocked(); |
| 471 | void setLedForControllerLocked(); |
| 472 | status_t mapLed(int32_t led, int32_t* outScanCode) const; |
| 473 | void setLedStateLocked(int32_t led, bool on); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 474 | }; |
| 475 | |
Chris Ye | 8594e19 | 2020-07-14 10:34:06 -0700 | [diff] [blame] | 476 | status_t openDeviceLocked(const std::string& devicePath); |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 477 | void openVideoDeviceLocked(const std::string& devicePath); |
Siarhei Vishniakou | f49608d | 2020-08-20 19:18:21 -0500 | [diff] [blame] | 478 | /** |
| 479 | * Try to associate a video device with an input device. If the association succeeds, |
| 480 | * the videoDevice is moved into the input device. 'videoDevice' will become null if this |
| 481 | * happens. |
| 482 | * Return true if the association succeeds. |
| 483 | * Return false otherwise. |
| 484 | */ |
| 485 | bool tryAddVideoDevice(Device& device, std::unique_ptr<TouchVideoDevice>& videoDevice); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 486 | void createVirtualKeyboardLocked(); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 487 | void addDeviceLocked(std::unique_ptr<Device> device); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 488 | void assignDescriptorLocked(InputDeviceIdentifier& identifier); |
| 489 | |
Chris Ye | 8594e19 | 2020-07-14 10:34:06 -0700 | [diff] [blame] | 490 | void closeDeviceByPathLocked(const std::string& devicePath); |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 491 | void closeVideoDeviceByPathLocked(const std::string& devicePath); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 492 | void closeDeviceLocked(Device& device); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 493 | void closeAllDevicesLocked(); |
| 494 | |
Siarhei Vishniakou | 2592031 | 2018-12-12 15:24:44 -0800 | [diff] [blame] | 495 | status_t registerFdForEpoll(int fd); |
| 496 | status_t unregisterFdFromEpoll(int fd); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 497 | status_t registerDeviceForEpollLocked(Device& device); |
Siarhei Vishniakou | 1259868 | 2018-11-02 17:19:19 -0700 | [diff] [blame] | 498 | void registerVideoDeviceForEpollLocked(const TouchVideoDevice& videoDevice); |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 499 | status_t unregisterDeviceFromEpollLocked(Device& device); |
Siarhei Vishniakou | 1259868 | 2018-11-02 17:19:19 -0700 | [diff] [blame] | 500 | void unregisterVideoDeviceFromEpollLocked(const TouchVideoDevice& videoDevice); |
Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 501 | |
Chris Ye | 8594e19 | 2020-07-14 10:34:06 -0700 | [diff] [blame] | 502 | status_t scanDirLocked(const std::string& dirname); |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 503 | status_t scanVideoDirLocked(const std::string& dirname); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 504 | void scanDevicesLocked(); |
| 505 | status_t readNotifyLocked(); |
| 506 | |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 507 | Device* getDeviceByDescriptorLocked(const std::string& descriptor) const; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 508 | Device* getDeviceLocked(int32_t deviceId) const; |
Chris Ye | 8594e19 | 2020-07-14 10:34:06 -0700 | [diff] [blame] | 509 | Device* getDeviceByPathLocked(const std::string& devicePath) const; |
Siarhei Vishniakou | 1259868 | 2018-11-02 17:19:19 -0700 | [diff] [blame] | 510 | /** |
| 511 | * Look through all available fd's (both for input devices and for video devices), |
| 512 | * and return the device pointer. |
| 513 | */ |
Siarhei Vishniakou | 4bc561c | 2018-11-02 17:41:58 -0700 | [diff] [blame] | 514 | Device* getDeviceByFdLocked(int fd) const; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 515 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 516 | int32_t getNextControllerNumberLocked(const std::string& name); |
| 517 | void releaseControllerNumberLocked(int32_t num); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 518 | |
| 519 | // Protect all internal state. |
Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 520 | mutable std::mutex mLock; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 521 | |
| 522 | // The actual id of the built-in keyboard, or NO_BUILT_IN_KEYBOARD if none. |
| 523 | // EventHub remaps the built-in keyboard to id 0 externally as required by the API. |
| 524 | enum { |
| 525 | // Must not conflict with any other assigned device ids, including |
| 526 | // the virtual keyboard id (-1). |
| 527 | NO_BUILT_IN_KEYBOARD = -2, |
| 528 | }; |
| 529 | int32_t mBuiltInKeyboardId; |
| 530 | |
| 531 | int32_t mNextDeviceId; |
| 532 | |
| 533 | BitSet32 mControllerNumbers; |
| 534 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 535 | std::unordered_map<int32_t, std::unique_ptr<Device>> mDevices; |
Siarhei Vishniakou | 22c8846 | 2018-12-13 19:34:53 -0800 | [diff] [blame] | 536 | /** |
| 537 | * Video devices that report touchscreen heatmap, but have not (yet) been paired |
| 538 | * with a specific input device. Video device discovery is independent from input device |
| 539 | * discovery, so the two types of devices could be found in any order. |
| 540 | * Ideally, video devices in this queue do not have an open fd, or at least aren't |
| 541 | * actively streaming. |
| 542 | */ |
| 543 | std::vector<std::unique_ptr<TouchVideoDevice>> mUnattachedVideoDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 544 | |
Chris Ye | 989bb93 | 2020-07-04 16:18:59 -0700 | [diff] [blame] | 545 | std::vector<std::unique_ptr<Device>> mOpeningDevices; |
| 546 | std::vector<std::unique_ptr<Device>> mClosingDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 547 | |
| 548 | bool mNeedToSendFinishedDeviceScan; |
| 549 | bool mNeedToReopenDevices; |
| 550 | bool mNeedToScanDevices; |
Siarhei Vishniakou | ec8f725 | 2018-07-06 11:19:32 +0100 | [diff] [blame] | 551 | std::vector<std::string> mExcludedDevices; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 552 | |
| 553 | int mEpollFd; |
| 554 | int mINotifyFd; |
| 555 | int mWakeReadPipeFd; |
| 556 | int mWakeWritePipeFd; |
| 557 | |
Siarhei Vishniakou | 951f362 | 2018-12-12 19:45:42 -0800 | [diff] [blame] | 558 | int mInputWd; |
| 559 | int mVideoWd; |
| 560 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 561 | // Maximum number of signalled FDs to handle at a time. |
| 562 | static const int EPOLL_MAX_EVENTS = 16; |
| 563 | |
| 564 | // The array of pending epoll events and the index of the next event to be handled. |
| 565 | struct epoll_event mPendingEventItems[EPOLL_MAX_EVENTS]; |
| 566 | size_t mPendingEventCount; |
| 567 | size_t mPendingEventIndex; |
| 568 | bool mPendingINotify; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 569 | }; |
| 570 | |
| 571 | }; // namespace android |
| 572 | |
| 573 | #endif // _RUNTIME_EVENT_HUB_H |