| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2010 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 |  | 
| Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 19 | #include <PointerControllerInterface.h> | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 20 | #include <android-base/thread_annotations.h> | 
| Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 21 | #include <utils/Condition.h> | 
|  | 22 | #include <utils/Mutex.h> | 
|  | 23 |  | 
|  | 24 | #include <memory> | 
|  | 25 | #include <unordered_map> | 
|  | 26 | #include <vector> | 
|  | 27 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 28 | #include "EventHub.h" | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 29 | #include "InputListener.h" | 
| Prabir Pradhan | 29c9533 | 2018-11-14 20:14:11 -0800 | [diff] [blame] | 30 | #include "InputReaderBase.h" | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 31 | #include "InputReaderContext.h" | 
| Prabir Pradhan | 5a57cff | 2019-10-31 18:40:33 -0700 | [diff] [blame] | 32 | #include "InputThread.h" | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 33 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 34 | namespace android { | 
|  | 35 |  | 
|  | 36 | class InputDevice; | 
|  | 37 | class InputMapper; | 
| Prabir Pradhan | baa5c82 | 2019-08-30 15:27:05 -0700 | [diff] [blame] | 38 | struct StylusState; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 39 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 40 | /* The input reader reads raw event data from the event hub and processes it into input events | 
|  | 41 | * that it sends to the input listener.  Some functions of the input reader, such as early | 
|  | 42 | * event filtering in low power states, are controlled by a separate policy object. | 
|  | 43 | * | 
| Prabir Pradhan | 28efc19 | 2019-11-05 01:10:04 +0000 | [diff] [blame] | 44 | * The InputReader owns a collection of InputMappers. InputReader starts its own thread, where | 
|  | 45 | * most of the work happens, but the InputReader can receive queries from other system | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 46 | * components running on arbitrary threads.  To keep things manageable, the InputReader | 
|  | 47 | * uses a single Mutex to guard its state.  The Mutex may be held while calling into the | 
|  | 48 | * EventHub or the InputReaderPolicy but it is never held while calling into the | 
| Prabir Pradhan | 28efc19 | 2019-11-05 01:10:04 +0000 | [diff] [blame] | 49 | * InputListener. All calls to InputListener must happen from InputReader's thread. | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 50 | */ | 
|  | 51 | class InputReader : public InputReaderInterface { | 
|  | 52 | public: | 
| Siarhei Vishniakou | 3bc7e09 | 2019-07-24 17:43:30 -0700 | [diff] [blame] | 53 | InputReader(std::shared_ptr<EventHubInterface> eventHub, | 
| Siarhei Vishniakou | 1805009 | 2021-09-01 13:32:49 -0700 | [diff] [blame] | 54 | const sp<InputReaderPolicyInterface>& policy, InputListenerInterface& listener); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 55 | virtual ~InputReader(); | 
|  | 56 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 57 | void dump(std::string& dump) override; | 
|  | 58 | void monitor() override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 59 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 60 | status_t start() override; | 
|  | 61 | status_t stop() override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 62 |  | 
| Chris Ye | 98d3f53 | 2020-10-01 21:48:59 -0700 | [diff] [blame] | 63 | std::vector<InputDeviceInfo> getInputDevices() const override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 64 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 65 | bool isInputDeviceEnabled(int32_t deviceId) override; | 
| Siarhei Vishniakou | e54cb85 | 2017-03-21 17:48:16 -0700 | [diff] [blame] | 66 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 67 | int32_t getScanCodeState(int32_t deviceId, uint32_t sourceMask, int32_t scanCode) override; | 
|  | 68 | int32_t getKeyCodeState(int32_t deviceId, uint32_t sourceMask, int32_t keyCode) override; | 
|  | 69 | int32_t getSwitchState(int32_t deviceId, uint32_t sourceMask, int32_t sw) override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 70 |  | 
| Vaibhav Devmurari | cbba14c | 2022-10-10 16:54:49 +0000 | [diff] [blame] | 71 | void addKeyRemapping(int32_t deviceId, int32_t fromKeyCode, int32_t toKeyCode) const override; | 
|  | 72 |  | 
| Philip Junker | 4af3b3d | 2021-12-14 10:36:55 +0100 | [diff] [blame] | 73 | int32_t getKeyCodeForKeyLocation(int32_t deviceId, int32_t locationKeyCode) const override; | 
|  | 74 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 75 | void toggleCapsLockState(int32_t deviceId) override; | 
| Andrii Kulian | 763a3a4 | 2016-03-08 10:46:16 -0800 | [diff] [blame] | 76 |  | 
| Siarhei Vishniakou | 7400794 | 2022-06-13 13:57:47 -0700 | [diff] [blame] | 77 | bool hasKeys(int32_t deviceId, uint32_t sourceMask, const std::vector<int32_t>& keyCodes, | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 78 | uint8_t* outFlags) override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 79 |  | 
| Prabir Pradhan | 4bf6d45 | 2023-04-18 21:26:56 +0000 | [diff] [blame] | 80 | void requestRefreshConfiguration(ConfigurationChanges changes) override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 81 |  | 
| Chris Ye | 8714371 | 2020-11-10 05:05:58 +0000 | [diff] [blame] | 82 | void vibrate(int32_t deviceId, const VibrationSequence& sequence, ssize_t repeat, | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 83 | int32_t token) override; | 
|  | 84 | void cancelVibrate(int32_t deviceId, int32_t token) override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 85 |  | 
| Chris Ye | 8714371 | 2020-11-10 05:05:58 +0000 | [diff] [blame] | 86 | bool isVibrating(int32_t deviceId) override; | 
|  | 87 |  | 
|  | 88 | std::vector<int32_t> getVibratorIds(int32_t deviceId) override; | 
|  | 89 |  | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 90 | bool canDispatchToDisplay(int32_t deviceId, int32_t displayId) override; | 
| Prabir Pradhan | da7c00c | 2019-08-29 14:12:42 -0700 | [diff] [blame] | 91 |  | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 92 | bool enableSensor(int32_t deviceId, InputDeviceSensorType sensorType, | 
|  | 93 | std::chrono::microseconds samplingPeriod, | 
|  | 94 | std::chrono::microseconds maxBatchReportLatency) override; | 
|  | 95 |  | 
|  | 96 | void disableSensor(int32_t deviceId, InputDeviceSensorType sensorType) override; | 
|  | 97 |  | 
|  | 98 | void flushSensor(int32_t deviceId, InputDeviceSensorType sensorType) override; | 
|  | 99 |  | 
| Kim Low | 03ea035 | 2020-11-06 12:45:07 -0800 | [diff] [blame] | 100 | std::optional<int32_t> getBatteryCapacity(int32_t deviceId) override; | 
|  | 101 |  | 
|  | 102 | std::optional<int32_t> getBatteryStatus(int32_t deviceId) override; | 
|  | 103 |  | 
| Prabir Pradhan | e287ecd | 2022-09-07 21:18:05 +0000 | [diff] [blame] | 104 | std::optional<std::string> getBatteryDevicePath(int32_t deviceId) override; | 
|  | 105 |  | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 106 | std::vector<InputDeviceLightInfo> getLights(int32_t deviceId) override; | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 107 |  | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 108 | std::vector<InputDeviceSensorInfo> getSensors(int32_t deviceId) override; | 
| Chris Ye | 3fdbfef | 2021-01-06 18:45:18 -0800 | [diff] [blame] | 109 |  | 
|  | 110 | bool setLightColor(int32_t deviceId, int32_t lightId, int32_t color) override; | 
|  | 111 |  | 
|  | 112 | bool setLightPlayerId(int32_t deviceId, int32_t lightId, int32_t playerId) override; | 
|  | 113 |  | 
|  | 114 | std::optional<int32_t> getLightColor(int32_t deviceId, int32_t lightId) override; | 
|  | 115 |  | 
|  | 116 | std::optional<int32_t> getLightPlayerId(int32_t deviceId, int32_t lightId) override; | 
|  | 117 |  | 
| Prabir Pradhan | b54ffb2 | 2022-10-27 18:03:34 +0000 | [diff] [blame] | 118 | std::optional<std::string> getBluetoothAddress(int32_t deviceId) const override; | 
|  | 119 |  | 
| Vaibhav Devmurari | 5fc7d85 | 2023-03-17 18:43:33 +0000 | [diff] [blame] | 120 | void sysfsNodeChanged(const std::string& sysfsNodePath) override; | 
|  | 121 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 122 | protected: | 
|  | 123 | // These members are protected so they can be instrumented by test cases. | 
| Arpit Singh | 7f1765e | 2023-07-07 13:12:37 +0000 | [diff] [blame] | 124 | virtual std::shared_ptr<InputDevice> createDeviceLocked(int32_t deviceId, | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 125 | const InputDeviceIdentifier& identifier) | 
|  | 126 | REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 127 |  | 
| Prabir Pradhan | 28efc19 | 2019-11-05 01:10:04 +0000 | [diff] [blame] | 128 | // With each iteration of the loop, InputReader reads and processes one incoming message from | 
|  | 129 | // the EventHub. | 
|  | 130 | void loopOnce(); | 
|  | 131 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 132 | class ContextImpl : public InputReaderContext { | 
|  | 133 | InputReader* mReader; | 
| Garfield Tan | ff1f1bb | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 134 | IdGenerator mIdGenerator; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 135 |  | 
|  | 136 | public: | 
| Chih-Hung Hsieh | 6d2ede1 | 2016-09-01 11:28:23 -0700 | [diff] [blame] | 137 | explicit ContextImpl(InputReader* reader); | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 138 | // lock is already held by the input loop | 
|  | 139 | void updateGlobalMetaState() NO_THREAD_SAFETY_ANALYSIS override; | 
|  | 140 | int32_t getGlobalMetaState() NO_THREAD_SAFETY_ANALYSIS override; | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 141 | void disableVirtualKeysUntil(nsecs_t time) REQUIRES(mReader->mLock) override; | 
|  | 142 | bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) | 
|  | 143 | REQUIRES(mReader->mLock) override; | 
|  | 144 | void fadePointer() REQUIRES(mReader->mLock) override; | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 145 | std::shared_ptr<PointerControllerInterface> getPointerController(int32_t deviceId) | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 146 | REQUIRES(mReader->mLock) override; | 
|  | 147 | void requestTimeoutAtTime(nsecs_t when) REQUIRES(mReader->mLock) override; | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 148 | int32_t bumpGeneration() NO_THREAD_SAFETY_ANALYSIS override; | 
|  | 149 | void getExternalStylusDevices(std::vector<InputDeviceInfo>& outDevices) | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 150 | REQUIRES(mReader->mLock) override; | 
| Siarhei Vishniakou | 2935db7 | 2022-09-22 13:35:22 -0700 | [diff] [blame] | 151 | [[nodiscard]] std::list<NotifyArgs> dispatchExternalStylusState(const StylusState& outState) | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 152 | REQUIRES(mReader->mLock) override; | 
|  | 153 | InputReaderPolicyInterface* getPolicy() REQUIRES(mReader->mLock) override; | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 154 | EventHubInterface* getEventHub() REQUIRES(mReader->mLock) override; | 
| Siarhei Vishniakou | f2f073b | 2021-02-09 21:59:56 +0000 | [diff] [blame] | 155 | int32_t getNextId() NO_THREAD_SAFETY_ANALYSIS override; | 
| Siarhei Vishniakou | 1983a71 | 2021-06-04 19:27:09 +0000 | [diff] [blame] | 156 | void updateLedMetaState(int32_t metaState) REQUIRES(mReader->mLock) override; | 
|  | 157 | int32_t getLedMetaState() REQUIRES(mReader->mLock) REQUIRES(mLock) override; | 
| Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 158 | void setPreventingTouchpadTaps(bool prevent) REQUIRES(mReader->mLock) | 
|  | 159 | REQUIRES(mLock) override; | 
|  | 160 | bool isPreventingTouchpadTaps() REQUIRES(mReader->mLock) REQUIRES(mLock) override; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 161 | } mContext; | 
|  | 162 |  | 
|  | 163 | friend class ContextImpl; | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 164 | // Test cases need to override the locked functions | 
|  | 165 | mutable std::mutex mLock; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 166 |  | 
|  | 167 | private: | 
| Prabir Pradhan | 5a57cff | 2019-10-31 18:40:33 -0700 | [diff] [blame] | 168 | std::unique_ptr<InputThread> mThread; | 
| Prabir Pradhan | 28efc19 | 2019-11-05 01:10:04 +0000 | [diff] [blame] | 169 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 170 | std::condition_variable mReaderIsAliveCondition; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 171 |  | 
| Siarhei Vishniakou | 3bc7e09 | 2019-07-24 17:43:30 -0700 | [diff] [blame] | 172 | // This could be unique_ptr, but due to the way InputReader tests are written, | 
|  | 173 | // it is made shared_ptr here. In the tests, an EventHub reference is retained by the test | 
|  | 174 | // in parallel to passing it to the InputReader. | 
|  | 175 | std::shared_ptr<EventHubInterface> mEventHub; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 176 | sp<InputReaderPolicyInterface> mPolicy; | 
| Siarhei Vishniakou | 06fa19e | 2023-08-15 17:28:49 -0700 | [diff] [blame] | 177 |  | 
|  | 178 | // The next stage that should receive the events generated inside InputReader. | 
|  | 179 | InputListenerInterface& mNextListener; | 
|  | 180 | // As various events are generated inside InputReader, they are stored inside this list. The | 
|  | 181 | // list can only be accessed with the lock, so the events inside it are well-ordered. | 
|  | 182 | // Once the reader is done working, these events will be swapped into a temporary storage and | 
|  | 183 | // sent to the 'mNextListener' without holding the lock. | 
|  | 184 | std::list<NotifyArgs> mPendingArgs GUARDED_BY(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 185 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 186 | InputReaderConfiguration mConfig GUARDED_BY(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 187 |  | 
| Nathaniel R. Lewis | a7b82e1 | 2020-02-12 15:40:45 -0800 | [diff] [blame] | 188 | // An input device can represent a collection of EventHub devices. This map provides a way | 
|  | 189 | // to lookup the input device instance from the EventHub device id. | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 190 | std::unordered_map<int32_t /*eventHubId*/, std::shared_ptr<InputDevice>> mDevices | 
|  | 191 | GUARDED_BY(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 192 |  | 
| Chris Ye | e731003 | 2020-09-22 15:36:28 -0700 | [diff] [blame] | 193 | // An input device contains one or more eventHubId, this map provides a way to lookup the | 
|  | 194 | // EventHubIds contained in the input device from the input device instance. | 
|  | 195 | std::unordered_map<std::shared_ptr<InputDevice>, std::vector<int32_t> /*eventHubId*/> | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 196 | mDeviceToEventHubIdsMap GUARDED_BY(mLock); | 
| Chris Ye | e731003 | 2020-09-22 15:36:28 -0700 | [diff] [blame] | 197 |  | 
| Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame] | 198 | // true if tap-to-click on touchpad currently disabled | 
|  | 199 | bool mPreventingTouchpadTaps GUARDED_BY(mLock){false}; | 
|  | 200 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 201 | // low-level input event decoding and device management | 
| Siarhei Vishniakou | 2935db7 | 2022-09-22 13:35:22 -0700 | [diff] [blame] | 202 | [[nodiscard]] std::list<NotifyArgs> processEventsLocked(const RawEvent* rawEvents, size_t count) | 
|  | 203 | REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 204 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 205 | void addDeviceLocked(nsecs_t when, int32_t eventHubId) REQUIRES(mLock); | 
|  | 206 | void removeDeviceLocked(nsecs_t when, int32_t eventHubId) REQUIRES(mLock); | 
| Siarhei Vishniakou | 2935db7 | 2022-09-22 13:35:22 -0700 | [diff] [blame] | 207 | [[nodiscard]] std::list<NotifyArgs> processEventsForDeviceLocked(int32_t eventHubId, | 
|  | 208 | const RawEvent* rawEvents, | 
|  | 209 | size_t count) REQUIRES(mLock); | 
|  | 210 | [[nodiscard]] std::list<NotifyArgs> timeoutExpiredLocked(nsecs_t when) REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 211 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 212 | void handleConfigurationChangedLocked(nsecs_t when) REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 213 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 214 | int32_t mGlobalMetaState GUARDED_BY(mLock); | 
|  | 215 | void updateGlobalMetaStateLocked() REQUIRES(mLock); | 
|  | 216 | int32_t getGlobalMetaStateLocked() REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 217 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 218 | int32_t mLedMetaState GUARDED_BY(mLock); | 
|  | 219 | void updateLedMetaStateLocked(int32_t metaState) REQUIRES(mLock); | 
|  | 220 | int32_t getLedMetaStateLocked() REQUIRES(mLock); | 
| arthurhung | c903df1 | 2020-08-11 15:08:42 +0800 | [diff] [blame] | 221 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 222 | void notifyExternalStylusPresenceChangedLocked() REQUIRES(mLock); | 
|  | 223 | void getExternalStylusDevicesLocked(std::vector<InputDeviceInfo>& outDevices) REQUIRES(mLock); | 
| Siarhei Vishniakou | 2935db7 | 2022-09-22 13:35:22 -0700 | [diff] [blame] | 224 | [[nodiscard]] std::list<NotifyArgs> dispatchExternalStylusStateLocked(const StylusState& state) | 
|  | 225 | REQUIRES(mLock); | 
| Michael Wright | 842500e | 2015-03-13 17:32:02 -0700 | [diff] [blame] | 226 |  | 
| Prabir Pradhan | c7ef27e | 2020-02-03 19:19:15 -0800 | [diff] [blame] | 227 | // The PointerController that is shared among all the input devices that need it. | 
| Michael Wright | 17db18e | 2020-06-26 20:51:44 +0100 | [diff] [blame] | 228 | std::weak_ptr<PointerControllerInterface> mPointerController; | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 229 | std::shared_ptr<PointerControllerInterface> getPointerControllerLocked(int32_t deviceId) | 
|  | 230 | REQUIRES(mLock); | 
|  | 231 | void updatePointerDisplayLocked() REQUIRES(mLock); | 
|  | 232 | void fadePointerLocked() REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 233 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 234 | int32_t mGeneration GUARDED_BY(mLock); | 
|  | 235 | int32_t bumpGenerationLocked() REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 236 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 237 | int32_t mNextInputDeviceId GUARDED_BY(mLock); | 
|  | 238 | int32_t nextInputDeviceIdLocked() REQUIRES(mLock); | 
| Nathaniel R. Lewis | a7b82e1 | 2020-02-12 15:40:45 -0800 | [diff] [blame] | 239 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 240 | std::vector<InputDeviceInfo> getInputDevicesLocked() const REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 241 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 242 | nsecs_t mDisableVirtualKeysTimeout GUARDED_BY(mLock); | 
|  | 243 | void disableVirtualKeysUntilLocked(nsecs_t time) REQUIRES(mLock); | 
|  | 244 | bool shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32_t scanCode) REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 245 |  | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 246 | nsecs_t mNextTimeout GUARDED_BY(mLock); | 
|  | 247 | void requestTimeoutAtTimeLocked(nsecs_t when) REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 248 |  | 
| Prabir Pradhan | 4bf6d45 | 2023-04-18 21:26:56 +0000 | [diff] [blame] | 249 | ConfigurationChanges mConfigurationChangesToRefresh GUARDED_BY(mLock); | 
|  | 250 | void refreshConfigurationLocked(ConfigurationChanges changes) REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 251 |  | 
| Prabir Pradhan | 5cc1a69 | 2021-08-06 14:01:18 +0000 | [diff] [blame] | 252 | PointerCaptureRequest mCurrentPointerCaptureRequest GUARDED_BY(mLock); | 
|  | 253 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 254 | // state queries | 
|  | 255 | typedef int32_t (InputDevice::*GetStateFunc)(uint32_t sourceMask, int32_t code); | 
|  | 256 | int32_t getStateLocked(int32_t deviceId, uint32_t sourceMask, int32_t code, | 
| Chris Ye | 1c2e089 | 2020-11-30 21:41:44 -0800 | [diff] [blame] | 257 | GetStateFunc getStateFunc) REQUIRES(mLock); | 
| Siarhei Vishniakou | 7400794 | 2022-06-13 13:57:47 -0700 | [diff] [blame] | 258 | bool markSupportedKeyCodesLocked(int32_t deviceId, uint32_t sourceMask, | 
|  | 259 | const std::vector<int32_t>& keyCodes, uint8_t* outFlags) | 
|  | 260 | REQUIRES(mLock); | 
| Nathaniel R. Lewis | a7b82e1 | 2020-02-12 15:40:45 -0800 | [diff] [blame] | 261 |  | 
|  | 262 | // find an InputDevice from an InputDevice id | 
| Philip Junker | 4af3b3d | 2021-12-14 10:36:55 +0100 | [diff] [blame] | 263 | InputDevice* findInputDeviceLocked(int32_t deviceId) const REQUIRES(mLock); | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 264 | }; | 
|  | 265 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 266 | } // namespace android |