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 PROCESSING_MOUSE_DEVICE_H
17 #define PROCESSING_MOUSE_DEVICE_H
18 
19 #include "device_base.h"
20 #include "msg_head.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 class ProcessingMouseDevice : public DeviceBase {
25     struct MouseEvent {
26         int32_t xPos { 0 };
27         int32_t yPos { 0 };
28         int32_t keyValue { 0 };
29         int32_t distance { 0 };
30         int64_t blockTime { 0 };
31         std::string eventType;
32         std::string direction;
33     };
34 public:
35     ProcessingMouseDevice() = default;
36     ~ProcessingMouseDevice() = default;
37     DISALLOW_COPY_AND_MOVE(ProcessingMouseDevice);
38     int32_t TransformJsonDataToInputData(const DeviceItem& inputEventArrays, InputEventArray& inputEventArray);
39 private:
40     int32_t AnalysisMouseEvent(const std::vector<DeviceEvent>& inputData, std::vector<MouseEvent>& mouseEventArray);
41     void TransformMouseEventToInputEvent(const std::vector<MouseEvent>& mouseEventArray,
42                                          InputEventArray& inputEventArray);
43     void TransformKeyPressEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
44     void TransformKeyReleaseEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
45     void TransformKeyClickEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
46     void TransformMouseMoveEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
47     void TransformMouseWheelEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
48     void TransformMouseHwheelEvent(const MouseEvent& mouseEvent, InputEventArray& inputEventArray);
49 };
50 } // namespace MMI
51 } // namespace OHOS
52 #endif // PROCESSING_MOUSE_DEVICE_H