• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_),
27       id_(other.id_),
28       actionTime_(other.actionTime_),
29       action_(other.action_),
30       actionStartTime_(other.actionStartTime_),
31       deviceId_(other.deviceId_),
32       targetDisplayId_(other.targetDisplayId_),
33       targetWindowId_(other.targetWindowId_),
34       agentWindowId_(other.agentWindowId_),
35       bitwise_(other.bitwise_),
36       processedCallback_(other.processedCallback_)
37 {}
38 
~InputEvent()39 InputEvent::~InputEvent()
40 {}
41 
Reset()42 void InputEvent::Reset()
43 {}
44 
Create()45 std::shared_ptr<InputEvent> InputEvent::Create()
46 {
47     return std::shared_ptr<InputEvent>(new InputEvent(InputEvent::EVENT_TYPE_BASE));
48 }
49 
GetId() const50 int32_t InputEvent::GetId() const
51 {
52     return id_;
53 }
54 
SetId(int32_t id)55 void InputEvent::SetId(int32_t id)
56 {
57     id_ = id;
58 }
59 
UpdateId()60 void InputEvent::UpdateId()
61 {}
62 
GetActionTime() const63 int64_t InputEvent::GetActionTime() const
64 {
65     return actionTime_;
66 }
67 
SetActionTime(int64_t actionTime)68 void InputEvent::SetActionTime(int64_t actionTime)
69 {
70     actionTime_ = actionTime;
71 }
72 
GetAction() const73 int32_t InputEvent::GetAction() const
74 {
75     return action_;
76 }
77 
SetAction(int32_t action)78 void InputEvent::SetAction(int32_t action)
79 {
80     action_ = action;
81 }
82 
GetActionStartTime() const83 int64_t InputEvent::GetActionStartTime() const
84 {
85     return actionStartTime_;
86 }
87 
SetActionStartTime(int64_t actionStartTime)88 void InputEvent::SetActionStartTime(int64_t actionStartTime)
89 {
90     actionStartTime_ = actionStartTime;
91 }
92 
GetFlag() const93 uint32_t InputEvent::GetFlag() const
94 {
95     return bitwise_;
96 }
97 
HasFlag(uint32_t flag)98 bool InputEvent::HasFlag(uint32_t flag)
99 {
100     return (bitwise_ & flag) != 0;
101 }
102 
AddFlag(uint32_t flag)103 void InputEvent::AddFlag(uint32_t flag)
104 {
105     bitwise_ |= flag;
106 }
107 
ClearFlag()108 void InputEvent::ClearFlag()
109 {
110     bitwise_ = EVENT_FLAG_NONE;
111 }
112 } // namespace MMI
113 } // namespace OHOS