1/* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit InputKit 19 */ 20 21/*** if arkts 1.1 */ 22import type { Callback, AsyncCallback } from './@ohos.base'; 23import type { KeyCode } from './@ohos.multimodalInput.keyCode'; 24/*** endif */ 25/*** if arkts 1.2 */ 26import { Callback, AsyncCallback } from './@ohos.base'; 27/*** endif */ 28 29/** 30 * The inputDevice module implements input device management functions such as listening for the connection 31 * and disconnection of input devices and querying input device information such as the device name. 32 * 33 * @namespace inputDevice 34 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 35 * @since arkts {'1.1':'8', '1.2':'20'} 36 * @arkts 1.1&1.2 37 */ 38declare namespace inputDevice { 39 /** 40 * Enumerates hot swap events. 41 * 42 * @typedef { 'add' | 'remove' } 43 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 44 * @since arkts {'1.1':'9', '1.2':'20'} 45 * @arkts 1.1&1.2 46 */ 47 type ChangedType = 'add' | 'remove'; 48 49 /** 50 * Enumerates input source of the axis. For example, if a mouse reports an x-axis event, the input source of the x-axis is the mouse. 51 * 52 * @typedef { 'keyboard' | 'mouse' | 'touchpad' | 'touchscreen' | 'joystick' | 'trackball' } 53 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 54 * @since arkts {'1.1':'9', '1.2':'20'} 55 * @arkts 1.1&1.2 56 */ 57 type SourceType = 'keyboard' | 'mouse' | 'touchpad' | 'touchscreen' | 'joystick' | 'trackball'; 58 59 /** 60 * Defines the axis type of an input device. 61 * 62 * @typedef { 'touchmajor'| 'touchminor' | 'orientation' | 'x' | 'y' | 'pressure' | 'toolminor' | 'toolmajor' | 'null' } 63 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 64 * @since arkts {'1.1':'9', '1.2':'20'} 65 * @arkts 1.1&1.2 66 */ 67 type AxisType = 68 'touchmajor' 69 | 'touchminor' 70 | 'orientation' 71 | 'x' 72 | 'y' 73 | 'pressure' 74 | 'toolminor' 75 | 'toolmajor' 76 | 'null'; 77 78 /** 79 * Enumerates keyboard types. 80 * 81 * @enum { number } 82 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 83 * @since 9 84 */ 85 enum KeyboardType { 86 /** 87 * Keyboard without keys. 88 * 89 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 90 * @since 9 91 */ 92 NONE = 0, 93 94 /** 95 * Keyboard with unknown keys. 96 * 97 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 98 * @since 9 99 */ 100 UNKNOWN = 1, 101 102 /** 103 * Full keyboard. 104 * 105 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 106 * @since 9 107 */ 108 ALPHABETIC_KEYBOARD = 2, 109 110 /** 111 * Keypad. 112 * 113 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 114 * @since 9 115 */ 116 DIGITAL_KEYBOARD = 3, 117 118 /** 119 * Stylus. 120 * 121 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 122 * @since 9 123 */ 124 HANDWRITING_PEN = 4, 125 126 /** 127 * Remote control. 128 * 129 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 130 * @since 9 131 */ 132 REMOTE_CONTROL = 5 133 } 134 135 /** 136 * Enumerates function key types. 137 * 138 * @enum { number } 139 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 140 * @since 15 141 */ 142 enum FunctionKey { 143 /** 144 * CapsLock key. This key can be enabled or disabled only for the input keyboard extension. 145 * 146 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 147 * @since 15 148 */ 149 CAPS_LOCK = 1 150 } 151 152 /** 153 * Provides hot swap information about an input device. 154 * 155 * @interface DeviceListener 156 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 157 * @since arkts {'1.1':'9', '1.2':'20'} 158 * @arkts 1.1&1.2 159 */ 160 interface DeviceListener { 161 /** 162 * Device change type, which indicates whether an input device is inserted or removed. 163 * 164 * @type { ChangedType } 165 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 166 * @since arkts {'1.1':'9', '1.2':'20'} 167 * @arkts 1.1&1.2 168 */ 169 type: ChangedType; 170 171 /** 172 * Unique ID of the input device. 173 * If a physical device is repeatedly reinstalled or restarted, its ID may change. 174 * 175 * @type { number } 176 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 177 * @since arkts {'1.1':'9', '1.2':'20'} 178 * @arkts 1.1&1.2 179 */ 180 deviceId: number; 181 } 182 183 /** 184 * Enables listening for device hot swap events. 185 * When performing this operation, you need to connect to external devices such as a mouse, keyboard, and touchscreen. 186 * 187 * @param { 'change' } type - Event type. This field has a fixed value of change. 188 * @param { Callback<DeviceListener> } listener - Listener for events of the input device. 189 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 190 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 191 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 192 * @since arkts {'1.1':'9', '1.2':'20'} 193 * @arkts 1.1&1.2 194 */ 195 function on(type: 'change', listener: Callback<DeviceListener>): void; 196 197 /** 198 * Disables listening for device hot swap events. 199 * This API is called before the application exits. 200 * 201 * @param { 'change' } type - Event type. This field has a fixed value of change. 202 * @param { Callback<DeviceListener> } listener - Callback to unregister. 203 * If this parameter is left unspecified, listening for hot swap events of all input devices will be canceled. 204 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 205 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 206 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 207 * @since 9 208 */ 209 function off(type: 'change', listener?: Callback<DeviceListener>): void; 210 211 /** 212 * Defines the axis range of an input device. 213 * 214 * @interface AxisRange 215 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 216 * @since arkts {'1.1':'8', '1.2':'20'} 217 * @arkts 1.1&1.2 218 */ 219 interface AxisRange { 220 /** 221 * Input source of the axis. 222 * 223 * @type { SourceType } 224 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 225 * @since arkts {'1.1':'8', '1.2':'20'} 226 * @arkts 1.1&1.2 227 */ 228 source: SourceType; 229 230 /** 231 * Axis type. 232 * 233 * @type { AxisType } 234 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 235 * @since arkts {'1.1':'8', '1.2':'20'} 236 * @arkts 1.1&1.2 237 */ 238 axis: AxisType; 239 240 /** 241 * Maximum value of the axis. 242 * 243 * @type { number } 244 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 245 * @since arkts {'1.1':'8', '1.2':'20'} 246 * @arkts 1.1&1.2 247 */ 248 max: number; 249 250 /** 251 * Minimum value of the axis. 252 * 253 * @type { number } 254 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 255 * @since arkts {'1.1':'8', '1.2':'20'} 256 * @arkts 1.1&1.2 257 */ 258 min: number; 259 260 /** 261 * Fuzzy value of the axis. 262 * 263 * @type { number } 264 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 265 * @since arkts {'1.1':'9', '1.2':'20'} 266 * @arkts 1.1&1.2 267 */ 268 fuzz: number; 269 270 /** 271 * Benchmark value of the axis. 272 * 273 * @type { number } 274 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 275 * @since arkts {'1.1':'9', '1.2':'20'} 276 * @arkts 1.1&1.2 277 */ 278 flat: number; 279 280 /** 281 * Resolution of the axis. 282 * 283 * @type { number } 284 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 285 * @since arkts {'1.1':'9', '1.2':'20'} 286 * @arkts 1.1&1.2 287 */ 288 resolution: number; 289 } 290 291 /** 292 * Provides information about an input device. 293 * 294 * @interface InputDeviceData 295 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 296 * @since arkts {'1.1':'8', '1.2':'20'} 297 * @arkts 1.1&1.2 298 */ 299 interface InputDeviceData { 300 /** 301 * Unique ID of the input device. 302 * If the same physical device is repeatedly reinstalled or restarted, its ID may change. 303 * 304 * @type { number } 305 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 306 * @since arkts {'1.1':'8', '1.2':'20'} 307 * @arkts 1.1&1.2 308 */ 309 id: number; 310 311 /** 312 * Name of the input device. 313 * 314 * @type { string } 315 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 316 * @since arkts {'1.1':'8', '1.2':'20'} 317 * @arkts 1.1&1.2 318 */ 319 name: string; 320 321 /** 322 * Input sources supported by the input device. An input device can have multiple input sources. 323 * For example, if a keyboard is equipped with a touchpad, the input device supports both keyboard 324 * and touchpad input capabilities. 325 * 326 * @type { Array<SourceType> } 327 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 328 * @since arkts {'1.1':'8', '1.2':'20'} 329 * @arkts 1.1&1.2 330 */ 331 sources: Array<SourceType>; 332 333 /** 334 * Axis information of the input device. 335 * 336 * @type { Array<AxisRange> } 337 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 338 * @since arkts {'1.1':'8', '1.2':'20'} 339 * @arkts 1.1&1.2 340 */ 341 axisRanges: Array<AxisRange>; 342 343 /** 344 * Bus type of the input device. By default, the bus type reported by the input device prevails. 345 * 346 * @type { number } 347 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 348 * @since arkts {'1.1':'9', '1.2':'20'} 349 * @arkts 1.1&1.2 350 */ 351 bus: number; 352 353 /** 354 * Product information of the input device. 355 * 356 * @type { number } 357 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 358 * @since arkts {'1.1':'9', '1.2':'20'} 359 * @arkts 1.1&1.2 360 */ 361 product: number; 362 363 /** 364 * Vendor information of the input device. 365 * 366 * @type { number } 367 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 368 * @since arkts {'1.1':'9', '1.2':'20'} 369 * @arkts 1.1&1.2 370 */ 371 vendor: number; 372 373 /** 374 * Version information of the input device. 375 * 376 * @type { number } 377 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 378 * @since arkts {'1.1':'9', '1.2':'20'} 379 * @arkts 1.1&1.2 380 */ 381 version: number; 382 383 /** 384 * Physical address of the input device. 385 * 386 * @type { string } 387 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 388 * @since arkts {'1.1':'9', '1.2':'20'} 389 * @arkts 1.1&1.2 390 */ 391 phys: string; 392 393 /** 394 * Unique ID of the input device. 395 * 396 * @type { string } 397 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 398 * @since arkts {'1.1':'9', '1.2':'20'} 399 * @arkts 1.1&1.2 400 */ 401 uniq: string; 402 } 403 404 /** 405 * Obtains the IDs of all input devices. 406 * This API uses an asynchronous callback to return the result. 407 * 408 * @param { AsyncCallback<Array<number>> } callback - Callback used to return the IDs of all input devices. 409 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 410 * @since 8 411 * @deprecated since 9 412 * @useinstead ohos.multimodalInput.inputDevice#getDeviceList 413 */ 414 function getDeviceIds(callback: AsyncCallback<Array<number>>): void; 415 416 /** 417 * Obtains the IDs of all input devices. 418 * This API uses a promise to return the result. 419 * 420 * @returns { Promise<Array<number>> } Promise used to return the IDs of all input devices. 421 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 422 * @since 8 423 * @deprecated since 9 424 * @useinstead ohos.multimodalInput.inputDevice#getDeviceList 425 */ 426 function getDeviceIds(): Promise<Array<number>>; 427 428 /** 429 * Obtains the information about the input device with the specified ID. 430 * This API uses an asynchronous callback to return the result. 431 * 432 * @param { number } deviceId - ID of the input device. 433 * @param { AsyncCallback<InputDeviceData> } callback - Callback used to return the information about the input device. 434 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 435 * @since 8 436 * @deprecated since 9 437 * @useinstead ohos.multimodalInput.inputDevice#getDeviceInfo 438 */ 439 function getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void; 440 441 /** 442 * Obtains the information about the input device with the specified ID. 443 * This API uses a promise to return the result. 444 * 445 * @param { number } deviceId - ID of the input device. 446 * @returns { Promise<InputDeviceData> } Promise used to return the information about the input device. 447 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 448 * @since 8 449 * @deprecated since 9 450 * @useinstead ohos.multimodalInput.inputDevice#getDeviceInfo 451 */ 452 function getDevice(deviceId: number): Promise<InputDeviceData>; 453 454 /** 455 * Obtains the IDs of all input devices. 456 * This API uses an asynchronous callback to return the result. 457 * 458 * @param { AsyncCallback<Array<number>> } callback - Callback used to return the IDs of all input devices. id is the unique ID of an input device. 459 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 460 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 461 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 462 * @since arkts {'1.1':'9', '1.2':'20'} 463 * @arkts 1.1&1.2 464 */ 465 function getDeviceList(callback: AsyncCallback<Array<number>>): void; 466 467 /** 468 * Obtains the IDs of all input devices. 469 * This API uses a promise to return the result. 470 * 471 * @returns { Promise<Array<number>> } - Promise used to return the IDs of all input devices. 472 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 473 * @since arkts {'1.1':'9', '1.2':'20'} 474 * @arkts 1.1&1.2 475 */ 476 function getDeviceList(): Promise<Array<number>>; 477 478 /** 479 * Obtains information about the specified input device. 480 * This API uses an asynchronous callback to return the result. 481 * 482 * @param { number } deviceId - ID of the input device. 483 * @param { AsyncCallback<InputDeviceData> } callback - Callback used to return information about the input device, 484 * including device ID, name, supported source, physical address, version information, and product information. 485 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 486 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 487 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 488 * @since arkts {'1.1':'9', '1.2':'20'} 489 * @arkts 1.1&1.2 490 */ 491 function getDeviceInfo(deviceId: number, callback: AsyncCallback<InputDeviceData>): void; 492 493 /** 494 * Obtains the information about the input device with the specified ID. 495 * This API uses a promise to return the result. 496 * 497 * @param { number } deviceId - ID of the input device. 498 * @returns { Promise<InputDeviceData> } Promise used to return the information about the input device. 499 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 500 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 501 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 502 * @since arkts {'1.1':'9', '1.2':'20'} 503 * @arkts 1.1&1.2 504 */ 505 function getDeviceInfo(deviceId: number): Promise<InputDeviceData>; 506 507 /** 508 * Obtains information about the specified input device. 509 * 510 * @param { number } deviceId - ID of the input device. 511 * @returns { InputDeviceData } Information about the input device, including device ID, name, supported source, 512 * physical address, version information, and product information. 513 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 514 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 515 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 516 * @since 10 517 */ 518 function getDeviceInfoSync(deviceId: number): InputDeviceData; 519 520 /** 521 * Checks whether the input device supports the specified keys. 522 * This API uses an asynchronous callback to return the result. 523 * 524 * @param { number } deviceId - ID of the input device. The device ID changes if the same physical device is repeatedly removed and inserted. 525 * @param { Array<KeyCode> } keys - Keycodes to be queried. A maximum of five keycodes can be specified. 526 * @param { AsyncCallback<Array<boolean>> } callback -Callback used to return the result. 527 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 528 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 529 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 530 * @since 9 531 */ 532 function supportKeys(deviceId: number, keys: Array<KeyCode>, callback: AsyncCallback<Array<boolean>>): void; 533 534 /** 535 * Checks whether the input device supports the specified keys. This API uses a promise to return the result. 536 * 537 * @param { number } deviceId - ID of the input device. The device ID changes if the same physical device is repeatedly removed and inserted. 538 * @param { Array<KeyCode> } keys - Keycodes to be queried. A maximum of five keycodes can be specified. 539 * @returns { Promise<Array<boolean>> } Returns a result indicating whether the specified key codes are supported. 540 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 541 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 542 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 543 * @since 9 544 */ 545 function supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<boolean>>; 546 547 /** 548 * Checks whether the input device supports the specified keys. 549 * 550 * @param { number } deviceId - ID of the input device. The device ID changes if the same physical device is repeatedly removed and inserted. 551 * @param { Array<KeyCode> } keys - Keycodes to be queried. A maximum of five keycodes can be specified. 552 * @returns { Array<boolean> } Result indicating whether the input device supports the keycode value. 553 * The value true indicates yes, and the value false indicates no. 554 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 555 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 556 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 557 * @since 10 558 */ 559 function supportKeysSync(deviceId: number, keys: Array<KeyCode>): Array<boolean>; 560 561 /** 562 * Obtains the keyboard type of the input device, such as full keyboard and numeric keypad. 563 * This API uses an asynchronous callback to return the result. 564 * The keyboard type of the input device is subject to the result returned by the API. 565 * 566 * @param { number } deviceId - Unique ID of the input device. If the same physical device is repeatedly reinstalled or restarted, its ID may change. 567 * @param { AsyncCallback<KeyboardType> } callback - Callback used to return the result. 568 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 569 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 570 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 571 * @since 9 572 */ 573 function getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void; 574 575 /** 576 * Obtains the keyboard type of an input device. 577 * This API uses a promise to return the result. 578 * 579 * @param { number } deviceId - Unique ID of the input device. If the same physical device is repeatedly reinstalled or restarted, its ID may change. 580 * @returns { Promise<KeyboardType> } Promise used to return the result. 581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 582 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 583 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 584 * @since 9 585 */ 586 function getKeyboardType(deviceId: number): Promise<KeyboardType>; 587 588 /** 589 * Obtains the keyboard type of the input device. 590 * 591 * @param { number } deviceId - Unique ID of the input device. If the same physical device is repeatedly reinstalled or restarted, its ID may change. 592 * @returns { KeyboardType } Keyboard type. 593 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 594 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 595 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 596 * @since 10 597 */ 598 function getKeyboardTypeSync(deviceId: number): KeyboardType; 599 600 /** 601 * Sets the keyboard repeat delay. 602 * This API uses an asynchronous callback to return the result. 603 * 604 * @param { number } delay - Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is 500. 605 * @param { AsyncCallback<void> } callback - Callback used to return the result. 606 * @throws { BusinessError } 202 - SystemAPI permission error. 607 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 608 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 609 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 610 * @systemapi hide for inner use. 611 * @since 10 612 */ 613 function setKeyboardRepeatDelay(delay: number, callback: AsyncCallback<void>): void; 614 615 /** 616 * Sets the keyboard repeat delay. 617 * This API uses a promise to return the result. 618 * 619 * @param { number } delay - Keyboard repeat delay, in ms. The value range is [300, 1000] and the default value is 500. 620 * @returns { Promise<void> } A promise that returns no value. 621 * @throws { BusinessError } 202 - SystemAPI permission error. 622 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 623 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 624 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 625 * @systemapi hide for inner use. 626 * @since 10 627 */ 628 function setKeyboardRepeatDelay(delay: number): Promise<void>; 629 630 /** 631 * Obtains the keyboard repeat delay. 632 * This API uses an asynchronous callback to return the result. 633 * 634 * @param { AsyncCallback<number> } callback - Callback used to return the keyboard repeat delay. 635 * @throws { BusinessError } 202 - SystemAPI permission error. 636 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 637 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 638 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 639 * @systemapi hide for inner use. 640 * @since 10 641 */ 642 function getKeyboardRepeatDelay(callback: AsyncCallback<number>): void; 643 644 /** 645 * Obtains the keyboard repeat delay. 646 * This API uses a promise to return the result. 647 * 648 * @returns { Promise<number> } Promise used to return the keyboard repeat delay. 649 * @throws { BusinessError } 202 - SystemAPI permission error. 650 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 651 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 652 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 653 * @systemapi hide for inner use. 654 * @since 10 655 */ 656 function getKeyboardRepeatDelay(): Promise<number>; 657 658 /** 659 * Sets the keyboard repeat rate. 660 * This API uses an asynchronous callback to return the result. 661 * 662 * @param { number } rate - Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50. 663 * @param { AsyncCallback<void> } callback - Callback used to return the result. 664 * @throws { BusinessError } 202 - SystemAPI permission error. 665 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 666 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 667 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 668 * @systemapi hide for inner use. 669 * @since 10 670 */ 671 function setKeyboardRepeatRate(rate: number, callback: AsyncCallback<void>): void; 672 673 /** 674 * Sets the keyboard repeat rate. 675 * This API uses a promise to return the result. 676 * 677 * @param { number } rate - Keyboard repeat rate, in ms/time. The value range is [36, 100] and the default value is 50. 678 * @returns { Promise<void> } A promise that returns no value. 679 * @throws { BusinessError } 202 - SystemAPI permission error. 680 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 681 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 682 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 683 * @systemapi hide for inner use. 684 * @since 10 685 */ 686 function setKeyboardRepeatRate(rate: number): Promise<void>; 687 688 /** 689 * Obtains the keyboard repeat rate. 690 * This API uses an asynchronous callback to return the result. 691 * 692 * @param { AsyncCallback<number> } callback - Callback used to return the keyboard repeat rate. 693 * @throws { BusinessError } 202 - SystemAPI permission error. 694 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 695 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 696 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 697 * @systemapi hide for inner use. 698 * @since 10 699 */ 700 function getKeyboardRepeatRate(callback: AsyncCallback<number>): void; 701 702 /** 703 * Obtains the keyboard repeat rate. 704 * This API uses a promise to return the result. 705 * 706 * @returns { Promise<number> } Promise used to return the keyboard repeat rate. 707 * @throws { BusinessError } 202 - SystemAPI permission error. 708 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 709 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 710 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 711 * @systemapi hide for inner use. 712 * @since 10 713 */ 714 function getKeyboardRepeatRate(): Promise<number>; 715 716 /** 717 * Obtains the interval (including the device sleep time) elapsed since the last system input event. 718 * This API uses a promise to return the result. 719 * 720 * @returns { Promise<number> } Promise used to return the interval since the last input. 721 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 722 * @since 14 723 */ 724 function getIntervalSinceLastInput(): Promise<number>; 725 726 /** 727 * Sets the input switch status of an input device. Take the touchscreen as an example. 728 * If the input switch is off, the touchscreen does not respond when being touched. 729 * If the input switch is on, the touchscreen wakes up when being touched. 730 * 731 * @permission ohos.permission.INPUT_DEVICE_CONTROLLER 732 * @param { number } deviceId - Device id. 733 * @param { boolean } enabled - Switch status of the input device. The value true indicates that the input device is enabled, 734 * and the value false indicates the opposite. 735 * @returns { Promise<void> } Returns the result through a promise. 736 * @throws { BusinessError } 201 - Permission denied. 737 * The application does not have the permission required to call the API 738 * @throws { BusinessError } 202 - Permission verification failed. 739 * A non-system application calls a system API. 740 * @throws { BusinessError } 401 - Input parameter error. Possible causes: 741 * 1. Mandatory parameters are left unspecified; 742 * 2. Incorrect parameter types; 743 * 3. Parameter verification failed. 744 * @throws { BusinessError } 3900001 - The specified device does not exist. 745 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 746 * @systemapi 747 * @since 18 748 */ 749 function setInputDeviceEnabled(deviceId: number, enabled: boolean): Promise<void>; 750 751 /** 752 * Specifies whether to enable a function key (for example, CapsLock). 753 * This API uses a promise to return the result. 754 * 755 * @permission ohos.permission.INPUT_KEYBOARD_CONTROLLER 756 * @param { number } functionKey - Type of the function key. 757 * @param { boolean } enabled - Status of the function key. The value true indicates that the function key is enabled, 758 * and the value false indicates the opposite. 759 * @returns { Promise<void> } Returns the result through a promise. 760 * @throws { BusinessError } 201 - Permission denied. 761 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 762 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 763 * @throws { BusinessError } 3900002 - There is currently no keyboard device connected. 764 * @throws { BusinessError } 3900003 - It is prohibited for non-input applications. 765 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 766 * @since 15 767 */ 768 function setFunctionKeyEnabled(functionKey: FunctionKey, enabled: boolean): Promise<void>; 769 770 /** 771 * Checks whether the specified function key (for example, CapsLock) is enabled. 772 * This API uses a promise to return the result. 773 * 774 * @param { number } functionKey - Type of the function key. 775 * @returns { Promise<boolean> } Promise used to return the result. The value true indicates that the function key is enabled, 776 * and the value false indicates the opposite. 777 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 778 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 779 * @throws { BusinessError } 3900002 - There is currently no keyboard device connected. 780 * @syscap SystemCapability.MultimodalInput.Input.InputDevice 781 * @since 15 782 */ 783 function isFunctionKeyEnabled(functionKey: FunctionKey): Promise<boolean>; 784} 785 786export default inputDevice;