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