Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 19 | #include <list> |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 20 | #include <memory> |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 21 | #include <vector> |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 22 | |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 23 | #include <PointerControllerInterface.h> |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 24 | #include <utils/Timers.h> |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 25 | |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 26 | #include "CapturedTouchpadEventConverter.h" |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 27 | #include "EventHub.h" |
| 28 | #include "InputDevice.h" |
| 29 | #include "InputMapper.h" |
Harry Cutts | edf6ce7 | 2023-01-04 12:15:53 +0000 | [diff] [blame] | 30 | #include "InputReaderBase.h" |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 31 | #include "NotifyArgs.h" |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 32 | #include "accumulator/MultiTouchMotionAccumulator.h" |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 33 | #include "gestures/GestureConverter.h" |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 34 | #include "gestures/HardwareStateConverter.h" |
Harry Cutts | 1b21791 | 2023-01-03 17:13:19 +0000 | [diff] [blame] | 35 | #include "gestures/PropertyProvider.h" |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 36 | |
| 37 | #include "include/gestures.h" |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 38 | |
| 39 | namespace android { |
| 40 | |
| 41 | class TouchpadInputMapper : public InputMapper { |
| 42 | public: |
Arpit Singh | 8e6fb25 | 2023-04-06 11:49:17 +0000 | [diff] [blame] | 43 | explicit TouchpadInputMapper(InputDeviceContext& deviceContext, |
| 44 | const InputReaderConfiguration& readerConfig); |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 45 | ~TouchpadInputMapper(); |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 46 | |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 47 | uint32_t getSources() const override; |
Harry Cutts | d02ea10 | 2023-03-17 18:21:30 +0000 | [diff] [blame] | 48 | void populateDeviceInfo(InputDeviceInfo& deviceInfo) override; |
Harry Cutts | ea73eaa | 2023-01-16 17:55:46 +0000 | [diff] [blame] | 49 | void dump(std::string& dump) override; |
| 50 | |
Arpit Singh | 4be4eef | 2023-03-28 14:26:01 +0000 | [diff] [blame] | 51 | [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when, |
Arpit Singh | ed6c3de | 2023-04-05 19:24:37 +0000 | [diff] [blame] | 52 | const InputReaderConfiguration& config, |
Prabir Pradhan | 4bf6d45 | 2023-04-18 21:26:56 +0000 | [diff] [blame] | 53 | ConfigurationChanges changes) override; |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 54 | [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override; |
| 55 | [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override; |
| 56 | |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 57 | void consumeGesture(const Gesture* gesture); |
| 58 | |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 59 | private: |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 60 | void resetGestureInterpreter(nsecs_t when); |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 61 | [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime, |
| 62 | SelfContainedHardwareState schs); |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 63 | [[nodiscard]] std::list<NotifyArgs> processGestures(nsecs_t when, nsecs_t readTime); |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 64 | |
| 65 | std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)> |
| 66 | mGestureInterpreter; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 67 | std::shared_ptr<PointerControllerInterface> mPointerController; |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 68 | |
Harry Cutts | 1b21791 | 2023-01-03 17:13:19 +0000 | [diff] [blame] | 69 | PropertyProvider mPropertyProvider; |
| 70 | |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 71 | // The MultiTouchMotionAccumulator is shared between the HardwareStateConverter and |
| 72 | // CapturedTouchpadEventConverter, so that if the touchpad is captured or released while touches |
| 73 | // are down, the relevant converter can still benefit from the current axis values stored in the |
| 74 | // accumulator. |
| 75 | MultiTouchMotionAccumulator mMotionAccumulator; |
| 76 | |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 77 | HardwareStateConverter mStateConverter; |
Harry Cutts | 4fb941a | 2022-12-14 19:14:04 +0000 | [diff] [blame] | 78 | GestureConverter mGestureConverter; |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 79 | CapturedTouchpadEventConverter mCapturedEventConverter; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 80 | |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 81 | bool mPointerCaptured = false; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 82 | bool mProcessing = false; |
Harry Cutts | bb24e27 | 2023-03-21 10:49:47 +0000 | [diff] [blame^] | 83 | bool mResettingInterpreter = false; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 84 | std::vector<Gesture> mGesturesToProcess; |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace android |