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 #ifndef I_INPUT_EVENT_HANDLER_H 17 #define I_INPUT_EVENT_HANDLER_H 18 19 #include <memory> 20 21 #include "define_multimodal.h" 22 #include "key_event.h" 23 #include "pointer_event.h" 24 #include "switch_event.h" 25 26 struct libinput_event; 27 28 namespace OHOS { 29 namespace MMI { 30 class IInputEventHandler { 31 public: 32 IInputEventHandler() = default; 33 DISALLOW_COPY_AND_MOVE(IInputEventHandler); 34 virtual ~IInputEventHandler() = default; 35 #ifdef OHOS_BUILD_ENABLE_KEYBOARD 36 virtual void HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent) = 0; 37 #endif // OHOS_BUILD_ENABLE_KEYBOARD 38 #ifdef OHOS_BUILD_ENABLE_POINTER 39 virtual void HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent) = 0; 40 #endif // OHOS_BUILD_ENABLE_POINTER 41 #ifdef OHOS_BUILD_ENABLE_TOUCH 42 virtual void HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent) = 0; 43 #endif // OHOS_BUILD_ENABLE_TOUCH 44 #ifdef OHOS_BUILD_ENABLE_SWITCH HandleSwitchEvent(const std::shared_ptr<SwitchEvent> switchEvent)45 virtual void HandleSwitchEvent(const std::shared_ptr<SwitchEvent> switchEvent) 46 { 47 if (nextHandler_ != nullptr) { 48 nextHandler_->HandleSwitchEvent(switchEvent); 49 } 50 } 51 #endif // OHOS_BUILD_ENABLE_SWITCH SetNext(std::shared_ptr<IInputEventHandler> nextHandler)52 virtual void SetNext(std::shared_ptr<IInputEventHandler> nextHandler) 53 { 54 nextHandler_ = nextHandler; 55 }; 56 57 protected: 58 std::shared_ptr<IInputEventHandler> nextHandler_ { nullptr }; 59 }; 60 } // namespace MMI 61 } // namespace OHOS 62 #endif // I_INPUT_EVENT_HANDLER_H