• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <functional>
20 
21 namespace OHOS::NWeb {
22 enum MMIAdapterKeyboardType : int32_t {
23     NONE = 0,
24     UNKNOWN_TYPE = 1,
25     ALPHABETIC_KEYBOARD = 2,
26     DIGITAL_KEYBOARD = 3,
27     HANDWRITING_PEN = 4,
28     REMOTE_CONTROL = 5,
29 };
30 
31 class MMIListenerAdapter {
32 public:
33     MMIListenerAdapter() = default;
34     virtual ~MMIListenerAdapter() = default;
35     virtual void OnDeviceAdded(int32_t deviceId, const std::string &type) = 0;
36     virtual void OnDeviceRemoved(int32_t deviceId, const std::string &type) = 0;
37 };
38 
39 using InputEventCallback = std::function<void(int32_t, int32_t)>;
40 
41 class MMIAdapter {
42 public:
43     MMIAdapter() = default;
44 
45     virtual ~MMIAdapter() = default;
46 
47     virtual const char* KeyCodeToString(int32_t keyCode) = 0;
48 
49     virtual int32_t RegisterMMIInputListener(const InputEventCallback&& eventCallback) = 0;
50 
51     virtual void UnregisterMMIInputListener(int32_t monitorId) = 0;
52 
53     virtual int32_t RegisterDevListener(std::string type, std::shared_ptr<MMIListenerAdapter> listener) = 0;
54 
55     virtual int32_t UnregisterDevListener(std::string type) = 0;
56 
57     virtual int32_t GetKeyboardType(int32_t deviceId, std::function<void(int32_t)> callback) = 0;
58 
59     virtual int32_t GetDeviceIds(std::function<void(std::vector<int32_t>&)> callback) = 0;
60 };
61 } // namespace OHOS::NWeb
62 
63 #endif // MMI_ADAPTER_H