blob: 6f152fa5573e41d111d0fb00087180dc646eae72 [file] [log] [blame]
Harry Cutts79cc9fa2022-10-28 15:32:39 +00001/*
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 Cutts4fb941a2022-12-14 19:14:04 +000019#include <list>
Harry Cutts1f48a442022-11-15 17:38:36 +000020#include <memory>
Harry Cutts47db1c72022-12-13 19:20:47 +000021#include <vector>
Harry Cutts1f48a442022-11-15 17:38:36 +000022
Harry Cutts74235542022-11-24 15:52:53 +000023#include <PointerControllerInterface.h>
24
Harry Cutts79cc9fa2022-10-28 15:32:39 +000025#include "EventHub.h"
26#include "InputDevice.h"
27#include "InputMapper.h"
Harry Cuttsedf6ce72023-01-04 12:15:53 +000028#include "InputReaderBase.h"
Harry Cutts79cc9fa2022-10-28 15:32:39 +000029#include "NotifyArgs.h"
Harry Cutts4fb941a2022-12-14 19:14:04 +000030#include "gestures/GestureConverter.h"
Harry Cutts47db1c72022-12-13 19:20:47 +000031#include "gestures/HardwareStateConverter.h"
Harry Cutts1b217912023-01-03 17:13:19 +000032#include "gestures/PropertyProvider.h"
Harry Cutts1f48a442022-11-15 17:38:36 +000033
34#include "include/gestures.h"
Harry Cutts79cc9fa2022-10-28 15:32:39 +000035
36namespace android {
37
38class TouchpadInputMapper : public InputMapper {
39public:
40 explicit TouchpadInputMapper(InputDeviceContext& deviceContext);
Harry Cutts74235542022-11-24 15:52:53 +000041 ~TouchpadInputMapper();
Harry Cutts79cc9fa2022-10-28 15:32:39 +000042
Harry Cutts1f48a442022-11-15 17:38:36 +000043 uint32_t getSources() const override;
Harry Cuttsd02ea102023-03-17 18:21:30 +000044 void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
Harry Cuttsea73eaa2023-01-16 17:55:46 +000045 void dump(std::string& dump) override;
46
Arpit Singh4be4eef2023-03-28 14:26:01 +000047 [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
48 const InputReaderConfiguration* config,
49 uint32_t changes) override;
Harry Cutts1f48a442022-11-15 17:38:36 +000050 [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
51 [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
52
Harry Cutts74235542022-11-24 15:52:53 +000053 void consumeGesture(const Gesture* gesture);
54
Harry Cutts1f48a442022-11-15 17:38:36 +000055private:
Harry Cutts47db1c72022-12-13 19:20:47 +000056 [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
57 SelfContainedHardwareState schs);
Harry Cutts74235542022-11-24 15:52:53 +000058 [[nodiscard]] std::list<NotifyArgs> processGestures(nsecs_t when, nsecs_t readTime);
Harry Cutts1f48a442022-11-15 17:38:36 +000059
60 std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
61 mGestureInterpreter;
Harry Cutts74235542022-11-24 15:52:53 +000062 std::shared_ptr<PointerControllerInterface> mPointerController;
Harry Cutts1f48a442022-11-15 17:38:36 +000063
Harry Cutts1b217912023-01-03 17:13:19 +000064 PropertyProvider mPropertyProvider;
65
Harry Cutts47db1c72022-12-13 19:20:47 +000066 HardwareStateConverter mStateConverter;
Harry Cutts4fb941a2022-12-14 19:14:04 +000067 GestureConverter mGestureConverter;
Harry Cutts74235542022-11-24 15:52:53 +000068
69 bool mProcessing = false;
70 std::vector<Gesture> mGesturesToProcess;
Harry Cutts79cc9fa2022-10-28 15:32:39 +000071};
72
73} // namespace android