1 /* 2 * Copyright (c) 2021-2023 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 DISTRIBUTED_INPUT_INJECT_H 17 #define DISTRIBUTED_INPUT_INJECT_H 18 19 #include <mutex> 20 #include <set> 21 #include <string> 22 23 #include "constants_dinput.h" 24 #include "distributed_input_handler.h" 25 #include "distributed_input_node_manager.h" 26 #include "i_input_node_listener.h" 27 28 namespace OHOS { 29 namespace DistributedHardware { 30 namespace DistributedInput { 31 class DistributedInputInject { 32 public: 33 static DistributedInputInject &GetInstance(); 34 int32_t RegisterDistributedHardware(const std::string &devId, const std::string &dhId, 35 const std::string ¶meters); 36 int32_t UnregisterDistributedHardware(const std::string &devId, const std::string &dhId); 37 int32_t RegisterDistributedEvent(const std::string &devId, const std::vector<RawEvent> &events); 38 int32_t StructTransJson(const InputDevice &pBuf, std::string &strDescriptor); 39 void StartInjectThread(); 40 void StopInjectThread(); 41 std::string GenerateVirtualTouchScreenDHId(const uint64_t sourceWinId, const uint32_t sourceWinWidth, 42 const uint32_t sourceWinHeight); 43 int32_t CreateVirtualTouchScreenNode(const std::string &devId, const std::string &dhId, const uint64_t srcWinId, 44 const uint32_t sourcePhyWidth, const uint32_t sourcePhyHeight); 45 int32_t RemoveVirtualTouchScreenNode(const std::string &devId, const std::string &dhId); 46 int32_t GetVirtualTouchScreenFd(); 47 int32_t RegisterInjectEventCb(sptr<ISessionStateCallback> callback); 48 int32_t UnregisterInjectEventCb(); 49 50 void NotifyNodeMgrScanVirNode(const std::string &devId, const std::string &dhId); 51 void GetVirtualKeyboardPaths(const std::string &devId, const std::vector<std::string> &dhIds, 52 std::vector<std::string> &virKeyboardPaths); 53 private: 54 DistributedInputInject(); 55 ~DistributedInputInject(); 56 57 std::unique_ptr<DistributedInputNodeManager> inputNodeManager_; 58 std::mutex inputNodeManagerMutex_; 59 }; 60 } // namespace DistributedInput 61 } // namespace DistributedHardware 62 } // namespace OHOS 63 64 #endif // DISTRIBUTED_INPUT_INJECT_H