1 /*
2 * Copyright (C) 2022 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 #define private public
17 #define protected public
18 #include "input_event.h"
19 #undef private
20 #undef protected
21 #include "mock_input_event.h"
22
23 namespace OHOS {
24 namespace MMI {
InputEvent(int32_t eventType)25 InputEvent::InputEvent(int32_t eventType) : eventType_(eventType)
26 {
27 Reset();
28 }
29
InputEvent(const InputEvent & other)30 InputEvent::InputEvent(const InputEvent& other)
31 : eventType_(other.eventType_),
32 id_(other.id_),
33 actionTime_(other.actionTime_),
34 action_(other.action_),
35 actionStartTime_(other.actionStartTime_),
36 deviceId_(other.deviceId_),
37 sourceType_(other.sourceType_),
38 targetDisplayId_(other.targetDisplayId_),
39 targetWindowId_(other.targetWindowId_),
40 agentWindowId_(other.agentWindowId_),
41 bitwise_(other.bitwise_),
42 processedCallback_(other.processedCallback_)
43 {}
44
~InputEvent()45 InputEvent::~InputEvent()
46 {}
47
Reset()48 void InputEvent::Reset()
49 {}
50
ToString()51 std::string InputEvent::ToString()
52 {
53 return "";
54 }
55
Create()56 std::shared_ptr<InputEvent> InputEvent::Create()
57 {
58 return std::make_shared<InputEvent>(InputEvent::EVENT_TYPE_BASE);
59 }
60
GetId() const61 int32_t InputEvent::GetId() const
62 {
63 return id_;
64 }
65
SetId(int32_t id)66 void InputEvent::SetId(int32_t id)
67 {
68 id_ = id;
69 }
70
UpdateId()71 void InputEvent::UpdateId()
72 {}
73
GetActionTime() const74 int64_t InputEvent::GetActionTime() const
75 {
76 return actionTime_;
77 }
78
SetActionTime(int64_t actionTime)79 void InputEvent::SetActionTime(int64_t actionTime)
80 {
81 actionTime_ = actionTime;
82 }
83
GetAction() const84 int32_t InputEvent::GetAction() const
85 {
86 return action_;
87 }
88
SetAction(int32_t action)89 void InputEvent::SetAction(int32_t action)
90 {
91 action_ = action;
92 }
93
GetActionStartTime() const94 int64_t InputEvent::GetActionStartTime() const
95 {
96 return actionStartTime_;
97 }
98
SetActionStartTime(int64_t actionStartTime)99 void InputEvent::SetActionStartTime(int64_t actionStartTime)
100 {
101 actionStartTime_ = actionStartTime;
102 }
103
GetSourceType() const104 int32_t InputEvent::GetSourceType() const
105 {
106 return sourceType_;
107 }
108
SetSourceType(int32_t sourceType)109 void InputEvent::SetSourceType(int32_t sourceType)
110 {
111 sourceType_ = sourceType;
112 }
113
GetFlag() const114 uint32_t InputEvent::GetFlag() const
115 {
116 return bitwise_;
117 }
118
HasFlag(uint32_t flag)119 bool InputEvent::HasFlag(uint32_t flag)
120 {
121 return (bitwise_ & flag) != 0;
122 }
123
AddFlag(uint32_t flag)124 void InputEvent::AddFlag(uint32_t flag)
125 {
126 bitwise_ |= flag;
127 }
128
ClearFlag()129 void InputEvent::ClearFlag()
130 {
131 bitwise_ = EVENT_FLAG_NONE;
132 }
133 } // namespace MMI
134 } // namespace OHOS