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