1 /*
2  * Copyright (c) 2020-2021 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 GRAPHIC_LITE_INPUT_EVENT_INFO_H
17 #define GRAPHIC_LITE_INPUT_EVENT_INFO_H
18 
19 #include <cstdint>
20 #include "gfx_utils/geometry2d.h"
21 
22 namespace OHOS {
23 const static uint8_t MAX_EVENT_SIZE = 10;
24 const static uint8_t MAX_INPUT_DEVICE_NUM = 10;
25 
26 /**
27  * @brief Enumerates input device types.
28  */
29 enum class InputDevType {
30     INDEV_TYPE_TOUCH,       /** Touchscreen */
31     INDEV_TYPE_KEY,         /** Physical key */
32     INDEV_TYPE_KEYBOARD,    /** Keyboard */
33     INDEV_TYPE_MOUSE,       /** Mouse */
34     INDEV_TYPE_BUTTON,      /** Virtual button */
35     INDEV_TYPE_CROWN,       /** Watch crown */
36     INDEV_TYPE_ENCODER,     /** Customized type of a specific function or event */
37     INDEV_TYPE_UNKNOWN,     /** Unknown input device type */
38 };
39 
40 /** @brief struct of raw event */
41 struct RawEvent {
42     int32_t deviceId;
43     InputDevType type;
44     union {
45         struct {
46             int16_t x;
47             int16_t y;
48             uint16_t state;
49         };
50         uint16_t keyId; /* key type device use this param for touched key id */
51     };
52     int32_t timestamp;
53 };
54 
55 struct DeviceData {
56     union {
57         Point point; /* pointer type device use this param for touched point */
58         uint16_t keyId; /* key type device use this param for touched key id */
59         int16_t encoderDiff; /* encode type device used this param for number of steps since the previous read */
60 #if ENABLE_ROTATE_INPUT
61         int16_t rotate; /* rotate type device used this param for rotate */
62 #endif
63         uint16_t type; /* for virtual device the currently event type */
64     };
65     uint16_t state;
66 #if ENABLE_WINDOW
67     int32_t winId;
68 #endif
69 };
70 
71 typedef enum {
72     LITEIMS_CLIENT_REGISTER,
73     LITEIMS_CLIENT_UNREGISTER
74 } LiteIMSCall;
75 
76 const char IMS_SERVICE_NAME[] = "IMS";
77 const int32_t IMS_DEFAULT_IPC_SIZE = 200;
78 } // namespace OHOS
79 #endif // GRAPHIC_LITE_INPUT_EVENT_INFO_H
80