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