js-apis-inputdevice.md 21.4 KB
Newer Older
Z
zengyawen 已提交
1 2 3
# Input Device


S
shawn_he 已提交
4
The Input Device module implements listening for connection, disconnection, and update events of input devices and displays 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.
Z
zengyawen 已提交
5 6


S
shawn_he 已提交
7 8
> **NOTE**
> 
Z
zengyawen 已提交
9 10 11 12 13 14
> 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.


## Modules to Import


S
shawn_he 已提交
15
```js
Z
zengyawen 已提交
16 17
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
S
shawn_he 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
## inputDevice.getDeviceList<sup>9+</sup>

getDeviceList(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

| Name    | Type                                    | Mandatory| Description      |
| -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes  | Callback used to return the result.|

**Example**

```js
try {
  inputDevice.getDeviceList((error, ids) => {
    if (error) {
      console.log(`Failed to get device list.
         error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
      return;
    }
    this.data = ids;
    console.log("The device ID list is: " + ids);
  });
} catch (error) {
  console.info("getDeviceList " + error.code + " " + error.message);
}
```

## inputDevice.getDeviceList<sup>9+</sup>

getDeviceList(): Promise&lt;Array&lt;number&gt;&gt;

Obtains the IDs of all input devices. This API uses a promise to return the result.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Return value**

| Name                              | Description                           |
| ---------------------------------- | ------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|

**Example**

```js
try {
  inputDevice.getDeviceList().then((ids) => {
    console.log("The device ID list is: " + ids);
  });
} catch (error) {
  console.info("getDeviceList " + error.code + " " + error.message);
}
```

## inputDevice.getDeviceInfo<sup>9+</sup>

getDeviceInfo(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void

Obtains information about an input device. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

| Name    | Type                                                    | Mandatory| Description                                   |
| -------- | -------------------------------------------------------- | ---- | --------------------------------------- |
| deviceId | number                                                   | Yes  | ID of the input device.                 |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes  | Callback used to return the result, which is an **InputDeviceData** object.|

**Example**

```js
// Obtain the name of the device whose ID is 1.
try {
  inputDevice.getDeviceInfo(1, (error, inputDevice) => {
    if (error) {
      console.log(`Failed to get device information.
          error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
      return;
    }
    console.log("The device name is: " + inputDevice.name);
  });
} catch (error) {
  console.info("getDeviceInfo " + error.code + " " + error.message);
}
```

## inputDevice.getDeviceInfo<sup>9+</sup>

getDeviceInfo(deviceId: number): Promise&lt;InputDeviceData&gt;

Obtains information about an input device. This API uses a promise to return the result.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

| Name    | Type  | Mandatory| Description                  |
| -------- | ------ | ---- | ---------------------- |
| deviceId | number | Yes  | ID of the input device.|

**Return value**

| Name                                              | Description                           |
| -------------------------------------------------- | ------------------------------- |
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|

**Example**

```js
// Obtain the name of the device whose ID is 1.
try {
  inputDevice.getDeviceInfo(id).then((inputDevice) => {
    console.log("The device name is: " + inputDevice.name);
  });
} catch (error) {
  console.info("getDeviceInfo " + error.code + " " + error.message);
}
```

Z
zengyawen 已提交
142

S
shawn_he 已提交
143 144 145 146 147 148 149 150 151 152
## inputDevice.on<sup>9+</sup>

on(type: "change", listener: Callback&lt;DeviceListener&gt;): void

Enables listening for hot swap events of an input device.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

S
shawn_he 已提交
153 154 155
| Name      | Type                                      | Mandatory  | Description         |
| -------- | ---------------------------------------- | ---- | ----------- |
| type     | string                                   | Yes   | Event type of the input device. |
S
shawn_he 已提交
156
| listener | Callback&lt;[DeviceListener](#devicelistener9)&gt; | Yes   | Listener for events of the input device.|
S
shawn_he 已提交
157 158 159 160 161

**Example**

```js
let isPhysicalKeyboardExist = true;
S
shawn_he 已提交
162 163
try {
  inputDevice.on("change", (data) => {
S
shawn_he 已提交
164
    console.log("type: " + data.type + ", deviceId: " + data.deviceId);
S
shawn_he 已提交
165
    inputDevice.getKeyboardType(data.deviceId, (err, ret) => {
S
shawn_he 已提交
166 167 168 169 170 171 172 173
      console.log("The keyboard type of the device is: " + ret);
      if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') {
        // The physical keyboard is connected.
        isPhysicalKeyboardExist = true;
      } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') {
        // The physical keyboard is disconnected.
        isPhysicalKeyboardExist = false;
      }
S
shawn_he 已提交
174
    });
S
shawn_he 已提交
175 176 177 178 179
  });
  // Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist.
} catch (error) {
  console.info("oninputdevcie " + error.code + " " + error.message);
}
S
shawn_he 已提交
180 181 182 183 184 185 186 187 188 189 190 191
```

## inputDevice.off<sup>9+</sup>

off(type: "change", listener?: Callback&lt;DeviceListener&gt;): void

Disables listening for hot swap events of an input device.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

S
shawn_he 已提交
192 193 194
| Name      | Type                                      | Mandatory  | Description         |
| -------- | ---------------------------------------- | ---- | ----------- |
| type     | string                                   | Yes   | Event type of the input device. |
S
shawn_he 已提交
195
| listener | Callback&lt;[DeviceListener](#devicelistener9)&gt; | No   | Listener for events of the input device.|
S
shawn_he 已提交
196 197 198 199

**Example**

```js
S
shawn_he 已提交
200
callback: function(data) {
S
shawn_he 已提交
201 202 203 204
  console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}

