• 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 #ifndef _UI_INPUTREADER_CURSOR_SCROLL_ACCUMULATOR_H
18 #define _UI_INPUTREADER_CURSOR_SCROLL_ACCUMULATOR_H
19 
20 #include <stdint.h>
21 
22 namespace android {
23 
24 class InputDeviceContext;
25 struct RawEvent;
26 
27 /* Keeps track of cursor scrolling motions. */
28 
29 class CursorScrollAccumulator {
30 public:
31     CursorScrollAccumulator();
32     void configure(InputDeviceContext& deviceContext);
33     void reset(InputDeviceContext& deviceContext);
34 
35     void process(const RawEvent* rawEvent);
36     void finishSync();
37 
haveRelativeVWheel()38     inline bool haveRelativeVWheel() const { return mHaveRelWheel; }
haveRelativeHWheel()39     inline bool haveRelativeHWheel() const { return mHaveRelHWheel; }
40 
getRelativeX()41     inline int32_t getRelativeX() const { return mRelX; }
getRelativeY()42     inline int32_t getRelativeY() const { return mRelY; }
getRelativeVWheel()43     inline int32_t getRelativeVWheel() const { return mRelWheel; }
getRelativeHWheel()44     inline int32_t getRelativeHWheel() const { return mRelHWheel; }
45 
46 private:
47     bool mHaveRelWheel;
48     bool mHaveRelHWheel;
49 
50     int32_t mRelX;
51     int32_t mRelY;
52     int32_t mRelWheel;
53     int32_t mRelHWheel;
54 
55     void clearRelativeAxes();
56 };
57 
58 } // namespace android
59 
60 #endif // _UI_INPUTREADER_CURSOR_SCROLL_ACCUMULATOR_H