js-apis-inputdevice.md 21.6 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.multimodalInput.inputDevice (Input Device)
Z
zengyawen 已提交
2

S
shawn_he 已提交
3
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 已提交
4

S
shawn_he 已提交
5
> **NOTE**<br>
Z
zengyawen 已提交
6 7 8 9
> 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 已提交
10
```js
Z
zengyawen 已提交
11 12
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
S
shawn_he 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
## 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 已提交
31
  inputDevice.getDeviceIds((error, ids) => {
S
shawn_he 已提交
32 33
    if (error) {
      console.log(`Failed to get device list.
Z
zhoujun62 已提交
34
         error code=${err.code} msg=${err.message}`);
S
shawn_he 已提交
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
      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 已提交
63
  inputDevice.getDeviceIds().then((ids) => {
S
shawn_he 已提交
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
    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.
Z
zhoujun62 已提交
94
          error code=${err.code} msg=${err.message}`);
S
shawn_he 已提交
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
      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 已提交
137

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

**Example**

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

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

**Example**

```js
S
shawn_he 已提交
195
callback: function(data) {
S
shawn_he 已提交
196 197 198 199
  console.log("type: " + data.type + ", deviceId: " + data.deviceId);
}

try {
S
shawn_he 已提交
200
  inputDevice.on("change", this.callback);
S
shawn_he 已提交
201 202
} catch (error) {
  console.info("oninputdevcie " + error.code + " " + error.message)
S
shawn_he 已提交
203 204
}

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

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

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

S
shawn_he 已提交
224
## inputDevice.getDeviceIds<sup>(deprecated)</sup>
Z
zengyawen 已提交
225 226 227

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

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

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

Z
zengyawen 已提交
232 233
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

E
ester.zhou 已提交
234
**Parameters**
Z
zengyawen 已提交
235

E
ester.zhou 已提交
236 237 238 239 240 241
| Name      | Type                                      | Mandatory  | Description   |
| -------- | ---------------------------------------- | ---- | ----- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes   | Callback used to return the result.|

**Example**

S
shawn_he 已提交
242
```js
S
shawn_he 已提交
243 244 245 246 247 248
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 已提交
249
});
E
ester.zhou 已提交
250
```
S
shawn_he 已提交
251
```
E
ester.zhou 已提交
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
```js
S
shawn_he 已提交
272 273
inputDevice.getDeviceIds().then((ids) => {
  console.log(`Device id list: ${JSON.stringify(ids)}`);
S
shawn_he 已提交
274
});
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
```js
// Obtain the name of the device whose ID is 1.
S
shawn_he 已提交
298 299 300 301 302 303
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 已提交
304
});
Z
zengyawen 已提交
305 306
```

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

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

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

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

E
ester.zhou 已提交
315 316
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

S
shawn_he 已提交
317 318
**Parameters**

S
shawn_he 已提交
319 320 321
| Name      | Type    | Mandatory  | Description          |
| -------- | ------ | ---- | ------------ |
| deviceId | number | Yes   | ID of the input device.|
S
shawn_he 已提交
322

E
ester.zhou 已提交
323 324
**Return value**

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

**Example**

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

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

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

S
shawn_he 已提交
342
Obtains the key codes supported by the input device. This API uses an asynchronous callback to return the result.
S
shawn_he 已提交
343 344 345 346 347

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

**Parameters**

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

**Example**

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

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

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

S
shawn_he 已提交
371
Obtains the key codes supported by the input device. This API uses a promise to return the result.
S
shawn_he 已提交
372 373 374 375 376

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

**Parameters**

S
shawn_he 已提交
377 378 379 380
| 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 已提交
381 382 383

**Return value**

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

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

S
shawn_he 已提交
403
getKeyboardType(deviceId: number, callback: AsyncCallback&lt;KeyboardType&gt;): void
S
shawn_he 已提交
404 405 406 407 408 409 410

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

**Example**

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

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

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

S
shawn_he 已提交
438
Obtains the keyboard type of an input device. This API uses a promise to return the result.
S
shawn_he 已提交
439 440 441 442 443

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

**Return value**

S
shawn_he 已提交
444 445
| Parameter                                      | Description                 |
| ---------------------------------------- | ------------------- |
S
shawn_he 已提交
446
| Promise&lt;[KeyboardType](#keyboardtype9)&gt; | Promise used to return the result.|
S
shawn_he 已提交
447 448 449 450 451

**Example**

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

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

S
shawn_he 已提交
463
Defines the listener for hot swap events of an input device.
S
shawn_he 已提交
464 465 466

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

S
shawn_he 已提交
467 468 469 470
| 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 已提交
471 472 473 474 475

## InputDeviceData

Defines the information about an input device.

E
ester.zhou 已提交
476 477
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice

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

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

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

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

S
shawn_he 已提交
497 498
| Name       | Type  | Readable  | Writable  | Description     |
| --------- | ------ | ---- | ---- | ------- |
H
houchengyu2022 已提交
499 500 501 502
| touchmajor  | string | Yes| No| touchmajor axis. |
| touchminor  | string | Yes| No| touchminor axis. |
| toolminor   | string | Yes| No| toolminor axis.  |
| toolmajor   | string | Yes| No| toolmajor axis.  |
S
shawn_he 已提交
503 504 505 506 507
| 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 已提交
508

S
shawn_he 已提交
509
## AxisRange
E
ester.zhou 已提交
510

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

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

S
shawn_he 已提交
515 516 517 518 519 520 521 522 523
| 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 已提交
524

S
shawn_he 已提交
525
## SourceType<sup>9+</sup>
Z
zengyawen 已提交
526

E
ester.zhou 已提交
527
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 已提交
528 529 530

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

S
shawn_he 已提交
531 532 533 534 535 536 537 538
| 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 已提交
539

S
shawn_he 已提交
540
## ChangedType<sup>9+</sup>
S
shawn_he 已提交
541 542 543 544 545

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

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

S
shawn_he 已提交
546 547 548 549
| 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 已提交
550 551 552 553 554 555 556

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

Enumerates the keyboard types.

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

S
shawn_he 已提交
557 558 559 560 561 562 563 564
| 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. |