• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 JS_INPUT_DEVICE_MANAGER_H
17 #define JS_INPUT_DEVICE_MANAGER_H
18 
19 #include "js_event_target.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 class JsInputDeviceManager : public JsEventTarget {
24 public:
25     JsInputDeviceManager() = default;
26     DISALLOW_COPY_AND_MOVE(JsInputDeviceManager);
27     ~JsInputDeviceManager() = default;
28 
29     void ResetEnv();
30     napi_value GetDeviceIds(napi_env env, napi_value handle = nullptr);
31     napi_value GetDevice(napi_env env, int32_t id, napi_value handle = nullptr);
32     napi_value SupportKeys(napi_env env, int32_t id, std::vector<int32_t> &keyCodes, napi_value handle = nullptr);
33     napi_value SupportKeysSync(napi_env env, int32_t id, std::vector<int32_t> &keyCodes);
34     static void SupportKeysSyncCallback(napi_env env, napi_value* result, std::vector<bool> &isSupported);
35     napi_value GetKeyboardType(napi_env env, int32_t id, napi_value handle = nullptr);
36     napi_value GetKeyboardTypeSync(napi_env env, int32_t id);
37     static void GetKeyboardTypeSyncCallback(napi_env env, napi_value* result, int32_t keyboardType);
38     void RegisterDevListener(napi_env env, const std::string &type, napi_value handle);
39     void UnregisterDevListener(napi_env env, const std::string &type, napi_value handle = nullptr);
40     napi_value GetDeviceList(napi_env env, napi_value handle = nullptr);
41     napi_value GetDeviceInfo(napi_env env, int32_t id, napi_value handle = nullptr);
42     napi_value GetDeviceInfoSync(napi_env env, int32_t id, napi_value handle = nullptr);
43     static void GetDeviceInfoSyncCallback(napi_env env, napi_value* result, sptr<JsUtil::CallbackInfo> cb,
44         std::shared_ptr<InputDevice> inputDevice);
45     napi_value SetKeyboardRepeatDelay(napi_env env, int32_t delay, napi_value handle = nullptr);
46     napi_value SetKeyboardRepeatRate(napi_env env, int32_t rate, napi_value handle = nullptr);
47     napi_value GetKeyboardRepeatDelay(napi_env env, napi_value handle = nullptr);
48     napi_value GetKeyboardRepeatRate(napi_env env, napi_value handle = nullptr);
49     napi_value GetIntervalSinceLastInput(napi_env env);
50     napi_value SetInputDeviceEnabled(napi_env env, int32_t deviceId, bool enable, napi_value handle = nullptr);
51     napi_value SetFunctionKeyEnabled(napi_env env, int32_t funcKey, bool state, napi_value handle = nullptr);
52     napi_value IsFunctionKeyEnabled(napi_env env, int32_t funcKey, napi_value handle = nullptr);
53 };
54 } // namespace MMI
55 } // namespace OHOS
56 #endif // JS_INPUT_DEVICE_MANAGER_H