/* * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INPUT_EVENT_HANDLER_H #define INPUT_EVENT_HANDLER_H #include #include "singleton.h" #include "event_dispatch_handler.h" #include "event_filter_handler.h" #include "event_interceptor_handler.h" #include "event_monitor_handler.h" #include "event_normalize_handler.h" #include "i_event_filter.h" #include "i_input_event_handler.h" #include "key_command_handler.h" #include "key_subscriber_handler.h" #ifdef OHOS_BUILD_ENABLE_POINTER #include "mouse_event_normalize.h" #endif // OHOS_BUILD_ENABLE_POINTER // #ifdef OHOS_BUILD_ENABLE_SWITCH #include "switch_subscriber_handler.h" // #endif // OHOS_BUILD_ENABLE_SWITCH namespace OHOS { namespace MMI { using EventFun = std::function; using NotifyDeviceChange = std::function; class InputEventHandler final : public std::enable_shared_from_this { DECLARE_DELAYED_SINGLETON(InputEventHandler); public: DISALLOW_COPY_AND_MOVE(InputEventHandler); void Init(UDSServer& udsServer); void OnEvent(void *event, int64_t frameTime); UDSServer *GetUDSServer() const; int32_t GetIntervalSinceLastInput(int64_t &timeInterval); std::shared_ptr GetEventNormalizeHandler() const; std::shared_ptr GetInterceptorHandler() const; std::shared_ptr GetSubscriberHandler() const; std::shared_ptr GetSwitchSubscriberHandler() const; std::shared_ptr GetKeyCommandHandler() const; std::shared_ptr GetMonitorHandler() const; std::shared_ptr GetFilterHandler() const; std::shared_ptr GetEventDispatchHandler() const; private: int32_t BuildInputHandlerChain(); bool IsTouchpadMistouch(libinput_event* event); bool IsTouchpadTapMistouch(libinput_event* event); UDSServer *udsServer_ { nullptr }; std::shared_ptr eventNormalizeHandler_ { nullptr }; std::shared_ptr eventFilterHandler_ { nullptr }; std::shared_ptr eventInterceptorHandler_ { nullptr }; std::shared_ptr eventSubscriberHandler_ { nullptr }; std::shared_ptr switchEventSubscriberHandler_ { nullptr }; std::shared_ptr eventKeyCommandHandler_ { nullptr }; std::shared_ptr eventMonitorHandler_ { nullptr }; std::shared_ptr eventDispatchHandler_ { nullptr }; uint64_t idSeed_ { 0 }; bool isTyping_ { false }; int32_t timerId_ { -1 }; bool isTapMistouch_ { false }; int64_t lastEventBeginTime_ { 0 }; }; #define InputHandler ::OHOS::DelayedSingleton::GetInstance() } // namespace MMI } // namespace OHOS #endif // INPUT_EVENT_HANDLER_H