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 #include "pointer_event.h"
17
18 #include <iomanip>
19
20 #include "mmi_log.h"
21
22 #undef MMI_LOG_TAG
23 #define MMI_LOG_TAG "PointerEvent"
24
25 using namespace OHOS::HiviewDFX;
26 namespace OHOS {
27 namespace MMI {
28 namespace {
29 constexpr double MAX_PRESSURE { 1.0 };
30 constexpr size_t MAX_N_PRESSED_BUTTONS { 10 };
31 constexpr size_t MAX_N_POINTER_ITEMS { 10 };
32 constexpr int32_t SIMULATE_EVENT_START_ID { 10000 };
33 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
34 constexpr size_t MAX_N_ENHANCE_DATA_SIZE { 64 };
35 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
36 constexpr size_t MAX_N_BUFFER_SIZE { 512 };
37 } // namespace
38
from(std::shared_ptr<InputEvent> inputEvent)39 std::shared_ptr<PointerEvent> PointerEvent::from(std::shared_ptr<InputEvent> inputEvent)
40 {
41 return nullptr;
42 }
43
PointerItem()44 PointerEvent::PointerItem::PointerItem() {}
45
~PointerItem()46 PointerEvent::PointerItem::~PointerItem() {}
47
GetPointerId() const48 int32_t PointerEvent::PointerItem::GetPointerId() const
49 {
50 return pointerId_;
51 }
52
SetPointerId(int32_t pointerId)53 void PointerEvent::PointerItem::SetPointerId(int32_t pointerId)
54 {
55 pointerId_ = pointerId;
56 }
57
GetDownTime() const58 int64_t PointerEvent::PointerItem::GetDownTime() const
59 {
60 return downTime_;
61 }
62
SetDownTime(int64_t downTime)63 void PointerEvent::PointerItem::SetDownTime(int64_t downTime)
64 {
65 downTime_ = downTime;
66 }
67
IsPressed() const68 bool PointerEvent::PointerItem::IsPressed() const
69 {
70 return pressed_;
71 }
72
SetPressed(bool pressed)73 void PointerEvent::PointerItem::SetPressed(bool pressed)
74 {
75 pressed_ = pressed;
76 }
77
GetDisplayX() const78 int32_t PointerEvent::PointerItem::GetDisplayX() const
79 {
80 return displayX_;
81 }
82
SetDisplayX(int32_t x)83 void PointerEvent::PointerItem::SetDisplayX(int32_t x)
84 {
85 displayX_ = x;
86 }
87
GetDisplayY() const88 int32_t PointerEvent::PointerItem::GetDisplayY() const
89 {
90 return displayY_;
91 }
92
SetDisplayY(int32_t y)93 void PointerEvent::PointerItem::SetDisplayY(int32_t y)
94 {
95 displayY_ = y;
96 }
97
GetWindowX() const98 int32_t PointerEvent::PointerItem::GetWindowX() const
99 {
100 return windowX_;
101 }
102
SetWindowX(int32_t x)103 void PointerEvent::PointerItem::SetWindowX(int32_t x)
104 {
105 windowX_ = x;
106 }
107
GetWindowY() const108 int32_t PointerEvent::PointerItem::GetWindowY() const
109 {
110 return windowY_;
111 }
112
SetWindowY(int32_t y)113 void PointerEvent::PointerItem::SetWindowY(int32_t y)
114 {
115 windowY_ = y;
116 }
117
GetDisplayXPos() const118 double PointerEvent::PointerItem::GetDisplayXPos() const
119 {
120 return displayXPos_;
121 }
122
SetDisplayXPos(double x)123 void PointerEvent::PointerItem::SetDisplayXPos(double x)
124 {
125 displayXPos_ = x;
126 }
127
GetDisplayYPos() const128 double PointerEvent::PointerItem::GetDisplayYPos() const
129 {
130 return displayYPos_;
131 }
132
SetDisplayYPos(double y)133 void PointerEvent::PointerItem::SetDisplayYPos(double y)
134 {
135 displayYPos_ = y;
136 }
137
GetWindowXPos() const138 double PointerEvent::PointerItem::GetWindowXPos() const
139 {
140 return windowXPos_;
141 }
142
SetWindowXPos(double x)143 void PointerEvent::PointerItem::SetWindowXPos(double x)
144 {
145 windowXPos_ = x;
146 }
147
GetWindowYPos() const148 double PointerEvent::PointerItem::GetWindowYPos() const
149 {
150 return windowYPos_;
151 }
152
SetWindowYPos(double y)153 void PointerEvent::PointerItem::SetWindowYPos(double y)
154 {
155 windowYPos_ = y;
156 }
157
GetWidth() const158 int32_t PointerEvent::PointerItem::GetWidth() const
159 {
160 return width_;
161 }
162
SetWidth(int32_t width)163 void PointerEvent::PointerItem::SetWidth(int32_t width)
164 {
165 width_ = width;
166 }
167
GetHeight() const168 int32_t PointerEvent::PointerItem::GetHeight() const
169 {
170 return height_;
171 }
172
SetHeight(int32_t height)173 void PointerEvent::PointerItem::SetHeight(int32_t height)
174 {
175 height_ = height;
176 }
177
GetTiltX() const178 double PointerEvent::PointerItem::GetTiltX() const
179 {
180 return tiltX_;
181 }
182
SetTiltX(double tiltX)183 void PointerEvent::PointerItem::SetTiltX(double tiltX)
184 {
185 tiltX_ = tiltX;
186 }
187
GetTiltY() const188 double PointerEvent::PointerItem::GetTiltY() const
189 {
190 return tiltY_;
191 }
192
SetTiltY(double tiltY)193 void PointerEvent::PointerItem::SetTiltY(double tiltY)
194 {
195 tiltY_ = tiltY;
196 }
197
GetToolDisplayX() const198 int32_t PointerEvent::PointerItem::GetToolDisplayX() const
199 {
200 return toolDisplayX_;
201 }
202
SetToolDisplayX(int32_t x)203 void PointerEvent::PointerItem::SetToolDisplayX(int32_t x)
204 {
205 toolDisplayX_ = x;
206 }
207
GetToolDisplayY() const208 int32_t PointerEvent::PointerItem::GetToolDisplayY() const
209 {
210 return toolDisplayY_;
211 }
212
SetToolDisplayY(int32_t y)213 void PointerEvent::PointerItem::SetToolDisplayY(int32_t y)
214 {
215 toolDisplayY_ = y;
216 }
217
GetToolWindowX() const218 int32_t PointerEvent::PointerItem::GetToolWindowX() const
219 {
220 return toolWindowX_;
221 }
222
SetToolWindowX(int32_t x)223 void PointerEvent::PointerItem::SetToolWindowX(int32_t x)
224 {
225 toolWindowX_ = x;
226 }
227
GetToolWindowY() const228 int32_t PointerEvent::PointerItem::GetToolWindowY() const
229 {
230 return toolWindowY_;
231 }
232
SetToolWindowY(int32_t y)233 void PointerEvent::PointerItem::SetToolWindowY(int32_t y)
234 {
235 toolWindowY_ = y;
236 }
237
GetToolWidth() const238 int32_t PointerEvent::PointerItem::GetToolWidth() const
239 {
240 return toolWidth_;
241 }
242
SetToolWidth(int32_t width)243 void PointerEvent::PointerItem::SetToolWidth(int32_t width)
244 {
245 toolWidth_ = width;
246 }
247
GetToolHeight() const248 int32_t PointerEvent::PointerItem::GetToolHeight() const
249 {
250 return toolHeight_;
251 }
252
SetToolHeight(int32_t height)253 void PointerEvent::PointerItem::SetToolHeight(int32_t height)
254 {
255 toolHeight_ = height;
256 }
257
GetPressure() const258 double PointerEvent::PointerItem::GetPressure() const
259 {
260 return pressure_;
261 }
262
SetPressure(double pressure)263 void PointerEvent::PointerItem::SetPressure(double pressure)
264 {
265 if (pressure < 0.0) {
266 pressure_ = 0.0;
267 } else if (TOOL_TYPE_PEN == GetToolType()) {
268 pressure_ = pressure >= MAX_PRESSURE ? MAX_PRESSURE : pressure;
269 } else {
270 pressure_ = pressure;
271 }
272 }
273
GetLongAxis() const274 int32_t PointerEvent::PointerItem::GetLongAxis() const
275 {
276 return longAxis_;
277 }
278
SetLongAxis(int32_t longAxis)279 void PointerEvent::PointerItem::SetLongAxis(int32_t longAxis)
280 {
281 longAxis_ = longAxis;
282 }
283
GetShortAxis() const284 int32_t PointerEvent::PointerItem::GetShortAxis() const
285 {
286 return shortAxis_;
287 }
288
SetShortAxis(int32_t shortAxis)289 void PointerEvent::PointerItem::SetShortAxis(int32_t shortAxis)
290 {
291 shortAxis_ = shortAxis;
292 }
293
GetDeviceId() const294 int32_t PointerEvent::PointerItem::GetDeviceId() const
295 {
296 return deviceId_;
297 }
298
SetDeviceId(int32_t deviceId)299 void PointerEvent::PointerItem::SetDeviceId(int32_t deviceId)
300 {
301 deviceId_ = deviceId;
302 }
303
GetToolType() const304 int32_t PointerEvent::PointerItem::GetToolType() const
305 {
306 return toolType_;
307 }
308
SetToolType(int32_t toolType)309 void PointerEvent::PointerItem::SetToolType(int32_t toolType)
310 {
311 toolType_ = toolType;
312 }
313
GetTargetWindowId() const314 int32_t PointerEvent::PointerItem::GetTargetWindowId() const
315 {
316 return targetWindowId_;
317 }
318
SetTargetWindowId(int32_t windowId)319 void PointerEvent::PointerItem::SetTargetWindowId(int32_t windowId)
320 {
321 targetWindowId_ = windowId;
322 }
323
GetRawDx() const324 int32_t PointerEvent::PointerItem::GetRawDx() const
325 {
326 return rawDx_;
327 }
328
SetRawDx(int32_t rawDx)329 void PointerEvent::PointerItem::SetRawDx(int32_t rawDx)
330 {
331 rawDx_ = rawDx;
332 }
333
GetOriginPointerId() const334 int32_t PointerEvent::PointerItem::GetOriginPointerId() const
335 {
336 return originPointerId_;
337 }
338
SetOriginPointerId(int32_t originPointerId)339 void PointerEvent::PointerItem::SetOriginPointerId(int32_t originPointerId)
340 {
341 originPointerId_ = originPointerId;
342 }
343
GetRawDy() const344 int32_t PointerEvent::PointerItem::GetRawDy() const
345 {
346 return rawDy_;
347 }
348
SetRawDy(int32_t rawDy)349 void PointerEvent::PointerItem::SetRawDy(int32_t rawDy)
350 {
351 rawDy_ = rawDy;
352 }
353
GetRawDisplayX() const354 int32_t PointerEvent::PointerItem::GetRawDisplayX() const
355 {
356 return rawDisplayX_;
357 }
358
SetRawDisplayX(int32_t rawDisplayX)359 void PointerEvent::PointerItem::SetRawDisplayX(int32_t rawDisplayX)
360 {
361 rawDisplayX_ = rawDisplayX;
362 }
363
GetRawDisplayY() const364 int32_t PointerEvent::PointerItem::GetRawDisplayY() const
365 {
366 return rawDisplayY_;
367 }
368
SetRawDisplayY(int32_t rawDisplayY)369 void PointerEvent::PointerItem::SetRawDisplayY(int32_t rawDisplayY)
370 {
371 rawDisplayY_ = rawDisplayY;
372 }
373
WriteToParcel(Parcel & out) const374 bool PointerEvent::PointerItem::WriteToParcel(Parcel &out) const
375 {
376 return (
377 out.WriteInt32(pointerId_) &&
378 out.WriteInt64(downTime_) &&
379 out.WriteBool(pressed_) &&
380 out.WriteInt32(displayX_) &&
381 out.WriteInt32(displayY_) &&
382 out.WriteInt32(windowX_) &&
383 out.WriteInt32(windowY_) &&
384 out.WriteInt32(width_) &&
385 out.WriteInt32(height_) &&
386 out.WriteInt32(toolDisplayX_) &&
387 out.WriteInt32(toolDisplayY_) &&
388 out.WriteInt32(toolWindowX_) &&
389 out.WriteInt32(toolWindowY_) &&
390 out.WriteInt32(toolWidth_) &&
391 out.WriteInt32(toolHeight_) &&
392 out.WriteDouble(tiltX_) &&
393 out.WriteDouble(tiltY_) &&
394 out.WriteDouble(pressure_) &&
395 out.WriteInt32(longAxis_) &&
396 out.WriteInt32(shortAxis_) &&
397 out.WriteInt32(toolType_) &&
398 out.WriteInt32(deviceId_) &&
399 out.WriteInt32(rawDx_) &&
400 out.WriteInt32(rawDy_) &&
401 out.WriteInt32(rawDisplayX_) &&
402 out.WriteInt32(rawDisplayY_) &&
403 out.WriteInt32(targetWindowId_) &&
404 out.WriteInt32(originPointerId_) &&
405 out.WriteDouble(displayXPos_) &&
406 out.WriteDouble(displayYPos_) &&
407 out.WriteDouble(windowXPos_) &&
408 out.WriteDouble(windowYPos_)
409 );
410 }
411
ReadFromParcel(Parcel & in)412 bool PointerEvent::PointerItem::ReadFromParcel(Parcel &in)
413 {
414 return (
415 in.ReadInt32(pointerId_) &&
416 in.ReadInt64(downTime_) &&
417 in.ReadBool(pressed_) &&
418 in.ReadInt32(displayX_) &&
419 in.ReadInt32(displayY_) &&
420 in.ReadInt32(windowX_) &&
421 in.ReadInt32(windowY_) &&
422 in.ReadInt32(width_) &&
423 in.ReadInt32(height_) &&
424 in.ReadInt32(toolDisplayX_) &&
425 in.ReadInt32(toolDisplayY_) &&
426 in.ReadInt32(toolWindowX_) &&
427 in.ReadInt32(toolWindowY_) &&
428 in.ReadInt32(toolWidth_) &&
429 in.ReadInt32(toolHeight_) &&
430 in.ReadDouble(tiltX_) &&
431 in.ReadDouble(tiltY_) &&
432 in.ReadDouble(pressure_) &&
433 in.ReadInt32(longAxis_) &&
434 in.ReadInt32(shortAxis_) &&
435 in.ReadInt32(toolType_) &&
436 in.ReadInt32(deviceId_) &&
437 in.ReadInt32(rawDx_) &&
438 in.ReadInt32(rawDy_) &&
439 in.ReadInt32(rawDisplayX_) &&
440 in.ReadInt32(rawDisplayY_) &&
441 in.ReadInt32(targetWindowId_) &&
442 in.ReadInt32(originPointerId_) &&
443 in.ReadDouble(displayXPos_) &&
444 in.ReadDouble(displayYPos_) &&
445 in.ReadDouble(windowXPos_) &&
446 in.ReadDouble(windowYPos_)
447 );
448 }
449
PointerEvent(int32_t eventType)450 PointerEvent::PointerEvent(int32_t eventType) : InputEvent(eventType) {}
451
PointerEvent(const PointerEvent & other)452 PointerEvent::PointerEvent(const PointerEvent& other)
453 : InputEvent(other), pointerId_(other.pointerId_), pointers_(other.pointers_),
454 pressedButtons_(other.pressedButtons_), sourceType_(other.sourceType_),
455 pointerAction_(other.pointerAction_), originPointerAction_(other.originPointerAction_),
456 buttonId_(other.buttonId_), fingerCount_(other.fingerCount_), pullId_(other.pullId_), zOrder_(other.zOrder_),
457 axes_(other.axes_), axisValues_(other.axisValues_), velocity_(other.velocity_),
458 pressedKeys_(other.pressedKeys_), buffer_(other.buffer_), axisEventType_(other.axisEventType_),
459 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
460 fingerprintDistanceX_(other.fingerprintDistanceX_), fingerprintDistanceY_(other.fingerprintDistanceY_),
461 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
462 dispatchTimes_(other.dispatchTimes_)
463 {}
464
~PointerEvent()465 PointerEvent::~PointerEvent() {}
466
Create()467 std::shared_ptr<PointerEvent> PointerEvent::Create()
468 {
469 auto event = std::shared_ptr<PointerEvent>(new (std::nothrow) PointerEvent(InputEvent::EVENT_TYPE_POINTER));
470 CHKPP(event);
471 return event;
472 }
473
Reset()474 void PointerEvent::Reset()
475 {
476 InputEvent::Reset();
477 pointerId_ = -1;
478 pointers_.clear();
479 pressedButtons_.clear();
480 sourceType_ = SOURCE_TYPE_UNKNOWN;
481 pointerAction_ = POINTER_ACTION_UNKNOWN;
482 originPointerAction_ = POINTER_ACTION_UNKNOWN;
483 buttonId_ = -1;
484 fingerCount_ = 0;
485 zOrder_ = -1.0f;
486 dispatchTimes_ = 0;
487 axes_ = 0U;
488 axisValues_.fill(0.0);
489 velocity_ = 0.0;
490 axisEventType_ = AXIS_EVENT_TYPE_UNKNOWN;
491 pressedKeys_.clear();
492 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
493 fingerprintDistanceX_ = 0.0;
494 fingerprintDistanceY_ = 0.0;
495 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
496 }
497
GetPointerAction() const498 int32_t PointerEvent::GetPointerAction() const
499 {
500 return pointerAction_;
501 }
502
SetPointerAction(int32_t pointerAction)503 void PointerEvent::SetPointerAction(int32_t pointerAction)
504 {
505 pointerAction_ = pointerAction;
506 originPointerAction_ = pointerAction;
507 }
508
GetOriginPointerAction() const509 int32_t PointerEvent::GetOriginPointerAction() const
510 {
511 return originPointerAction_;
512 }
513
SetOriginPointerAction(int32_t pointerAction)514 void PointerEvent::SetOriginPointerAction(int32_t pointerAction)
515 {
516 originPointerAction_ = pointerAction;
517 }
518
519 static const std::unordered_map<int32_t, std::string> pointerActionMap = {
520 { PointerEvent::POINTER_ACTION_CANCEL, "cancel" },
521 { PointerEvent::POINTER_ACTION_DOWN, "down" },
522 { PointerEvent::POINTER_ACTION_MOVE, "move" },
523 { PointerEvent::POINTER_ACTION_UP, "up" },
524 { PointerEvent::POINTER_ACTION_AXIS_BEGIN, "axis-begin" },
525 { PointerEvent::POINTER_ACTION_AXIS_UPDATE, "axis-update" },
526 { PointerEvent::POINTER_ACTION_AXIS_END, "axis-end" },
527 { PointerEvent::POINTER_ACTION_BUTTON_DOWN, "button-down" },
528 { PointerEvent::POINTER_ACTION_BUTTON_UP, "button-up" },
529 { PointerEvent::POINTER_ACTION_ENTER_WINDOW, "enter-window" },
530 { PointerEvent::POINTER_ACTION_LEAVE_WINDOW, "leave-window" },
531 { PointerEvent::POINTER_ACTION_PULL_DOWN, "pull-down" },
532 { PointerEvent::POINTER_ACTION_PULL_MOVE, "pull-move" },
533 { PointerEvent::POINTER_ACTION_PULL_UP, "pull-up" },
534 { PointerEvent::POINTER_ACTION_PULL_IN_WINDOW, "pull-in-window" },
535 { PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW, "pull-out-window" },
536 { PointerEvent::POINTER_ACTION_SWIPE_BEGIN, "swipe-begin" },
537 { PointerEvent::POINTER_ACTION_SWIPE_UPDATE, "swipe-update" },
538 { PointerEvent::POINTER_ACTION_SWIPE_END, "swipe-end" },
539 { PointerEvent::POINTER_ACTION_ROTATE_BEGIN, "rotate-begin" },
540 { PointerEvent::POINTER_ACTION_ROTATE_UPDATE, "rotate-update" },
541 { PointerEvent::POINTER_ACTION_ROTATE_END, "rotate-end" },
542 { PointerEvent::POINTER_ACTION_TRIPTAP, "touchpad-triptap" },
543 { PointerEvent::POINTER_ACTION_QUADTAP, "quadtap" },
544 { PointerEvent::POINTER_ACTION_HOVER_MOVE, "hover-move" },
545 { PointerEvent::POINTER_ACTION_HOVER_ENTER, "hover-enter" },
546 { PointerEvent::POINTER_ACTION_HOVER_EXIT, "hover-exit" },
547 { PointerEvent::POINTER_ACTION_FINGERPRINT_DOWN, "fingerprint-down" },
548 { PointerEvent::POINTER_ACTION_FINGERPRINT_UP, "fingerprint-up" },
549 { PointerEvent::POINTER_ACTION_FINGERPRINT_SLIDE, "fingerprint-slide" },
550 { PointerEvent::POINTER_ACTION_FINGERPRINT_RETOUCH, "fingerprint-retouch" },
551 { PointerEvent::POINTER_ACTION_FINGERPRINT_CLICK, "fingerprint-click" },
552 { PointerEvent::POINTER_ACTION_PROXIMITY_IN, "pen-proximity-in" },
553 { PointerEvent::POINTER_ACTION_PROXIMITY_OUT, "pen-proximity-out" },
554 };
555
DumpPointerAction() const556 const char* PointerEvent::DumpPointerAction() const
557 {
558 auto it = pointerActionMap.find(pointerAction_);
559 if (it != pointerActionMap.end()) {
560 return it->second.c_str();
561 }
562 return "unknown";
563 }
564
GetPointerId() const565 int32_t PointerEvent::GetPointerId() const
566 {
567 return pointerId_;
568 }
569
SetPointerId(int32_t pointerId)570 void PointerEvent::SetPointerId(int32_t pointerId)
571 {
572 pointerId_ = pointerId;
573 }
574
GetPointerItem(int32_t pointerId,PointerItem & pointerItem)575 bool PointerEvent::GetPointerItem(int32_t pointerId, PointerItem &pointerItem)
576 {
577 for (const auto &item : pointers_) {
578 if (item.GetPointerId() == pointerId) {
579 pointerItem = item;
580 return true;
581 }
582 }
583 return false;
584 }
585
RemovePointerItem(int32_t pointerId)586 void PointerEvent::RemovePointerItem(int32_t pointerId)
587 {
588 for (auto it = pointers_.begin(); it != pointers_.end(); ++it) {
589 if (it->GetPointerId() == pointerId) {
590 pointers_.erase(it);
591 break;
592 }
593 }
594 }
595
RemoveAllPointerItems()596 void PointerEvent::RemoveAllPointerItems()
597 {
598 pointers_.clear();
599 }
600
AddPointerItem(PointerItem & pointerItem)601 void PointerEvent::AddPointerItem(PointerItem &pointerItem)
602 {
603 if (pointers_.size() >= MAX_N_POINTER_ITEMS) {
604 MMI_HILOGE("Exceed maximum allowed number of pointer items");
605 return;
606 }
607 int32_t pointerId = pointerItem.GetPointerId();
608 for (auto &item : pointers_) {
609 if (item.GetPointerId() == pointerId) {
610 item = pointerItem;
611 return;
612 }
613 }
614 pointers_.push_back(pointerItem);
615 }
616
UpdatePointerItem(int32_t pointerId,PointerItem & pointerItem)617 void PointerEvent::UpdatePointerItem(int32_t pointerId, PointerItem &pointerItem)
618 {
619 for (auto &item : pointers_) {
620 if ((item.GetPointerId() % SIMULATE_EVENT_START_ID) == pointerId) {
621 item = pointerItem;
622 return;
623 }
624 }
625 AddPointerItem(pointerItem);
626 }
627
GetPressedButtons() const628 std::set<int32_t> PointerEvent::GetPressedButtons() const
629 {
630 return pressedButtons_;
631 }
632
IsButtonPressed(int32_t buttonId) const633 bool PointerEvent::IsButtonPressed(int32_t buttonId) const
634 {
635 return (pressedButtons_.find(buttonId) != pressedButtons_.end());
636 }
637
SetButtonPressed(int32_t buttonId)638 void PointerEvent::SetButtonPressed(int32_t buttonId)
639 {
640 if (pressedButtons_.size() >= MAX_N_PRESSED_BUTTONS) {
641 MMI_HILOGE("Exceed maximum allowed number of pressed buttons");
642 return;
643 }
644 auto iter = pressedButtons_.insert(buttonId);
645 if (!iter.second) {
646 MMI_HILOGE("Insert value failed, button:%{public}d", buttonId);
647 }
648 }
649
DeleteReleaseButton(int32_t buttonId)650 void PointerEvent::DeleteReleaseButton(int32_t buttonId)
651 {
652 if (pressedButtons_.find(buttonId) != pressedButtons_.end()) {
653 pressedButtons_.erase(buttonId);
654 }
655 }
656
ClearButtonPressed()657 void PointerEvent::ClearButtonPressed()
658 {
659 pressedButtons_.clear();
660 }
661
GetPointerCount() const662 int32_t PointerEvent::GetPointerCount() const
663 {
664 return static_cast<int32_t>(pointers_.size());
665 }
666
GetPointerIds() const667 std::vector<int32_t> PointerEvent::GetPointerIds() const
668 {
669 std::vector<int32_t> pointerIdList;
670 for (const auto &item : pointers_) {
671 pointerIdList.push_back(item.GetPointerId());
672 }
673 return pointerIdList;
674 }
675
GetAllPointerItems() const676 std::list<PointerEvent::PointerItem> PointerEvent::GetAllPointerItems() const
677 {
678 return pointers_;
679 }
680
GetSourceType() const681 int32_t PointerEvent::GetSourceType() const
682 {
683 return sourceType_;
684 }
685
SetSourceType(int32_t sourceType)686 void PointerEvent::SetSourceType(int32_t sourceType)
687 {
688 sourceType_ = sourceType;
689 }
690
DumpSourceType() const691 const char* PointerEvent::DumpSourceType() const
692 {
693 switch (sourceType_) {
694 case PointerEvent::SOURCE_TYPE_MOUSE: {
695 return "mouse";
696 }
697 case PointerEvent::SOURCE_TYPE_TOUCHSCREEN: {
698 return "touch-screen";
699 }
700 case PointerEvent::SOURCE_TYPE_TOUCHPAD: {
701 return "touch-pad";
702 }
703 case PointerEvent::SOURCE_TYPE_JOYSTICK: {
704 return "joystick";
705 }
706 case PointerEvent::SOURCE_TYPE_FINGERPRINT: {
707 return "fingerprint";
708 }
709 case PointerEvent::SOURCE_TYPE_CROWN: {
710 return "crown";
711 }
712 default: {
713 break;
714 }
715 }
716 return "unknown";
717 }
718
GetButtonId() const719 int32_t PointerEvent::GetButtonId() const
720 {
721 return buttonId_;
722 }
723
SetButtonId(int32_t buttonId)724 void PointerEvent::SetButtonId(int32_t buttonId)
725 {
726 buttonId_ = buttonId;
727 }
728
GetFingerCount() const729 int32_t PointerEvent::GetFingerCount() const
730 {
731 return fingerCount_;
732 }
733
SetFingerCount(int32_t fingerCount)734 void PointerEvent::SetFingerCount(int32_t fingerCount)
735 {
736 fingerCount_ = fingerCount;
737 }
738
GetZOrder() const739 float PointerEvent::GetZOrder() const
740 {
741 return zOrder_;
742 }
743
SetZOrder(float zOrder)744 void PointerEvent::SetZOrder(float zOrder)
745 {
746 zOrder_ = zOrder;
747 }
748
GetAxisValue(AxisType axis) const749 double PointerEvent::GetAxisValue(AxisType axis) const
750 {
751 double axisValue {};
752 if ((axis >= AXIS_TYPE_UNKNOWN) && (axis < AXIS_TYPE_MAX)) {
753 axisValue = axisValues_[axis];
754 }
755 return axisValue;
756 }
757
SetAxisValue(AxisType axis,double axisValue)758 void PointerEvent::SetAxisValue(AxisType axis, double axisValue)
759 {
760 if ((axis >= AXIS_TYPE_UNKNOWN) && (axis < AXIS_TYPE_MAX)) {
761 axisValues_[axis] = axisValue;
762 axes_ = static_cast<uint32_t>(axes_ | static_cast<uint32_t>(1 << axis));
763 }
764 }
765
ClearAxisValue()766 void PointerEvent::ClearAxisValue()
767 {
768 axisValues_ = {};
769 axes_ = 0;
770 }
771
HasAxis(uint32_t axes,AxisType axis)772 bool PointerEvent::HasAxis(uint32_t axes, AxisType axis)
773 {
774 bool ret { false };
775 if ((axis >= AXIS_TYPE_UNKNOWN) && (axis < AXIS_TYPE_MAX)) {
776 ret = static_cast<bool>(static_cast<uint32_t>(axes) & (1 << static_cast<uint32_t>(axis)));
777 }
778 return ret;
779 }
780
GetVelocity() const781 double PointerEvent::GetVelocity() const
782 {
783 return velocity_;
784 }
785
SetVelocity(double velocity)786 void PointerEvent::SetVelocity(double velocity)
787 {
788 velocity_ = velocity;
789 }
790
SetPressedKeys(const std::vector<int32_t> pressedKeys)791 void PointerEvent::SetPressedKeys(const std::vector<int32_t> pressedKeys)
792 {
793 pressedKeys_ = pressedKeys;
794 }
795
GetPressedKeys() const796 std::vector<int32_t> PointerEvent::GetPressedKeys() const
797 {
798 return pressedKeys_;
799 }
800
GetAxisEventType() const801 int32_t PointerEvent::GetAxisEventType() const
802 {
803 return axisEventType_;
804 }
805
SetAxisEventType(int32_t axisEventType)806 void PointerEvent::SetAxisEventType(int32_t axisEventType)
807 {
808 axisEventType_ = axisEventType;
809 }
810
GetPullId() const811 int32_t PointerEvent::GetPullId() const
812 {
813 return pullId_;
814 }
815
SetPullId(int32_t pullId)816 void PointerEvent::SetPullId(int32_t pullId)
817 {
818 pullId_ = pullId;
819 }
820
821 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
SetEnhanceData(const std::vector<uint8_t> & enhanceData)822 void PointerEvent::SetEnhanceData(const std::vector<uint8_t>& enhanceData)
823 {
824 enhanceData_ = enhanceData;
825 }
826
GetEnhanceData() const827 std::vector<uint8_t> PointerEvent::GetEnhanceData() const
828 {
829 return enhanceData_;
830 }
831 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
832
WriteToParcel(Parcel & out) const833 bool PointerEvent::WriteToParcel(Parcel &out) const
834 {
835 if (!InputEvent::WriteToParcel(out)) {
836 return false;
837 }
838
839 WRITEINT32(out, pointerId_);
840
841 WRITEINT32(out, static_cast<int32_t>(pointers_.size()));
842
843 for (const auto &item : pointers_) {
844 if (!item.WriteToParcel(out)) {
845 return false;
846 }
847 }
848
849 WRITEINT32(out, static_cast<int32_t>(buffer_.size()));
850
851 for (const auto& buff : buffer_) {
852 WRITEUINT8(out, buff);
853 }
854
855 WRITEINT32(out, static_cast<int32_t>(pressedButtons_.size()));
856
857 for (const auto &item : pressedButtons_) {
858 WRITEINT32(out, item);
859 }
860
861 WRITEINT32(out, sourceType_);
862
863 WRITEINT32(out, pointerAction_);
864
865 WRITEINT32(out, originPointerAction_);
866
867 WRITEINT32(out, buttonId_);
868
869 WRITEINT32(out, fingerCount_);
870
871 WRITEFLOAT(out, zOrder_);
872
873 const uint32_t axes { GetAxes() };
874 WRITEUINT32(out, axes);
875
876 for (int32_t i = AXIS_TYPE_UNKNOWN; i < AXIS_TYPE_MAX; ++i) {
877 const AxisType axis { static_cast<AxisType>(i) };
878 if (HasAxis(axes, axis)) {
879 WRITEDOUBLE(out, GetAxisValue(axis));
880 }
881 }
882
883 WRITEINT32(out, axisEventType_);
884 WRITEINT32(out, pullId_);
885 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
886 WRITEINT32(out, static_cast<int32_t>(enhanceData_.size()));
887 for (uint32_t i = 0; i < enhanceData_.size(); i++) {
888 WRITEUINT32(out, enhanceData_[i]);
889 }
890 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
891
892 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
893 WRITEDOUBLE(out, fingerprintDistanceX_);
894 WRITEDOUBLE(out, fingerprintDistanceY_);
895 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
896 return true;
897 }
898
ReadFromParcel(Parcel & in)899 bool PointerEvent::ReadFromParcel(Parcel &in)
900 {
901 if (!InputEvent::ReadFromParcel(in)) {
902 return false;
903 }
904
905 READINT32(in, pointerId_);
906
907 int32_t nPointers;
908 READINT32(in, nPointers);
909 if (nPointers > static_cast<int32_t>(MAX_N_POINTER_ITEMS)) {
910 return false;
911 }
912
913 for (int32_t i = 0; i < nPointers; ++i) {
914 PointerItem item;
915 if (!item.ReadFromParcel(in)) {
916 return false;
917 }
918 AddPointerItem(item);
919 }
920
921 if (!ReadBufferFromParcel(in)) {
922 return false;
923 }
924
925 int32_t nPressedButtons;
926 READINT32(in, nPressedButtons);
927 if (nPressedButtons > static_cast<int32_t>(MAX_N_PRESSED_BUTTONS)) {
928 return false;
929 }
930
931 for (int32_t i = 0; i < nPressedButtons; ++i) {
932 int32_t buttonId = 0;
933 READINT32(in, buttonId);
934 SetButtonPressed(buttonId);
935 }
936
937 READINT32(in, sourceType_);
938
939 READINT32(in, pointerAction_);
940
941 READINT32(in, originPointerAction_);
942
943 READINT32(in, buttonId_);
944
945 READINT32(in, fingerCount_);
946
947 READFLOAT(in, zOrder_);
948
949 if (!ReadAxisFromParcel(in)) {
950 return false;
951 }
952
953 READINT32(in, axisEventType_);
954 READINT32(in, pullId_);
955 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
956 if (!ReadEnhanceDataFromParcel(in)) {
957 return false;
958 }
959 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
960
961 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
962 READDOUBLE(in, fingerprintDistanceX_);
963 READDOUBLE(in, fingerprintDistanceY_);
964 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
965 return true;
966 }
967
ReadAxisFromParcel(Parcel & in)968 bool PointerEvent::ReadAxisFromParcel(Parcel &in)
969 {
970 uint32_t axes = 0;
971 READUINT32(in, axes);
972
973 for (int32_t i = AXIS_TYPE_UNKNOWN; i < AXIS_TYPE_MAX; ++i) {
974 const AxisType axis { static_cast<AxisType>(i) };
975 if (HasAxis(axes, axis)) {
976 double val;
977 READDOUBLE(in, val);
978 SetAxisValue(axis, val);
979 }
980 }
981 return true;
982 }
983
984 #ifdef OHOS_BUILD_ENABLE_FINGERPRINT
SetFingerprintDistanceX(double x)985 void PointerEvent::SetFingerprintDistanceX(double x)
986 {
987 fingerprintDistanceX_ = x;
988 }
989
SetFingerprintDistanceY(double y)990 void PointerEvent::SetFingerprintDistanceY(double y)
991 {
992 fingerprintDistanceY_ = y;
993 }
994
GetFingerprintDistanceX() const995 double PointerEvent::GetFingerprintDistanceX() const
996 {
997 return fingerprintDistanceX_;
998 }
999
GetFingerprintDistanceY() const1000 double PointerEvent::GetFingerprintDistanceY() const
1001 {
1002 return fingerprintDistanceY_;
1003 }
1004 #endif // OHOS_BUILD_ENABLE_FINGERPRINT
1005
1006 #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT
ReadEnhanceDataFromParcel(Parcel & in)1007 bool PointerEvent::ReadEnhanceDataFromParcel(Parcel &in)
1008 {
1009 int32_t size = 0;
1010 READINT32(in, size);
1011 if (size > static_cast<int32_t>(MAX_N_ENHANCE_DATA_SIZE) || size < 0) {
1012 MMI_HILOGE("enhanceData_ size is invalid");
1013 return false;
1014 }
1015
1016 for (int32_t i = 0; i < size; i++) {
1017 uint32_t val = 0;
1018 READUINT32(in, val);
1019 enhanceData_.emplace_back(val);
1020 }
1021 return true;
1022 }
1023 #endif // OHOS_BUILD_ENABLE_SECURITY_COMPONENT
1024
ReadBufferFromParcel(Parcel & in)1025 bool PointerEvent::ReadBufferFromParcel(Parcel &in)
1026 {
1027 int32_t bufflen = 0;
1028 READINT32(in, bufflen);
1029 if (bufflen > static_cast<int32_t>(MAX_N_BUFFER_SIZE)) {
1030 return false;
1031 }
1032
1033 for (int32_t i = 0; i < bufflen; ++i) {
1034 uint8_t data;
1035 READUINT8(in, data);
1036 buffer_.push_back(data);
1037 }
1038 return true;
1039 }
1040
IsValidCheckMouseFunc() const1041 bool PointerEvent::IsValidCheckMouseFunc() const
1042 {
1043 CALL_DEBUG_ENTER;
1044 if (pointers_.size() != 1) {
1045 MMI_HILOGE("Pointers_ is invalid");
1046 return false;
1047 }
1048
1049 const size_t maxPressedButtons = 3;
1050 if (pressedButtons_.size() > maxPressedButtons) {
1051 MMI_HILOGE("PressedButtons_.size is greater than three and is invalid");
1052 return false;
1053 }
1054
1055 for (const auto &item : pressedButtons_) {
1056 if (item != MOUSE_BUTTON_LEFT && item != MOUSE_BUTTON_RIGHT && item != MOUSE_BUTTON_MIDDLE) {
1057 MMI_HILOGE("PressedButtons_ is invalid");
1058 return false;
1059 }
1060 }
1061
1062 int32_t pointAction = GetPointerAction();
1063 bool checkFlag = pointAction != POINTER_ACTION_CANCEL && pointAction != POINTER_ACTION_MOVE &&
1064 pointAction != POINTER_ACTION_AXIS_BEGIN && pointAction != POINTER_ACTION_AXIS_UPDATE &&
1065 pointAction != POINTER_ACTION_AXIS_END && pointAction != POINTER_ACTION_BUTTON_DOWN &&
1066 pointAction != POINTER_ACTION_BUTTON_UP;
1067 if (checkFlag) {
1068 MMI_HILOGE("PointAction is invalid");
1069 return false;
1070 }
1071
1072 int32_t buttonId = GetButtonId();
1073 if (pointAction == POINTER_ACTION_BUTTON_DOWN || pointAction == POINTER_ACTION_BUTTON_UP) {
1074 if (buttonId != MOUSE_BUTTON_LEFT && buttonId != MOUSE_BUTTON_RIGHT && buttonId != MOUSE_BUTTON_MIDDLE) {
1075 MMI_HILOGE("ButtonId is invalid");
1076 return false;
1077 }
1078 } else {
1079 if (buttonId != BUTTON_NONE) {
1080 MMI_HILOGE("ButtonId is not BUTTON_NONE and is invalid");
1081 return false;
1082 }
1083 }
1084 return true;
1085 }
1086
IsValidCheckMouse() const1087 bool PointerEvent::IsValidCheckMouse() const
1088 {
1089 CALL_DEBUG_ENTER;
1090 int32_t mousePointID = GetPointerId();
1091 if (mousePointID < 0) {
1092 MMI_HILOGE("MousePointID is invalid");
1093 return false;
1094 }
1095
1096 if (!IsValidCheckMouseFunc()) {
1097 MMI_HILOGE("IsValidCheckMouseFunc is invalid");
1098 return false;
1099 }
1100
1101 for (const auto &item : pointers_) {
1102 if (item.GetPointerId() < 0) {
1103 MMI_HILOGE("Item.pointerid is invalid");
1104 return false;
1105 }
1106
1107 if (item.GetPointerId() != mousePointID) {
1108 MMI_HILOGE("Item.pointerid is not same to mousePointID and is invalid");
1109 return false;
1110 }
1111
1112 if (item.GetDownTime() > 0) {
1113 MMI_HILOGE("Item.downtime is invalid");
1114 return false;
1115 }
1116
1117 if (item.IsPressed() != false) {
1118 MMI_HILOGE("Item.ispressed is not false and is invalid");
1119 return false;
1120 }
1121 }
1122 return true;
1123 }
1124
IsValidCheckTouchFunc() const1125 bool PointerEvent::IsValidCheckTouchFunc() const
1126 {
1127 CALL_DEBUG_ENTER;
1128 if (GetPointerId() < 0) {
1129 MMI_HILOGE("TouchPointID is invalid");
1130 return false;
1131 }
1132
1133 if (!pressedButtons_.empty()) {
1134 MMI_HILOGE("PressedButtons_.size is invalid");
1135 return false;
1136 }
1137
1138 int32_t pointAction = GetPointerAction();
1139 if (pointAction != POINTER_ACTION_CANCEL && pointAction != POINTER_ACTION_MOVE &&
1140 pointAction != POINTER_ACTION_DOWN && pointAction != POINTER_ACTION_UP) {
1141 MMI_HILOGE("PointAction is invalid");
1142 return false;
1143 }
1144
1145 if (GetButtonId() != BUTTON_NONE) {
1146 MMI_HILOGE("ButtonId is invalid");
1147 return false;
1148 }
1149 return true;
1150 }
1151
IsValidCheckTouch() const1152 bool PointerEvent::IsValidCheckTouch() const
1153 {
1154 CALL_DEBUG_ENTER;
1155 if (!IsValidCheckTouchFunc()) {
1156 MMI_HILOGE("IsValidCheckTouchFunc is invalid");
1157 return false;
1158 }
1159 bool isSameItem = false;
1160 int32_t touchPointID = GetPointerId();
1161 for (auto item = pointers_.begin(); item != pointers_.end(); item++) {
1162 if (item->GetPointerId() < 0) {
1163 MMI_HILOGE("Item.pointerid is invalid");
1164 return false;
1165 }
1166
1167 if (item->GetPointerId() == touchPointID) {
1168 isSameItem = true;
1169 }
1170
1171 if (item->GetDownTime() <= 0) {
1172 MMI_HILOGE("Item.downtime is invalid");
1173 return false;
1174 }
1175
1176 if (item->IsPressed() != false) {
1177 MMI_HILOGE("Item.ispressed is not false and is invalid");
1178 return false;
1179 }
1180
1181 auto itemtmp = item;
1182 for (++itemtmp; itemtmp != pointers_.end(); itemtmp++) {
1183 if (item->GetPointerId() == itemtmp->GetPointerId()) {
1184 MMI_HILOGE("Pointitems pointerid exist same items and is invalid");
1185 return false;
1186 }
1187 }
1188 }
1189
1190 if (!isSameItem) {
1191 MMI_HILOGE("Item.pointerid is not same to touchPointID and is invalid");
1192 return false;
1193 }
1194 return true;
1195 }
1196
IsValid() const1197 bool PointerEvent::IsValid() const
1198 {
1199 CALL_DEBUG_ENTER;
1200 switch (GetSourceType()) {
1201 case SOURCE_TYPE_MOUSE: {
1202 if (!IsValidCheckMouse()) {
1203 MMI_HILOGE("IsValidCheckMouse is invalid");
1204 return false;
1205 }
1206 break;
1207 }
1208 case SOURCE_TYPE_TOUCHSCREEN:
1209 case SOURCE_TYPE_TOUCHPAD: {
1210 if (!IsValidCheckTouch()) {
1211 MMI_HILOGE("IsValidCheckTouch is invalid");
1212 return false;
1213 }
1214 break;
1215 }
1216 case SOURCE_TYPE_JOYSTICK:
1217 break;
1218 default: {
1219 MMI_HILOGE("SourceType is invalid");
1220 return false;
1221 }
1222 }
1223 return true;
1224 }
1225
SetBuffer(std::vector<uint8_t> buffer)1226 void PointerEvent::SetBuffer(std::vector<uint8_t> buffer)
1227 {
1228 buffer_ = buffer;
1229 }
1230
ClearBuffer()1231 void PointerEvent::ClearBuffer()
1232 {
1233 buffer_.clear();
1234 }
1235
GetBuffer() const1236 std::vector<uint8_t> PointerEvent::GetBuffer() const
1237 {
1238 return buffer_;
1239 }
1240
GetDispatchTimes() const1241 int32_t PointerEvent::GetDispatchTimes() const
1242 {
1243 return dispatchTimes_;
1244 }
1245
SetDispatchTimes(int32_t dispatchTimes)1246 void PointerEvent::SetDispatchTimes(int32_t dispatchTimes)
1247 {
1248 dispatchTimes_ = dispatchTimes;
1249 }
1250
SetHandlerEventType(HandleEventType eventType)1251 void PointerEvent::SetHandlerEventType(HandleEventType eventType)
1252 {
1253 handleEventType_ = eventType;
1254 }
1255
GetHandlerEventType() const1256 HandleEventType PointerEvent::GetHandlerEventType() const
1257 {
1258 return handleEventType_;
1259 }
1260
1261 #ifdef OHOS_BUILD_ENABLE_ANCO
SetAncoDeal(bool ancoDeal)1262 void PointerEvent::SetAncoDeal(bool ancoDeal)
1263 {
1264 ancoDeal_ = ancoDeal;
1265 }
1266
GetAncoDeal() const1267 bool PointerEvent::GetAncoDeal() const
1268 {
1269 return ancoDeal_;
1270 }
1271 #endif // OHOS_BUILD_ENABLE_ANCO
1272
ActionToShortStr(int32_t action)1273 std::string_view PointerEvent::ActionToShortStr(int32_t action)
1274 {
1275 // 该函数逻辑简单,功能单一,考虑性能影响,使用switch-case而不是表驱动实现。
1276 switch (action) {
1277 case PointerEvent::POINTER_ACTION_CANCEL:
1278 return "P:C:";
1279 case PointerEvent::POINTER_ACTION_DOWN:
1280 return "P:D:";
1281 case PointerEvent::POINTER_ACTION_MOVE:
1282 return "P:M:";
1283 case PointerEvent::POINTER_ACTION_UP:
1284 return "P:U:";
1285 case PointerEvent::POINTER_ACTION_AXIS_BEGIN:
1286 return "P:AB:";
1287 case PointerEvent::POINTER_ACTION_AXIS_UPDATE:
1288 return "P:AU:";
1289 case PointerEvent::POINTER_ACTION_AXIS_END:
1290 return "P:AE:";
1291 case PointerEvent::POINTER_ACTION_BUTTON_DOWN:
1292 return "P:BD:";
1293 case PointerEvent::POINTER_ACTION_BUTTON_UP:
1294 return "P:BU:";
1295 case PointerEvent::POINTER_ACTION_ENTER_WINDOW:
1296 return "P:EW:";
1297 case PointerEvent::POINTER_ACTION_LEAVE_WINDOW:
1298 return "P:LW:";
1299 case PointerEvent::POINTER_ACTION_PULL_DOWN:
1300 return "P:PD:";
1301 case PointerEvent::POINTER_ACTION_PULL_MOVE:
1302 return "P:PM:";
1303 case PointerEvent::POINTER_ACTION_PULL_UP:
1304 return "P:PU:";
1305 case PointerEvent::POINTER_ACTION_PULL_IN_WINDOW:
1306 return "P:PI:";
1307 case PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW:
1308 return "P:PO:";
1309 case PointerEvent::POINTER_ACTION_SWIPE_BEGIN:
1310 return "P:SB:";
1311 case PointerEvent::POINTER_ACTION_SWIPE_UPDATE:
1312 return "P:SU:";
1313 case PointerEvent::POINTER_ACTION_SWIPE_END:
1314 return "P:SE:";
1315 case PointerEvent::POINTER_ACTION_ROTATE_BEGIN:
1316 return "P:RB:";
1317 case PointerEvent::POINTER_ACTION_ROTATE_UPDATE:
1318 return "P:RU:";
1319 case PointerEvent::POINTER_ACTION_ROTATE_END:
1320 return "P:RE:";
1321 case PointerEvent::POINTER_ACTION_TRIPTAP:
1322 return "P:TT:";
1323 case PointerEvent::POINTER_ACTION_QUADTAP:
1324 return "P:Q:";
1325 case PointerEvent::POINTER_ACTION_HOVER_MOVE:
1326 return "P:HM:";
1327 case PointerEvent::POINTER_ACTION_HOVER_ENTER:
1328 return "P:HE:";
1329 case PointerEvent::POINTER_ACTION_HOVER_EXIT:
1330 return "P:HEX:";
1331 case PointerEvent::POINTER_ACTION_FINGERPRINT_DOWN:
1332 return "P:FD:";
1333 case PointerEvent::POINTER_ACTION_FINGERPRINT_UP:
1334 return "P:FU:";
1335 case PointerEvent::POINTER_ACTION_FINGERPRINT_SLIDE:
1336 return "P:FS:";
1337 case PointerEvent::POINTER_ACTION_FINGERPRINT_RETOUCH:
1338 return "P:FR:";
1339 case PointerEvent::POINTER_ACTION_FINGERPRINT_CLICK:
1340 return "P:FC:";
1341 case PointerEvent::POINTER_ACTION_FINGERPRINT_CANCEL:
1342 return "P:FCA:";
1343 case PointerEvent::POINTER_ACTION_UNKNOWN:
1344 return "P:UK:";
1345 default:
1346 return "P:?:";
1347 }
1348 }
1349 } // namespace MMI
1350 } // namespace OHOS
1351