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