1885b47fbSopenharmony_ci/*
2885b47fbSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd.
3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License.
5885b47fbSopenharmony_ci * You may obtain a copy of the License at
6885b47fbSopenharmony_ci *
7885b47fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8885b47fbSopenharmony_ci *
9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and
13885b47fbSopenharmony_ci * limitations under the License.
14885b47fbSopenharmony_ci */
15885b47fbSopenharmony_ci
16885b47fbSopenharmony_ci#ifndef ACCESSIBILITY_MULTIFINGER_MULTITAP_H
17885b47fbSopenharmony_ci#define ACCESSIBILITY_MULTIFINGER_MULTITAP_H
18885b47fbSopenharmony_ci
19885b47fbSopenharmony_ci#include <cmath>
20885b47fbSopenharmony_ci#include <vector>
21885b47fbSopenharmony_ci
22885b47fbSopenharmony_ci#include "accessibility_gesture_recognizer.h"
23885b47fbSopenharmony_ci#ifdef OHOS_BUILD_ENABLE_DISPLAY_MANAGER
24885b47fbSopenharmony_ci#include "accessibility_display_manager.h"
25885b47fbSopenharmony_ci#endif
26885b47fbSopenharmony_ci#include "accessibility_event_info.h"
27885b47fbSopenharmony_ci#include "accessible_ability_manager_service.h"
28885b47fbSopenharmony_ci#include "accessibility_def.h"
29885b47fbSopenharmony_ci#include "event_handler.h"
30885b47fbSopenharmony_ci#include "event_runner.h"
31885b47fbSopenharmony_ci#include "pointer_event.h"
32885b47fbSopenharmony_ci#include "singleton.h"
33885b47fbSopenharmony_ci
34885b47fbSopenharmony_cinamespace OHOS {
35885b47fbSopenharmony_cinamespace Accessibility {
36885b47fbSopenharmony_cinamespace {
37885b47fbSopenharmony_ci    constexpr uint32_t MAX_TAP_NUM = 3;
38885b47fbSopenharmony_ci    constexpr uint32_t MAX_MULTI_FINGER_TYPE = 3;
39885b47fbSopenharmony_ci} // namespace
40885b47fbSopenharmony_ci
41885b47fbSopenharmony_cienum MoveGirectionType : int32_t {
42885b47fbSopenharmony_ci    SWIPE_LEFT = 0,
43885b47fbSopenharmony_ci    SWIPE_RIGHT = 1,
44885b47fbSopenharmony_ci    SWIPE_UP = 2,
45885b47fbSopenharmony_ci    SWIPE_DOWN = 3
46885b47fbSopenharmony_ci};
47885b47fbSopenharmony_ci
48885b47fbSopenharmony_cienum FingerTouchUpState : int32_t {
49885b47fbSopenharmony_ci    NOT_ALL_FINGER_TOUCH_UP = 0,
50885b47fbSopenharmony_ci    ALL_FINGER_TOUCH_UP = 1,
51885b47fbSopenharmony_ci    TOUCH_DOWN_AFTER_ALL_FINGER_TOUCH_UP = 2,
52885b47fbSopenharmony_ci};
53885b47fbSopenharmony_ci
54885b47fbSopenharmony_cienum MultiFingerGestureState : int32_t {
55885b47fbSopenharmony_ci    GESTURE_NOT_START = 0,
56885b47fbSopenharmony_ci    GESTURE_START = 1,
57885b47fbSopenharmony_ci    GESTURE_CANCLE = 2,
58885b47fbSopenharmony_ci    GESTURE_COMPLETE = 3,
59885b47fbSopenharmony_ci    GESTURE_WAIT = 4,
60885b47fbSopenharmony_ci};
61885b47fbSopenharmony_ci
62885b47fbSopenharmony_ciclass AccessibilityMultiTapGestureRecognizer;
63885b47fbSopenharmony_ciclass MultiFingerGestureHandler : public AppExecFwk::EventHandler {
64885b47fbSopenharmony_cipublic:
65885b47fbSopenharmony_ci    MultiFingerGestureHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
66885b47fbSopenharmony_ci        AccessibilityMultiTapGestureRecognizer &server);
67885b47fbSopenharmony_ci    virtual ~MultiFingerGestureHandler() = default;
68885b47fbSopenharmony_ci    /**
69885b47fbSopenharmony_ci     * @brief Process the event of install system bundles.
70885b47fbSopenharmony_ci     * @param event Indicates the event to be processed.
71885b47fbSopenharmony_ci     */
72885b47fbSopenharmony_ci    virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
73885b47fbSopenharmony_ciprivate:
74885b47fbSopenharmony_ci    /**
75885b47fbSopenharmony_ci     * @brief Process the multi finger gesture by Gesture type.
76885b47fbSopenharmony_ci     * @param gestureType Indicates the gesture type to be processed.
77885b47fbSopenharmony_ci     */
78885b47fbSopenharmony_ci    void ProcessMultiFingerGestureTypeEvent(const GestureType gestureType);
79885b47fbSopenharmony_ci
80885b47fbSopenharmony_ci    /**
81885b47fbSopenharmony_ci     * @brief Process the multi finger gesture event.
82885b47fbSopenharmony_ci     * @param event Indicates the event to be processed.
83885b47fbSopenharmony_ci     * @return true if the gesture event is processed success, else false.
84885b47fbSopenharmony_ci     */
85885b47fbSopenharmony_ci    bool ProcessMultiFingerGestureEvent(const AppExecFwk::InnerEvent::Pointer &event);
86885b47fbSopenharmony_ci
87885b47fbSopenharmony_ci    /**
88885b47fbSopenharmony_ci     * @brief check whether the gesture is a tap gesture.
89885b47fbSopenharmony_ci     * @param gestureType Indicates the gesture to be processed.
90885b47fbSopenharmony_ci     * @return true if the gesture is a tap gesture, else false.
91885b47fbSopenharmony_ci     */
92885b47fbSopenharmony_ci    bool IsTapGesture(const GestureType gestureType);
93885b47fbSopenharmony_ci
94885b47fbSopenharmony_ci    AccessibilityMultiTapGestureRecognizer &server_;
95885b47fbSopenharmony_ci};
96885b47fbSopenharmony_ci
97885b47fbSopenharmony_ciclass AccessibilityMultiTapGestureRecognizer : public AppExecFwk::EventHandler {
98885b47fbSopenharmony_cipublic:
99885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_SINGLE_TAP_MSG = 3;
100885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_LONG_PRESS_MSG = 4;
101885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_MSG = 5;
102885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 6;
103885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_MSG = 7;
104885b47fbSopenharmony_ci    static constexpr uint32_t TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 8;
105885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_SINGLE_TAP_MSG = 9;
106885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_LONG_PRESS_MSG = 10;
107885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_MSG = 11;
108885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 12;
109885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_MSG = 13;
110885b47fbSopenharmony_ci    static constexpr uint32_t THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 14;
111885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_SINGLE_TAP_MSG = 15;
112885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_LONG_PRESS_MSG = 16;
113885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_MSG = 17;
114885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG = 18;
115885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_MSG = 19;
116885b47fbSopenharmony_ci    static constexpr uint32_t FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG = 20;
117885b47fbSopenharmony_ci    static constexpr uint32_t WAIT_ANOTHER_FINGER_DOWN_MSG = 21;
118885b47fbSopenharmony_ci    static constexpr uint32_t CANCEL_WAIT_FINGER_DOWN_MSG = 22;
119885b47fbSopenharmony_ci    static constexpr uint32_t CANCEL_GESTURE = 23;
120885b47fbSopenharmony_ci    static constexpr uint32_t COMPLETE_GESTURE = 24;
121885b47fbSopenharmony_ci
122885b47fbSopenharmony_ci    static constexpr uint32_t GESTURE_TAP_MSG[MAX_TAP_NUM][MAX_MULTI_FINGER_TYPE] = {
123885b47fbSopenharmony_ci        {
124885b47fbSopenharmony_ci            TWO_FINGER_SINGLE_TAP_MSG,
125885b47fbSopenharmony_ci            THREE_FINGER_SINGLE_TAP_MSG,
126885b47fbSopenharmony_ci            FOUR_FINGER_SINGLE_TAP_MSG,
127885b47fbSopenharmony_ci        },
128885b47fbSopenharmony_ci        {
129885b47fbSopenharmony_ci            TWO_FINGER_DOUBLE_TAP_MSG,
130885b47fbSopenharmony_ci            THREE_FINGER_DOUBLE_TAP_MSG,
131885b47fbSopenharmony_ci            FOUR_FINGER_DOUBLE_TAP_MSG,
132885b47fbSopenharmony_ci        },
133885b47fbSopenharmony_ci        {
134885b47fbSopenharmony_ci            TWO_FINGER_TRIPLE_TAP_MSG,
135885b47fbSopenharmony_ci            THREE_FINGER_TRIPLE_TAP_MSG,
136885b47fbSopenharmony_ci            FOUR_FINGER_TRIPLE_TAP_MSG,
137885b47fbSopenharmony_ci        }
138885b47fbSopenharmony_ci    };
139885b47fbSopenharmony_ci
140885b47fbSopenharmony_ci    static constexpr uint32_t GESTURE_HOLD_MSG[MAX_TAP_NUM][MAX_MULTI_FINGER_TYPE] = {
141885b47fbSopenharmony_ci        {
142885b47fbSopenharmony_ci            TWO_FINGER_LONG_PRESS_MSG,
143885b47fbSopenharmony_ci            THREE_FINGER_LONG_PRESS_MSG,
144885b47fbSopenharmony_ci            FOUR_FINGER_LONG_PRESS_MSG,
145885b47fbSopenharmony_ci        },
146885b47fbSopenharmony_ci        {
147885b47fbSopenharmony_ci            TWO_FINGER_DOUBLE_TAP_AND_HOLD_MSG,
148885b47fbSopenharmony_ci            THREE_FINGER_DOUBLE_TAP_AND_HOLD_MSG,
149885b47fbSopenharmony_ci            FOUR_FINGER_DOUBLE_TAP_AND_HOLD_MSG,
150885b47fbSopenharmony_ci        },
151885b47fbSopenharmony_ci        {
152885b47fbSopenharmony_ci            TWO_FINGER_TRIPLE_TAP_AND_HOLD_MSG,
153885b47fbSopenharmony_ci            THREE_FINGER_TRIPLE_TAP_AND_HOLD_MSG,
154885b47fbSopenharmony_ci            FOUR_FINGER_TRIPLE_TAP_AND_HOLD_MSG,
155885b47fbSopenharmony_ci        }
156885b47fbSopenharmony_ci    };
157885b47fbSopenharmony_ci
158885b47fbSopenharmony_ci    AccessibilityMultiTapGestureRecognizer();
159885b47fbSopenharmony_ci    ~AccessibilityMultiTapGestureRecognizer() = default;
160885b47fbSopenharmony_ci
161885b47fbSopenharmony_ci    /**
162885b47fbSopenharmony_ci     * @brief Register GestureRecognizeListener.
163885b47fbSopenharmony_ci     * @param listener the listener from touchguide.
164885b47fbSopenharmony_ci     */
165885b47fbSopenharmony_ci    void RegisterListener(AccessibilityGestureRecognizeListener &listener);
166885b47fbSopenharmony_ci
167885b47fbSopenharmony_ci    /**
168885b47fbSopenharmony_ci     * @brief Get the GestureRecognizeListener.
169885b47fbSopenharmony_ci     * @return AccessibilityGestureRecognizeListener ptr.
170885b47fbSopenharmony_ci     */
171885b47fbSopenharmony_ci    AccessibilityGestureRecognizeListener *GetRecognizeListener() const
172885b47fbSopenharmony_ci    {
173885b47fbSopenharmony_ci        return listener_;
174885b47fbSopenharmony_ci    }
175885b47fbSopenharmony_ci
176885b47fbSopenharmony_ci    /**
177885b47fbSopenharmony_ci     * @brief Handle a touch event. If an action is completed, the appropriate callback is called.
178885b47fbSopenharmony_ci     *
179885b47fbSopenharmony_ci     * @param event  the touch event to be handled.
180885b47fbSopenharmony_ci     */
181885b47fbSopenharmony_ci    void OnPointerEvent(MMI::PointerEvent &event);
182885b47fbSopenharmony_ci
183885b47fbSopenharmony_ci    /**
184885b47fbSopenharmony_ci     * @brief Cancle multi finger gesture rocognize state, buffer etc.
185885b47fbSopenharmony_ci     */
186885b47fbSopenharmony_ci    void Clear();
187885b47fbSopenharmony_ci
188885b47fbSopenharmony_ci    /**
189885b47fbSopenharmony_ci     * @brief Get the target fingers number touch down in first round.
190885b47fbSopenharmony_ci     * @return the finger numbers touch down in first round.
191885b47fbSopenharmony_ci     */
192885b47fbSopenharmony_ci    int32_t GetTargetFingers() const
193885b47fbSopenharmony_ci    {
194885b47fbSopenharmony_ci        return targetFingers_;
195885b47fbSopenharmony_ci    }
196885b47fbSopenharmony_ci
197885b47fbSopenharmony_ci    /**
198885b47fbSopenharmony_ci     * @brief Get finger touch up state.
199885b47fbSopenharmony_ci     * @return the touch up state, indicates if fingers is still on the screen.
200885b47fbSopenharmony_ci     */
201885b47fbSopenharmony_ci    int32_t GetFingerTouchUpState() const
202885b47fbSopenharmony_ci    {
203885b47fbSopenharmony_ci        return fingerTouchUpState_;
204885b47fbSopenharmony_ci    }
205885b47fbSopenharmony_ci
206885b47fbSopenharmony_ci    /**
207885b47fbSopenharmony_ci     * @brief Set the finger touch up state when touch up or finish touch down.
208885b47fbSopenharmony_ci     * @param touchUpState the touchUpState to be set.
209885b47fbSopenharmony_ci     */
210885b47fbSopenharmony_ci    void SetFingerTouchUpState(const int32_t touchUpState)
211885b47fbSopenharmony_ci    {
212885b47fbSopenharmony_ci        fingerTouchUpState_ = touchUpState;
213885b47fbSopenharmony_ci    }
214885b47fbSopenharmony_ci
215885b47fbSopenharmony_ci    /**
216885b47fbSopenharmony_ci     * @brief Set multi finger gesture state, when gesture recognize start, cancel, complete etc.
217885b47fbSopenharmony_ci     * @param gestureState the multiFingerGestureState to be set.
218885b47fbSopenharmony_ci     */
219885b47fbSopenharmony_ci    void SetMultiFingerGestureState(const int32_t gestureState)
220885b47fbSopenharmony_ci    {
221885b47fbSopenharmony_ci        multiFingerGestureState_ = gestureState;
222885b47fbSopenharmony_ci    }
223885b47fbSopenharmony_ci
224885b47fbSopenharmony_ci    /**
225885b47fbSopenharmony_ci     * @brief Determine whether multi finger gesture is started.
226885b47fbSopenharmony_ci     * @return true if gesture recognize is started, else false.
227885b47fbSopenharmony_ci     */
228885b47fbSopenharmony_ci    bool IsMultiFingerGestureStarted() const
229885b47fbSopenharmony_ci    {
230885b47fbSopenharmony_ci        return multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START;
231885b47fbSopenharmony_ci    }
232885b47fbSopenharmony_ci
233885b47fbSopenharmony_ci    /**
234885b47fbSopenharmony_ci     * @brief Determine whether multi finger gesture is started or finished.
235885b47fbSopenharmony_ci     * @return true if gesture recognize is started or finished, else false.
236885b47fbSopenharmony_ci     */
237885b47fbSopenharmony_ci    bool IsMultiFingerRecognize() const
238885b47fbSopenharmony_ci    {
239885b47fbSopenharmony_ci        return (multiFingerGestureState_ == MultiFingerGestureState::GESTURE_START ||
240885b47fbSopenharmony_ci            multiFingerGestureState_ == MultiFingerGestureState::GESTURE_COMPLETE);
241885b47fbSopenharmony_ci    }
242885b47fbSopenharmony_ci
243885b47fbSopenharmony_ci    /**
244885b47fbSopenharmony_ci     * @brief Get the two finger move threshold.
245885b47fbSopenharmony_ci     * @return the two finger move threshold, indicates tap state to move state.
246885b47fbSopenharmony_ci     */
247885b47fbSopenharmony_ci    float GetTouchSlop() const
248885b47fbSopenharmony_ci    {
249885b47fbSopenharmony_ci        return touchSlop_;
250885b47fbSopenharmony_ci    }
251885b47fbSopenharmony_ciprivate:
252885b47fbSopenharmony_ci    /**
253885b47fbSopenharmony_ci     * @brief Cancle the pendding two finger gesture recognize event.
254885b47fbSopenharmony_ci     */
255885b47fbSopenharmony_ci    void CancelTwoFingerEvent();
256885b47fbSopenharmony_ci
257885b47fbSopenharmony_ci    /**
258885b47fbSopenharmony_ci     * @brief Cancle the pendding three finger gesture recognize event.
259885b47fbSopenharmony_ci     */
260885b47fbSopenharmony_ci    void CancelThreeFingerEvent();
261885b47fbSopenharmony_ci
262885b47fbSopenharmony_ci    /**
263885b47fbSopenharmony_ci     * @brief Cancle the pendding four finger gesture recognize event.
264885b47fbSopenharmony_ci     */
265885b47fbSopenharmony_ci    void CancelFourFingerEvent();
266885b47fbSopenharmony_ci
267885b47fbSopenharmony_ci    /**
268885b47fbSopenharmony_ci     * @brief Cancle the pendding finger gesture recognize event by finger num.
269885b47fbSopenharmony_ci     * @param fingerNum which type gesture pendding event to be canceled.
270885b47fbSopenharmony_ci     */
271885b47fbSopenharmony_ci    void CancelTapAndHoldGestureEvent(const int32_t fingerNum);
272885b47fbSopenharmony_ci
273885b47fbSopenharmony_ci    /**
274885b47fbSopenharmony_ci     * @brief Cancle the pendding multi finger hold gesture recognize event.
275885b47fbSopenharmony_ci     */
276885b47fbSopenharmony_ci    void CancelHoldGestureEvent();
277885b47fbSopenharmony_ci
278885b47fbSopenharmony_ci    /**
279885b47fbSopenharmony_ci     * @brief Cancle All pendding inner event.
280885b47fbSopenharmony_ci     */
281885b47fbSopenharmony_ci    void CancelAllPenddingEvent();
282885b47fbSopenharmony_ci
283885b47fbSopenharmony_ci    /**
284885b47fbSopenharmony_ci     * @brief Cancel the multi gesture recognize process.
285885b47fbSopenharmony_ci     * @param isNoDelayFlag if gesture cancel event is immediately processed.
286885b47fbSopenharmony_ci     */
287885b47fbSopenharmony_ci    void CancelGesture(const bool isNoDelayFlag);
288885b47fbSopenharmony_ci
289885b47fbSopenharmony_ci    /**
290885b47fbSopenharmony_ci     * @brief param check for two finger Double tap recognize gesture.
291885b47fbSopenharmony_ci     * @param fingerNum the touch event from Multimodal.
292885b47fbSopenharmony_ci     * @return true if the used param is ok, else false.
293885b47fbSopenharmony_ci     */
294885b47fbSopenharmony_ci    bool ParamCheck(const int32_t fingerNum);
295885b47fbSopenharmony_ci
296885b47fbSopenharmony_ci    /**
297885b47fbSopenharmony_ci     * @brief Get the last touch up time of the first finger.
298885b47fbSopenharmony_ci     * @param fingerNum total touch down finger nums, means the lastUpPoint_ size.
299885b47fbSopenharmony_ci     * @return the first finger's last touch up time.
300885b47fbSopenharmony_ci     */
301885b47fbSopenharmony_ci    int64_t GetLastFirstPointUpTime(const int32_t fingerNum);
302885b47fbSopenharmony_ci
303885b47fbSopenharmony_ci    /**
304885b47fbSopenharmony_ci     * @brief Get the current and pre PointerItems with fingerNum, store in curPoints and prePoints.
305885b47fbSopenharmony_ci     * @param curPoints to store the cur touch event pointerItems rst, size is fingerNum.
306885b47fbSopenharmony_ci     * @param prePoints to store the pre touch event pointerItems rst, size is fingerNum.
307885b47fbSopenharmony_ci     * @param event current touch event, to get the curPoints.
308885b47fbSopenharmony_ci     * @param prePointsEventInfo pre touch Event storage, to get the prePoints.
309885b47fbSopenharmony_ci     * @return true if the get rst is ok, else false.
310885b47fbSopenharmony_ci     */
311885b47fbSopenharmony_ci    bool GetPointerItemWithFingerNum(int32_t fingerNum, std::vector<MMI::PointerEvent::PointerItem> &curPoints,
312885b47fbSopenharmony_ci        std::vector<MMI::PointerEvent::PointerItem> &prePoints, MMI::PointerEvent &event,
313885b47fbSopenharmony_ci        std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> &prePointsEventInfo);
314885b47fbSopenharmony_ci
315885b47fbSopenharmony_ci    /**
316885b47fbSopenharmony_ci     * @brief check whether the two taps offset is less than slop threshold.
317885b47fbSopenharmony_ci     * @param fingerNum touch down finger nums to be processed.
318885b47fbSopenharmony_ci     * @param curPoints current touch down pointer infos, size is fingerNum.
319885b47fbSopenharmony_ci     * @param prePoints first round touch down pointer infos, size is fingfingerNumerNums.
320885b47fbSopenharmony_ci     * @return true if the offset of two taps is less than slop threshold, else false.
321885b47fbSopenharmony_ci     */
322885b47fbSopenharmony_ci    bool IsDoubelTapSlopConditionMatch(const int32_t fingerNum,
323885b47fbSopenharmony_ci        const std::vector<MMI::PointerEvent::PointerItem> &curPoints,
324885b47fbSopenharmony_ci        const std::vector<MMI::PointerEvent::PointerItem> &prePoints);
325885b47fbSopenharmony_ci
326885b47fbSopenharmony_ci    /**
327885b47fbSopenharmony_ci     * @brief Determine whether it is a multi finger double tap gesture.
328885b47fbSopenharmony_ci     * @param event the touch event from Multimodal.
329885b47fbSopenharmony_ci     * @param fingerNum the target fingerNum to be processed.
330885b47fbSopenharmony_ci     * @return true if the gesture is multi finger double tap, else false.
331885b47fbSopenharmony_ci     */
332885b47fbSopenharmony_ci    bool IsMultiFingerDoubleTap(MMI::PointerEvent &event, const int32_t fingerNum);
333885b47fbSopenharmony_ci
334885b47fbSopenharmony_ci    /**
335885b47fbSopenharmony_ci     * @brief save touch down point event info.
336885b47fbSopenharmony_ci     */
337885b47fbSopenharmony_ci    void storeBaseDownPoint();
338885b47fbSopenharmony_ci
339885b47fbSopenharmony_ci    /**
340885b47fbSopenharmony_ci     * @brief Get move direction by move distance.
341885b47fbSopenharmony_ci     * @param dx the x axis distance between base point and current point.
342885b47fbSopenharmony_ci     * @param dy the y axis distance between base point and current point.
343885b47fbSopenharmony_ci     * @return the move direction, value range is MoveGirectionType.
344885b47fbSopenharmony_ci     */
345885b47fbSopenharmony_ci    int32_t GetSwipeDirection(const int32_t dx, const int32_t dy);
346885b47fbSopenharmony_ci
347885b47fbSopenharmony_ci    /**
348885b47fbSopenharmony_ci     * @brief Get the base point Item info by point Id.
349885b47fbSopenharmony_ci     * @param basePointerIterm to save th base pointItem info.
350885b47fbSopenharmony_ci     * @param pId the point Id to get the pointItem.
351885b47fbSopenharmony_ci     * @param pointInfo the touch down event point info storage.
352885b47fbSopenharmony_ci     * @return true if get base pointItem success, else false.
353885b47fbSopenharmony_ci     */
354885b47fbSopenharmony_ci    bool GetBasePointItem(MMI::PointerEvent::PointerItem &basePointerIterm,
355885b47fbSopenharmony_ci        int32_t pId, std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> &pointInfo);
356885b47fbSopenharmony_ci
357885b47fbSopenharmony_ci    /**
358885b47fbSopenharmony_ci     * @brief Save move gesture path info.
359885b47fbSopenharmony_ci     * @param event the touch event to be handled.
360885b47fbSopenharmony_ci     * @param pId the point Id to be handled.
361885b47fbSopenharmony_ci     * @param pointerIterm the point Item info to be saved.
362885b47fbSopenharmony_ci     * @param dx the x axis distance between base point and current point.
363885b47fbSopenharmony_ci     * @param dy the y axis distance between base point and current point.
364885b47fbSopenharmony_ci     */
365885b47fbSopenharmony_ci    void SaveMoveGesturePointerInfo(MMI::PointerEvent &event,
366885b47fbSopenharmony_ci        const int32_t pId, const MMI::PointerEvent::PointerItem &pointerIterm, const int32_t dx, const int32_t dy);
367885b47fbSopenharmony_ci
368885b47fbSopenharmony_ci    /**
369885b47fbSopenharmony_ci     * @brief recognize the move path is correct and match a move gesture.
370885b47fbSopenharmony_ci     * @param path move path pointer info storage.
371885b47fbSopenharmony_ci     * @return true if the move path is correct and match a move gesture, else false.
372885b47fbSopenharmony_ci     */
373885b47fbSopenharmony_ci    bool recognizeGesturePath(const std::vector<Pointer> &path);
374885b47fbSopenharmony_ci
375885b47fbSopenharmony_ci    /**
376885b47fbSopenharmony_ci     * @brief Get the matched move gesture by moveDirection and fingerNum.
377885b47fbSopenharmony_ci     * @return the matched gesture Id.
378885b47fbSopenharmony_ci     */
379885b47fbSopenharmony_ci    GestureType GetMoveGestureId();
380885b47fbSopenharmony_ci
381885b47fbSopenharmony_ci    /**
382885b47fbSopenharmony_ci     * @brief whether the multi finger move event match a move gesture.
383885b47fbSopenharmony_ci     * @return true if multi finger move event match a move gesture, else false.
384885b47fbSopenharmony_ci     */
385885b47fbSopenharmony_ci    bool IsMoveGestureRecognize();
386885b47fbSopenharmony_ci
387885b47fbSopenharmony_ci    /**
388885b47fbSopenharmony_ci     * @brief Save move gesture path info when finger up.
389885b47fbSopenharmony_ci     * @param event the touch event to be handled.
390885b47fbSopenharmony_ci     */
391885b47fbSopenharmony_ci    void StoreUpPointInPointerRoute(MMI::PointerEvent &event);
392885b47fbSopenharmony_ci
393885b47fbSopenharmony_ci    /**
394885b47fbSopenharmony_ci     * @brief Handle the first touch down event.
395885b47fbSopenharmony_ci     * @param event the touch event to be handled.
396885b47fbSopenharmony_ci     */
397885b47fbSopenharmony_ci    void HanleFirstTouchDownEvent(MMI::PointerEvent &event);
398885b47fbSopenharmony_ci
399885b47fbSopenharmony_ci    /**
400885b47fbSopenharmony_ci     * @brief Handle the continue touch down event.
401885b47fbSopenharmony_ci     * @param event the touch event to be handled.
402885b47fbSopenharmony_ci     */
403885b47fbSopenharmony_ci    void HandleContinueTouchDownEvent(MMI::PointerEvent &event);
404885b47fbSopenharmony_ci
405885b47fbSopenharmony_ci    /**
406885b47fbSopenharmony_ci     * @brief Handle the multi finger touch move event.
407885b47fbSopenharmony_ci     * @param event the touch event to be handled.
408885b47fbSopenharmony_ci     */
409885b47fbSopenharmony_ci    void HandleMultiFingerMoveEvent(MMI::PointerEvent &event);
410885b47fbSopenharmony_ci
411885b47fbSopenharmony_ci    /**
412885b47fbSopenharmony_ci     * @brief Handle the touch up event, not a move gesture.
413885b47fbSopenharmony_ci     * @param event the touch event to be handled.
414885b47fbSopenharmony_ci     */
415885b47fbSopenharmony_ci    void HandleMultiFingerTouchUpEvent(MMI::PointerEvent &event);
416885b47fbSopenharmony_ci
417885b47fbSopenharmony_ci    /**
418885b47fbSopenharmony_ci     * @brief Handle the continue touch down event, decide whether it is a multi tap event.
419885b47fbSopenharmony_ci     * @param event the touch event to be handled.
420885b47fbSopenharmony_ci     * @param fingerNum the touch down fingerNum to be handled.
421885b47fbSopenharmony_ci     */
422885b47fbSopenharmony_ci    void HandleMultiTapEvent(MMI::PointerEvent &event, const int32_t fingerNum);
423885b47fbSopenharmony_ci
424885b47fbSopenharmony_ci    float touchSlop_ = 0.0f;
425885b47fbSopenharmony_ci    int32_t doubleTapOffsetThresh_ = 0;
426885b47fbSopenharmony_ci    int32_t targetFingers_ = -1; // touch down finger numbers before first time the finger touch up
427885b47fbSopenharmony_ci    uint32_t addContinueTapNum_ = 0; // total number of touch down, except the first touch down
428885b47fbSopenharmony_ci    int32_t multiFingerGestureState_ = 0; // recognize state, value is MultiFingerGestureState
429885b47fbSopenharmony_ci    int32_t fingerTouchUpState_ = FingerTouchUpState::ALL_FINGER_TOUCH_UP;
430885b47fbSopenharmony_ci    bool isFirstUp_ = 0; // whether the first time finger touch up
431885b47fbSopenharmony_ci    bool isMoveGestureRecognizing = false; // in move gesture recognize process or not
432885b47fbSopenharmony_ci    int32_t moveDirection = -1;
433885b47fbSopenharmony_ci    float mMinPixelsBetweenSamplesX_ = 0;
434885b47fbSopenharmony_ci    float mMinPixelsBetweenSamplesY_ = 0;
435885b47fbSopenharmony_ci
436885b47fbSopenharmony_ci    std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> firstDownPoint_; // first round touch down points
437885b47fbSopenharmony_ci    std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> currentDownPoint_; // current round touch down points
438885b47fbSopenharmony_ci    std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> preGesturePoint_; // pre move event points
439885b47fbSopenharmony_ci    std::map<int32_t, std::shared_ptr<MMI::PointerEvent>> lastUpPoint_; // last time finger touch up points
440885b47fbSopenharmony_ci    std::map<int32_t, std::vector<Pointer>> pointerRoute_;
441885b47fbSopenharmony_ci
442885b47fbSopenharmony_ci    AccessibilityGestureRecognizeListener *listener_ = nullptr;
443885b47fbSopenharmony_ci    std::shared_ptr<MultiFingerGestureHandler> handler_ = nullptr; // multi finger gesture recognize event handler
444885b47fbSopenharmony_ci    std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
445885b47fbSopenharmony_ci};
446885b47fbSopenharmony_ci} // namespace Accessibility
447885b47fbSopenharmony_ci} // namespace OHOS
448885b47fbSopenharmony_ci#endif // ACCESSIBILITY_MULTIFINGER_MULTITAP_H