• 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 
16 #ifndef MULTIMODAL_INPUT_CONNECT_MANAGER_H
17 #define MULTIMODAL_INPUT_CONNECT_MANAGER_H
18 
19 #include <map>
20 #include <memory>
21 #include <set>
22 #include <string>
23 
24 #include "nocopyable.h"
25 
26 #include "i_multimodal_input_connect.h"
27 #include "multimodalinput_ipc_interface_code.h"
28 
29 namespace OHOS {
30 namespace MMI {
31 class MultimodalInputConnectManager final : public std::enable_shared_from_this<MultimodalInputConnectManager> {
32 public:
33     ~MultimodalInputConnectManager() = default;
34     static std::shared_ptr<MultimodalInputConnectManager> GetInstance();
35     int32_t AllocSocketPair(const int32_t moduleType);
36     int32_t GetClientSocketFdOfAllocedSocketPair() const;
GetTokenType()37     int32_t GetTokenType() const
38     {
39         return tokenType_;
40     }
41     int32_t AddInputEventFilter(sptr<IEventFilter> filter, int32_t filterId, int32_t priority, uint32_t deviceTags);
42     int32_t RemoveInputEventFilter(int32_t filterId);
43     int32_t GetDisplayBindInfo(DisplayBindInfos &infos);
44     int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg);
45     int32_t SetMouseScrollRows(int32_t rows);
46     int32_t GetMouseScrollRows(int32_t &rows);
47     int32_t SetPointerSize(int32_t size);
48     int32_t GetPointerSize(int32_t &size);
49     int32_t SetMouseIcon(int32_t windowId, void* pixelMap);
50     int32_t SetMouseHotSpot(int32_t windowId, int32_t hotSpotX, int32_t hotSpotY);
51     int32_t SetMousePrimaryButton(int32_t primaryButton);
52     int32_t GetMousePrimaryButton(int32_t &primaryButton);
53     int32_t SetHoverScrollState(bool state);
54     int32_t GetHoverScrollState(bool &state);
55     int32_t SetPointerVisible(bool visible);
56     int32_t IsPointerVisible(bool &visible);
57     int32_t MarkProcessed(int32_t eventType, int32_t eventId);
58     int32_t SetPointerColor(int32_t color);
59     int32_t GetPointerColor(int32_t &color);
60     int32_t SetPointerSpeed(int32_t speed);
61     int32_t GetPointerSpeed(int32_t &speed);
62     int32_t SetPointerStyle(int32_t windowId, PointerStyle pointerStyle);
63     int32_t GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle);
64     int32_t SupportKeys(int32_t deviceId, std::vector<int32_t> &keys, std::vector<bool> &keystroke);
65     int32_t GetDeviceIds(std::vector<int32_t> &ids);
66     int32_t GetDevice(int32_t deviceId, std::shared_ptr<InputDevice> &inputDevice);
67     int32_t RegisterDevListener();
68     int32_t UnregisterDevListener();
69     int32_t GetKeyboardType(int32_t deviceId, int32_t &keyboardType);
70     int32_t SetKeyboardRepeatDelay(int32_t delay);
71     int32_t SetKeyboardRepeatRate(int32_t rate);
72     int32_t GetKeyboardRepeatDelay(int32_t &delay);
73     int32_t GetKeyboardRepeatRate(int32_t &rate);
74     int32_t AddInputHandler(InputHandlerType handlerType, HandleEventType eventType, int32_t priority,
75         uint32_t deviceTags);
76     int32_t RemoveInputHandler(InputHandlerType handlerType, HandleEventType eventType, int32_t priority,
77         uint32_t deviceTags);
78     int32_t MarkEventConsumed(int32_t eventId);
79     int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY);
80     int32_t InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent);
81     int32_t SubscribeKeyEvent(int32_t subscribeId, const std::shared_ptr<KeyOption> option);
82     int32_t UnsubscribeKeyEvent(int32_t subscribeId);
83     int32_t SubscribeSwitchEvent(int32_t subscribeId);
84     int32_t UnsubscribeSwitchEvent(int32_t subscribeId);
85     int32_t InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent);
86     int32_t SetAnrObserver();
87     int32_t GetFunctionKeyState(int32_t funcKey, bool &state);
88     int32_t SetFunctionKeyState(int32_t funcKey, bool enable);
89     int32_t SetPointerLocation(int32_t x, int32_t y);
90     int32_t SetMouseCaptureMode(int32_t windowId, bool isCaptureMode);
91     int32_t GetWindowPid(int32_t windowId);
92     int32_t AppendExtraData(const ExtraData& extraData);
93     int32_t EnableInputDevice(bool enable);
94     int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay);
95     int32_t SetTouchpadScrollSwitch(bool switchFlag);
96     int32_t GetTouchpadScrollSwitch(bool &switchFlag);
97     int32_t SetTouchpadScrollDirection(bool state);
98     int32_t GetTouchpadScrollDirection(bool &state);
99     int32_t SetTouchpadTapSwitch(bool switchFlag);
100     int32_t GetTouchpadTapSwitch(bool &switchFlag);
101     int32_t SetTouchpadPointerSpeed(int32_t speed);
102     int32_t GetTouchpadPointerSpeed(int32_t &speed);
103     int32_t SetTouchpadPinchSwitch(bool switchFlag);
104     int32_t GetTouchpadPinchSwitch(bool &switchFlag);
105     int32_t SetTouchpadSwipeSwitch(bool switchFlag);
106     int32_t GetTouchpadSwipeSwitch(bool &switchFlag);
107     int32_t SetTouchpadRightClickType(int32_t type);
108     int32_t GetTouchpadRightClickType(int32_t &type);
109 
110 private:
111     MultimodalInputConnectManager() = default;
112     DISALLOW_COPY_AND_MOVE(MultimodalInputConnectManager);
113 
114     bool ConnectMultimodalInputService();
115     void OnDeath();
116     void Clean();
117     void NotifyDeath();
118     sptr<IMultimodalInputConnect> multimodalInputConnectService_ { nullptr };
119     sptr<IRemoteObject::DeathRecipient> multimodalInputConnectRecipient_ { nullptr };
120     int32_t socketFd_ { IMultimodalInputConnect::INVALID_SOCKET_FD };
121     int32_t tokenType_ { -1 };
122     std::mutex lock_;
123 };
124 } // namespace MMI
125 } // namespace OHOS
126 #define MultimodalInputConnMgr MultimodalInputConnectManager::GetInstance()
127 #endif // MULTIMODAL_INPUT_CONNECT_MANAGER_H