• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <ui/Rotation.h>
20 
21 #include "CursorScrollAccumulator.h"
22 #include "InputMapper.h"
23 
24 namespace android {
25 
26 class RotaryEncoderInputMapper : public InputMapper {
27 public:
28     template <class T, class... Args>
29     friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
30                                                 const InputReaderConfiguration& readerConfig,
31                                                 Args... args);
32     virtual ~RotaryEncoderInputMapper();
33 
34     virtual uint32_t getSources() const override;
35     virtual void populateDeviceInfo(InputDeviceInfo& deviceInfo) override;
36     virtual void dump(std::string& dump) override;
37     [[nodiscard]] std::list<NotifyArgs> reconfigure(nsecs_t when,
38                                                     const InputReaderConfiguration& config,
39                                                     ConfigurationChanges changes) override;
40     [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
41     [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
42 
43 private:
44     CursorScrollAccumulator mRotaryEncoderScrollAccumulator;
45 
46     int32_t mSource;
47     float mScalingFactor;
48     ui::Rotation mOrientation;
49 
50     explicit RotaryEncoderInputMapper(InputDeviceContext& deviceContext,
51                                       const InputReaderConfiguration& readerConfig);
52     [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when, nsecs_t readTime);
53 };
54 
55 } // namespace android
56