• 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_TOUCH_BUTTON_ACCUMULATOR_H
18 #define _UI_INPUTREADER_TOUCH_BUTTON_ACCUMULATOR_H
19 
20 #include <stdint.h>
21 
22 namespace android {
23 
24 class InputDeviceContext;
25 struct RawEvent;
26 
27 /* Keeps track of the state of touch, stylus and tool buttons. */
28 class TouchButtonAccumulator {
29 public:
30     TouchButtonAccumulator();
31     void configure(InputDeviceContext& deviceContext);
32     void reset(InputDeviceContext& deviceContext);
33 
34     void process(const RawEvent* rawEvent);
35 
36     uint32_t getButtonState() const;
37     int32_t getToolType() const;
38     bool isToolActive() const;
39     bool isHovering() const;
40     bool hasStylus() const;
41 
42 private:
43     bool mHaveBtnTouch;
44     bool mHaveStylus;
45 
46     bool mBtnTouch;
47     bool mBtnStylus;
48     bool mBtnStylus2;
49     bool mBtnToolFinger;
50     bool mBtnToolPen;
51     bool mBtnToolRubber;
52     bool mBtnToolBrush;
53     bool mBtnToolPencil;
54     bool mBtnToolAirbrush;
55     bool mBtnToolMouse;
56     bool mBtnToolLens;
57     bool mBtnToolDoubleTap;
58     bool mBtnToolTripleTap;
59     bool mBtnToolQuadTap;
60 
61     void clearButtons();
62 };
63 
64 } // namespace android
65 
66 #endif // _UI_INPUTREADER_TOUCH_BUTTON_ACCUMULATOR_H