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