1 /*
2  * Copyright (C) 2019 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 
19 #include "InputMapper.h"
20 
21 #include "SingleTouchMotionAccumulator.h"
22 #include "StylusState.h"
23 #include "TouchButtonAccumulator.h"
24 
25 namespace android {
26 
27 class ExternalStylusInputMapper : public InputMapper {
28 public:
29     template <class T, class... Args>
30     friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
31                                                 const InputReaderConfiguration& readerConfig,
32                                                 Args... args);
33     virtual ~ExternalStylusInputMapper() = default;
34 
35     uint32_t getSources() const override;
36     void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
37     void dump(std::string& dump) override;
38     [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
39                                                     const InputReaderConfiguration& config,
40                                                     ConfigurationChanges changes) override;
41     [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
42     [[nodiscard]] std::list<NotifyArgs> process(const RawEvent& rawEvent) override;
43 
44 private:
45     SingleTouchMotionAccumulator mSingleTouchMotionAccumulator;
46     RawAbsoluteAxisInfo mRawPressureAxis;
47     TouchButtonAccumulator mTouchButtonAccumulator;
48 
49     StylusState mStylusState;
50 
51     explicit ExternalStylusInputMapper(InputDeviceContext& deviceContext,
52                                        const InputReaderConfiguration& readerConfig);
53     [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when);
54 };
55 
56 } // namespace android
57