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 #include "switch_event_input_subscribe_manager.h" 26 27 namespace OHOS { 28 namespace MMI { 29 enum RES_STATUS : uint8_t { 30 REG_STATUS_NOT_SYNC = 0, 31 REG_STATUS_SYNCED = 1 32 }; 33 34 class MultimodalEventHandler final { 35 DECLARE_SINGLETON(MultimodalEventHandler); 36 37 public: 38 DISALLOW_MOVE(MultimodalEventHandler); 39 40 MMIClientPtr GetMMIClient(); 41 bool InitClient(EventHandlerPtr eventHandler = nullptr); 42 #ifdef OHOS_BUILD_ENABLE_KEYBOARD 43 int32_t SubscribeKeyEvent(const KeyEventInputSubscribeManager::SubscribeKeyEventInfo& subscribeInfo); 44 int32_t UnsubscribeKeyEvent(int32_t subscribeId); 45 int32_t InjectEvent(const std::shared_ptr<KeyEvent> keyEvent, bool isNativeInject); 46 #endif // OHOS_BUILD_ENABLE_KEYBOARD 47 #ifdef OHOS_BUILD_ENABLE_SWITCH 48 int32_t SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType); 49 int32_t UnsubscribeSwitchEvent(int32_t subscribeId); 50 #endif // OHOS_BUILD_ENABLE_SWITCH 51 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) 52 int32_t InjectPointerEvent(std::shared_ptr<PointerEvent> pointerEvent, bool isNativeInject); 53 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH 54 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) 55 int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY); 56 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING 57 int32_t Authorize(bool isAuthorize); 58 int32_t CancelInjection(); 59 60 private: 61 MMIClientPtr client_ { nullptr }; 62 }; 63 64 #define MMIEventHdl ::OHOS::Singleton<MultimodalEventHandler>::GetInstance() 65 } // namespace MMI 66 } // namespace OHOS 67 #endif // MULTIMODAL_EVENT_HANDLER_H