1 /*
2  * Copyright (c) 2021-2022 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 STRUCT_MULTIMODAL_H
17 #define STRUCT_MULTIMODAL_H
18 
19 #include <string>
20 #include "proto.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 inline constexpr int32_t MAX_DEVICENAME { 64 };
25 inline constexpr int32_t MAX_UUIDSIZE { 64 };
26 inline constexpr int32_t SYSTEMUID { 1000 };
27 inline constexpr int32_t MAX_SOLTED_COORDS_NUMS { 10 };
28 
29 enum SENIOR_DEVICE_TYPE {
30     INPUT_DEVICE_AISENSOR = 31,
31     INPUT_DEVICE_KNUCKLE = 41
32 };
33 
34 enum DEVICE_TYPE {
35     DEVICE_TYPE_UNKNOWN = -1,
36     DEVICE_TYPE_TOUCH_PANEL = 0,
37     DEVICE_TYPE_KEYBOARD = 1,
38     DEVICE_TYPE_MOUSE = 2,
39     DEVICE_TYPE_STYLUS = 3,
40     DEVICE_TYPE_BUILTIN_KEY = 4,
41     DEVICE_TYPE_ROTATION = 5,
42     DEVICE_TYPE_AI_SPEECH = 6,
43     DEVICE_TYPE_JOYSTICK = 7,
44     DEVICE_TYPE_TOUCHPAD = 8,
45     DEVICE_TYPE_KNUCKLE = 9,
46     DEVICE_TYPE_VIRTUAL_KEYBOARD = 10,
47 };
48 
49 enum BUTTON_STATE {
50     BUTTON_STATE_RELEASED = 0,
51     BUTTON_STATE_PRESSED = 1
52 };
53 
54 enum KEY_STATE {
55     KEY_STATE_RELEASED,
56     KEY_STATE_PRESSED
57 };
58 
59 enum POINTER_AXIS {
60     POINTER_AXIS_SCROLL_VERTICAL = 0,
61     POINTER_AXIS_SCROLL_HORIZONTAL = 1,
62 };
63 
64 enum POINTER_AXIS_SOURCE {
65     POINTER_AXIS_SOURCE_WHEEL = 1,
66     POINTER_AXIS_SOURCE_FINGER,
67     POINTER_AXIS_SOURCE_CONTINUOUS,
68     POINTER_AXIS_SOURCE_WHEEL_TILT,
69 };
70 
71 enum TABLE_TOOL_TYPE {
72     TABLET_TOOL_TYPE_PEN = 1,
73     TABLET_TOOL_TYPE_ERASER,
74     TABLET_TOOL_TYPE_BRUSH,
75     TABLET_TOOL_TYPE_PENCIL,
76     TABLET_TOOL_TYPE_AIRBRUSH,
77     TABLET_TOOL_TYPE_MOUSE,
78     TABLET_TOOL_TYPE_LENS,
79     TABLET_TOOL_TYPE_TOTEM,
80 };
81 
82 enum TABLE_TOOL_PROXIMITY_STATE {
83     TABLET_TOOL_PROXIMITY_STATE_OUT = 0,
84     TABLET_TOOL_PROXIMITY_STATE_IN = 1,
85 };
86 
87 enum TABLE_TOOL_TIP_STATE {
88     TABLET_TOOL_TIP_UP = 0,
89     TABLET_TOOL_TIP_DOWN = 1,
90 };
91 
92 enum POINT_EVENT_TYPE {
93     EVENT_TYPE_INVALID = 0,
94     PRIMARY_POINT_DOWN = 1,
95     PRIMARY_POINT_UP = 2,
96     POINT_MOVE = 3,
97     OTHER_POINT_DOWN = 4,
98     OTHER_POINT_UP = 5,
99 };
100 
101 enum TABLET_PAD_RING_AXIS_SOURCE {
102     TABLET_PAD_RING_SOURCE_UNKNOWN = 1,
103     TABLET_PAD_RING_SOURCE_FINGER,
104 };
105 
106 enum TABLET_PAD_STRIP_AXIS_SOURCE {
107     TABLET_PAD_STRIP_SOURCE_UNKNOWN = 1,
108     TABLET_PAD_STRIP_SOURCE_FINGER,
109 };
110 
111 enum MOUSE_ICON {
112     DEFAULT = 0,
113     EAST = 1,
114     WEST = 2,
115     SOUTH = 3,
116     NORTH = 4,
117     WEST_EAST = 5,
118     NORTH_SOUTH = 6,
119     NORTH_EAST = 7,
120     NORTH_WEST = 8,
121     SOUTH_EAST = 9,
122     SOUTH_WEST = 10,
123     NORTH_EAST_SOUTH_WEST = 11,
124     NORTH_WEST_SOUTH_EAST = 12,
125     CROSS = 13,
126     CURSOR_COPY = 14,
127     CURSOR_FORBID = 15,
128     COLOR_SUCKER = 16,
129     HAND_GRABBING = 17,
130     HAND_OPEN = 18,
131     HAND_POINTING = 19,
132     HELP = 20,
133     CURSOR_MOVE = 21,
134     RESIZE_LEFT_RIGHT = 22,
135     RESIZE_UP_DOWN = 23,
136     SCREENSHOT_CHOOSE = 24,
137     SCREENSHOT_CURSOR = 25,
138     TEXT_CURSOR = 26,
139     ZOOM_IN = 27,
140     ZOOM_OUT = 28,
141     MIDDLE_BTN_EAST = 29,
142     MIDDLE_BTN_WEST = 30,
143     MIDDLE_BTN_SOUTH = 31,
144     MIDDLE_BTN_NORTH = 32,
145     MIDDLE_BTN_NORTH_SOUTH = 33,
146     MIDDLE_BTN_NORTH_EAST = 34,
147     MIDDLE_BTN_NORTH_WEST = 35,
148     MIDDLE_BTN_SOUTH_EAST = 36,
149     MIDDLE_BTN_SOUTH_WEST = 37,
150     MIDDLE_BTN_NORTH_SOUTH_WEST_EAST = 38,
151     HORIZONTAL_TEXT_CURSOR = 39,
152     CURSOR_CROSS = 40,
153     CURSOR_CIRCLE = 41,
154     LOADING = 42,
155     RUNNING = 43,
156     RUNNING_LEFT = 44,
157     RUNNING_RIGHT = 45,
158     DEVELOPER_DEFINED_ICON = -100,
159 };
160 
161 enum RightClickType {
162     TOUCHPAD_RIGHT_BUTTON = 1,
163     TOUCHPAD_LEFT_BUTTON = 2,
164     TOUCHPAD_TWO_FINGER_TAP = 3,
165 };
166 
167 enum ICON_TYPE {
168     ANGLE_E = 0,
169     ANGLE_S = 1,
170     ANGLE_W = 2,
171     ANGLE_N = 3,
172     ANGLE_SE = 4,
173     ANGLE_NE = 5,
174     ANGLE_SW = 6,
175     ANGLE_NW = 7,
176     ANGLE_CENTER = 8,
177     ANGLE_NW_RIGHT = 9,
178 };
179 
180 enum PrimaryButton {
181     LEFT_BUTTON = 0,
182     RIGHT_BUTTON = 1,
183 };
184 
185 enum SHIELD_MODE {
186     UNSET_MODE = -1,
187     FACTORY_MODE = 0,
188     OOBE_MODE = 1,
189 };
190 struct IconStyle {
191     int32_t alignmentWay { 0 };
192     std::string iconPath;
193 };
194 
195 struct CursorFocus {
196     int32_t x { 0 };
197     int32_t y { 0 };
198 };
199 
200 #pragma pack(1)
201 struct TagPackHead {
202     MmiMessageId idMsg;
203     int32_t sizeEvent[1];
204 };
205 #pragma pack()
206 
207 struct SeniorDeviceInfo {
208     char physical[MAX_DEVICENAME];
209     enum SENIOR_DEVICE_TYPE seniorDeviceType;
210 };
211 
212 struct EventJoyStickAxisAbsInfo {
213     int32_t code;
214     int32_t value;
215     int32_t minimum;
216     int32_t maximum;
217     int32_t fuzz;
218     int32_t flat;
219     int32_t resolution;
220     float standardValue;
221     bool isChanged;
222 };
223 
224 struct EventJoyStickAxis {
225     int32_t deviceId;
226     char physical[MAX_DEVICENAME];
227     char deviceName[MAX_DEVICENAME];
228     DEVICE_TYPE deviceType;
229     int32_t eventType;
230     char uuid[MAX_UUIDSIZE];
231     int64_t time;
232     EventJoyStickAxisAbsInfo abs_throttle;
233     EventJoyStickAxisAbsInfo abs_hat0x;
234     EventJoyStickAxisAbsInfo abs_hat0y;
235     EventJoyStickAxisAbsInfo abs_x;
236     EventJoyStickAxisAbsInfo abs_y;
237     EventJoyStickAxisAbsInfo abs_z;
238     EventJoyStickAxisAbsInfo abs_rx;
239     EventJoyStickAxisAbsInfo abs_ry;
240     EventJoyStickAxisAbsInfo abs_rz;
241     EventJoyStickAxisAbsInfo abs_wheel;
242 };
243 
244 struct NormalizedCoords {
245     double x {};
246     double y {};
247 };
248 
249 struct PhysicalCoordinate {
250     double x {};
251     double y {};
252 };
253 
254 struct LogicalCoordinate {
255     int32_t x {};
256     int32_t y {};
257 };
258 
259 struct LogicalRectangle {
260     LogicalCoordinate point;
261     int32_t width;
262     int32_t height;
263 };
264 
265 struct TiltDegrees {
266     double x {};
267     double y {};
268 };
269 
270 struct PhysEllipsis {
271     double major {};
272     double minor {};
273 };
274 
275 struct Threshold {
276     int32_t upper {};
277     int32_t lower {};
278 };
279 
280 struct WinInfo {
281     int32_t windowPid {};
282     int32_t windowId {};
283 };
284 
285 struct RegisteredEvent {
286     int32_t deviceId {};
287     char uuid[MAX_UUIDSIZE] {};
288     int32_t eventType {};
289     int64_t occurredTime {};
290     DEVICE_TYPE deviceType;
291     char physical[MAX_DEVICENAME] {};
292 };
293 
294 struct StandardTouchStruct {
295     int64_t time {};
296     uint32_t msgType {};
297     int32_t buttonType {};
298     int32_t buttonCount {};
299     int32_t buttonState {};
300     int32_t reRventType {};
301     int32_t curRventType {};
302     int32_t tipState {};
303     double x {};
304     double y {};
305 };
306 
307 struct EventKeyboard {
308     int32_t deviceId {};
309     char physical[MAX_DEVICENAME] {};
310     char deviceName[MAX_DEVICENAME] {};
311     DEVICE_TYPE deviceType;
312     int32_t eventType {};
313     char uuid[MAX_UUIDSIZE] {};
314     int64_t time {};
315     int32_t key {};
316     uint32_t seat_key_count {};
317     enum KEY_STATE state;
318     int32_t unicode {};
319     bool isIntercepted { true };
320 };
321 
322 struct EventPointer {
323     int32_t deviceId {};
324     char physical[MAX_DEVICENAME] {};
325     char deviceName[MAX_DEVICENAME] {};
326     DEVICE_TYPE deviceType;
327     int32_t eventType {};
328     char uuid[MAX_UUIDSIZE] {};
329     int64_t time {};
330     NormalizedCoords delta;
331     PhysicalCoordinate deltaRaw;
332     PhysicalCoordinate absolute;
333     PhysicalCoordinate discrete;
334     int32_t button {};
335     int32_t seatButtonCount {};
336     enum BUTTON_STATE state;
337     enum POINTER_AXIS_SOURCE source;
338     enum POINTER_AXIS axis;
339 };
340 
341 struct Pointer {
342     PhysicalCoordinate absolute;
343 };
344 
345 struct TabletAxes {
346     PhysicalCoordinate point;
347     NormalizedCoords delta;
348     double distance {};
349     double pressure {};
350     TiltDegrees tilt;
351     double rotation {};
352     double slider {};
353     double wheel {};
354     int32_t wheel_discrete {};
355     PhysEllipsis size;
356 };
357 
358 struct TabletTool {
359     uint32_t serial {};
360     uint32_t tool_id {};
361     enum TABLE_TOOL_TYPE type;
362 };
363 
364 struct EventTabletTool {
365     int32_t deviceId {};
366     char physical[MAX_DEVICENAME] {};
367     char deviceName[MAX_DEVICENAME] {};
368     DEVICE_TYPE deviceType;
369     int32_t eventType {};
370     char uuid[MAX_UUIDSIZE] {};
371     uint32_t button {};
372     enum BUTTON_STATE state;
373     uint32_t seat_button_count {};
374     int64_t time {};
375     TabletAxes axes;
376     TabletTool tool;
377     enum TABLE_TOOL_PROXIMITY_STATE proximity_state;
378     enum TABLE_TOOL_TIP_STATE tip_state;
379 };
380 
381 struct EventTouch {
382     int32_t deviceId {};
383     char physical[MAX_DEVICENAME] {};
384     char deviceName[MAX_DEVICENAME] {};
385     char uuid[MAX_UUIDSIZE] {};
386     int32_t eventType {};
387     int64_t time {};
388     int32_t slot {};
389     int32_t seatSlot {};
390     LogicalCoordinate point;
391     LogicalRectangle toolRect;
392     DEVICE_TYPE deviceType;
393     double pressure {};
394     double area {};
395 };
396 
397 struct SlotedCoords {
398     bool isActive {};
399     float x {};
400     float y {};
401 };
402 
403 struct SlotedCoordsInfo {
404     SlotedCoords coords[MAX_SOLTED_COORDS_NUMS];
405     uint32_t activeCount {};
406 };
407 
408 struct EventGesture {
409     int32_t deviceId {};
410     char physical[MAX_DEVICENAME] {};
411     char deviceName[MAX_DEVICENAME] {};
412     DEVICE_TYPE deviceType;
413     int32_t eventType {};
414     char uuid[MAX_UUIDSIZE] {};
415     int64_t time {};
416     int32_t fingerCount {};
417     int32_t cancelled {};
418     NormalizedCoords delta;
419     NormalizedCoords deltaUnaccel;
420     SlotedCoordsInfo soltTouches;
421     double scale {};
422     double angle {};
423     int32_t pointerEventType {};
424 };
425 
426 struct RawInputEvent {
427     uint32_t stamp {};
428     uint32_t ev_type {};
429     uint32_t ev_code {};
430     uint32_t ev_value {};
431 };
432 
433 struct TestSurfaceData {
434     int32_t screenId {};
435     int32_t onLayerId {};
436     int32_t surfaceId {};
437     int32_t opacity {};
438     int32_t visibility {};
439     int32_t srcX {};
440     int32_t srcY {};
441     int32_t srcW {};
442     int32_t srcH {};
443 };
444 
445 struct VirtualKey {
446     bool isPressed {};
447     int32_t keyCode {};
448     int64_t keyDownDuration {};
449     bool isIntercepted { true };
450 };
451 
452 struct DeviceManage {
453     uint32_t deviceId {};
454     char physical[MAX_DEVICENAME] {};
455     char deviceName[MAX_DEVICENAME] {};
456     DEVICE_TYPE deviceType;
457     int32_t eventType {};
458     char uuid[MAX_UUIDSIZE] {};
459 };
460 
461 struct EventTabletPad {
462     uint32_t deviceId {};
463     char physical[MAX_DEVICENAME] {};
464     char deviceName[MAX_DEVICENAME] {};
465     DEVICE_TYPE deviceType;
466     int32_t eventType {};
467     char uuid[MAX_UUIDSIZE] {};
468     int64_t time {};
469     uint32_t mode {};
470     struct {
471         uint32_t number {};
472         enum BUTTON_STATE state;
473     } button;
474     struct {
475         uint32_t code {};
476         enum KEY_STATE state;
477     } key;
478     struct {
479         enum TABLET_PAD_RING_AXIS_SOURCE source;
480         double position {};
481         int32_t number {};
482     } ring;
483     struct {
484         enum TABLET_PAD_STRIP_AXIS_SOURCE source;
485         double position {};
486         int32_t number {};
487     } strip;
488 };
489 } // namespace MMI
490 } // namespace OHOS
491 #endif // STRUCT_MULTIMODAL_H
492