1 /*
2  * Copyright (c) 2021-2024 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 POINTER_EVENT_H
17 #define POINTER_EVENT_H
18 
19 #include <array>
20 #include <list>
21 #include <memory>
22 #include <set>
23 #include <unordered_map>
24 #include <vector>
25 
26 #include "nocopyable.h"
27 #include "parcel.h"
28 
29 #include "input_event.h"
30 #include "input_handler_type.h"
31 
32 namespace OHOS {
33 namespace MMI {
34 class PointerEvent : public InputEvent {
35 public:
36     /**
37      * Indicates an unknown pointer action. It is usually used as initial value.
38      *
39      * @since 9
40      */
41     static constexpr int32_t POINTER_ACTION_UNKNOWN = 0;
42 
43     /**
44      * Indicates a pointer action that has been canceled.
45      *
46      * @since 9
47      */
48     static constexpr int32_t POINTER_ACTION_CANCEL = 1;
49 
50     /**
51      * Indicates a pointer action representing that a finger is pressed on a touchscreen or touchpad.
52      *
53      * @since 9
54      */
55     static constexpr int32_t POINTER_ACTION_DOWN = 2;
56 
57     /**
58      * Indicates a pointer action representing that a finger moves on a touchscreen or touchpad or a mouse
59      * pointer moves.
60      *
61      * @since 9
62      */
63     static constexpr int32_t POINTER_ACTION_MOVE = 3;
64 
65     /**
66      * Indicates a pointer action representing that a finger leaves the touchscreen or touchpad.
67      *
68      * @since 9
69      */
70     static constexpr int32_t POINTER_ACTION_UP = 4;
71 
72     /**
73      * Indicates the start action of the axis event related to the pointer.
74      *
75      * @since 9
76      */
77     static constexpr int32_t POINTER_ACTION_AXIS_BEGIN = 5;
78 
79     /**
80      * Indicates the update action of the axis event related to the pointer.
81      *
82      * @since 9
83      */
84     static constexpr int32_t POINTER_ACTION_AXIS_UPDATE = 6;
85 
86     /**
87      * Indicates the end action of the axis event related to the pointer.
88      *
89      * @since 9
90      */
91     static constexpr int32_t POINTER_ACTION_AXIS_END = 7;
92 
93     /**
94      * Indicates a pointer action representing that a button is pressed.
95      *
96      * @since 9
97      */
98     static constexpr int32_t POINTER_ACTION_BUTTON_DOWN = 8;
99 
100     /**
101      * Indicates a pointer action representing that a button is released.
102      *
103      * @since 9
104      */
105     static constexpr int32_t POINTER_ACTION_BUTTON_UP = 9;
106 
107     /**
108      * Indicates that the pointer enters the window.
109      *
110      * @since 9
111      */
112     static constexpr int32_t POINTER_ACTION_ENTER_WINDOW = 10;
113 
114     /**
115      * Indicates that the pointer leaves the window.
116      *
117      * @since 9
118      */
119     static constexpr int32_t POINTER_ACTION_LEAVE_WINDOW = 11;
120 
121     static constexpr int32_t POINTER_ACTION_PULL_DOWN = 12;
122 
123     static constexpr int32_t POINTER_ACTION_PULL_MOVE = 13;
124 
125     static constexpr int32_t POINTER_ACTION_PULL_UP = 14;
126 
127     static constexpr int32_t POINTER_ACTION_PULL_IN_WINDOW = 15;
128 
129     static constexpr int32_t POINTER_ACTION_PULL_OUT_WINDOW = 16;
130 
131     /**
132      * Indicates that the fingers swipe up in touch pad.
133      *
134      * @since 9
135      */
136     static constexpr int32_t POINTER_ACTION_SWIPE_BEGIN = 17;
137 
138     static constexpr int32_t POINTER_ACTION_SWIPE_UPDATE = 18;
139 
140     static constexpr int32_t POINTER_ACTION_SWIPE_END = 19;
141 
142     /**
143      * Indicates that the fingers rotate in touch pad.
144      *
145      * @since 11
146      */
147     static constexpr int32_t POINTER_ACTION_ROTATE_BEGIN = 20;
148 
149     static constexpr int32_t POINTER_ACTION_ROTATE_UPDATE = 21;
150 
151     static constexpr int32_t POINTER_ACTION_ROTATE_END = 22;
152 
153     static constexpr int32_t POINTER_ACTION_TRIPTAP = 23;
154 
155     static constexpr int32_t POINTER_ACTION_QUADTAP = 24;
156 
157     /**
158      * Indicates that the hover action.
159      *
160      * @since 11
161      */
162     static constexpr int32_t POINTER_ACTION_HOVER_MOVE = 25;
163 
164     static constexpr int32_t POINTER_ACTION_HOVER_ENTER = 26;
165 
166     static constexpr int32_t POINTER_ACTION_HOVER_EXIT = 27;
167 
168     /**
169      * Indicates that the fingerprint action.
170      *
171      * @since 12
172      */
173     static constexpr int32_t POINTER_ACTION_FINGERPRINT_DOWN = 28;
174 
175     static constexpr int32_t POINTER_ACTION_FINGERPRINT_UP = 29;
176 
177     static constexpr int32_t POINTER_ACTION_FINGERPRINT_SLIDE = 30;
178 
179     static constexpr int32_t POINTER_ACTION_FINGERPRINT_RETOUCH = 31;
180 
181     static constexpr int32_t POINTER_ACTION_FINGERPRINT_CLICK = 32;
182 
183     static constexpr int32_t POINTER_ACTION_FINGERPRINT_CANCEL = 34;
184 
185     static constexpr int32_t POINTER_ACTION_HOVER_CANCEL = 33;
186 
187     /**
188      * Indicates that the pen proximity action.
189      *
190      * @since 12
191      */
192     static constexpr int32_t POINTER_ACTION_PROXIMITY_IN = 35;
193 
194     static constexpr int32_t POINTER_ACTION_PROXIMITY_OUT = 36;
195 
196     static constexpr int32_t POINTER_ACTION_PULL_CANCEL = 37;
197 
198     enum AxisType {
199         /**
200          * Indicates an unknown axis type. It is generally used as the initial value.
201          *
202          * @since 9
203          */
204         AXIS_TYPE_UNKNOWN,
205 
206         /**
207          * Indicates the vertical scroll axis. When you scroll the mouse wheel or make certain gestures on the touchpad,
208          * the status of the vertical scroll axis changes.
209          *
210          * @since 9
211          */
212         AXIS_TYPE_SCROLL_VERTICAL,
213 
214         /**
215          * Indicates the horizontal scroll axis.
216          * When you scroll the mouse wheel or make certain gestures on the touchpad,
217          * the status of the horizontal scroll axis changes.
218          *
219          * @since 9
220          */
221         AXIS_TYPE_SCROLL_HORIZONTAL,
222 
223         /**
224          * Indicates the pinch axis, which is used to describe a pinch gesture on the touchscreen or touchpad.
225          *
226          * @since 9
227          */
228         AXIS_TYPE_PINCH,
229 
230         /**
231          * Indicates the rotate axis, which is used to describe a rotate gesture on the touchpad.
232          *
233          * @since 11
234          */
235         AXIS_TYPE_ROTATE,
236 
237         /**
238          * Indicates the x axis. The status of the x axis changes when you operate the joystick.
239          *
240          * @since 9
241          */
242         AXIS_TYPE_ABS_X,
243 
244         /**
245          * Indicates the y axis. The status of the y axis changes when you operate the joystick.
246          *
247          * @since 9
248          */
249         AXIS_TYPE_ABS_Y,
250 
251         /**
252          * Indicates the z axis. The status of the z axis changes when you operate the joystick.
253          *
254          * @since 9
255          */
256         AXIS_TYPE_ABS_Z,
257 
258         /**
259          * Indicates the rz axis. The status of the rz axis changes when you operate the joystick.
260          *
261          * @since 9
262          */
263         AXIS_TYPE_ABS_RZ,
264 
265         /**
266          * Indicates the gas axis. The status of the gas axis changes when you operate the joystick.
267          *
268          * @since 9
269          */
270         AXIS_TYPE_ABS_GAS,
271 
272         /**
273          * Indicates the brake axis. The status of the brake axis changes when you operate the joystick.
274          *
275          * @since 9
276          */
277         AXIS_TYPE_ABS_BRAKE,
278 
279         /**
280          * Indicates the hat0x axis. The status of the hat0x axis changes when you operate the joystick.
281          *
282          * @since 9
283          */
284         AXIS_TYPE_ABS_HAT0X,
285 
286         /**
287          * Indicates the hat0y axis. The status of the hat0y axis changes when you operate the joystick.
288          *
289          * @since 9
290          */
291         AXIS_TYPE_ABS_HAT0Y,
292 
293         /**
294          * Indicates the throttle axis. The status of the throttle axis changes when you operate the joystick.
295          *
296          * @since 9
297          */
298         AXIS_TYPE_ABS_THROTTLE,
299 
300         /**
301          * Indicates the maximum number of defined axis types.
302          *
303          * @since 9
304          */
305         AXIS_TYPE_MAX
306     };
307 
308     /**
309      * Indicates an unknown input source type. It is usually used as the initial value.
310      *
311      * @since 9
312      */
313     static constexpr int32_t SOURCE_TYPE_UNKNOWN = 0;
314 
315     /**
316      * Indicates that the input source generates events similar to mouse cursor movement,
317      * button press and release, and wheel scrolling.
318      *
319      * @since 9
320      */
321     static constexpr int32_t SOURCE_TYPE_MOUSE = 1;
322 
323     /**
324      * Indicates that the input source generates a touchscreen multi-touch event.
325      *
326      * @since 9
327      */
328     static constexpr int32_t SOURCE_TYPE_TOUCHSCREEN = 2;
329 
330     /**
331      * Indicates that the input source generates a touchpad multi-touch event.
332      *
333      * @since 9
334      */
335     static constexpr int32_t SOURCE_TYPE_TOUCHPAD = 3;
336 
337     /**
338      * Indicates joystick-like events generated by the input source, such as button pressing, button lifting,
339      * and wheel scrolling.
340      *
341      * @since 9
342      */
343     static constexpr int32_t SOURCE_TYPE_JOYSTICK = 4;
344 
345     /**
346      * Indicates that the input source generates a fingerprint event.
347      *
348      * @since 12
349      */
350     static constexpr int32_t SOURCE_TYPE_FINGERPRINT = 5;
351 
352     /**
353      * Indicates that the input source generates a crown event.
354      *
355      * @since 12
356      */
357     static constexpr int32_t SOURCE_TYPE_CROWN = 6;
358 
359     /**
360      * Indicates an invalid button ID.
361      *
362      * @since 9
363      */
364     static constexpr int32_t BUTTON_NONE = -1;
365 
366     /**
367      * Indicates the left button on a mouse.
368      *
369      * @since 9
370      */
371     static constexpr int32_t MOUSE_BUTTON_LEFT = 0;
372 
373     /**
374      * Indicates the right button on a mouse.
375      *
376      * @since 9
377      */
378     static constexpr int32_t MOUSE_BUTTON_RIGHT = 1;
379 
380     /**
381      * Indicates the middle button on a mouse.
382      *
383      * @since 9
384      */
385     static constexpr int32_t MOUSE_BUTTON_MIDDLE = 2;
386 
387     /**
388      * Indicates the side button on a mouse.
389      *
390      * @since 9
391      */
392     static constexpr int32_t MOUSE_BUTTON_SIDE = 3;
393 
394     /**
395      * Indicates the extra button on a mouse.
396      *
397      * @since 9
398      */
399     static constexpr int32_t MOUSE_BUTTON_EXTRA = 4;
400 
401     /**
402      * Indicates the forward button on a mouse.
403      *
404      * @since 9
405      */
406     static constexpr int32_t MOUSE_BUTTON_FORWARD = 5;
407 
408     /**
409      * Indicates the back button on a mouse.
410      *
411      * @since 9
412      */
413     static constexpr int32_t MOUSE_BUTTON_BACK = 6;
414 
415     /**
416      * Indicates the task button on a mouse.
417      *
418      * @since 9
419      */
420     static constexpr int32_t MOUSE_BUTTON_TASK = 7;
421 
422     /**
423      * Indicates a finger.
424      *
425      * @since 9
426      */
427     static constexpr int32_t TOOL_TYPE_FINGER = 0;
428 
429     /**
430      * Indicates a stylus.
431      *
432      * @since 9
433      */
434     static constexpr int32_t TOOL_TYPE_PEN = 1;
435 
436     /**
437      * Indicates an eraser.
438      *
439      * @since 9
440      */
441     static constexpr int32_t TOOL_TYPE_RUBBER = 2;
442 
443     /**
444      * Indicates a brush.
445      *
446      * @since 9
447      */
448     static constexpr int32_t TOOL_TYPE_BRUSH = 3;
449 
450     /**
451      * Indicates a pencil.
452      *
453      * @since 9
454      */
455     static constexpr int32_t TOOL_TYPE_PENCIL = 4;
456 
457     /**
458      * Indicates an air brush.
459      *
460      * @since 9
461      */
462     static constexpr int32_t TOOL_TYPE_AIRBRUSH = 5;
463 
464     /**
465      * Indicates a mouse.
466      *
467      * @since 9
468      */
469     static constexpr int32_t TOOL_TYPE_MOUSE = 6;
470 
471     /**
472      * Indicates a lens.
473      *
474      * @since 9
475      */
476     static constexpr int32_t TOOL_TYPE_LENS = 7;
477 
478     /**
479      * Indicates a knuckle.
480      *
481      * @since 11
482      */
483     static constexpr int32_t TOOL_TYPE_KNUCKLE = 8;
484 
485     /**
486      * Indicates a touchpad.
487      *
488      * @since 9
489      */
490     static constexpr int32_t TOOL_TYPE_TOUCHPAD = 9;
491 
492     /**
493      * Indicates a palm.
494      *
495      * @since 10
496      */
497     static constexpr int32_t TOOL_TYPE_PALM = 10;
498 
499     /**
500      * Indicates the TL2 key on the joystick.
501      *
502      * @since 9
503      */
504     static constexpr int32_t JOYSTICK_BUTTON_TL2 = 0;
505 
506     /**
507      * Indicates the TR2 key on the joystick.
508      *
509      * @since 9
510      */
511     static constexpr int32_t JOYSTICK_BUTTON_TR2 = 1;
512 
513     /**
514      * Indicates the TL key on the joystick.
515      *
516      * @since 9
517      */
518     static constexpr int32_t JOYSTICK_BUTTON_TL = 2;
519 
520     /**
521      * Indicates the TR key on the joystick.
522      *
523      * @since 9
524      */
525     static constexpr int32_t JOYSTICK_BUTTON_TR = 3;
526 
527     /**
528      * Indicates the WEST key on the joystick.
529      *
530      * @since 9
531      */
532     static constexpr int32_t JOYSTICK_BUTTON_WEST = 4;
533 
534     /**
535      * Indicates the SOUTH key on the joystick.
536      *
537      * @since 9
538      */
539     static constexpr int32_t JOYSTICK_BUTTON_SOUTH = 5;
540 
541     /**
542      * Indicates the NORTH key on the joystick.
543      *
544      * @since 9
545      */
546     static constexpr int32_t JOYSTICK_BUTTON_NORTH = 6;
547 
548     /**
549      * Indicates the EAST key on the joystick.
550      *
551      * @since 9
552      */
553     static constexpr int32_t JOYSTICK_BUTTON_EAST = 7;
554 
555     /**
556      * Indicates the START key on the joystick.
557      *
558      * @since 9
559      */
560     static constexpr int32_t JOYSTICK_BUTTON_START = 8;
561 
562     /**
563      * Indicates the SELECT key on the joystick.
564      *
565      * @since 9
566      */
567     static constexpr int32_t JOYSTICK_BUTTON_SELECT = 9;
568 
569     /**
570      * Indicates the HOMEPAGE key on the joystick.
571      *
572      * @since 9
573      */
574     static constexpr int32_t JOYSTICK_BUTTON_HOMEPAGE = 10;
575 
576     /**
577      * Indicates the THUMBL key on the joystick.
578      *
579      * @since 9
580      */
581     static constexpr int32_t JOYSTICK_BUTTON_THUMBL = 11;
582 
583     /**
584      * Indicates the THUMBR key on the joystick.
585      *
586      * @since 9
587      */
588     static constexpr int32_t JOYSTICK_BUTTON_THUMBR = 12;
589 
590     /**
591      * Indicates the TRIGGER key on the joystick.
592      *
593      * @since 9
594      */
595     static constexpr int32_t JOYSTICK_BUTTON_TRIGGER = 13;
596 
597     /**
598      * Indicates the THUMB key on the joystick.
599      *
600      * @since 9
601      */
602     static constexpr int32_t JOYSTICK_BUTTON_THUMB = 14;
603 
604     /**
605      * Indicates the THUMB2 key on the joystick.
606      *
607      * @since 9
608      */
609     static constexpr int32_t JOYSTICK_BUTTON_THUMB2 = 15;
610 
611     /**
612      * Indicates the TOP key on the joystick.
613      *
614      * @since 9
615      */
616     static constexpr int32_t JOYSTICK_BUTTON_TOP = 16;
617 
618     /**
619      * Indicates the TOP2 key on the joystick.
620      *
621      * @since 9
622      */
623     static constexpr int32_t JOYSTICK_BUTTON_TOP2 = 17;
624 
625     /**
626      * Indicates the PINKIE key on the joystick.
627      *
628      * @since 9
629      */
630     static constexpr int32_t JOYSTICK_BUTTON_PINKIE = 18;
631 
632     /**
633      * Indicates the BASE key on the joystick.
634      *
635      * @since 9
636      */
637     static constexpr int32_t JOYSTICK_BUTTON_BASE = 19;
638 
639     /**
640      * Indicates the BASE2 key on the joystick.
641      *
642      * @since 9
643      */
644     static constexpr int32_t JOYSTICK_BUTTON_BASE2 = 20;
645 
646     /**
647      * Indicates the BASE3 key on the joystick.
648      *
649      * @since 9
650      */
651     static constexpr int32_t JOYSTICK_BUTTON_BASE3 = 21;
652 
653     /**
654      * Indicates the BASE4 key on the joystick.
655      *
656      * @since 9
657      */
658     static constexpr int32_t JOYSTICK_BUTTON_BASE4 = 22;
659 
660     /**
661      * Indicates the BASE5 key on the joystick.
662      *
663      * @since 9
664      */
665     static constexpr int32_t JOYSTICK_BUTTON_BASE5 = 23;
666 
667     /**
668      * Indicates the BASE6 key on the joystick.
669      *
670      * @since 9
671      */
672     static constexpr int32_t JOYSTICK_BUTTON_BASE6 = 24;
673 
674     /**
675      * Indicates the DEAD key on the joystick.
676      *
677      * @since 9
678      */
679     static constexpr int32_t JOYSTICK_BUTTON_DEAD = 25;
680 
681     /**
682      * Indicates the C key on the joystick.
683      *
684      * @since 9
685      */
686     static constexpr int32_t JOYSTICK_BUTTON_C = 26;
687 
688     /**
689      * Indicates the Z key on the joystick.
690      *
691      * @since 9
692      */
693     static constexpr int32_t JOYSTICK_BUTTON_Z = 27;
694 
695     /**
696      * Indicates the MODE key on the joystick.
697      *
698      * @since 9
699      */
700     static constexpr int32_t JOYSTICK_BUTTON_MODE = 28;
701 
702     enum AxisEventType {
703         /**
704          * Indicates an unknown axis events.
705          *
706          * @since 12
707          */
708         AXIS_EVENT_TYPE_UNKNOWN = -1,
709         /**
710          * Indicates two-finger pinch events. The axis value can be AXIS_TYPE_PINCH or AXIS_TYPE_ROTATE.
711          *
712          * @since 12
713          */
714         AXIS_EVENT_TYPE_PINCH = 1,
715         /**
716          * Indicates scroll axis events. The axis value can be AXIS_TYPE_SCROLL_VERTICAL or AXIS_TYPE_SCROLL_HORIZONTAL.
717          * Wherein, the value of AXIS_TYPE_SCROLL_HORIZONTAL is 0 for a mouse wheel event.
718          *
719          * @since 12
720          */
721         AXIS_EVENT_TYPE_SCROLL = 2,
722     };
723 public:
724     static std::shared_ptr<PointerEvent> from(std::shared_ptr<InputEvent> inputEvent);
725 
726 public:
727     class PointerItem {
728     public:
729         PointerItem();
730         ~PointerItem();
731 
732     public:
733         /**
734          * @brief Obtains the ID of the pointer in this event.
735          * @return Returns the pointer ID.
736          * @since 9
737          */
738         int32_t GetPointerId() const;
739 
740         /**
741          * @brief Sets the ID of the pointer in this event.
742          * @param pointerId Indicates the pointer ID to set.
743          * @return void
744          * @since 9
745          */
746         void SetPointerId(int32_t pointerId);
747 
748         /**
749          * @brief Obtains the origin id of the pointer in this event.
750          * @return Returns the pointer id.
751          * @since 12
752          */
753         int32_t GetOriginPointerId() const;
754 
755         /**
756          * @brief Sets the origin id of the pointer in this event.
757          * @param pointerId Indicates the pointer id to set.
758          * @return void
759          * @since 12
760          */
761         void SetOriginPointerId(int32_t originPointerId);
762 
763         /**
764          * @brief Obtains the time when the pointer is pressed.
765          * @return Returns the time.
766          * @since 9
767          */
768         int64_t GetDownTime() const;
769 
770         /**
771          * @brief Sets the time when the pointer is pressed.
772          * @param downTime Indicates the time to set.
773          * @return void
774          * @since 9
775          */
776         void SetDownTime(int64_t downTime);
777 
778         /**
779          * @brief Checks whether the pointer is pressed.
780          * @return Returns <b>true</b> if the pointer is pressed; returns <b>false</b> otherwise.
781          * @since 9
782          */
783         bool IsPressed() const;
784 
785         /**
786          * @brief Sets whether to enable the pressed state for the pointer.
787          * @param pressed Specifies whether to set the pressed state for the pointer.
788          * The value <b>true</b> means to set the pressed state for the pointer, and the
789          * value <b>false</b> means the opposite.
790          * @return void
791          * @since 9
792          */
793         void SetPressed(bool pressed);
794 
795         /**
796          * @brief Obtains the x coordinate relative to the upper left corner of the screen.
797          * For a touchpad input event, the value is the absolute x coordinate on the touchpad.
798          * For other pointer input events, the value is the x coordinate on the target screen.
799          * @return Returns the x coordinate.
800          * @since 9
801          */
802         int32_t GetDisplayX() const;
803 
804         /**
805          * @brief Obtains the x coordinate relative to the upper left corner of the screen.
806          * For a touchpad input event, the value is the absolute x coordinate on the touchpad.
807          * For other pointer input events, the value is the x coordinate on the target screen.
808          * @return Returns the x coordinate.
809          * @since 9
810          */
811         double GetDisplayXPos() const;
812 
813         /**
814          * @brief Sets the x coordinate relative to the upper left corner of the screen.
815          * @param displayX Indicates the x coordinate to set.
816          * @return void
817          * @since 9
818          */
819         void SetDisplayX(int32_t displayX);
820 
821         /**
822          * @brief Sets the x coordinate relative to the upper left corner of the screen.
823          * @param displayX Indicates the x coordinate to set.
824          * @return void
825          * @since 9
826          */
827         void SetDisplayXPos(double displayX);
828 
829         /**
830          * @brief Obtains the y coordinate relative to the upper left corner of the screen.
831          * For a touchpad input event, the value is the absolute y coordinate on the touchpad.
832          * For other pointer input events, the value is the y coordinate on the target screen.
833          * @return Returns the y coordinate.
834          * @since 9
835          */
836         int32_t GetDisplayY() const;
837 
838         /**
839          * @brief Obtains the y coordinate relative to the upper left corner of the screen.
840          * For a touchpad input event, the value is the absolute y coordinate on the touchpad.
841          * For other pointer input events, the value is the y coordinate on the target screen.
842          * @return Returns the y coordinate.
843          * @since 9
844          */
845         double GetDisplayYPos() const;
846 
847         /**
848          * @brief Sets the y coordinate relative to the upper left corner of the screen.
849          * @param displayY Indicates the y coordinate to set.
850          * @return void
851          * @since 9
852          */
853         void SetDisplayY(int32_t displayY);
854 
855         /**
856          * @brief Sets the y coordinate relative to the upper left corner of the screen.
857          * @param displayY Indicates the y coordinate to set.
858          * @return void
859          * @since 9
860          */
861         void SetDisplayYPos(double displayY);
862 
863         /**
864          * @brief Obtains the x coordinate of the active window.
865          * @return Returns the x coordinate.
866          * @since 9
867          */
868         int32_t GetWindowX() const;
869 
870         /**
871          * @brief Obtains the x coordinate of the active window.
872          * @return Returns the x coordinate.
873          * @since 9
874          */
875         double GetWindowXPos() const;
876 
877         /**
878          * @brief Sets the x coordinate of the active window.
879          * @param x Indicates the x coordinate to set.
880          * @return void
881          * @since 9
882          */
883         void SetWindowX(int32_t x);
884 
885         /**
886          * @brief Sets the x coordinate of the active window.
887          * @param x Indicates the x coordinate to set.
888          * @return void
889          * @since 9
890          */
891         void SetWindowXPos(double x);
892 
893         /**
894          * @brief Obtains the y coordinate of the active window.
895          * @return Returns the y coordinate.
896          * @since 9
897          */
898         int32_t GetWindowY() const;
899 
900         /**
901          * @brief Obtains the y coordinate of the active window.
902          * @return Returns the y coordinate.
903          * @since 9
904          */
905         double GetWindowYPos() const;
906 
907         /**
908          * @brief Sets the y coordinate of the active window.
909          * @param y Indicates the y coordinate to set.
910          * @return void
911          * @since 9
912          */
913         void SetWindowY(int32_t y);
914 
915         /**
916          * @brief Sets the y coordinate of the active window.
917          * @param y Indicates the y coordinate to set.
918          * @return void
919          * @since 9
920          */
921         void SetWindowYPos(double y);
922 
923         /**
924          * @brief Obtains the width of the pressed area.
925          * @return Returns the width.
926          * @since 9
927          */
928         int32_t GetWidth() const;
929 
930         /**
931          * @brief Sets the width of the pressed area.
932          * @param width Indicates the width to set.
933          * @return void
934          * @since 9
935          */
936         void SetWidth(int32_t width);
937 
938         /**
939          * @brief Obtains the height of the pressed area.
940          * @return Returns the height.
941          * @since 9
942          */
943         int32_t GetHeight() const;
944 
945         /**
946          * @brief Sets the height of the pressed area.
947          * @param height Indicates the height to set.
948          * @return void
949          * @since 9
950          */
951         void SetHeight(int32_t height);
952 
953         /**
954          * @brief Obtains the X coordinate of the tool area's center point relative to the
955          * upper left corner of the screen.
956          * @return Returns the X coordinate.
957          * @since 9
958          */
959         int32_t GetToolDisplayX() const;
960 
961         /**
962          * @brief Sets the X coordinate of the tool area's center point relative to the
963          * upper left corner of the screen.
964          * @param x Indicates the X coordinate.
965          * @return void
966          * @since 9
967          */
968         void SetToolDisplayX(int32_t displayX);
969 
970         /**
971          * @brief Obtains the Y coordinate of the tool area's center point relative to the
972          * upper left corner of the screen.
973          * @return Returns the Y coordinate.
974          * @since 9
975          */
976         int32_t GetToolDisplayY() const;
977 
978         /**
979          * @brief Sets the Y coordinate of the tool area's center point relative to the
980          * upper left corner of the screen.
981          * @param y Indicates the Y coordinate.
982          * @return void
983          * @since 9
984          */
985         void SetToolDisplayY(int32_t displayY);
986 
987         /**
988          * @brief Obtains the X coordinate of the tool area's center point relative to the
989          * upper left corner of the window.
990          * @return Returns the X coordinate.
991          * @since 9
992          */
993         int32_t GetToolWindowX() const;
994 
995         /**
996          * @brief Sets the X coordinate of the tool area's center point relative to the
997          * upper left corner of the window.
998          * @param x Indicates the X coordinate.
999          * @return void
1000          * @since 9
1001          */
1002         void SetToolWindowX(int32_t x);
1003 
1004         /**
1005          * @brief Obtains the Y coordinate of the tool area's center point relative to the
1006          * upper left corner of the window.
1007          * @return Returns the Y coordinate.
1008          * @since 9
1009          */
1010         int32_t GetToolWindowY() const;
1011 
1012         /**
1013          * @brief Sets the Y coordinate of the tool area's center point relative to the
1014          * upper left corner of the window.
1015          * @param y Indicates the Y coordinate.
1016          * @return void
1017          * @since 9
1018          */
1019         void SetToolWindowY(int32_t y);
1020 
1021         /**
1022          * @brief Obtains the width of the tool area.
1023          * @return Returns the width of the tool area.
1024          * @since 9
1025          */
1026         int32_t GetToolWidth() const;
1027 
1028         /**
1029          * @brief Sets the width of the tool area.
1030          * @param width Indicates the width of the tool area.
1031          * @return void
1032          * @since 9
1033          */
1034         void SetToolWidth(int32_t width);
1035 
1036         /**
1037          * @brief Obtains the height of the tool area.
1038          * @return Returns the height of the tool area.
1039          * @since 9
1040          */
1041         int32_t GetToolHeight() const;
1042 
1043         /**
1044          * @brief Sets the height of the tool area.
1045          * @param height Indicates the height of the tool area.
1046          * @return void
1047          * @since 9
1048          */
1049         void SetToolHeight(int32_t height);
1050 
1051         /**
1052          * @brief Obtains the tilt angle of the x axis.
1053          * @return Returns the tilt angle of the x axis.
1054          * @since 9
1055          */
1056         double GetTiltX() const;
1057 
1058         /**
1059          * @brief Sets the tilt angle of the x axis.
1060          * @param tiltX Indicates the tilt angle to set.
1061          * @return void
1062          * @since 9
1063          */
1064         void SetTiltX(double tiltX);
1065 
1066         /**
1067          * @brief Obtains the tilt angle of the y axis.
1068          * @return Returns the tilt angle of the y axis.
1069          * @since 9
1070          */
1071         double GetTiltY() const;
1072 
1073         /**
1074          * @brief Sets the tilt angle of the y axis.
1075          * @param tiltY Indicates the tilt angle to set.
1076          * @return void
1077          * @since 9
1078          */
1079         void SetTiltY(double tiltY);
1080 
1081         /**
1082          * @brief Obtains the pressure in this event.
1083          * @return Returns the pressure.
1084          * @since 9
1085          */
1086         double GetPressure() const;
1087 
1088         /**
1089          * @brief Sets the pressure for this event.
1090          * @param pressure Indicates the pressure to set.
1091          * @return void
1092          * @since 9
1093          */
1094         void SetPressure(double pressure);
1095 
1096         /**
1097          * @brief Obtains the long axis of the touch point area.
1098          * @return Returns the long axis of the touch point area.
1099          * @since 9
1100          */
1101         int32_t GetLongAxis() const;
1102 
1103         /**
1104          * @brief Sets the long axis of the touch point area.
1105          * @param longAxis Indicates the long axis of the touch point area.
1106          * @return void
1107          * @since 9
1108          */
1109         void SetLongAxis(int32_t longAxis);
1110 
1111         /**
1112          * @brief Obtains the short axis of the touch point area.
1113          * @return Returns the short axis of the touch point area.
1114          * @since 9
1115          */
1116         int32_t GetShortAxis() const;
1117 
1118         /**
1119          * @brief Sets the short axis of the touch point area.
1120          * @param shortAxis Indicates the short axis of the touch point area.
1121          * @return void
1122          * @since 9
1123          */
1124         void SetShortAxis(int32_t shortAxis);
1125 
1126         /**
1127          * @brief Obtains the ID of the current device.
1128          * @return Returns the device ID.
1129          * @since 9
1130          */
1131         int32_t GetDeviceId() const;
1132 
1133         /**
1134          * @brief Sets the ID for the current device.
1135          * @param deviceId Indicates the device ID to set.
1136          * @return void
1137          * @since 9
1138          */
1139         void SetDeviceId(int32_t deviceId);
1140 
1141         /**
1142          * @brief Obtains the tool type.
1143          * @return Returns the tool type.
1144          * @since 9
1145          */
1146         int32_t GetToolType() const;
1147 
1148         /**
1149          * @brief Sets the tool type.
1150          * @param toolType Indicates the tool type to set.
1151          * @return void
1152          * @since 9
1153          */
1154         void SetToolType(int32_t toolType);
1155 
1156         /**
1157          * @brief Obtains the ID of the window corresponding to the finger touch position.
1158          * @return Returns the ID of the target window.
1159          * @since 9
1160          */
1161         int32_t GetTargetWindowId() const;
1162 
1163         /**
1164          * @brief Sets the ID of the window corresponding to the finger touch position.
1165          * @param windowId Indicates the ID of the target window.
1166          * @return void
1167          * @since 9
1168          */
1169         void SetTargetWindowId(int32_t windowId);
1170 
1171         /**
1172          * @brief Writes data to a <b>Parcel</b> object.
1173          * @param out Indicates the object into which data will be written.
1174          * @return Returns <b>true</b> if the data is successfully written; returns <b>false</b> otherwise.
1175          * @since 9
1176          */
1177         bool WriteToParcel(Parcel &out) const;
1178 
1179         /**
1180          * @brief Reads data from a <b>Parcel</b> object.
1181          * @param in Indicates the object from which data will be read.
1182          * @return Returns <b>true</b> if the data is successfully read; returns <b>false</b> otherwise.
1183          * @since 9
1184          */
1185         bool ReadFromParcel(Parcel &in);
1186 
1187         /**
1188          * @brief Obtains the raw X coordinate.
1189          * @return Returns the raw X coordinate.
1190          * @since 9
1191          */
1192         int32_t GetRawDx() const;
1193 
1194         /**
1195          * @brief Sets the raw X coordinate.
1196          * @param rawDx Indicates the raw X coordinate to set.
1197          * @return void
1198          * @since 9
1199          */
1200 
1201         void SetRawDx(int32_t rawDx);
1202         /**
1203          * @brief Obtains the raw Y coordinate.
1204          * @return Returns the raw Y coordinate.
1205          * @since 9
1206          */
1207         int32_t GetRawDy() const;
1208 
1209         /**
1210          * @brief Sets the raw Y coordinate.
1211          * @param rawDy Indicates the raw Y coordinate to set.
1212          * @return void
1213          * @since 9
1214          */
1215         void SetRawDy(int32_t rawDy);
1216 
1217          /**
1218          * @brief Sets the raw X coordinate of the tool area's center point relative to the
1219          * upper left corner of the screen.
1220          * @param rawDisplayX Indicates the raw X coordinate to set.
1221          * @return void
1222          * @since 12
1223          */
1224         void SetRawDisplayX(int32_t rawDisplayX);
1225 
1226         /**
1227          * @brief Obtains the raw X coordinate relative to the upper left corner of the screen.
1228          * @return Returns the raw X coordinate.
1229          * @since 12
1230          */
1231         int32_t GetRawDisplayX() const;
1232 
1233         /**
1234          * @brief Sets the raw Y coordinate of the tool area's center point relative to the
1235          * upper left corner of the screen.
1236          * @param rawDisplayY Indicates the raw Y coordinate to set.
1237          * @return void
1238          * @since 12
1239          */
1240 
1241         void SetRawDisplayY(int32_t rawDisplayY);
1242         /**
1243          * @brief Obtains the raw Y coordinate relative to the upper left corner of the screen..
1244          * @return Returns the raw Y coordinate.
1245          * @since 12
1246          */
1247         int32_t GetRawDisplayY() const;
1248     private:
1249         int32_t pointerId_ { -1 };
1250         bool pressed_ { false };
1251         int32_t displayX_ {};
1252         int32_t displayY_ {};
1253         int32_t windowX_ {};
1254         int32_t windowY_ {};
1255         double displayXPos_ {};
1256         double displayYPos_ {};
1257         double windowXPos_ {};
1258         double windowYPos_ {};
1259         int32_t width_ {};
1260         int32_t height_ {};
1261         double tiltX_ {};
1262         double tiltY_ {};
1263         int32_t toolDisplayX_ {};
1264         int32_t toolDisplayY_ {};
1265         int32_t toolWindowX_ {};
1266         int32_t toolWindowY_ {};
1267         int32_t toolWidth_ {};
1268         int32_t toolHeight_ {};
1269         double pressure_ {};
1270         int32_t longAxis_ {};
1271         int32_t shortAxis_ {};
1272         int32_t deviceId_ {};
1273         int64_t downTime_ {};
1274         int32_t toolType_ {};
1275         int32_t targetWindowId_ { -1 };
1276         int32_t originPointerId_ { 0 };
1277         int32_t rawDx_ {};
1278         int32_t rawDy_ {};
1279         int32_t rawDisplayX_ {};
1280         int32_t rawDisplayY_ {};
1281     };
1282 
1283 public:
1284     /**
1285      * @brief Copy constructor function for PointerEvent
1286      * @since 9
1287      */
1288     PointerEvent(const PointerEvent& other);
1289 
1290     /**
1291      * Virtual destructor of PointerEvent
1292      *
1293      * @since 9
1294      */
1295     virtual ~PointerEvent();
1296 
1297     PointerEvent& operator=(const PointerEvent& other) = delete;
1298     DISALLOW_MOVE(PointerEvent);
1299 
1300     /**
1301      * @brief Create PointerEvent object
1302      * @since 9
1303      */
1304     static std::shared_ptr<PointerEvent> Create();
1305 
1306     virtual void Reset() override;
1307 
1308     /**
1309      * @brief Obtains the pointer action in this event.
1310      * @return Returns the pointer action.
1311      * @since 9
1312      */
1313     int32_t GetPointerAction() const;
1314 
1315     /**
1316      * @brief Sets a pointer action for this event.
1317      * @param pointerAction Indicates the pointer action to set.
1318      * @return void
1319      * @since 9
1320      */
1321     void SetPointerAction(int32_t pointerAction);
1322 
1323     /**
1324      * @brief Dumps the action of this pointer input event as a string.
1325      * @return Returns the pointer to the string.
1326      * @since 9
1327      */
1328     const char* DumpPointerAction() const;
1329 
1330     /**
1331      * @brief Obtains the pointer ID in this event.
1332      * @return Returns the pointer ID.
1333      * @since 9
1334      */
1335     int32_t GetPointerId() const;
1336 
1337     /**
1338      * @brief Sets an ID for the pointer in this event.
1339      * @param pointerId Indicates the pointer ID to set.
1340      * @return void
1341      * @since 9
1342      */
1343     void SetPointerId(int32_t pointerId);
1344 
1345     /**
1346      * @brief Obtains the pointer item of a specified pointer ID.
1347      * @param pointerId Indicates the pointer ID.
1348      * @param pointerItem Indicates the item used to receive the data of the pointer.
1349      * @return Returns <b>true</b> if the data of the pointer with the specified ID exists;
1350      * returns <b>false</b> otherwise.
1351      * @since 9
1352      */
1353     bool GetPointerItem(int32_t pointerId, PointerItem &pointerItem);
1354 
1355     /**
1356      * @brief Adds a pointer item.
1357      * @param pointerItem Indicates the pointer item to add.
1358      * @return void
1359      * @since 9
1360      */
1361     void AddPointerItem(PointerItem &pointerItem);
1362 
1363     /**
1364      * @brief Removes a pointer item based on the pointer ID.
1365      * @param pointerId Indicates the ID of the pointer from which the pointer item is to be removed.
1366      * @return void
1367      * @since 9
1368      */
1369     void RemovePointerItem(int32_t pointerId);
1370 
1371     /**
1372      * @brief All of the pointer items is be removed.
1373      * @return void
1374      * @since 9
1375      */
1376     void RemoveAllPointerItems();
1377 
1378     /**
1379      * @brief Return all the pointerItems.
1380      * @return Returns pointers_.
1381      * @since 9
1382      */
1383     std::list<PointerItem> GetAllPointerItems() const;
1384 
1385     /**
1386      * @brief Updates a pointer item based on the pointer ID.
1387      * @param pointerId Indicates the ID of the pointer from which the pointer item is to be updated.
1388      * @param pointerItem Indicates the pointer item to update.
1389      * @return void
1390      * @since 9
1391      */
1392     void UpdatePointerItem(int32_t pointerId, PointerItem &pointerItem);
1393 
1394     /**
1395      * @brief Obtains the set of pressed buttons.
1396      * @return Returns the pressed buttons.
1397      * @since 9
1398      */
1399     std::set<int32_t> GetPressedButtons() const;
1400 
1401     /**
1402      * @brief Checks whether a specified button is being pressed.
1403      * @param buttonId Indicates the button ID.
1404      * @return Returns <b>true</b> if the button is being pressed; returns <b>false</b> otherwise.
1405      * @since 9
1406      */
1407     bool IsButtonPressed(int32_t buttonId) const;
1408 
1409     /**
1410      * @brief Sets the pressed state for a button.
1411      * @param buttonId Indicates the button ID of the button to be set in the pressed state.
1412      * @return void
1413      * @since 9
1414      */
1415     void SetButtonPressed(int32_t buttonId);
1416 
1417     /**
1418      * @brief Deletes a released button.
1419      * @param buttonId Indicates the button ID of the button.
1420      * @return void
1421      * @since 9
1422      */
1423     void DeleteReleaseButton(int32_t buttonId);
1424 
1425     /**
1426      * @brief Clears the button in the pressed state.
1427      * @return void
1428      * @since 9
1429      */
1430     void ClearButtonPressed();
1431 
1432     int32_t GetPointerCount() const;
1433 
1434     /**
1435      * @brief Obtains all pointers in this event.
1436      * @return Returns all the pointer IDs.
1437      * @since 9
1438      */
1439     std::vector<int32_t> GetPointerIds() const;
1440 
1441     /**
1442      * @brief Obtains the source type of this event.
1443      * @return Returns the source type.
1444      * @since 9
1445      */
1446     int32_t GetSourceType() const;
1447 
1448     /**
1449      * @brief Sets the source type for this event.
1450      * @param sourceType Indicates the source type to set.
1451      * @return void
1452      * @since 9
1453      */
1454     void SetSourceType(int32_t sourceType);
1455 
1456     /**
1457      * @brief Dumps the source type of this pointer input event as a string.
1458      * @return Returns the pointer to the string.
1459      * @since 9
1460      */
1461     const char* DumpSourceType() const;
1462 
1463     /**
1464      * @brief Obtains the button ID in this event.
1465      * @return Returns the button ID.
1466      * @since 9
1467      */
1468     int32_t GetButtonId() const;
1469 
1470     /**
1471      * @brief Sets the button ID for this event.
1472      * @param buttonId Indicates the button ID to set.
1473      * @return void
1474      * @since 9
1475      */
1476     void SetButtonId(int32_t buttonId);
1477 
1478     /**
1479      * @brief Obtains the finger count in this event.
1480      * @return Returns the finger count.
1481      * @since 9
1482      */
1483     int32_t GetFingerCount() const;
1484 
1485     /**
1486      * @brief Sets the finger count for this event.
1487      * @param fingerCount Indicates the finger count to set.
1488      * @return void
1489      * @since 9
1490      */
1491     void SetFingerCount(int32_t fingerCount);
1492 
1493     /**
1494      * @brief Obtains the zOrder in this event, inject to windows whose zOrder less than the target zOrder.
1495      * @return Returns the zOrder.
1496      * @since 9
1497      */
1498     float GetZOrder() const;
1499 
1500     /**
1501      * @brief Sets the zOrder for this event, inject to windows whose zOrder less than the target zOrder.
1502      * @param fingerCount Indicates the zOrder to set.
1503      * @return void
1504      * @since 9
1505      */
1506     void SetZOrder(float zOrder);
1507 
1508     /**
1509      * @brief Obtains the axis value.
1510      * @param axis Indicates the axis type.
1511      * @return Returns the axis value.
1512      * @since 9
1513      */
1514     double GetAxisValue(AxisType axis) const;
1515 
1516     /**
1517      * @brief Sets the axis value.
1518      * @param axis Indicates the axis type.
1519      * @param axisValue Indicates the axis value to set.
1520      * @return void
1521      * @since 9
1522      */
1523     void SetAxisValue(AxisType axis, double axisValue);
1524 
1525     /**
1526      * @brief Clear the axis value of PointerEvent when a mouse event is received.
1527      * @return void
1528      * @since 9
1529      */
1530     void ClearAxisValue();
1531 
1532     /**
1533      * @brief Checks whether this event contains a specified axis type.
1534      * @param axis Indicates the axis type.
1535      * @return Returns <b>true</b> if the event contains the specified axis type; returns <b>false</b> otherwise.
1536      * @since 9
1537      */
1538     bool HasAxis(AxisType axis) const;
1539 
1540     /**
1541      * @brief Obtains all axis of this event.
1542      * @return Returns all the axis, Each bit indicates an axis.
1543      * @since 9
1544      */
1545     uint32_t GetAxes() const;
1546 
1547     /**
1548      * @brief Obtains the axis value velocity.
1549      * @return Returns the axis value velocity.
1550      * @since 12
1551      */
1552     double GetVelocity() const;
1553 
1554     /**
1555      * @brief Sets the axis value velocity.
1556      * @param velocity Indicates the axis value velocity.
1557      * @return void
1558      * @since 12
1559      */
1560     void SetVelocity(double velocity);
1561 
1562     /**
1563      * @brief Set the front keys in the key combination.
1564      * @param pressedKeys Indicates the front keys to set.
1565      * @return void.
1566      * @since 9
1567      */
1568     void SetPressedKeys(const std::vector<int32_t> pressedKeys);
1569 
1570     /**
1571      * @brief Obtains the set of pressed keys.
1572      * @return Returns the pressed keys.
1573      * @since 9
1574      */
1575     std::vector<int32_t> GetPressedKeys() const;
1576 
1577     /**
1578      * @brief Checks whether this input event is valid.
1579      * @return Returns <b>true</b> if the input event is valid; returns <b>false</b> otherwise.
1580      * @since 9
1581      */
1582     bool IsValid() const;
1583 
1584     /**
1585      * @brief 设置buffer值.
1586      * @param buffer 表示该事件所携带的buffer值.
1587      * @return void.
1588      * @since 9
1589      */
1590     void SetBuffer(std::vector<uint8_t> buffer);
1591 
1592     /**
1593      * @brief 清空buffer值.
1594      * @param void.
1595      * @return void.
1596      * @since 9
1597      */
1598     void ClearBuffer();
1599 
1600     /**
1601      * @brief 获取buffer值.
1602      * @return Returns buffer.
1603      * @since 9
1604      */
1605     std::vector<uint8_t> GetBuffer() const;
1606 
1607 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1608     /**
1609      * @brief Set the enhance data.
1610      * @return void.
1611      * @since 10
1612      */
1613     void SetEnhanceData(const std::vector<uint8_t>& enhanceData);
1614     /**
1615      * @brief Obtains the enhance data.
1616      * @return Returns the enhance data.
1617      * @since 10
1618      */
1619     std::vector<uint8_t> GetEnhanceData() const;
1620 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1621 
1622 public:
1623     /**
1624      * @brief Checks whether the axes set represented by <b>axes</b> contains a specified type of axis.
1625      * @param axes Indicates the set of axes. Each bit indicates an axis.
1626      * @param axis Indicates the type of the axis to check.
1627      * @return Returns <b>true</b> if the axes set contains the specified axis type; returns <b>false</b> otherwise.
1628      * @since 9
1629      */
1630     static bool HasAxis(uint32_t axes, AxisType axis);
1631 
1632     /**
1633      * @brief Converts a pointer event action into a short string.
1634      * @param Indicates the pointer event action.
1635      * @return Returns the string converted from the pointer action.
1636      * @since 12
1637      */
1638     static std::string_view ActionToShortStr(int32_t action);
1639 public:
1640     /**
1641      * @brief Writes data to a <b>Parcel</b> object.
1642      * @param out Indicates the object into which data will be written.
1643      * @return Returns <b>true</b> if the data is successfully written; returns <b>false</b> otherwise.
1644      * @since 9
1645      */
1646     bool WriteToParcel(Parcel &out) const;
1647 
1648     /**
1649      * @brief Reads data from a <b>Parcel</b> object.
1650      * @param in Indicates the object from which data will be read.
1651      * @return Returns <b>true</b> if the data is successfully read; returns <b>false</b> otherwise.
1652      * @since 9
1653      */
1654     bool ReadFromParcel(Parcel &in);
1655 
1656     /**
1657     * @brief Set the handlerEventType for pointerEvent
1658     * @return void
1659     * @since 12
1660     */
1661     void SetHandlerEventType(HandleEventType eventType);
1662 
1663     /**
1664      * @brief Get the handlerEventType for pointerEvent
1665      * @return handlerEventType
1666      * @since 12
1667      */
1668     HandleEventType GetHandlerEventType() const;
1669 
1670     /**
1671      * @brief Get the originPointerAction for pointerEvent
1672      * @return originPointerAction
1673      * @since 12
1674      */
1675     int32_t GetOriginPointerAction() const;
1676 
1677     /**
1678      * @brief Set the originPointerAction for pointerEvent
1679      * @return void
1680      * @since 12
1681      */
1682     void SetOriginPointerAction(int32_t pointerAction);
1683 
1684     /**
1685      * @brief Obtains the axis event type.
1686      * @return Returns the axis event type.
1687      * @since 12
1688      */
1689     int32_t GetAxisEventType() const;
1690 
1691     /**
1692      * @brief Sets axis event type.
1693      * @param axisEventType Indicates the axis event type to set.
1694      * @return void
1695      * @since 12
1696      */
1697     void SetAxisEventType(int32_t axisEventType);
1698 
1699     /**
1700      * @brief Obtains the drag id.
1701      * @return Returns the drag id.
1702      * @since 12
1703      */
1704     int32_t GetPullId() const;
1705 
1706     /**
1707      * @brief Sets drag id.
1708      * @param pullId Indicates the drag id to set.
1709      * @return void
1710      * @since 12
1711      */
1712     void SetPullId(int32_t pullId);
1713 
1714 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
1715     /**
1716      * @brief Set the fingerprint distance X.
1717      * @param X Indicates the distance X.
1718      * @return void.
1719      * @since 12
1720      */
1721     void SetFingerprintDistanceX(double x);
1722 
1723     /**
1724      * @brief Set the fingerprint distance Y.
1725      * @param Y Indicates the distance Y.
1726      * @return void.
1727      * @since 12
1728      */
1729     void SetFingerprintDistanceY(double y);
1730 
1731     /**
1732      * @brief Get the fingerprint distance X.
1733      * @return distance X.
1734      * @since 12
1735      */
1736     double GetFingerprintDistanceX() const;
1737 
1738     /**
1739      * @brief Get the fingerprint distance Y.
1740      * @return distance Y.
1741      * @since 12
1742      */
1743     double GetFingerprintDistanceY() const;
1744 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
1745 
1746     /**
1747      * @brief The number of times the input event is dispatched.
1748      * @return Return the event dispatch times.
1749      * @since 12
1750      */
1751     int32_t GetDispatchTimes() const;
1752 
1753     /**
1754      * @brief The number of times the same input event was distributed to multiple different windows.
1755      * @return void
1756      * @since 12
1757      */
1758     void SetDispatchTimes(int32_t dispatchTimes);
1759 
1760 #ifdef OHOS_BUILD_ENABLE_ANCO
1761     void SetAncoDeal(bool ancoDeal);
1762 
1763     bool GetAncoDeal() const;
1764 #endif // OHOS_BUILD_ENABLE_ANCO
1765 
1766 protected:
1767     /**
1768      * @brief Constructs an input event object by using the specified input event type. Generally, this method
1769      * is used to construct a base class object when constructing a derived class object.
1770      * @since 9
1771      */
1772     explicit PointerEvent(int32_t eventType);
1773 
1774 private:
1775     bool IsValidCheckMouseFunc() const;
1776     bool IsValidCheckMouse() const;
1777     bool IsValidCheckTouchFunc() const;
1778     bool IsValidCheckTouch() const;
1779 
1780 private:
1781     bool ReadEnhanceDataFromParcel(Parcel &in);
1782     bool ReadBufferFromParcel(Parcel &in);
1783     bool ReadAxisFromParcel(Parcel &in);
1784 
1785 private:
1786     int32_t pointerId_ { -1 };
1787     std::list<PointerItem> pointers_;
1788     std::set<int32_t> pressedButtons_;
1789     int32_t sourceType_ { SOURCE_TYPE_UNKNOWN };
1790     int32_t pointerAction_ { POINTER_ACTION_UNKNOWN };
1791     int32_t originPointerAction_ { POINTER_ACTION_UNKNOWN };
1792     int32_t buttonId_ { -1 };
1793     int32_t fingerCount_ { 0 };
1794     int32_t pullId_ { -1 };
1795     float zOrder_ { -1.0f };
1796     uint32_t axes_ { 0U };
1797     std::array<double, AXIS_TYPE_MAX> axisValues_ {};
1798     double velocity_ { 0.0 };
1799     std::vector<int32_t> pressedKeys_;
1800     std::vector<uint8_t> buffer_;
1801     int32_t axisEventType_ { AXIS_EVENT_TYPE_UNKNOWN };
1802 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
1803     double fingerprintDistanceX_ { 0.0 };
1804     double fingerprintDistanceY_ { 0.0 };
1805 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
1806     int32_t dispatchTimes_ { 0 };
1807 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1808     std::vector<uint8_t> enhanceData_;
1809 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1810     HandleEventType handleEventType_ = HANDLE_EVENT_TYPE_POINTER;
1811 #ifdef OHOS_BUILD_ENABLE_ANCO
1812     bool ancoDeal_ { false };
1813 #endif // OHOS_BUILD_ENABLE_ANCO
1814 };
1815 
HasAxis(AxisType axis)1816 inline bool PointerEvent::HasAxis(AxisType axis) const
1817 {
1818     return HasAxis(axes_, axis);
1819 }
1820 
GetAxes()1821 inline uint32_t PointerEvent::GetAxes() const
1822 {
1823     return axes_;
1824 }
1825 } // namespace MMI
1826 } // namespace OHOS
1827 #endif // POINTER_EVENT_H
1828