blob: b3bc831baf25d9308e4fb458f8a67e2538d01f7d [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"
28#include "NotifyArgs.h"
Harry Cutts4fb941a2022-12-14 19:14:04 +000029#include "gestures/GestureConverter.h"
Harry Cutts47db1c72022-12-13 19:20:47 +000030#include "gestures/HardwareStateConverter.h"
Harry Cutts1f48a442022-11-15 17:38:36 +000031
32#include "include/gestures.h"
Harry Cutts79cc9fa2022-10-28 15:32:39 +000033
34namespace android {
35
36class TouchpadInputMapper : public InputMapper {
37public:
38 explicit TouchpadInputMapper(InputDeviceContext& deviceContext);
Harry Cutts74235542022-11-24 15:52:53 +000039 ~TouchpadInputMapper();
Harry Cutts79cc9fa2022-10-28 15:32:39 +000040
Harry Cutts1f48a442022-11-15 17:38:36 +000041 uint32_t getSources() const override;
42 [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
43 [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
44
Harry Cutts74235542022-11-24 15:52:53 +000045 void consumeGesture(const Gesture* gesture);
46
Harry Cutts1f48a442022-11-15 17:38:36 +000047private:
Harry Cutts47db1c72022-12-13 19:20:47 +000048 [[nodiscard]] std::list<NotifyArgs> sendHardwareState(nsecs_t when, nsecs_t readTime,
49 SelfContainedHardwareState schs);
Harry Cutts74235542022-11-24 15:52:53 +000050 [[nodiscard]] std::list<NotifyArgs> processGestures(nsecs_t when, nsecs_t readTime);
Harry Cutts1f48a442022-11-15 17:38:36 +000051
52 std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
53 mGestureInterpreter;
Harry Cutts74235542022-11-24 15:52:53 +000054 std::shared_ptr<PointerControllerInterface> mPointerController;
Harry Cutts1f48a442022-11-15 17:38:36 +000055
Harry Cutts47db1c72022-12-13 19:20:47 +000056 HardwareStateConverter mStateConverter;
Harry Cutts4fb941a2022-12-14 19:14:04 +000057 GestureConverter mGestureConverter;
Harry Cutts74235542022-11-24 15:52:53 +000058
59 bool mProcessing = false;
60 std::vector<Gesture> mGesturesToProcess;
Harry Cutts79cc9fa2022-10-28 15:32:39 +000061};
62
63} // namespace android