• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "if_mmi_client.h"
19 #include "key_event_input_subscribe_manager.h"
20 #include "long_press_event.h"
21 #include "pointer_event.h"
22 #include "switch_event_input_subscribe_manager.h"
23 #include "tablet_event_input_subscribe_manager.h"
24 #include "touchpad_control_display_gain.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 SubscribeHotkey(const KeyEventInputSubscribeManager::SubscribeKeyEventInfo &subscribeInfo);
45     int32_t UnsubscribeHotkey(int32_t subscribeId);
46     int32_t SubscribeKeyMonitor(const KeyMonitorOption &keyOption);
47     int32_t UnsubscribeKeyMonitor(const KeyMonitorOption &keyOption);
48     int32_t InjectEvent(const std::shared_ptr<KeyEvent> keyEvent, bool isNativeInject);
49 #endif // OHOS_BUILD_ENABLE_KEYBOARD
50 #ifdef OHOS_BUILD_ENABLE_SWITCH
51     int32_t SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType);
52     int32_t UnsubscribeSwitchEvent(int32_t subscribeId);
53 #endif // OHOS_BUILD_ENABLE_SWITCH
54     int32_t SubscribeTabletProximity(int32_t subscribeId);
55     int32_t UnsubscribetabletProximity(int32_t subscribeId);
56     int32_t SubscribeLongPressEvent(int32_t subscribeId, const LongPressRequest &longPressRequest);
57     int32_t UnsubscribeLongPressEvent(int32_t subscribeId);
58 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
59     int32_t InjectPointerEvent(std::shared_ptr<PointerEvent> pointerEvent, bool isNativeInject);
60 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
61 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
62     int32_t InjectTouchPadEvent(std::shared_ptr<PointerEvent> pointerEvent, const TouchpadCDG &touchpadCDG,
63         bool isNativeInject);
64 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
65 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
66     int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY);
67 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
68     int32_t Authorize(bool isAuthorize);
69     int32_t CancelInjection();
70 
71 private:
72     int32_t SetClientInfo(int32_t pid, uint64_t readThreadId);
73     std::mutex mtx_;
74     MMIClientPtr client_ { nullptr };
75 };
76 
77 #define MMIEventHdl ::OHOS::Singleton<MultimodalEventHandler>::GetInstance()
78 } // namespace MMI
79 } // namespace OHOS
80 #endif // MULTIMODAL_EVENT_HANDLER_H