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
Create()51 std::shared_ptr<InputEvent> InputEvent::Create()
52 {
53 return std::make_shared<InputEvent>(InputEvent::EVENT_TYPE_BASE);
54 }
55
GetId() const56 int32_t InputEvent::GetId() const
57 {
58 return id_;
59 }
60
SetId(int32_t id)61 void InputEvent::SetId(int32_t id)
62 {
63 id_ = id;
64 }
65
UpdateId()66 void InputEvent::UpdateId()
67 {}
68
GetActionTime() const69 int64_t InputEvent::GetActionTime() const
70 {
71 return actionTime_;
72 }
73
SetActionTime(int64_t actionTime)74 void InputEvent::SetActionTime(int64_t actionTime)
75 {
76 actionTime_ = actionTime;
77 }
78
GetAction() const79 int32_t InputEvent::GetAction() const
80 {
81 return action_;
82 }
83
SetAction(int32_t action)84 void InputEvent::SetAction(int32_t action)
85 {
86 action_ = action;
87 }
88
GetActionStartTime() const89 int64_t InputEvent::GetActionStartTime() const
90 {
91 return actionStartTime_;
92 }
93
SetActionStartTime(int64_t actionStartTime)94 void InputEvent::SetActionStartTime(int64_t actionStartTime)
95 {
96 actionStartTime_ = actionStartTime;
97 }
98
GetSourceType() const99 int32_t InputEvent::GetSourceType() const
100 {
101 return sourceType_;
102 }
103
SetSourceType(int32_t sourceType)104 void InputEvent::SetSourceType(int32_t sourceType)
105 {
106 sourceType_ = sourceType;
107 }
108
GetFlag() const109 uint32_t InputEvent::GetFlag() const
110 {
111 return bitwise_;
112 }
113
HasFlag(uint32_t flag)114 bool InputEvent::HasFlag(uint32_t flag)
115 {
116 return (bitwise_ & flag) != 0;
117 }
118
AddFlag(uint32_t flag)119 void InputEvent::AddFlag(uint32_t flag)
120 {
121 bitwise_ |= flag;
122 }
123
ClearFlag()124 void InputEvent::ClearFlag()
125 {
126 bitwise_ = EVENT_FLAG_NONE;
127 }
128 } // namespace MMI
129 } // namespace OHOS