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 namespace android {
20 
21 class InputDeviceContext;
22 struct RawEvent;
23 
24 /* Keeps track of cursor scrolling motions. */
25 class CursorScrollAccumulator {
26 public:
27     CursorScrollAccumulator();
28     void configure(InputDeviceContext& deviceContext);
29     void reset(InputDeviceContext& deviceContext);
30 
31     void process(const RawEvent& rawEvent);
32     void finishSync();
33 
haveRelativeVWheel()34     inline bool haveRelativeVWheel() const { return mHaveRelWheel; }
haveRelativeHWheel()35     inline bool haveRelativeHWheel() const { return mHaveRelHWheel; }
36 
getRelativeVWheel()37     inline float getRelativeVWheel() const { return mRelWheel; }
getRelativeHWheel()38     inline float getRelativeHWheel() const { return mRelHWheel; }
39 
40 private:
41     bool mHaveRelWheel;
42     bool mHaveRelHWheel;
43     bool mHaveRelWheelHighRes;
44     bool mHaveRelHWheelHighRes;
45 
46     float mRelWheel;
47     float mRelHWheel;
48 
49     void clearRelativeAxes();
50 };
51 
52 } // namespace android
53