1 /* 2 * Copyright (c) 2024 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 GENERAL_DEVICE_H 17 #define GENERAL_DEVICE_H 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 24 #include "nocopyable.h" 25 26 #include "v_input_device.h" 27 28 namespace OHOS { 29 namespace MMI { 30 class GeneralDevice { 31 public: 32 GeneralDevice() = default; 33 virtual ~GeneralDevice() = default; 34 DISALLOW_COPY_AND_MOVE(GeneralDevice); 35 36 virtual bool SetUp() = 0; 37 virtual void Close(); 38 void SendEvent(uint16_t type, uint16_t code, int32_t value); 39 40 std::string GetDevPath() const; 41 42 protected: 43 bool OpenDevice(const std::string &name); 44 bool FindDeviceNode(const std::string &name, std::string &node); 45 void Execute(std::vector<std::string> &results); 46 void GetInputDeviceNodes(std::map<std::string, std::string> &nodes); 47 48 std::unique_ptr<VInputDevice> vDev_; 49 }; 50 } // namespace MMI 51 } // namespace OHOS 52 #endif // GENERAL_DEVICE_H