1 /* 2 * Copyright (c) 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 MMI_ADAPTER_H 17 #define MMI_ADAPTER_H 18 19 #include <string> 20 21 namespace OHOS::NWeb { 22 23 enum MMIAdapterKeyboardType : int32_t { 24 NONE = 0, 25 UNKNOWN_TYPE = 1, 26 ALPHABETIC_KEYBOARD = 2, 27 DIGITAL_KEYBOARD = 3, 28 HANDWRITING_PEN = 4, 29 REMOTE_CONTROL = 5, 30 }; 31 32 class MMIDeviceInfoAdapter { 33 public: 34 MMIDeviceInfoAdapter() = default; 35 36 virtual ~MMIDeviceInfoAdapter() = default; 37 38 virtual int32_t GetId() = 0; 39 40 virtual int32_t GetType() = 0; 41 42 virtual int32_t GetBus() = 0; 43 44 virtual int32_t GetVersion() = 0; 45 46 virtual int32_t GetProduct() = 0; 47 48 virtual int32_t GetVendor() = 0; 49 50 virtual std::string GetName() = 0; 51 52 virtual std::string GetPhys() = 0; 53 54 virtual std::string GetUniq() = 0; 55 56 virtual void SetId(int32_t id) = 0; 57 58 virtual void SetType(int32_t type) = 0; 59 60 virtual void SetBus(int32_t bus) = 0; 61 62 virtual void SetVersion(int32_t version) = 0; 63 64 virtual void SetProduct(int32_t product) = 0; 65 66 virtual void SetVendor(int32_t vendor) = 0; 67 68 virtual void SetName(std::string name) = 0; 69 70 virtual void SetPhys(std::string phys) = 0; 71 72 virtual void SetUniq(std::string uniq) = 0; 73 }; 74 75 class MMIListenerAdapter { 76 public: 77 MMIListenerAdapter() = default; 78 virtual ~MMIListenerAdapter() = default; 79 virtual void OnDeviceAdded(int32_t deviceId, const std::string& type) = 0; 80 virtual void OnDeviceRemoved(int32_t deviceId, const std::string& type) = 0; 81 }; 82 83 class MMIInputListenerAdapter { 84 public: 85 MMIInputListenerAdapter() = default; 86 virtual ~MMIInputListenerAdapter() = default; 87 virtual void OnInputEvent(int32_t keyCode, int32_t keyAction) = 0; 88 }; 89 90 class MMIAdapter { 91 public: 92 MMIAdapter() = default; 93 94 virtual ~MMIAdapter() = default; 95 96 virtual char* KeyCodeToString(int32_t keyCode) = 0; 97 98 virtual int32_t RegisterMMIInputListener(std::shared_ptr<MMIInputListenerAdapter> eventCallback) = 0; 99 100 virtual void UnregisterMMIInputListener(int32_t monitorId) = 0; 101 102 virtual int32_t RegisterDevListener(std::string type, std::shared_ptr<MMIListenerAdapter> listener) = 0; 103 104 virtual int32_t UnregisterDevListener(std::string type) = 0; 105 106 virtual int32_t GetKeyboardType(int32_t deviceId, int32_t& type) = 0; 107 108 virtual int32_t GetDeviceIds(std::vector<int32_t>& ids) = 0; 109 110 virtual int32_t GetDeviceInfo(int32_t deviceId, std::shared_ptr<MMIDeviceInfoAdapter> info) = 0; 111 }; 112 113 } // namespace OHOS::NWeb 114 115 #endif // MMI_ADAPTER_H 116