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 | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 19 | #include <memory> |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 20 | #include <vector> |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 21 | |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 22 | #include <PointerControllerInterface.h> |
| 23 | |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 24 | #include "EventHub.h" |
| 25 | #include "InputDevice.h" |
| 26 | #include "InputMapper.h" |
| 27 | #include "NotifyArgs.h" |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 28 | #include "gestures/HardwareStateConverter.h" |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 29 | |
| 30 | #include "include/gestures.h" |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | class TouchpadInputMapper : public InputMapper { |
| 35 | public: |
| 36 | explicit TouchpadInputMapper(InputDeviceContext& deviceContext); |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 37 | ~TouchpadInputMapper(); |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 38 | |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 39 | uint32_t getSources() const override; |
| 40 | [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override; |
| 41 | [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override; |
| 42 | |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 43 | void consumeGesture(const Gesture* gesture); |
| 44 | |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 45 | private: |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 46 | [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime, |
| 47 | SelfContainedHardwareState schs); |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 48 | [[nodiscard]] std::list<NotifyArgs> processGestures(nsecs_t when, nsecs_t readTime); |
| 49 | NotifyArgs handleMove(nsecs_t when, nsecs_t readTime, const Gesture& gesture); |
| 50 | [[nodiscard]] std::list<NotifyArgs> handleButtonsChange(nsecs_t when, nsecs_t readTime, |
| 51 | const Gesture& gesture); |
| 52 | |
| 53 | NotifyMotionArgs makeMotionArgs(nsecs_t when, nsecs_t readTime, int32_t action, |
| 54 | int32_t actionButton, int32_t buttonState, |
| 55 | uint32_t pointerCount, |
| 56 | const PointerProperties* pointerProperties, |
| 57 | const PointerCoords* pointerCoords, float xCursorPosition, |
| 58 | float yCursorPosition); |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 59 | |
| 60 | std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)> |
| 61 | mGestureInterpreter; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 62 | std::shared_ptr<PointerControllerInterface> mPointerController; |
Harry Cutts | 1f48a44 | 2022-11-15 17:38:36 +0000 | [diff] [blame] | 63 | |
Harry Cutts | 47db1c7 | 2022-12-13 19:20:47 +0000 | [diff] [blame] | 64 | HardwareStateConverter mStateConverter; |
Harry Cutts | 7423554 | 2022-11-24 15:52:53 +0000 | [diff] [blame] | 65 | |
| 66 | bool mProcessing = false; |
| 67 | std::vector<Gesture> mGesturesToProcess; |
| 68 | |
| 69 | // The current button state according to the gestures library, but converted into MotionEvent |
| 70 | // button values (AMOTION_EVENT_BUTTON_...). |
| 71 | uint32_t mButtonState = 0; |
| 72 | nsecs_t mDownTime = 0; |
Harry Cutts | 79cc9fa | 2022-10-28 15:32:39 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace android |