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 28 namespace OHOS { 29 namespace MMI { 30 class MultimodalInputConnectManager : public std::enable_shared_from_this<MultimodalInputConnectManager> { 31 public: 32 virtual ~MultimodalInputConnectManager() = default; 33 static std::shared_ptr<MultimodalInputConnectManager> GetInstance(); 34 int32_t AllocSocketPair(const int32_t moduleType); 35 int32_t GetClientSocketFdOfAllocedSocketPair() const; GetTokenType()36 int32_t GetTokenType() const 37 { 38 return tokenType_; 39 } 40 int32_t AddInputEventFilter(sptr<IEventFilter> filter); 41 int32_t SetPointerVisible(bool visible); 42 int32_t IsPointerVisible(bool &visible); 43 int32_t SetPointerSpeed(int32_t speed); 44 int32_t GetPointerSpeed(int32_t &speed); 45 int32_t SetPointerStyle(int32_t windowId, int32_t pointerStyle); 46 int32_t GetPointerStyle(int32_t windowId, int32_t &pointerStyle); 47 int32_t SupportKeys(int32_t userData, int32_t deviceId, std::vector<int32_t> &keys); 48 int32_t GetDeviceIds(int32_t userData); 49 int32_t GetDevice(int32_t userData, int32_t id); 50 int32_t RegisterDevListener(); 51 int32_t UnregisterDevListener(); 52 int32_t GetKeyboardType(int32_t userData, int32_t deviceId); 53 int32_t AddInputHandler(InputHandlerType handlerType, HandleEventType eventType); 54 int32_t RemoveInputHandler(InputHandlerType handlerType, HandleEventType eventType); 55 int32_t MarkEventConsumed(int32_t eventId); 56 int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY); 57 int32_t InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent); 58 int32_t SubscribeKeyEvent(int32_t subscribeId, const std::shared_ptr<KeyOption> option); 59 int32_t UnsubscribeKeyEvent(int32_t subscribeId); 60 int32_t InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent); 61 int32_t SetAnrObserver(); 62 int32_t RegisterCooperateListener(); 63 int32_t UnregisterCooperateListener(); 64 int32_t EnableInputDeviceCooperate(int32_t userData, bool enabled); 65 int32_t StartInputDeviceCooperate(int32_t userData, const std::string &sinkDeviceId, int32_t srcInputDeviceId); 66 int32_t StopDeviceCooperate(int32_t userData); 67 int32_t GetInputDeviceCooperateState(int32_t userData, const std::string &deviceId); 68 int32_t SetInputDevice(const std::string& dhid, const std::string& screenId); 69 int32_t GetFunctionKeyState(int32_t funcKey, bool &state); 70 int32_t SetFunctionKeyState(int32_t funcKey, bool enable); 71 72 private: 73 MultimodalInputConnectManager() = default; 74 DISALLOW_COPY_AND_MOVE(MultimodalInputConnectManager); 75 76 bool ConnectMultimodalInputService(); 77 void OnDeath(); 78 void Clean(); 79 void NotifyDeath(); 80 sptr<IMultimodalInputConnect> multimodalInputConnectService_ { nullptr }; 81 sptr<IRemoteObject::DeathRecipient> multimodalInputConnectRecipient_ { nullptr }; 82 int32_t socketFd_ { IMultimodalInputConnect::INVALID_SOCKET_FD }; 83 int32_t tokenType_ { -1 }; 84 std::mutex lock_; 85 }; 86 } // namespace MMI 87 } // namespace OHOS 88 #define MultimodalInputConnMgr MultimodalInputConnectManager::GetInstance() 89 #endif // MULTIMODAL_INPUT_CONNECT_MANAGER_H