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 #include "mock_input_event.h"
17
18 namespace OHOS {
19 namespace MMI {
InputEvent(int32_t eventType)20 InputEvent::InputEvent(int32_t eventType) : eventType_(eventType)
21 {
22 Reset();
23 }
24
InputEvent(const InputEvent & other)25 InputEvent::InputEvent(const InputEvent& other)
26 : eventType_(other.eventType_), id_(other.id_), actionTime_(other.actionTime_),
27 action_(other.action_), actionStartTime_(other.actionStartTime_),
28 deviceId_(other.deviceId_), targetDisplayId_(other.targetDisplayId_),
29 targetWindowId_(other.targetWindowId_), agentWindowId_(other.agentWindowId_),
30 bitwise_(other.bitwise_), processedCallback_(other.processedCallback_)
31 {}
32
~InputEvent()33 InputEvent::~InputEvent() {}
34
Reset()35 void InputEvent::Reset()
36 {
37 }
38
Create()39 std::shared_ptr<InputEvent> InputEvent::Create()
40 {
41 return std::shared_ptr<InputEvent>(new InputEvent(InputEvent::EVENT_TYPE_BASE));
42 }
43
GetId() const44 int32_t InputEvent::GetId() const
45 {
46 return id_;
47 }
48
SetId(int32_t id)49 void InputEvent::SetId(int32_t id)
50 {
51 id_ = id;
52 }
53
UpdateId()54 void InputEvent::UpdateId()
55 {
56 }
57
GetActionTime() const58 int64_t InputEvent::GetActionTime() const
59 {
60 return actionTime_;
61 }
62
SetActionTime(int64_t actionTime)63 void InputEvent::SetActionTime(int64_t actionTime)
64 {
65 actionTime_ = actionTime;
66 }
67
GetAction() const68 int32_t InputEvent::GetAction() const
69 {
70 return action_;
71 }
72
SetAction(int32_t action)73 void InputEvent::SetAction(int32_t action)
74 {
75 action_ = action;
76 }
77
GetActionStartTime() const78 int64_t InputEvent::GetActionStartTime() const
79 {
80 return actionStartTime_;
81 }
82
SetActionStartTime(int64_t actionStartTime)83 void InputEvent::SetActionStartTime(int64_t actionStartTime)
84 {
85 actionStartTime_ = actionStartTime;
86 }
87
GetFlag() const88 uint32_t InputEvent::GetFlag() const
89 {
90 return bitwise_;
91 }
92
HasFlag(uint32_t flag)93 bool InputEvent::HasFlag(uint32_t flag)
94 {
95 return (bitwise_ & flag) != 0;
96 }
97
AddFlag(uint32_t flag)98 void InputEvent::AddFlag(uint32_t flag)
99 {
100 bitwise_ |= flag;
101 }
102
ClearFlag()103 void InputEvent::ClearFlag()
104 {
105 bitwise_ = EVENT_FLAG_NONE;
106 }
107 }
108 }