diff --git a/api/@ohos.multimodalInput.inputDevice.d.ts b/api/@ohos.multimodalInput.inputDevice.d.ts index 8823d8574ef80dbe1081bb981aec62000879d8c2..0627f4ee29eaa3c402d4700b5138a527460b234a 100644 --- a/api/@ohos.multimodalInput.inputDevice.d.ts +++ b/api/@ohos.multimodalInput.inputDevice.d.ts @@ -1,5 +1,5 @@ /* -* Copyright (C) 2021 Huawei Device Co., Ltd. +* Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,7 +13,7 @@ * limitations under the License. */ -import { AsyncCallback } from './basic'; +import { Callback } from "./basic"; /** * The input device management module is configured to obtain an ID and device information of an input device. @@ -24,10 +24,63 @@ import { AsyncCallback } from './basic'; */ declare namespace inputDevice { + type EventType = 'add' | 'remove'; + type SourceType = 'keyboard' | 'mouse' | 'touchpad' | 'touchscreen' | 'joystick' | 'trackball'; type AxisType = 'NULL'; + /** + * Defines the monitor for input device events. + * + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param deviceId ID of the input device for the reported input device event. + */ + interface DeviceMonitor{ + (type: EventType, deviceId: number): void; + } + + /** + * Starts monitoring for an input device event. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param monitor Callback for the input device event. + */ + function on(type: EventType, monitor: DeviceMonitor): void; + + /** + * Stops monitoring for an input device event. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param monitor Callback for the input device event. + */ + function off(type: EventType, monitor?: DeviceMonitor): void; + + /** + * Starts monitoring for an input device event. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param monitor Callback for the input device event. + */ + function on(type: EventType, monitor: Callback): void; + + /** + * Stops monitoring for an input device event. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param type Type of the input device event. The options are add and remove. + * @param monitor Callback for the input device event. + */ + function off(type: EventType, monitor?: Callback): void; + /** * Defines axis information about events that can be reported by an input device. * For example, a touchscreen may report information such as x, y, and pressure, @@ -65,21 +118,45 @@ declare namespace inputDevice { * * @since 8 * @syscap SystemCapability.MultimodalInput.Input.InputDevice - * @param callback callback function, receive reported data + * @return Returns a list of input device IDs. */ - function getDeviceIds(callback: AsyncCallback>): void; + function getDeviceIds(callback: Callback>): void; function getDeviceIds(): Promise>; /** - * Obtain the information about an input device. + * Obtains information about an input device. * * @since 8 * @syscap SystemCapability.MultimodalInput.Input.InputDevice - * @param deviceId ID of the input device whose information is to be obtained. - * @param callback callback function, receive reported data + * @param deviceId ID of the input device. + * @return Returns the information about the input device. */ - function getDevice(deviceId: number, callback: AsyncCallback): void; + function getDevice(deviceId: number, callback: Callback): void; function getDevice(deviceId: number): Promise; + + /** + * Defines whether the specified data structure is supported a key code. + * + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param keyCode Key code. + * @param isSupport Whether the data structure is supported by the key code. The value **true** indicates that the data structure is supported by the key code, and the value **false** indicates the opposite. + */ + interface KeystrokeAbility { + keyCode: number; + isSupport: boolean; + } + + /** + * Checks whether the specified key codes of an input device are supported. + * + * @since 8 + * @syscap SystemCapability.MultimodalInput.Input.InputDevice + * @param deviceId ID of the input device. + * @param keyCodes Key codes of the input device. + * @return Returns a result indicating whether the specified key codes are supported. + */ + function getKeystrokeAbility(deviceId: number, keyCodes: Array, callback: Callback>): void; + function getKeystrokeAbility(deviceId: number, keyCodes: Array): Promise>; } export default inputDevice; \ No newline at end of file