The input device management module is used to listen for the connection, disconnection, and updates of input devices and display information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse.
The input device management module is used to listen for the connection, disconnection, and updates of input devices and display information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| deviceId | number | Yes | ID of the input device whose information is to be obtained. |
| deviceId | number | Yes | ID of the input device. |
| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the **InputDeviceData** object.|
| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.|
**Example**
**Example**
```
```js
export default {
// Obtain the name of the device whose ID is 1.
InputDeviceData: {
inputDevice.getDevice(1,(inputDevice)=>{
deviceId : 0,
console.log("The device name is: "+inputDevice.name);
name : "NA",
});
sources : Array,
axisRanges : Array,
},
callback: function(deviceData) {
this.InputDeviceData = deviceData;
},
testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1.
| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| name | string | Name of the input device. |
| name | string | Name of the input device. |
| sources | Array<[SourceType](#sourcetype)> | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| sources | Array<[SourceType](#sourcetype)> | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.|
| axisRanges | Array<[axisRanges](#axisrange)> | Axis information of the input device. |
| bus<sup>9+</sup> | number | Bus type of the input device. |
| product<sup>9+</sup> | number | Product information of the input device. |
| vendor<sup>9+</sup> | number | Vendor information of the input device. |
| version<sup>9+</sup> | number | Version information of the input device. |
| phys<sup>9+</sup> | string | Physical address of the input device. |
| uniq<sup>9+</sup> | string | Unique ID of the input device. |
## AxisType
## AxisType<sup>9+</sup>
Axis type. This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
> - The APIs of this module are system APIs and cannot be called by third-party applications.
Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.
Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.
...
@@ -109,7 +122,7 @@ Represents the class of the callback used to return the touch event. The value *
...
@@ -109,7 +122,7 @@ Represents the class of the callback used to return the touch event. The value *
### (touchEvent: TouchEvent): Boolean
### (touchEvent: TouchEvent): Boolean
Represents the callback used to return the touch event. You need to define the name of the callback function in the correct format. Ensure that the input parameter is of the TouchEvent type, and the return value is of the Boolean type.
Represents the callback used to return the touch event. You need to define the name of the callback function in the correct format. Ensure that the input parameter is of the **TouchEvent** type, and the return value is of the **Boolean** type.