1 /*
2 * Copyright (C) 2021 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 "manipulation_event.h"
17 #include "mmi_point.h"
18 namespace OHOS {
Initialize(MultimodalProperty & multiProperty,ManipulationProperty & manipulationProperty)19 void ManipulationEvent::Initialize(MultimodalProperty &multiProperty,
20 ManipulationProperty &manipulationProperty)
21 {
22 MultimodalEvent::Initialize(multiProperty);
23 manipulationProperty_.startTime = manipulationProperty.startTime;
24 manipulationProperty_.operationState = manipulationProperty.operationState;
25 manipulationProperty_.pointerCount = manipulationProperty.pointerCount;
26 manipulationProperty_.pointerId = manipulationProperty.pointerId;
27 manipulationProperty_.mp = manipulationProperty.mp;
28 manipulationProperty_.touchArea = manipulationProperty.touchArea;
29 manipulationProperty_.touchPressure = manipulationProperty.touchPressure;
30 manipulationProperty_.offsetX = manipulationProperty.offsetX;
31 manipulationProperty_.offsetY = manipulationProperty.offsetY;
32
33 }
34
GetStartTime()35 int32_t ManipulationEvent::GetStartTime()
36 {
37 return manipulationProperty_.startTime;
38 }
39
GetPhase()40 int ManipulationEvent::GetPhase()
41 {
42 return manipulationProperty_.operationState;
43 }
44
GetPointerPosition(int index)45 MmiPoint ManipulationEvent::GetPointerPosition(int index)
46 {
47 return MmiPoint(manipulationProperty_.mp.px_ - manipulationProperty_.offsetX,
48 manipulationProperty_.mp.py_ - manipulationProperty_.offsetY);
49 }
50
SetScreenOffset(float offsetX,float offsetY)51 void ManipulationEvent::SetScreenOffset(float offsetX, float offsetY)
52 {
53 manipulationProperty_.offsetX = offsetX;
54 manipulationProperty_.offsetY = offsetY;
55 }
56
GetPointerScreenPosition(int index)57 MmiPoint ManipulationEvent::GetPointerScreenPosition(int index)
58 {
59 return manipulationProperty_.mp;
60 }
61
GetPointerCount()62 int ManipulationEvent::GetPointerCount()
63 {
64 return manipulationProperty_.pointerCount;
65 }
66
GetPointerId(int index)67 int ManipulationEvent::GetPointerId(int index)
68 {
69 return manipulationProperty_.pointerId;
70 }
71
GetForce(int index)72 float ManipulationEvent::GetForce(int index)
73 {
74 return manipulationProperty_.touchArea;
75 }
76
GetRadius(int index)77 float ManipulationEvent::GetRadius(int index)
78 {
79 return manipulationProperty_.touchPressure;
80 }
81
Marshalling(Parcel & parcel) const82 bool ManipulationEvent::Marshalling(Parcel &parcel) const
83 {
84 return false;
85 }
86
Unmarshalling(Parcel & parcel)87 ManipulationEvent *ManipulationEvent::Unmarshalling(Parcel &parcel)
88 {
89 ManipulationEvent *event = new (std::nothrow) ManipulationEvent();
90 if (event == nullptr) {
91 return nullptr;
92 }
93 return event;
94 }
95 }
96