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_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H 17 #define FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H 18 19 #include <list> 20 #include <memory> 21 #include <set> 22 #include <array> 23 #include <vector> 24 #include <optional> 25 #include <functional> 26 27 #include "adapter/preview/external/multimodalinput/common_type.h" 28 29 namespace OHOS { 30 namespace MMI { 31 32 enum class TouchType : size_t { 33 DOWN = 0, 34 UP, 35 MOVE, 36 CANCEL, 37 PULL_DOWN, 38 PULL_UP, 39 PULL_MOVE, 40 PULL_IN_WINDOW, 41 PULL_OUT_WINDOW, 42 UNKNOWN, 43 }; 44 45 struct TouchPoint final { 46 int32_t id = 0; 47 float x = 0.0f; 48 float y = 0.0f; 49 float screenX = 0.0f; 50 float screenY = 0.0f; 51 double globalDisplayX = 0.0; 52 double globalDisplayY = 0.0; 53 TimeStamp downTime; 54 double size = 0.0; 55 float force = 0.0f; 56 std::optional<float> tiltX; 57 std::optional<float> tiltY; 58 SourceTool sourceTool = SourceTool::UNKNOWN; 59 bool isPressed = false; 60 }; 61 62 class PointerEvent { 63 public: 64 PointerEvent() = default; 65 ~PointerEvent() = default; 66 67 public: 68 int32_t id = 0; 69 float x = 0.0f; 70 float y = 0.0f; 71 float screenX = 0.0f; 72 float screenY = 0.0f; 73 double globalDisplayX = 0.0; 74 double globalDisplayY = 0.0; 75 TouchType type = TouchType::UNKNOWN; 76 TouchType pullType = TouchType::UNKNOWN; 77 TimeStamp time; 78 double size = 0.0; 79 float force = 0.0f; 80 std::optional<float> tiltX; 81 std::optional<float> tiltY; 82 int64_t deviceId = 0; 83 int32_t sourceType = 0; // SOURCE_TYPE_UNKNOWN == SourceType::NONE == 0 84 SourceTool sourceTool = SourceTool::UNKNOWN; 85 std::vector<TouchPoint> pointers; 86 87 // pointerAction_ 88 static constexpr int32_t POINTER_ACTION_UNKNOWN = 0; 89 static constexpr int32_t POINTER_ACTION_CANCEL = 1; 90 static constexpr int32_t POINTER_ACTION_DOWN = 2; 91 static constexpr int32_t POINTER_ACTION_MOVE = 3; 92 static constexpr int32_t POINTER_ACTION_UP = 4; 93 static constexpr int32_t POINTER_ACTION_AXIS_BEGIN = 5; 94 static constexpr int32_t POINTER_ACTION_AXIS_UPDATE = 6; 95 static constexpr int32_t POINTER_ACTION_AXIS_END = 7; 96 static constexpr int32_t POINTER_ACTION_BUTTON_DOWN = 8; 97 static constexpr int32_t POINTER_ACTION_BUTTON_UP = 9; 98 static constexpr int32_t POINTER_ACTION_ENTER_WINDOW = 10; 99 static constexpr int32_t POINTER_ACTION_LEAVE_WINDOW = 11; 100 static constexpr int32_t POINTER_ACTION_PULL_DOWN = 12; 101 static constexpr int32_t POINTER_ACTION_PULL_MOVE = 13; 102 static constexpr int32_t POINTER_ACTION_PULL_UP = 14; 103 static constexpr int32_t POINTER_ACTION_PULL_IN_WINDOW = 15; 104 static constexpr int32_t POINTER_ACTION_PULL_OUT_WINDOW = 16; 105 static constexpr int32_t POINTER_ACTION_SWIPE_BEGIN = 17; 106 static constexpr int32_t POINTER_ACTION_SWIPE_UPDATE = 18; 107 static constexpr int32_t POINTER_ACTION_SWIPE_END = 19; 108 static constexpr int32_t POINTER_ACTION_ROTATE_BEGIN = 20; 109 static constexpr int32_t POINTER_ACTION_ROTATE_UPDATE = 21; 110 static constexpr int32_t POINTER_ACTION_ROTATE_END = 22; 111 112 // sourceType 113 static constexpr int32_t SOURCE_TYPE_UNKNOWN = 0; 114 static constexpr int32_t SOURCE_TYPE_MOUSE = 1; 115 static constexpr int32_t SOURCE_TYPE_TOUCHSCREEN = 2; 116 static constexpr int32_t SOURCE_TYPE_TOUCHPAD = 3; 117 static constexpr int32_t SOURCE_TYPE_JOYSTICK = 4; 118 static constexpr int32_t SOURCE_TYPE_CROWN = 5; 119 120 // buttonId_ 121 static constexpr int32_t BUTTON_NONE = -1; 122 static constexpr int32_t MOUSE_BUTTON_LEFT = 0; 123 static constexpr int32_t MOUSE_BUTTON_RIGHT = 1; 124 static constexpr int32_t MOUSE_BUTTON_MIDDLE = 2; 125 static constexpr int32_t MOUSE_BUTTON_SIDE = 3; 126 static constexpr int32_t MOUSE_BUTTON_EXTRA = 4; 127 static constexpr int32_t MOUSE_BUTTON_FORWARD = 5; 128 static constexpr int32_t MOUSE_BUTTON_BACK = 6; 129 static constexpr int32_t MOUSE_BUTTON_TASK = 7; 130 131 enum AxisType { 132 AXIS_TYPE_UNKNOWN, 133 AXIS_TYPE_SCROLL_VERTICAL, 134 AXIS_TYPE_SCROLL_HORIZONTAL, 135 AXIS_TYPE_PINCH, 136 AXIS_TYPE_ROTATE, 137 AXIS_TYPE_ABS_X, 138 AXIS_TYPE_ABS_Y, 139 AXIS_TYPE_ABS_Z, 140 AXIS_TYPE_ABS_RZ, 141 AXIS_TYPE_ABS_GAS, 142 AXIS_TYPE_ABS_BRAKE, 143 AXIS_TYPE_ABS_HAT0X, 144 AXIS_TYPE_ABS_HAT0Y, 145 AXIS_TYPE_ABS_THROTTLE, 146 AXIS_TYPE_MAX 147 }; 148 149 int32_t pointerAction_ { POINTER_ACTION_UNKNOWN }; 150 int32_t buttonId_ { -1 }; 151 std::set<int32_t> pressedButtons_; 152 std::array<double, AXIS_TYPE_MAX> axisValues_ {}; 153 int32_t targetDisplayId_ { -1 }; // InputEvent 154 }; 155 156 } // namespace MMI 157 } // namespace OHOS 158 #endif // FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H 159