try {
S
shawn_he 已提交
205
  inputDevice.on("change", this.callback);
S
shawn_he 已提交
206 207
} catch (error) {
  console.info("oninputdevcie " + error.code + " " + error.message)
S
shawn_he 已提交
208 209
}

S
shawn_he 已提交
210 211 212
// Enable listening for hot swap events of an input device.
inputDevice.on("change", listener);

S
shawn_he 已提交
213
// Disable this listener.
S
shawn_he 已提交
214
try {
S
shawn_he 已提交
215
  inputDevice.off("change", this.callback);
S
shawn_he 已提交
216 217 218
} catch (error) {
  console.info("offinputdevcie " + error.code + " " + error.message)
}
S
shawn_he 已提交
219 220

// Disable all listeners.
S
shawn_he 已提交
221 222 223 224 225
try {
  inputDevice.off("change");
} catch (error) {
  console.info("offinputdevcie " + error.code + " " + error.message);
}
S
shawn_he 已提交
226 227
// By default, the soft keyboard is closed when listening is disabled.
```
Z
zengyawen 已提交
228

S
shawn_he 已提交
229
## inputDevice.getDeviceIds<sup>(deprecated)</sup>
Z
zengyawen 已提交
230 231 232

getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

E
ester.zhou 已提交
233
Obtains the IDs of all input devices. This API uses an asynchronous callback to return the result.
Z
zengyawen 已提交
234

S
shawn_he 已提交
235 236
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead.

Z
zengyawen 已提交
237 238
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

E
ester.zhou 已提交
239
**Parameters**
Z
zengyawen 已提交
240

E
ester.zhou 已提交
241 242 243 244 245 246
| Name      | Type                                      | Mandatory  | Description   |
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes   | Callback used to return the result.|

**Example**

S
shawn_he 已提交
247 248 249 250
```js
inputDevice.getDeviceIds((ids)=>{
    console.log("The device ID list is: " + ids);
});
E
ester.zhou 已提交
251 252
```

S
shawn_he 已提交
253
## inputDevice.getDeviceIds<sup>(deprecated)</sup>
E
ester.zhou 已提交
254

S
shawn_he 已提交
255
getDeviceIds(): Promise&lt;Array&lt;number&gt;&gt;
E
ester.zhou 已提交
256 257 258

Obtains the IDs of all input devices. This API uses a promise to return the result.

S
shawn_he 已提交
259 260
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceList](#inputdevicegetdevicelist9) instead.

E
ester.zhou 已提交
261 262 263 264
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Return value**

S
shawn_he 已提交
265 266
| Parameter                                | Description                 |
| ---------------------------------- | ------------------- |
S
shawn_he 已提交
267
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
E
ester.zhou 已提交
268 269

**Example**
Z
zengyawen 已提交
270

S
shawn_he 已提交
271 272 273 274
```js
inputDevice.getDeviceIds().then((ids)=>{
    console.log("The device ID list is: " + ids);
});
Z
zengyawen 已提交
275
```
E
ester.zhou 已提交
276

S
shawn_he 已提交
277
## inputDevice.getDevice<sup>(deprecated)</sup>
Z
zengyawen 已提交
278 279 280

getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void

S
shawn_he 已提交
281
Obtains information about an input device. This API uses an asynchronous callback to return the result.
Z
zengyawen 已提交
282

S
shawn_he 已提交
283 284
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead.

Z
zengyawen 已提交
285 286
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

E
ester.zhou 已提交
287 288 289 290
**Parameters**

| Name      | Type                                      | Mandatory  | Description                         |
| -------- | ---------------------------------------- | ---- | --------------------------- |
S
shawn_he 已提交
291 292
| deviceId | number                                   | Yes   | ID of the input device.               |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes   | Callback used to return the result, which is an **InputDeviceData** object.|
Z
zengyawen 已提交
293

E
ester.zhou 已提交
294
**Example**
Z
zengyawen 已提交
295

S
shawn_he 已提交
296 297 298 299 300
```js
// Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1, (inputDevice)=>{
    console.log("The device name is: " + inputDevice.name);
});
Z
zengyawen 已提交
301 302
```

S
shawn_he 已提交
303
## inputDevice.getDevice<sup>(deprecated)</sup>
E
ester.zhou 已提交
304

S
shawn_he 已提交
305
getDevice(deviceId: number): Promise&lt;InputDeviceData&gt;
E
ester.zhou 已提交
306

S
shawn_he 已提交
307
Obtains information about an input device. This API uses a promise to return the result.
E
ester.zhou 已提交
308

S
shawn_he 已提交
309 310
This API is deprecated since API version 9. You are advised to use [inputDevice.getDeviceInfo](#inputdevicegetdeviceinfo9) instead.

E
ester.zhou 已提交
311 312
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
313 314
**Parameters**

S
shawn_he 已提交
315 316 317
| Name      | Type    | Mandatory  | Description          |
| -------- | ------ | ---- | ------------ |
| deviceId | number | Yes   | ID of the input device.|
S
shawn_he 已提交
318

E
ester.zhou 已提交
319 320
**Return value**

S
shawn_he 已提交
321 322
| Parameter                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
323
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
E
ester.zhou 已提交
324 325 326

**Example**

S
shawn_he 已提交
327 328 329 330 331
```js
// Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1).then((inputDevice)=>{
    console.log("The device name is: " + inputDevice.name);
});
E
ester.zhou 已提交
332
```
S
shawn_he 已提交
333 334 335

## inputDevice.supportKeys<sup>9+</sup>

S
shawn_he 已提交
336
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;, callback: AsyncCallback &lt;Array&lt;boolean&gt;&gt;): void
S
shawn_he 已提交
337

S
shawn_he 已提交
338
Obtains the key codes supported by the input device. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
339 340 341 342 343

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

S
shawn_he 已提交
344 345 346 347
| Name      | Type                                  | Mandatory  | Description                               |
| -------- | ------------------------------------ | ---- | --------------------------------- |
| deviceId | number                               | Yes   | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys     | Array&lt;KeyCode&gt;                 | Yes   | Key codes to be queried. A maximum of five key codes can be specified.             |
S
shawn_he 已提交
348
| callback | AsyncCallback&lt;Array&lt;boolean&gt;&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
349 350 351 352 353

**Example**

```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
S
shawn_he 已提交
354 355
try {
  inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => {
S
shawn_he 已提交
356
    console.log("The query result is as follows: " + ret);
S
shawn_he 已提交
357 358 359 360
  });
} catch (error) {
  console.info("supportKeys " + error.code + " " + error.message);
}
S
shawn_he 已提交
361 362 363 364
```

## inputDevice.supportKeys<sup>9+</sup>

S
shawn_he 已提交
365
supportKeys(deviceId: number, keys: Array&lt;KeyCode&gt;): Promise&lt;Array&lt;boolean&gt;&gt;
S
shawn_he 已提交
366

S
shawn_he 已提交
367
Obtains the key codes supported by the input device. This API uses a promise to return the result.
S
shawn_he 已提交
368 369 370 371 372

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

S
shawn_he 已提交
373 374 375 376
| Name      | Type                  | Mandatory  | Description                               |
| -------- | -------------------- | ---- | --------------------------------- |
| deviceId | number               | Yes   | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| keys     | Array&lt;KeyCode&gt; | Yes   | Key codes to be queried. A maximum of five key codes can be specified.             |
S
shawn_he 已提交
377 378 379

**Return value**

S
shawn_he 已提交
380 381
| Parameter                                 | Description                 |
| ----------------------------------- | ------------------- |
S
shawn_he 已提交
382 383 384 385 386 387
| Promise&lt;Array&lt;boolean&gt;&gt; | Promise used to return the result.|

**Example**

```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
S
shawn_he 已提交
388 389
try {
  inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => {
S
shawn_he 已提交
390
    console.log("The query result is as follows: " + ret);
S
shawn_he 已提交
391 392 393 394
  });
} catch (error) {
  console.info("supportKeys " + error.code + " " + error.message);
}
S
shawn_he 已提交
395 396 397 398
```

## inputDevice.getKeyboardType<sup>9+</sup>

S
shawn_he 已提交
399
getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): void
S
shawn_he 已提交
400 401 402 403 404 405 406

Obtains the keyboard type of an input device. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Parameters**

S
shawn_he 已提交
407 408 409
| Name      | Type                                      | Mandatory  | Description                               |
| -------- | ---------------------------------------- | ---- | --------------------------------- |
| deviceId | number                                   | Yes   | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
S
shawn_he 已提交
410
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype9)&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
411 412 413 414 415

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
416 417 418 419 420 421 422 423 424 425 426 427
try {
  inputDevice.getKeyboardType(1, (error, number) => {
    if (error) {
      console.log(`Failed to get keyboardtype.
          error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
      return;
    }
    console.log("The keyboard type of the device is: " + number);
  });
} catch (error) {
  console.info("getKeyboardType " + error.code + " " + error.message);
}
E
ester.zhou 已提交
428 429
```

S
shawn_he 已提交
430
## inputDevice.getKeyboardType<sup>9+</sup>
E
ester.zhou 已提交
431

S
shawn_he 已提交
432
getKeyboardType(deviceId: number,): Promise&lt;KeyboardType&gt;
S
shawn_he 已提交
433

S
shawn_he 已提交
434
Obtains the keyboard type of an input device. This API uses a promise to return the result.
S
shawn_he 已提交
435 436 437 438 439

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Return value**

S
shawn_he 已提交
440 441
| Parameter                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
442
| Promise&lt;[KeyboardType](#keyboardtype9)&gt; | Promise used to return the result.|
S
shawn_he 已提交
443 444 445 446 447

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
448 449 450 451 452 453 454
try {
  inputDevice.getKeyboardType(1).then((number) => {
    console.log("The keyboard type of the device is: " + number);
  });
} catch (error) {
  console.info("getKeyboardType " + error.code + " " + error.message);
}
S
shawn_he 已提交
455 456 457 458
```

