1 /* 2 * Copyright (c) 2023 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_POINTER_EVENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H 18 19 #include <map> 20 21 #include "base/geometry/point.h" 22 #include "core/event/ace_events.h" 23 24 namespace OHOS::MMI { 25 class PointerEvent; 26 } 27 28 namespace OHOS::Ace { 29 30 enum class KeyCode : int32_t; 31 32 enum class PointerAction : int32_t { 33 UNKNOWN = 0, 34 CANCEL = 1, 35 DOWN = 2, 36 MOVE = 3, 37 UP = 4, 38 AXIS_BEGIN = 5, 39 AXIS_UPDATE = 6, 40 AXIS_END = 7, 41 BUTTON_DOWN = 8, 42 BUTTON_UP = 9, 43 ENTER_WINDOW = 10, 44 LEAVE_WINDOW = 11, 45 PULL_DOWN = 12, 46 PULL_MOVE = 13, 47 PULL_UP = 14, 48 PULL_IN_WINDOW = 15, 49 PULL_OUT_WINDOW = 16, 50 SWIPE_BEGIN = 17, 51 SWIPE_UPDATE = 18, 52 SWIPE_END = 19, 53 POINTER_ACTION_ROTATE_BEGIN = 20, 54 POINTER_ACTION_ROTATE_UPDATE = 21, 55 POINTER_ACTION_ROTATE_END = 22, 56 }; 57 58 struct PointerEvent final { 59 int32_t pointerEventId = 0; 60 int32_t pointerId = 0; 61 int32_t pullId = -1; 62 bool pressed = false; 63 int32_t windowX = 0; 64 int32_t windowY = 0; 65 int32_t displayX = 0; 66 int32_t displayY = 0; 67 double size = 0.0; 68 float force = 0.0f; 69 int32_t deviceId = 0; 70 TimeStamp downTime; 71 TimeStamp time; 72 SourceTool sourceTool = SourceTool::UNKNOWN; 73 int32_t targetWindowId = -1; 74 int32_t x = 0; 75 int32_t y = 0; 76 std::shared_ptr<MMI::PointerEvent> rawPointerEvent; 77 PointerAction action = PointerAction::UNKNOWN; 78 std::vector<KeyCode> pressedKeyCodes_; 79 80 PointerEvent() = default; PointerEventfinal81 PointerEvent(int32_t x, int32_t y) : x(x), y(y) {} PointerEventfinal82 PointerEvent(int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY) 83 : windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY) 84 {} PointerEventfinal85 PointerEvent(int32_t pointerEventId, int32_t windowX, int32_t windowY, int32_t displayX, int32_t displayY) 86 : pointerEventId(pointerEventId), windowX(windowX), windowY(windowY), displayX(displayX), displayY(displayY) 87 {} 88 GetPointfinal89 Point GetPoint() const 90 { 91 if (!x && !y) { 92 return Point(windowX, windowY, displayX, displayY); 93 } else { 94 return Point(x, y, x, y); 95 } 96 } 97 GetDisplayXfinal98 int32_t GetDisplayX() const 99 { 100 return displayX; 101 } 102 GetDisplayYfinal103 int32_t GetDisplayY() const 104 { 105 return displayY; 106 } 107 }; 108 } // namespace OHOS::Ace 109 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_EVENT_POINTER_EVENT_H