1 /* 2 * Copyright (c) 2021-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 #ifndef MULTIMODAL_EVENT_HANDLER_H 16 #define MULTIMODAL_EVENT_HANDLER_H 17 18 #include "nocopyable.h" 19 #include "singleton.h" 20 21 #include "if_mmi_client.h" 22 #include "key_event_input_subscribe_manager.h" 23 #include "pointer_event.h" 24 #include "proto.h" 25 26 namespace OHOS { 27 namespace MMI { 28 enum RES_STATUS : uint8_t { 29 REG_STATUS_NOT_SYNC = 0, 30 REG_STATUS_SYNCED = 1 31 }; 32 33 class MultimodalEventHandler final { 34 DECLARE_SINGLETON(MultimodalEventHandler); 35 36 public: 37 DISALLOW_MOVE(MultimodalEventHandler); 38 39 MMIClientPtr GetMMIClient(); 40 bool InitClient(EventHandlerPtr eventHandler = nullptr); 41 #ifdef OHOS_BUILD_ENABLE_KEYBOARD 42 int32_t SubscribeKeyEvent(const KeyEventInputSubscribeManager::SubscribeKeyEventInfo& subscribeInfo); 43 int32_t UnsubscribeKeyEvent(int32_t subscribeId); 44 int32_t InjectEvent(const std::shared_ptr<KeyEvent> keyEvent); 45 #endif // OHOS_BUILD_ENABLE_KEYBOARD 46 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) 47 int32_t InjectPointerEvent(std::shared_ptr<PointerEvent> pointerEvent); 48 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 49 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) 50 int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY); 51 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING 52 53 private: 54 MMIClientPtr client_ { nullptr }; 55 }; 56 57 #define MMIEventHdl ::OHOS::Singleton<MultimodalEventHandler>::GetInstance() 58 } // namespace MMI 59 } // namespace OHOS 60 #endif // MULTIMODAL_EVENT_HANDLER_H