• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
18 
19 #include <list>
20 #include <memory>
21 #include <set>
22 #include <array>
23 #include <vector>
24 #include <optional>
25 #include <functional>
26 
27 #include "adapter/preview/external/multimodalinput/common_type.h"
28 
29 namespace OHOS {
30 namespace MMI {
31 
32 enum class TouchType : size_t {
33     DOWN = 0,
34     UP,
35     MOVE,
36     CANCEL,
37     PULL_DOWN,
38     PULL_UP,
39     PULL_MOVE,
40     PULL_IN_WINDOW,
41     PULL_OUT_WINDOW,
42     UNKNOWN,
43 };
44 
45 struct TouchPoint final {
46     int32_t id = 0;
47     float x = 0.0f;
48     float y = 0.0f;
49     float screenX = 0.0f;
50     float screenY = 0.0f;
51     TimeStamp downTime;
52     double size = 0.0;
53     float force = 0.0f;
54     std::optional<float> tiltX;
55     std::optional<float> tiltY;
56     SourceTool sourceTool = SourceTool::UNKNOWN;
57     bool isPressed = false;
58 };
59 
60 class PointerEvent {
61 public:
62     PointerEvent() = default;
63     ~PointerEvent() = default;
64 
65 public:
66     int32_t id = 0;
67     float x = 0.0f;
68     float y = 0.0f;
69     float screenX = 0.0f;
70     float screenY = 0.0f;
71     TouchType type = TouchType::UNKNOWN;
72     TouchType pullType = TouchType::UNKNOWN;
73     TimeStamp time;
74     double size = 0.0;
75     float force = 0.0f;
76     std::optional<float> tiltX;
77     std::optional<float> tiltY;
78     int64_t deviceId = 0;
79     int32_t sourceType = 0; // SOURCE_TYPE_UNKNOWN == SourceType::NONE == 0
80     SourceTool sourceTool = SourceTool::UNKNOWN;
81     std::vector<TouchPoint> pointers;
82 
83     // pointerAction_
84     static constexpr int32_t POINTER_ACTION_UNKNOWN = 0;
85     static constexpr int32_t POINTER_ACTION_CANCEL = 1;
86     static constexpr int32_t POINTER_ACTION_DOWN = 2;
87     static constexpr int32_t POINTER_ACTION_MOVE = 3;
88     static constexpr int32_t POINTER_ACTION_UP = 4;
89     static constexpr int32_t POINTER_ACTION_AXIS_BEGIN = 5;
90     static constexpr int32_t POINTER_ACTION_AXIS_UPDATE = 6;
91     static constexpr int32_t POINTER_ACTION_AXIS_END = 7;
92     static constexpr int32_t POINTER_ACTION_BUTTON_DOWN = 8;
93     static constexpr int32_t POINTER_ACTION_BUTTON_UP = 9;
94     static constexpr int32_t POINTER_ACTION_ENTER_WINDOW = 10;
95     static constexpr int32_t POINTER_ACTION_LEAVE_WINDOW = 11;
96     static constexpr int32_t POINTER_ACTION_PULL_DOWN = 12;
97     static constexpr int32_t POINTER_ACTION_PULL_MOVE = 13;
98     static constexpr int32_t POINTER_ACTION_PULL_UP = 14;
99     static constexpr int32_t POINTER_ACTION_PULL_IN_WINDOW = 15;
100     static constexpr int32_t POINTER_ACTION_PULL_OUT_WINDOW = 16;
101     static constexpr int32_t POINTER_ACTION_SWIPE_BEGIN = 17;
102     static constexpr int32_t POINTER_ACTION_SWIPE_UPDATE = 18;
103     static constexpr int32_t POINTER_ACTION_SWIPE_END = 19;
104     static constexpr int32_t POINTER_ACTION_ROTATE_BEGIN = 20;
105     static constexpr int32_t POINTER_ACTION_ROTATE_UPDATE = 21;
106     static constexpr int32_t POINTER_ACTION_ROTATE_END = 22;
107 
108     // sourceType
109     static constexpr int32_t SOURCE_TYPE_UNKNOWN = 0;
110     static constexpr int32_t SOURCE_TYPE_MOUSE = 1;
111     static constexpr int32_t SOURCE_TYPE_TOUCHSCREEN = 2;
112     static constexpr int32_t SOURCE_TYPE_TOUCHPAD = 3;
113     static constexpr int32_t SOURCE_TYPE_JOYSTICK = 4;
114     static constexpr int32_t SOURCE_TYPE_CROWN = 5;
115 
116     // buttonId_
117     static constexpr int32_t BUTTON_NONE = -1;
118     static constexpr int32_t MOUSE_BUTTON_LEFT = 0;
119     static constexpr int32_t MOUSE_BUTTON_RIGHT = 1;
120     static constexpr int32_t MOUSE_BUTTON_MIDDLE = 2;
121     static constexpr int32_t MOUSE_BUTTON_SIDE = 3;
122     static constexpr int32_t MOUSE_BUTTON_EXTRA = 4;
123     static constexpr int32_t MOUSE_BUTTON_FORWARD = 5;
124     static constexpr int32_t MOUSE_BUTTON_BACK = 6;
125     static constexpr int32_t MOUSE_BUTTON_TASK = 7;
126 
127     enum AxisType {
128         AXIS_TYPE_UNKNOWN,
129         AXIS_TYPE_SCROLL_VERTICAL,
130         AXIS_TYPE_SCROLL_HORIZONTAL,
131         AXIS_TYPE_PINCH,
132         AXIS_TYPE_ROTATE,
133         AXIS_TYPE_ABS_X,
134         AXIS_TYPE_ABS_Y,
135         AXIS_TYPE_ABS_Z,
136         AXIS_TYPE_ABS_RZ,
137         AXIS_TYPE_ABS_GAS,
138         AXIS_TYPE_ABS_BRAKE,
139         AXIS_TYPE_ABS_HAT0X,
140         AXIS_TYPE_ABS_HAT0Y,
141         AXIS_TYPE_ABS_THROTTLE,
142         AXIS_TYPE_MAX
143     };
144 
145     int32_t pointerAction_ { POINTER_ACTION_UNKNOWN };
146     int32_t buttonId_ { -1 };
147     std::set<int32_t> pressedButtons_;
148     std::array<double, AXIS_TYPE_MAX> axisValues_ {};
149     int32_t targetDisplayId_ { -1 }; // InputEvent
150 };
151 
152 } // namespace MMI
153 } // namespace OHOS
154 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
155