js-apis-inputdevice.md 21.7 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.multimodalInput.inputDevice
Z
zengyawen 已提交
2 3


S
shawn_he 已提交
4
The **inputDevice** 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
> **NOTE**<br>
Z
zengyawen 已提交
8 9 10 11 12 13
> 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 已提交
14
```js
Z
zengyawen 已提交
15 16
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
S
shawn_he 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
## 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 {
S
shawn_he 已提交
35
  inputDevice.getDeviceIds((error, ids) => {
S
shawn_he 已提交
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
    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 {
S
shawn_he 已提交
67
  inputDevice.getDeviceIds().then((ids) => {
S
shawn_he 已提交
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
    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 已提交
141

S
shawn_he 已提交
142 143 144 145 146 147 148 149 150 151
## 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 已提交
152 153 154
| Name      | Type                                      | Mandatory  | Description         |
| -------- | ---------------------------------------- | ---- | ----------- |
| type     | string                                   | Yes   | Event type of the input device. |
S
shawn_he 已提交
155
| listener | Callback&lt;[DeviceListener](#devicelistener9)&gt; | Yes   | Listener for events of the input device.|
S
shawn_he 已提交
156 157 158 159 160

**Example**

```js
let isPhysicalKeyboardExist = true;
S
shawn_he 已提交
161 162
try {
  inputDevice.on("change", (data) => {
S
shawn_he 已提交
163
    console.log("type: " + data.type + ", deviceId: " + data.deviceId);
S
shawn_he 已提交
164
    inputDevice.getKeyboardType(data.deviceId, (err, ret) => {
S
shawn_he 已提交
165 166 167 168 169 170 171 172
      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 已提交
173
    });
S
shawn_he 已提交
174 175 176 177 178
  });
  // 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 已提交
179 180 181 182 183 184 185 186 187 188 189 190
```

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

**Example**

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

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

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

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

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

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

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

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

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

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

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

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

**Example**

S
shawn_he 已提交
246
```js
S
shawn_he 已提交
247 248 249 250 251 252
inputDevice.getDeviceIds((error, ids) => {
  if (error) {
    console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`);
    return;
  }
  console.log(`Device id list: ${JSON.stringify(ids)}`);
S
shawn_he 已提交
253
});
E
ester.zhou 已提交
254
```
S
shawn_he 已提交
255
```
E
ester.zhou 已提交
256

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

S
shawn_he 已提交
259
getDeviceIds(): Promise&lt;Array&lt;number&gt;&gt;
E
ester.zhou 已提交
260 261 262

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

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

E
ester.zhou 已提交
265 266 267 268
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

**Return value**

S
shawn_he 已提交
269 270
| Parameter                                | Description                 |
| ---------------------------------- | ------------------- |
S
shawn_he 已提交
271
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
E
ester.zhou 已提交
272 273

**Example**
Z
zengyawen 已提交
274

S
shawn_he 已提交
275
```js
S
shawn_he 已提交
276 277
inputDevice.getDeviceIds().then((ids) => {
  console.log(`Device id list: ${JSON.stringify(ids)}`);
S
shawn_he 已提交
278
});
Z
zengyawen 已提交
279
```
E
ester.zhou 已提交
280

S
shawn_he 已提交
281
## inputDevice.getDevice<sup>(deprecated)</sup>
Z
zengyawen 已提交
282 283 284

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

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

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

Z
zengyawen 已提交
289 290
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

E
ester.zhou 已提交
291 292 293 294
**Parameters**

| Name      | Type                                      | Mandatory  | Description                         |
| -------- | ---------------------------------------- | ---- | --------------------------- |
S
shawn_he 已提交
295 296
| 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 已提交
297

E
ester.zhou 已提交
298
**Example**
Z
zengyawen 已提交
299

S
shawn_he 已提交
300 301
```js
// Obtain the name of the device whose ID is 1.
S
shawn_he 已提交
302 303 304 305 306 307
inputDevice.getDevice(1, (error, deviceData) => {
  if (error) {
    console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`);
    return;
  }
  console.log(`Device info: ${JSON.stringify(deviceData)}`);
S
shawn_he 已提交
308
});
Z
zengyawen 已提交
309 310
```

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

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

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

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

E
ester.zhou 已提交
319 320
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
321 322
**Parameters**

S
shawn_he 已提交
323 324 325
| Name      | Type    | Mandatory  | Description          |
| -------- | ------ | ---- | ------------ |
| deviceId | number | Yes   | ID of the input device.|
S
shawn_he 已提交
326

E
ester.zhou 已提交
327 328
**Return value**

S
shawn_he 已提交
329 330
| Parameter                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
331
| Promise&lt;[InputDeviceData](#inputdevicedata)&gt; | Promise used to return the result.|
E
ester.zhou 已提交
332 333 334

**Example**

S
shawn_he 已提交
335 336
```js
// Obtain the name of the device whose ID is 1.
S
shawn_he 已提交
337 338
inputDevice.getDevice(1).then((deviceData) => {
  console.log(`Device info: ${JSON.stringify(deviceData)}`);
S
shawn_he 已提交
339
});
E
ester.zhou 已提交
340
```
S
shawn_he 已提交
341 342 343

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

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

S
shawn_he 已提交
346
Obtains the key codes supported by the input device. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
347 348 349 350 351

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

**Parameters**

S
shawn_he 已提交
352 353 354 355
| 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 已提交
356
| callback | AsyncCallback&lt;Array&lt;boolean&gt;&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
357 358 359 360 361

**Example**

```js
// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055.
S
shawn_he 已提交
362 363
try {
  inputDevice.supportKeys(1, [17, 22, 2055], (error, ret) => {
S
shawn_he 已提交
364
    console.log("The query result is as follows: " + ret);
S
shawn_he 已提交
365 366 367 368
  });
} catch (error) {
  console.info("supportKeys " + error.code + " " + error.message);
}
S
shawn_he 已提交
369 370 371 372
```

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

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

S
shawn_he 已提交
375
Obtains the key codes supported by the input device. This API uses a promise to return the result.
S
shawn_he 已提交
376 377 378 379 380

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

**Parameters**

S
shawn_he 已提交
381 382 383 384
| 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 已提交
385 386 387

**Return value**

S
shawn_he 已提交
388 389
| Parameter                                 | Description                 |
| ----------------------------------- | ------------------- |
S
shawn_he 已提交
390 391 392 393 394 395
| 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 已提交
396 397
try {
  inputDevice.supportKeys(1, [17, 22, 2055]).then((ret) => {
S
shawn_he 已提交
398
    console.log("The query result is as follows: " + ret);
S
shawn_he 已提交
399 400 401 402
  });
} catch (error) {
  console.info("supportKeys " + error.code + " " + error.message);
}
S
shawn_he 已提交
403 404 405 406
```

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

S
shawn_he 已提交
407
getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): void
S
shawn_he 已提交
408 409 410 411 412 413 414

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 已提交
415 416 417
| 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 已提交
418
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype9)&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
419 420 421 422 423

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
424 425 426 427 428 429 430 431 432 433 434 435
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 已提交
436 437
```

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

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

S
shawn_he 已提交
442
Obtains the keyboard type of an input device. This API uses a promise to return the result.
S
shawn_he 已提交
443 444 445 446 447

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

**Return value**

S
shawn_he 已提交
448 449
| Parameter                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
450
| Promise&lt;[KeyboardType](#keyboardtype9)&gt; | Promise used to return the result.|
S
shawn_he 已提交
451 452 453 454 455

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
456 457 458 459 460 461 462
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 已提交
463 464 465 466
```

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

S
shawn_he 已提交
467
Defines the listener for hot swap events of an input device.
S
shawn_he 已提交
468 469 470

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

S
shawn_he 已提交
471 472 473 474
| 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 已提交
475 476 477 478 479

## InputDeviceData

Defines the information about an input device.

E
ester.zhou 已提交
480 481
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
482 483 484 485 486
| 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.|
S
shawn_he 已提交
487
| axisRanges           | Array&lt;[AxisRange](#axisrange)&gt;  | Yes| No| Axis information of the input device.                                          |
S
shawn_he 已提交
488 489 490 491 492 493
| 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 已提交
494

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

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

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

S
shawn_he 已提交
501 502 503 504 505 506 507 508 509 510 511
| 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 已提交
512

S
shawn_he 已提交
513
## AxisRange
E
ester.zhou 已提交
514

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

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

S
shawn_he 已提交
519 520 521 522 523 524 525 526 527
| 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 已提交
528

S
shawn_he 已提交
529
## SourceType<sup>9+</sup>
Z
zengyawen 已提交
530

E
ester.zhou 已提交
531
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 已提交
532 533 534

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

S
shawn_he 已提交
535 536 537 538 539 540 541 542
| 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 已提交
543

S
shawn_he 已提交
544
## ChangedType<sup>9+</sup>
S
shawn_he 已提交
545 546 547 548 549

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

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

S
shawn_he 已提交
550 551 552 553
| 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 已提交
554 555 556 557 558 559 560

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

Enumerates the keyboard types.

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

S
shawn_he 已提交
561 562 563 564 565 566 567 568
| 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. |