123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ci
1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
1823b3eb3cSopenharmony_ci
1923b3eb3cSopenharmony_ci#include <list>
2023b3eb3cSopenharmony_ci#include <memory>
2123b3eb3cSopenharmony_ci#include <set>
2223b3eb3cSopenharmony_ci#include <array>
2323b3eb3cSopenharmony_ci#include <vector>
2423b3eb3cSopenharmony_ci#include <optional>
2523b3eb3cSopenharmony_ci#include <functional>
2623b3eb3cSopenharmony_ci
2723b3eb3cSopenharmony_ci#include "adapter/preview/external/multimodalinput/common_type.h"
2823b3eb3cSopenharmony_ci
2923b3eb3cSopenharmony_cinamespace OHOS {
3023b3eb3cSopenharmony_cinamespace MMI {
3123b3eb3cSopenharmony_ci
3223b3eb3cSopenharmony_cienum class TouchType : size_t {
3323b3eb3cSopenharmony_ci    DOWN = 0,
3423b3eb3cSopenharmony_ci    UP,
3523b3eb3cSopenharmony_ci    MOVE,
3623b3eb3cSopenharmony_ci    CANCEL,
3723b3eb3cSopenharmony_ci    PULL_DOWN,
3823b3eb3cSopenharmony_ci    PULL_UP,
3923b3eb3cSopenharmony_ci    PULL_MOVE,
4023b3eb3cSopenharmony_ci    PULL_IN_WINDOW,
4123b3eb3cSopenharmony_ci    PULL_OUT_WINDOW,
4223b3eb3cSopenharmony_ci    UNKNOWN,
4323b3eb3cSopenharmony_ci};
4423b3eb3cSopenharmony_ci
4523b3eb3cSopenharmony_cistruct TouchPoint final {
4623b3eb3cSopenharmony_ci    int32_t id = 0;
4723b3eb3cSopenharmony_ci    float x = 0.0f;
4823b3eb3cSopenharmony_ci    float y = 0.0f;
4923b3eb3cSopenharmony_ci    float screenX = 0.0f;
5023b3eb3cSopenharmony_ci    float screenY = 0.0f;
5123b3eb3cSopenharmony_ci    TimeStamp downTime;
5223b3eb3cSopenharmony_ci    double size = 0.0;
5323b3eb3cSopenharmony_ci    float force = 0.0f;
5423b3eb3cSopenharmony_ci    std::optional<float> tiltX;
5523b3eb3cSopenharmony_ci    std::optional<float> tiltY;
5623b3eb3cSopenharmony_ci    SourceTool sourceTool = SourceTool::UNKNOWN;
5723b3eb3cSopenharmony_ci    bool isPressed = false;
5823b3eb3cSopenharmony_ci};
5923b3eb3cSopenharmony_ci
6023b3eb3cSopenharmony_ciclass PointerEvent {
6123b3eb3cSopenharmony_cipublic:
6223b3eb3cSopenharmony_ci    PointerEvent() = default;
6323b3eb3cSopenharmony_ci    ~PointerEvent() = default;
6423b3eb3cSopenharmony_ci
6523b3eb3cSopenharmony_cipublic:
6623b3eb3cSopenharmony_ci    int32_t id = 0;
6723b3eb3cSopenharmony_ci    float x = 0.0f;
6823b3eb3cSopenharmony_ci    float y = 0.0f;
6923b3eb3cSopenharmony_ci    float screenX = 0.0f;
7023b3eb3cSopenharmony_ci    float screenY = 0.0f;
7123b3eb3cSopenharmony_ci    TouchType type = TouchType::UNKNOWN;
7223b3eb3cSopenharmony_ci    TouchType pullType = TouchType::UNKNOWN;
7323b3eb3cSopenharmony_ci    TimeStamp time;
7423b3eb3cSopenharmony_ci    double size = 0.0;
7523b3eb3cSopenharmony_ci    float force = 0.0f;
7623b3eb3cSopenharmony_ci    std::optional<float> tiltX;
7723b3eb3cSopenharmony_ci    std::optional<float> tiltY;
7823b3eb3cSopenharmony_ci    int64_t deviceId = 0;
7923b3eb3cSopenharmony_ci    int32_t sourceType = 0; // SOURCE_TYPE_UNKNOWN == SourceType::NONE == 0
8023b3eb3cSopenharmony_ci    SourceTool sourceTool = SourceTool::UNKNOWN;
8123b3eb3cSopenharmony_ci    std::vector<TouchPoint> pointers;
8223b3eb3cSopenharmony_ci
8323b3eb3cSopenharmony_ci    // pointerAction_
8423b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_UNKNOWN = 0;
8523b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_CANCEL = 1;
8623b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_DOWN = 2;
8723b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_MOVE = 3;
8823b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_UP = 4;
8923b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_AXIS_BEGIN = 5;
9023b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_AXIS_UPDATE = 6;
9123b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_AXIS_END = 7;
9223b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_BUTTON_DOWN = 8;
9323b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_BUTTON_UP = 9;
9423b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_ENTER_WINDOW = 10;
9523b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_LEAVE_WINDOW = 11;
9623b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_PULL_DOWN = 12;
9723b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_PULL_MOVE = 13;
9823b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_PULL_UP = 14;
9923b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_PULL_IN_WINDOW = 15;
10023b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_PULL_OUT_WINDOW = 16;
10123b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_SWIPE_BEGIN = 17;
10223b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_SWIPE_UPDATE = 18;
10323b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_SWIPE_END = 19;
10423b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_ROTATE_BEGIN = 20;
10523b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_ROTATE_UPDATE = 21;
10623b3eb3cSopenharmony_ci    static constexpr int32_t POINTER_ACTION_ROTATE_END = 22;
10723b3eb3cSopenharmony_ci
10823b3eb3cSopenharmony_ci    // sourceType
10923b3eb3cSopenharmony_ci    static constexpr int32_t SOURCE_TYPE_UNKNOWN = 0;
11023b3eb3cSopenharmony_ci    static constexpr int32_t SOURCE_TYPE_MOUSE = 1;
11123b3eb3cSopenharmony_ci    static constexpr int32_t SOURCE_TYPE_TOUCHSCREEN = 2;
11223b3eb3cSopenharmony_ci    static constexpr int32_t SOURCE_TYPE_TOUCHPAD = 3;
11323b3eb3cSopenharmony_ci    static constexpr int32_t SOURCE_TYPE_JOYSTICK = 4;
11423b3eb3cSopenharmony_ci
11523b3eb3cSopenharmony_ci    // buttonId_
11623b3eb3cSopenharmony_ci    static constexpr int32_t BUTTON_NONE = -1;
11723b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_LEFT = 0;
11823b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_RIGHT = 1;
11923b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_MIDDLE = 2;
12023b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_SIDE = 3;
12123b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_EXTRA = 4;
12223b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_FORWARD = 5;
12323b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_BACK = 6;
12423b3eb3cSopenharmony_ci    static constexpr int32_t MOUSE_BUTTON_TASK = 7;
12523b3eb3cSopenharmony_ci
12623b3eb3cSopenharmony_ci    enum AxisType {
12723b3eb3cSopenharmony_ci        AXIS_TYPE_UNKNOWN,
12823b3eb3cSopenharmony_ci        AXIS_TYPE_SCROLL_VERTICAL,
12923b3eb3cSopenharmony_ci        AXIS_TYPE_SCROLL_HORIZONTAL,
13023b3eb3cSopenharmony_ci        AXIS_TYPE_PINCH,
13123b3eb3cSopenharmony_ci        AXIS_TYPE_ROTATE,
13223b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_X,
13323b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_Y,
13423b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_Z,
13523b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_RZ,
13623b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_GAS,
13723b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_BRAKE,
13823b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_HAT0X,
13923b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_HAT0Y,
14023b3eb3cSopenharmony_ci        AXIS_TYPE_ABS_THROTTLE,
14123b3eb3cSopenharmony_ci        AXIS_TYPE_MAX
14223b3eb3cSopenharmony_ci    };
14323b3eb3cSopenharmony_ci
14423b3eb3cSopenharmony_ci    int32_t pointerAction_ { POINTER_ACTION_UNKNOWN };
14523b3eb3cSopenharmony_ci    int32_t buttonId_ { -1 };
14623b3eb3cSopenharmony_ci    std::set<int32_t> pressedButtons_;
14723b3eb3cSopenharmony_ci    std::array<double, AXIS_TYPE_MAX> axisValues_ {};
14823b3eb3cSopenharmony_ci    int32_t targetDisplayId_ { -1 }; // InputEvent
14923b3eb3cSopenharmony_ci};
15023b3eb3cSopenharmony_ci
15123b3eb3cSopenharmony_ci} // namespace MMI
15223b3eb3cSopenharmony_ci} // namespace OHOS
15323b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_ADAPTER_PREVIEW_EXTERNAL_MULTIMODALINPUT_POINTER_EVENT_H
154