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