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       targetDisplayId_(other.targetDisplayId_),
38       targetWindowId_(other.targetWindowId_),
39       agentWindowId_(other.agentWindowId_),
40       bitwise_(other.bitwise_),
41       processedCallback_(other.processedCallback_)
42 {}
43 
~InputEvent()44 InputEvent::~InputEvent()
45 {}
46 
Reset()47 void InputEvent::Reset()
48 {}
49 
Create()50 std::shared_ptr<InputEvent> InputEvent::Create()
51 {
52     return std::make_shared<InputEvent>(InputEvent::EVENT_TYPE_BASE);
53 }
54 
GetId() const55 int32_t InputEvent::GetId() const
56 {
57     return id_;
58 }
59 
SetId(int32_t id)60 void InputEvent::SetId(int32_t id)
61 {
62     id_ = id;
63 }
64 
UpdateId()65 void InputEvent::UpdateId()
66 {}
67 
GetActionTime() const68 int64_t InputEvent::GetActionTime() const
69 {
70     return actionTime_;
71 }
72 
SetActionTime(int64_t actionTime)73 void InputEvent::SetActionTime(int64_t actionTime)
74 {
75     actionTime_ = actionTime;
76 }
77 
GetAction() const78 int32_t InputEvent::GetAction() const
79 {
80     return action_;
81 }
82 
SetAction(int32_t action)83 void InputEvent::SetAction(int32_t action)
84 {
85     action_ = action;
86 }
87 
GetActionStartTime() const88 int64_t InputEvent::GetActionStartTime() const
89 {
90     return actionStartTime_;
91 }
92 
SetActionStartTime(int64_t actionStartTime)93 void InputEvent::SetActionStartTime(int64_t actionStartTime)
94 {
95     actionStartTime_ = actionStartTime;
96 }
97 
GetFlag() const98 uint32_t InputEvent::GetFlag() const
99 {
100     return bitwise_;
101 }
102 
HasFlag(uint32_t flag)103 bool InputEvent::HasFlag(uint32_t flag)
104 {
105     return (bitwise_ & flag) != 0;
106 }
107 
AddFlag(uint32_t flag)108 void InputEvent::AddFlag(uint32_t flag)
109 {
110     bitwise_ |= flag;
111 }
112 
ClearFlag()113 void InputEvent::ClearFlag()
114 {
115     bitwise_ = EVENT_FLAG_NONE;
116 }
117 } // namespace MMI
118 } // namespace OHOS