js-apis-inputdevice.md 21.4 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 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
## 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 已提交
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 247 248 249
```js
inputDevice.getDeviceIds((ids)=>{
    console.log("The device ID list is: " + ids);
});
E
ester.zhou 已提交
250 251
```

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

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

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

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

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

**Return value**

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

**Example**
Z
zengyawen 已提交
269

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

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

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

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

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

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

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

| Name      | Type                                      | Mandatory  | Description                         |
| -------- | ---------------------------------------- | ---- | --------------------------- |
S
shawn_he 已提交
290 291
| 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 已提交
292

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

S
shawn_he 已提交
295 296 297 298 299
```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 已提交
300 301
```

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

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

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

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

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

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

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

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

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

**Example**

S
shawn_he 已提交
326 327 328 329 330
```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 已提交
331
```
S
shawn_he 已提交
332 333 334

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

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

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

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

**Parameters**

S
shawn_he 已提交
343 344 345 346
| 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 已提交
347
| callback | AsyncCallback&lt;Array&lt;boolean&gt;&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
348 349 350 351 352

**Example**

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

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

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

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

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

**Parameters**

S
shawn_he 已提交
372 373 374 375
| 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 已提交
376 377 378

**Return value**

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

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

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

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 已提交
406 407 408
| 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 已提交
409
| callback | AsyncCallback&lt;[KeyboardType](#keyboardtype9)&gt; | Yes   | Callback used to return the result.                   |
S
shawn_he 已提交
410 411 412 413 414

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
415 416 417 418 419 420 421 422 423 424 425 426
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 已提交
427 428
```

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

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

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

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

**Return value**

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

**Example**

```js
// Query the keyboard type of the input device whose ID is 1.
S
shawn_he 已提交
447 448 449 450 451 452 453
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 已提交
454 455 456 457
```

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

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

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

S
shawn_he 已提交
462 463 464 465
| 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 已提交
466 467 468 469 470

## InputDeviceData

Defines the information about an input device.

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

S
shawn_he 已提交
473 474 475 476 477 478 479 480 481 482 483 484
| 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 已提交
485

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

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

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

S
shawn_he 已提交
492 493 494 495 496 497 498 499 500 501 502
| 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 已提交
503

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

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

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

S
shawn_he 已提交
510 511 512 513 514 515 516 517 518
| 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 已提交
519

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

E
ester.zhou 已提交
522
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 已提交
523 524 525

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

S
shawn_he 已提交
526 527 528 529 530 531 532 533
| 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 已提交
534

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

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

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

S
shawn_he 已提交
541 542 543 544
| 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 已提交
545 546 547 548 549 550 551

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

Enumerates the keyboard types.

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

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