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 "accessibility_event_transmission.h"
17 #include "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace Accessibility {
OnKeyEvent(MMI::KeyEvent & event)21 bool EventTransmission::OnKeyEvent(MMI::KeyEvent &event)
22 {
23     HILOG_DEBUG();
24 
25     auto next = GetNext();
26     if (next != nullptr) {
27         return next->OnKeyEvent(event);
28     }
29     return false;
30 }
31 
OnPointerEvent(MMI::PointerEvent & event)32 bool EventTransmission::OnPointerEvent(MMI::PointerEvent &event)
33 {
34     HILOG_DEBUG();
35 
36     auto next = GetNext();
37     if (next != nullptr) {
38         return next->OnPointerEvent(event);
39     }
40     return false;
41 }
42 
OnMoveMouse(int32_t offsetX,int32_t offsetY)43 void EventTransmission::OnMoveMouse(int32_t offsetX, int32_t offsetY)
44 {
45     HILOG_DEBUG();
46 
47     auto next = GetNext();
48     if (next != nullptr) {
49         next->OnMoveMouse(offsetX, offsetY);
50     }
51 }
52 
SetNext(const sptr<EventTransmission> & next)53 void EventTransmission::SetNext(const sptr<EventTransmission> &next)
54 {
55     HILOG_DEBUG();
56 
57     next_ = next;
58 }
59 
GetNext()60 sptr<EventTransmission> EventTransmission::GetNext()
61 {
62     HILOG_DEBUG();
63 
64     return next_;
65 }
66 
DestroyEvents()67 void EventTransmission::DestroyEvents()
68 {
69     HILOG_DEBUG();
70 
71     auto next = GetNext();
72     if (next != nullptr) {
73         next->DestroyEvents();
74     }
75 }
76 } // namespace Accessibility
77 } // namespace OHOS
78