• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2021 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
16import { AsyncCallback } from './basic';
17
18 /**
19 * The input device management module is configured to obtain an ID and device information of an input device.
20 *
21 * @since 8
22 * @syscap SystemCapability.MultimodalInput.Input.InputDevice
23 * @import import inputDevice from '@ohos.multimodalInput.inputDevice';
24 */
25
26declare namespace inputDevice {
27    type SourceType = 'keyboard' | 'mouse' | 'touchpad' | 'touchscreen' | 'joystick' | 'trackball';
28
29    type AxisType = 'NULL';
30
31    /**
32     * Defines axis information about events that can be reported by an input device.
33     * For example, a touchscreen may report information such as x, y, and pressure,
34     * which indicate the x-axis coordinate, y-axis coordinate, and pressure, respectively.
35     *
36     * @syscap SystemCapability.MultimodalInput.Input.InputDevice
37     * @param source Input source type of the axis. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse.
38     * @param axis Type of the axis. for example, the x-axis, y-axis, and pressure axis.
39     * @param max Maximum value of the data reported on this axis.
40     * @param min Minimum value of the data reported on this axis.
41     */
42    interface AxisRange {
43        source: SourceType;
44        axis : AxisType;
45        max : number;
46        min: number;
47    }
48
49    /**
50     * Defines the information about an input device.
51     *
52     * @syscap SystemCapability.MultimodalInput.Input.InputDevice
53     * @param name Name of the input device.
54     * @param sources Source type supported by the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.
55     */
56    interface InputDeviceData {
57        id: number;
58        name: string;
59        sources : Array<SourceType>;
60        axisRanges : Array<AxisRange>;
61    }
62
63    /**
64     * Obtains the IDs of all input devices.
65     *
66     * @since 8
67     * @syscap SystemCapability.MultimodalInput.Input.InputDevice
68     * @param callback callback function, receive reported data
69     */
70    function getDeviceIds(callback: AsyncCallback<Array<number>>): void;
71    function getDeviceIds(): Promise<Array<number>>;
72
73    /**
74     * Obtain the information about an input device.
75     *
76     * @since 8
77     * @syscap SystemCapability.MultimodalInput.Input.InputDevice
78     * @param deviceId ID of the input device whose information is to be obtained.
79     * @param callback callback function, receive reported data
80     */
81    function getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void;
82    function getDevice(deviceId: number): Promise<InputDeviceData>;
83}
84
85export default inputDevice;