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 FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_EVENT_CONVERTOR_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_EVENT_CONVERTOR_H 18 19 #include <vector> 20 21 #include "core/event/mouse_event.h" 22 #include "core/event/touch_event.h" 23 24 namespace OHOS::Ace { 25 26 constexpr int32_t ROTATION_DIVISOR = 64; 27 28 struct alignas(8) AceActionData { 29 enum class ActionType : int64_t { 30 UNKNOWN = -1, 31 CANCEL = 0, 32 ADD, 33 REMOVE, 34 HOVER, 35 DOWN, 36 MOVE, 37 UP, 38 }; 39 40 int64_t timeStamp = 0; 41 ActionType actionType = ActionType::UNKNOWN; 42 int64_t actionId = 0; 43 double physicalX = 0.0; 44 double physicalY = 0.0; 45 46 double pressure = 0.0; 47 double maxPressure = 0.0; 48 double size = 0.0; 49 int64_t sourceDevice = 0; 50 int64_t sourceDeviceId = 0; 51 }; 52 53 struct alignas(8) AceMouseData { 54 enum class Action : int64_t { 55 NONE, 56 PRESS, 57 RELEASE, 58 MOVE, 59 HOVER_ENTER, 60 HOVER_MOVE, 61 HOVER_EXIT, 62 }; 63 64 enum class ActionButton : int64_t { 65 NONE_BUTTON = 0, 66 LEFT_BUTTON = 1, 67 RIGHT_BUTTON = 2, 68 MIDDLE_BUTTON = 4, 69 BACK_BUTTON = 8, 70 FORWARD_BUTTON = 16, 71 }; 72 73 double physicalX; 74 double physicalY; 75 double physicalZ; 76 double deltaX; 77 double deltaY; 78 double deltaZ; 79 double scrollDeltaX; 80 double scrollDeltaY; 81 double scrollDeltaZ; 82 Action action; 83 ActionButton actionButton; 84 int64_t pressedButtons; 85 int64_t timeStamp; 86 int64_t deviceId; 87 }; 88 89 void SetTouchEventType(AceActionData::ActionType actionType, TouchEvent& point, std::vector<TouchEvent>& events); 90 91 void UpdateTouchEvent(std::vector<TouchEvent>& events); 92 93 void ConvertMouseEvent(const std::vector<uint8_t>& data, MouseEvent& events); 94 95 } // namespace OHOS::Ace 96 97 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_EVENT_CONVERTOR_H 98