/* * 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_MANAGER_IMPL_H #define INPUT_MANAGER_IMPL_H #include #include "singleton.h" #include "display_info.h" #include "i_input_event_consumer.h" #include "pointer_event.h" #include "if_mmi_client.h" #include "net_packet.h" #include "if_client_msg_handler.h" #include "event_filter_service.h" #include "input_monitor_manager.h" #include "input_interceptor_manager.h" namespace OHOS { namespace MMI { class InputManagerImpl : public DelayedSingleton { public: virtual ~InputManagerImpl() = default; InputManagerImpl() = default; void UpdateDisplayInfo(const std::vector &physicalDisplays, const std::vector &logicalDisplays); // 建议本地调用,可IPC int32_t AddInputEventFilter(std::function)> filter); void SetWindowInputEventConsumer(std::shared_ptr inputEventConsumer); void OnKeyEvent(std::shared_ptr keyEvent); void OnPointerEvent(std::shared_ptr pointerEvent); int32_t PackDisplayData(NetPacket &pkt); int32_t AddMonitor(std::function)> monitor); int32_t AddMontior(std::function)> monitor); int32_t AddMonitor(std::shared_ptr consumer); void RemoveMonitor(int32_t monitorId); void MarkConsumed(int32_t monitorId, int32_t eventId); int32_t AddInterceptor(std::shared_ptr interceptor); int32_t AddInterceptor(int32_t sourceType, std::function)> interceptor); int32_t AddInterceptor(std::function)> interceptor); void RemoveInterceptor(int32_t interceptorId); void SimulateInputEvent(std::shared_ptr keyEvent); void SimulateInputEvent(std::shared_ptr pointerEvent); void OnConnected(); private: int32_t PackPhysicalDisplay(NetPacket &pkt); int32_t PackLogicalDisplay(NetPacket &pkt); void PrintDisplayDebugInfo(); void SendDisplayInfo(); private: sptr eventFilterService_ {nullptr}; std::shared_ptr consumer_ = nullptr; std::vector physicalDisplays_; std::vector logicalDisplays_; InputMonitorManager monitorManager_; InputInterceptorManager interceptorManager_; }; } // namespace MMI } // namespace OHOS #endif // INPUT_MANAGER_IMPL_H