• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef TOUCH_EVENT_H
17 #define TOUCH_EVENT_H
18 
19 #include "manipulation_event.h"
20 
21 namespace OHOS {
22 struct TouchProperty {
23     int action;
24     int index;
25     float forcePrecision;
26     float maxForce;
27     float tapCount;
28 
29     std::shared_ptr<MultimodalEvent> multimodalEvent;
30 };
31 
32 class TouchEvent : public ManipulationEvent {
33 public:
34     void Initialize(MultimodalProperty &multimodalStruct,
35         ManipulationProperty &manipulationProperty, TouchProperty touchProperty);
36 
SetMultimodalEvent(std::shared_ptr<MultimodalEvent> multimodalEvent)37     void SetMultimodalEvent(std::shared_ptr<MultimodalEvent> multimodalEvent) {
38         touchProperty_.multimodalEvent = multimodalEvent;
39     }
40 
GetMultimodalEvent()41     const std::shared_ptr<MultimodalEvent> GetMultimodalEvent() {
42         return touchProperty_.multimodalEvent;
43     }
44 
45     virtual int GetAction();
46 
47     virtual int GetIndex();
48 
49     virtual float GetForcePrecision();
50 
51     virtual float GetMaxForce();
52 
53     virtual float GetTapCount();
54 
55     int GetPhase() override;
56 
57     bool Marshalling(Parcel &parcel) const override;
58     static TouchEvent *Unmarshalling(Parcel &parcel);
59 
60     static constexpr int NONE = 0;
61 
62     static constexpr int PRIMARY_POINT_DOWN = 1;
63 
64     static constexpr int PRIMARY_POINT_UP = 2;
65 
66     static constexpr int POINT_MOVE = 3;
67 
68     static constexpr int OTHER_POINT_DOWN = 4;
69 
70     static constexpr int OTHER_POINT_UP = 5;
71 
72     static constexpr int CANCEL = 6;
73 
74     static constexpr int HOVER_POINTER_ENTER = 7;
75 
76     static constexpr int HOVER_POINTER_MOVE = 8;
77 
78     static constexpr int HOVER_POINTER_EXIT = 9;
79 
80     static constexpr int OTHER = 10;
81 protected:
82     TouchProperty touchProperty_;
83 };
84 }  // namespace OHOS
85 #endif  // TOUCH_EVENT_H