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