## DeviceListener<sup>9+</sup>

S
shawn_he 已提交
459
Defines the listener for hot swap events of an input device.
S
shawn_he 已提交
460 461 462

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
463 464 465 466
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| type     | [ChangedType](#changedtype) | Yes| No| Device change type, which indicates whether an input device is inserted or removed.|
| deviceId | number                      | Yes| No| Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
Z
zengyawen 已提交
467 468 469 470 471

## InputDeviceData

Defines the information about an input device.

E
ester.zhou 已提交
472 473
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
474 475 476 477 478 479 480 481 482 483 484 485
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| id                   | number                                 | Yes| No| Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.|
| name                 | string                                 | Yes| No| Name of the input device.                                            |
| sources              | Array&lt;[SourceType](#sourcetype)&gt; | Yes| No| Source type 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&lt;[axisRanges](#axisrange)&gt;  | Yes| No| Axis information of the input device.                                          |
| bus<sup>9+</sup>     | number                                 | Yes| No| Bus type of the input device.                                        |
| product<sup>9+</sup> | number                                 | Yes| No| Product information of the input device.                                        |
| vendor<sup>9+</sup>  | number                                 | Yes| No| Vendor information of the input device.                                        |
| version<sup>9+</sup> | number                                 | Yes| No| Version information of the input device.                                        |
| phys<sup>9+</sup>    | string                                 | Yes| No| Physical address of the input device.                                        |
| uniq<sup>9+</sup>    | string                                 | Yes| No| Unique ID of the input device.                                        |
E
ester.zhou 已提交
486

S
shawn_he 已提交
487
## AxisType<sup>9+</sup>
E
ester.zhou 已提交
488

S
shawn_he 已提交
489
Defines the axis type of an input device.
E
ester.zhou 已提交
490

S
shawn_he 已提交
491
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
E
ester.zhou 已提交
492

S
shawn_he 已提交
493 494 495 496 497 498 499 500 501 502 503
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| touchMajor  | string | Yes| No| touchMajor axis. |
| touchMinor  | string | Yes| No| touchMinor axis. |
| toolMinor   | string | Yes| No| toolMinor axis.  |
| toolMajor   | string | Yes| No| toolMajor axis.  |
| orientation | string | Yes| No| Orientation axis.|
| pressure    | string | Yes| No| Pressure axis.   |
| x           | string | Yes| No| X axis.          |
| y           | string | Yes| No| Y axis.          |
| NULL        | string | Yes| No| None.             |
E
ester.zhou 已提交
504

S
shawn_he 已提交
505
## AxisRange
E
ester.zhou 已提交
506

S
shawn_he 已提交
507
Defines the axis range of an input device.
E
ester.zhou 已提交
508

S
shawn_he 已提交
509
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
Z
zengyawen 已提交
510

S
shawn_he 已提交
511 512 513 514 515 516 517 518 519
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| source                  | [SourceType](#sourcetype) | Yes| No| Input source type of the axis.|
| axis                    | [AxisType](#axistype9)    | Yes| No| Axis type.   |
| max                     | number                    | Yes| No| Maximum value of the axis.  |
| min                     | number                    | Yes| No| Minimum value of the axis.  |
| fuzz<sup>9+</sup>       | number                    | Yes| No| Fuzzy value of the axis.  |
| flat<sup>9+</sup>       | number                    | Yes| No| Benchmark value of the axis.  |
| resolution<sup>9+</sup> | number                    | Yes| No| Resolution of the axis.  |
Z
zengyawen 已提交
520

S
shawn_he 已提交
521
## SourceType<sup>9+</sup>
Z
zengyawen 已提交
522

E
ester.zhou 已提交
523
Enumerates the input source types. For example, if a mouse reports an x-axis event, the source of the x-axis is the mouse.
Z
zengyawen 已提交
524 525 526

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
527 528 529 530 531 532 533 534
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| keyboard    | string | Yes| No| The input device is a keyboard. |
| touchscreen | string | Yes| No| The input device is a touchscreen.|
| mouse       | string | Yes| No| The input device is a mouse. |
| trackball   | string | Yes| No| The input device is a trackball.|
| touchpad    | string | Yes| No| The input device is a touchpad.|
| joystick    | string | Yes| No| The input device is a joystick.|
S
shawn_he 已提交
535

S
shawn_he 已提交
536
## ChangedType<sup>9+</sup>
S
shawn_he 已提交
537 538 539 540 541

Defines the change type for the hot swap event of an input device.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
542 543 544 545
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
| add    | string | Yes| No| An input device is inserted.|
| remove | string | Yes| No| An input device is removed.|
S
shawn_he 已提交
546 547 548 549 550 551 552

## KeyboardType<sup>9+</sup>

Enumerates the keyboard types.

**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
553 554 555 556 557 558 559 560
| Name                 | Value   | Description       |
| ------------------- | ---- | --------- |
| NONE                | 0    | Keyboard without keys. |
| UNKNOWN             | 1    | Keyboard with unknown keys.|
| ALPHABETIC_KEYBOARD | 2    | Full keyboard. |
| DIGITAL_KEYBOARD    | 3    | Keypad. |
| HANDWRITING_PEN     | 4    | Stylus. |
| REMOTE_CONTROL      | 5    | Remote control. |