1 /* 2 * Copyright (c) 2024 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 * @addtogroup input 18 * @{ 19 * 20 * @brief Provides the C interface in the multi-modal input domain. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file oh_input_manager.h 27 * 28 * @brief Provides capabilities such as event injection and key status query. 29 * 30 * @syscap SystemCapability.MultimodalInput.Input.Core 31 * @library liboh_input.so 32 * @since 12 33 */ 34 35 #ifndef OH_INPUT_MANAGER_H 36 #define OH_INPUT_MANAGER_H 37 38 #include <stdint.h> 39 40 #include "oh_axis_type.h" 41 #include "oh_key_code.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Enumerated values of key event action. 49 * 50 * @since 12 51 */ 52 typedef enum Input_KeyStateAction { 53 /** Default */ 54 KEY_DEFAULT = -1, 55 /** Pressing of a key */ 56 KEY_PRESSED = 0, 57 /** Release of a key */ 58 KEY_RELEASED = 1, 59 /** Key switch enabled */ 60 KEY_SWITCH_ON = 2, 61 /** Key switch disabled */ 62 KEY_SWITCH_OFF = 3 63 } Input_KeyStateAction; 64 65 /** 66 * @brief Enumerates key event types. 67 * 68 * @since 12 69 */ 70 typedef enum Input_KeyEventAction { 71 /** Cancellation of a key action. */ 72 KEY_ACTION_CANCEL = 0, 73 /** Pressing of a key. */ 74 KEY_ACTION_DOWN = 1, 75 /** Release of a key. */ 76 KEY_ACTION_UP = 2, 77 } Input_KeyEventAction; 78 79 /** 80 * @brief Enumerated values of mouse event action. 81 * 82 * @since 12 83 */ 84 typedef enum Input_MouseEventAction { 85 /** Cancel. */ 86 MOUSE_ACTION_CANCEL = 0, 87 /** Moving of the mouse pointer. */ 88 MOUSE_ACTION_MOVE = 1, 89 /** Pressing down of the mouse. */ 90 MOUSE_ACTION_BUTTON_DOWN = 2, 91 /** Lifting of the mouse button. */ 92 MOUSE_ACTION_BUTTON_UP = 3, 93 /** Beginning of the mouse axis event */ 94 MOUSE_ACTION_AXIS_BEGIN = 4, 95 /** Updating of the mouse axis event */ 96 MOUSE_ACTION_AXIS_UPDATE = 5, 97 /** End of the mouse axis event */ 98 MOUSE_ACTION_AXIS_END = 6, 99 } Input_MouseEventAction; 100 101 /** 102 * @brief Mouse axis types. 103 * 104 * @since 12 105 */ 106 typedef enum InputEvent_MouseAxis { 107 /** Vertical scroll axis */ 108 MOUSE_AXIS_SCROLL_VERTICAL = 0, 109 /** Horizontal scroll axis */ 110 MOUSE_AXIS_SCROLL_HORIZONTAL = 1, 111 } InputEvent_MouseAxis; 112 113 /** 114 * @brief Enumerated values of mouse event button. 115 * 116 * @since 12 117 */ 118 typedef enum Input_MouseEventButton { 119 /** Invalid button */ 120 MOUSE_BUTTON_NONE = -1, 121 /** Left button on the mouse. */ 122 MOUSE_BUTTON_LEFT = 0, 123 /** Middle button on the mouse. */ 124 MOUSE_BUTTON_MIDDLE = 1, 125 /** Right button on the mouse. */ 126 MOUSE_BUTTON_RIGHT = 2, 127 /** Forward button on the mouse. */ 128 MOUSE_BUTTON_FORWARD = 3, 129 /** Back button on the mouse. */ 130 MOUSE_BUTTON_BACK = 4, 131 } Input_MouseEventButton; 132 133 /** 134 * @brief Enumerated values of touch event action. 135 * 136 * @since 12 137 */ 138 typedef enum Input_TouchEventAction { 139 /** Touch cancelled. */ 140 TOUCH_ACTION_CANCEL = 0, 141 /** Touch pressed. */ 142 TOUCH_ACTION_DOWN = 1, 143 /** Touch moved. */ 144 TOUCH_ACTION_MOVE = 2, 145 /** Touch lifted. */ 146 TOUCH_ACTION_UP = 3, 147 } Input_TouchEventAction; 148 149 /** 150 * @brief Enumerates event source types. 151 * 152 * @since 12 153 */ 154 typedef enum InputEvent_SourceType { 155 /** 156 * Indicates that the input source generates events similar to mouse cursor movement, 157 * button press and release, and wheel scrolling. 158 * 159 * @since 12 160 */ 161 SOURCE_TYPE_MOUSE = 1, 162 /** 163 * Indicates that the input source generates a touchscreen multi-touch event. 164 * 165 * @since 12 166 */ 167 SOURCE_TYPE_TOUCHSCREEN = 2, 168 /** 169 * Indicates that the input source generates a touchpad multi-touch event. 170 * 171 * @since 12 172 */ 173 SOURCE_TYPE_TOUCHPAD = 3 174 } InputEvent_SourceType; 175 176 /** 177 * @brief 键盘输入设备的类型。 178 * 179 * @since 13 180 */ 181 typedef enum Input_KeyboardType { 182 /** 表示无按键设备。 */ 183 KEYBOARD_TYPE_NONE = 0, 184 /** 表示未知按键设备。 */ 185 KEYBOARD_TYPE_UNKNOWN = 1, 186 /** 表示全键盘设备。 */ 187 KEYBOARD_TYPE_ALPHABETIC = 2, 188 /** 表示数字键盘设备。 */ 189 KEYBOARD_TYPE_DIGITAL = 3, 190 /** 表示手写笔设备。 */ 191 KEYBOARD_TYPE_STYLUS = 4, 192 /** 表示遥控器设备。 */ 193 KEYBOARD_TYPE_REMOTE_CONTROL = 5, 194 } Input_KeyboardType; 195 196 /** 197 * @brief Defines key information, which identifies a key pressing behavior. 198 * For example, the Ctrl key information contains the key value and key type. 199 * 200 * @since 12 201 */ 202 typedef struct Input_KeyState Input_KeyState; 203 204 /** 205 * @brief The key event to be injected. 206 * 207 * @since 12 208 */ 209 typedef struct Input_KeyEvent Input_KeyEvent; 210 211 /** 212 * @brief The mouse event to be injected. 213 * 214 * @since 12 215 */ 216 typedef struct Input_MouseEvent Input_MouseEvent; 217 218 /** 219 * @brief The touch event to be injected. 220 * 221 * @since 12 222 */ 223 typedef struct Input_TouchEvent Input_TouchEvent; 224 225 /** 226 * @brief Enumerates axis events. 227 * 228 * @since 12 229 */ 230 typedef struct Input_AxisEvent Input_AxisEvent; 231 232 /** 233 * @brief Enumerates error codes. 234 * 235 * @since 12 236 */ 237 typedef enum Input_Result { 238 /** Success */ 239 INPUT_SUCCESS = 0, 240 /** Permission verification failed */ 241 INPUT_PERMISSION_DENIED = 201, 242 /** Non-system application */ 243 INPUT_NOT_SYSTEM_APPLICATION = 202, 244 /** Parameter check failed */ 245 INPUT_PARAMETER_ERROR = 401, 246 /** Capability not supported */ 247 INPUT_DEVICE_NOT_SUPPORTED = 801, 248 /** Service error */ 249 INPUT_SERVICE_EXCEPTION = 3800001, 250 /** Interceptor repeatedly created for an application */ 251 INPUT_REPEAT_INTERCEPTOR = 4200001, 252 /** @error Already occupied by the system */ 253 INPUT_OCCUPIED_BY_SYSTEM = 4200002, 254 /** @error Already occupied by the other */ 255 INPUT_OCCUPIED_BY_OTHER = 4200003, 256 /** @error No keyboard device connected */ 257 INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002 258 } Input_Result; 259 260 /** 261 * @brief Defines the hot key structure. 262 * 263 * @since 13 264 */ 265 typedef struct Input_Hotkey Input_Hotkey; 266 267 /** 268 * @brief Defines a lifecycle callback for **keyEvent**. 269 * If the callback is triggered, **keyEvent** will be destroyed. 270 * @since 12 271 */ 272 typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); 273 274 /** 275 * @brief Defines a lifecycle callback for **mouseEvent**. 276 * If the callback is triggered, **mouseEvent** will be destroyed. 277 * @since 12 278 */ 279 typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); 280 281 /** 282 * @brief Defines a lifecycle callback for **touchEvent**. 283 * If the callback is triggered, **touchEvent** will be destroyed. 284 * @since 12 285 */ 286 typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); 287 288 /** 289 * @brief Defines a lifecycle callback for **axisEvent**. 290 * If the callback is triggered, **axisEvent** will be destroyed. 291 * @since 12 292 */ 293 typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); 294 295 /** 296 * @brief Callback used to return shortcut key events. 297 * @since 13 298 */ 299 typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey); 300 301 /** 302 * @brief 回调函数,用于回调输入设备的上线事件。 303 * @param deviceId 设备的id。 304 * @since 13 305 */ 306 typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); 307 308 /** 309 * @brief 回调函数,用于回调输入设备的下线事件。 310 * @param deviceId 设备的id。 311 * @since 13 312 */ 313 typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); 314 315 /** 316 * @brief Defines the structure for the interceptor of event callbacks, 317 * including mouseCallback, touchCallback, and axisCallback. 318 * @since 12 319 */ 320 typedef struct Input_InterceptorEventCallback { 321 /** Defines a lifecycle callback for **mouseEvent**. */ 322 Input_MouseEventCallback mouseCallback; 323 /** Defines a lifecycle callback for **touchEvent**. */ 324 Input_TouchEventCallback touchCallback; 325 /** Defines a lifecycle callback for **axisEvent**. */ 326 Input_AxisEventCallback axisCallback; 327 } Input_InterceptorEventCallback; 328 329 /** 330 * @brief 定义一个结构体用于监听设备热插拔 331 * @since 13 332 */ 333 typedef struct Input_DeviceListener { 334 /** 定义一个回调函数用于回调设备上线事件 */ 335 Input_DeviceAddedCallback deviceAddedCallback; 336 /** 定义一个回调函数用于回调设备下线事件 */ 337 Input_DeviceRemovedCallback deviceRemovedCallback; 338 } Input_DeviceListener; 339 340 /** 341 * @brief Defines event interceptor options. 342 * @since 12 343 */ 344 typedef struct Input_InterceptorOptions Input_InterceptorOptions; 345 346 /** 347 * @brief 输入设备信息。 348 * 349 * @since 13 350 */ 351 typedef struct Input_DeviceInfo Input_DeviceInfo; 352 353 /** 354 * @brief Queries the key state. 355 * 356 * @param keyState Key state. 357 * @HTTP4O4 Returns {@Link Input_Result#INPUT_SUCCESS} if the operation is successful; 358 * returns an error code defined in {@Link Input_Result} otherwise. 359 * @syscap SystemCapability.MultimodalInput.Input.Core 360 * @since 12 361 */ 362 Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState); 363 364 /** 365 * @brief Creates a key status enumeration object. 366 * 367 * @return Returns an {@link Input_KeyState} pointer object if the operation is successful. 368 * returns a null pointer otherwise. 369 * @syscap SystemCapability.MultimodalInput.Input.Core 370 * @since 12 371 */ 372 struct Input_KeyState* OH_Input_CreateKeyState(); 373 374 /** 375 * @brief Destroys a key status enumeration object. 376 * 377 * @param keyState Key status enumeration object. 378 * @syscap SystemCapability.MultimodalInput.Input.Core 379 * @since 12 380 */ 381 void OH_Input_DestroyKeyState(struct Input_KeyState** keyState); 382 383 /** 384 * @brief Sets the key value of a key status enumeration object. 385 * 386 * @param keyState Key status enumeration object. 387 * @param keyCode Key value of the key status enumeration object. 388 * @syscap SystemCapability.MultimodalInput.Input.Core 389 * @since 12 390 */ 391 void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode); 392 393 /** 394 * @brief Obtains the key value of a key status enumeration object. 395 * 396 * @param keyState Key status enumeration object. 397 * @return Key value of the key status enumeration object. 398 * @syscap SystemCapability.MultimodalInput.Input.Core 399 * @since 12 400 */ 401 int32_t OH_Input_GetKeyCode(const struct Input_KeyState* keyState); 402 403 /** 404 * @brief Sets whether the key specific to a key status enumeration object is pressed. 405 * 406 * @param keyState Key status enumeration object. 407 * @param keyAction Whether the key is pressed. 408 * @syscap SystemCapability.MultimodalInput.Input.Core 409 * @since 12 410 */ 411 void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction); 412 413 /** 414 * @brief Checks whether the key specific to a key status enumeration object is pressed. 415 * 416 * @param keyState Key status enumeration object. 417 * @return Key pressing status of the key status enumeration object. 418 * @syscap SystemCapability.MultimodalInput.Input.Core 419 * @since 12 420 */ 421 int32_t OH_Input_GetKeyPressed(const struct Input_KeyState* keyState); 422 423 /** 424 * @brief Sets the key switch of the key status enumeration object. 425 * 426 * @param keyState Key status enumeration object. 427 * @param keySwitch Key switch of the key status enumeration object. 428 * @syscap SystemCapability.MultimodalInput.Input.Core 429 * @since 12 430 */ 431 void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); 432 433 /** 434 * @brief Obtains the key switch of the key status enumeration object. 435 * 436 * @param keyState Key status enumeration object. 437 * @return Key switch of the key status enumeration object. 438 * @syscap SystemCapability.MultimodalInput.Input.Core 439 * @since 12 440 */ 441 int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); 442 443 /** 444 * @brief Inject system keys. 445 * 446 * @param keyEvent - the key event to be injected. 447 * @return 0 - Success. 448 * 201 - Missing permissions. 449 * 401 - Parameter error. 450 * @syscap SystemCapability.MultimodalInput.Input.Core 451 * @since 12 452 */ 453 int32_t OH_Input_InjectKeyEvent(const struct Input_KeyEvent* keyEvent); 454 455 /** 456 * @brief Creates a key event object. 457 * 458 * @return Returns an {@link Input_KeyEvent} pointer object if the operation is successful. 459 * returns a null pointer otherwise. 460 * @syscap SystemCapability.MultimodalInput.Input.Core 461 * @since 12 462 */ 463 struct Input_KeyEvent* OH_Input_CreateKeyEvent(); 464 465 /** 466 * @brief Destroys a key event object. 467 * 468 * @param keyEvent Key event object. 469 * @syscap SystemCapability.MultimodalInput.Input.Core 470 * @since 12 471 */ 472 void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent); 473 474 /** 475 * @brief Sets the key event type. 476 * 477 * @param keyEvent Key event object. 478 * @param action Key event type. 479 * @syscap SystemCapability.MultimodalInput.Input.Core 480 * @since 12 481 */ 482 void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action); 483 484 /** 485 * @brief Obtains the key event type. 486 * 487 * @param keyEvent Key event object. 488 * @return Key event type. 489 * @syscap SystemCapability.MultimodalInput.Input.Core 490 * @since 12 491 */ 492 int32_t OH_Input_GetKeyEventAction(const struct Input_KeyEvent* keyEvent); 493 494 /** 495 * @brief Sets the key value for a key event. 496 * 497 * @param keyEvent Key event object. 498 * @param keyCode keyCode Key code. 499 * @syscap SystemCapability.MultimodalInput.Input.Core 500 * @since 12 501 */ 502 void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode); 503 504 /** 505 * @brief Obtains the key value of a key event. 506 * 507 * @param keyEvent Key event object. 508 * @return Key code. 509 * @syscap SystemCapability.MultimodalInput.Input.Core 510 * @since 12 511 */ 512 int32_t OH_Input_GetKeyEventKeyCode(const struct Input_KeyEvent* keyEvent); 513 514 /** 515 * @brief Sets the time when a key event occurs. 516 * 517 * @param keyEvent Key event object. 518 * @param actionTime Time when the key event occurs. 519 * @syscap SystemCapability.MultimodalInput.Input.Core 520 * @since 12 521 */ 522 void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime); 523 524 /** 525 * @brief Obtains the time when a key event occurs. 526 * 527 * @param keyEvent Key event object. 528 * @return Returns the time when the key event occurs. 529 * @syscap SystemCapability.MultimodalInput.Input.Core 530 * @since 12 531 */ 532 int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); 533 534 /** 535 * @brief Sets the windowId for a key event. 536 * 537 * @param keyEvent Key event object. 538 * @param windowId The windowId for a key event. 539 * @syscap SystemCapability.MultimodalInput.Input.Core 540 * @since 15 541 */ 542 void OH_Input_SetKeyEventWindowId(struct Input_KeyEvent* keyEvent, int32_t windowId); 543 544 /** 545 * @brief Obtains the windowId of a key event. 546 * 547 * @param keyEvent Key event object. 548 * @return windowId. 549 * @syscap SystemCapability.MultimodalInput.Input.Core 550 * @since 15 551 */ 552 int32_t OH_Input_GetKeyEventWindowId(const struct Input_KeyEvent* keyEvent); 553 554 /** 555 * @brief Sets the displayId for a key event. 556 * 557 * @param keyEvent Key event object. 558 * @param displayId The displayId for a key event. 559 * @syscap SystemCapability.MultimodalInput.Input.Core 560 * @since 15 561 */ 562 void OH_Input_SetKeyEventDisplayId(struct Input_KeyEvent* keyEvent, int32_t displayId); 563 564 /** 565 * @brief Obtains the displayId of a key event. 566 * 567 * @param keyEvent Key event object. 568 * @return displayId. 569 * @syscap SystemCapability.MultimodalInput.Input.Core 570 * @since 15 571 */ 572 int32_t OH_Input_GetKeyEventDisplayId(const struct Input_KeyEvent* keyEvent); 573 574 /** 575 * @brief Inject mouse event. 576 * 577 * @param mouseEvent - the mouse event to be injected. 578 * @return 0 - Success. 579 * 201 - Missing permissions. 580 * 401 - Parameter error. 581 * @syscap SystemCapability.MultimodalInput.Input.Core 582 * @since 12 583 */ 584 int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent); 585 586 /** 587 * @brief Creates a mouse event object. 588 * 589 * @return Returns an {@link Input_MouseEvent} pointer object if the operation is successful. 590 * returns a null pointer otherwise. 591 * @syscap SystemCapability.MultimodalInput.Input.Core 592 * @since 12 593 */ 594 struct Input_MouseEvent* OH_Input_CreateMouseEvent(); 595 596 /** 597 * @brief Destroys a mouse event object. 598 * 599 * @param mouseEvent Mouse event object. 600 * @syscap SystemCapability.MultimodalInput.Input.Core 601 * @since 12 602 */ 603 void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent); 604 605 /** 606 * @brief Sets the action for a mouse event. 607 * 608 * @param mouseEvent Mouse event object. 609 * @param action Mouse action. 610 * @syscap SystemCapability.MultimodalInput.Input.Core 611 * @since 12 612 */ 613 void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action); 614 615 /** 616 * @brief Obtains the action of a mouse event. 617 * 618 * @param mouseEvent Mouse event object. 619 * @return Mouse action. 620 * @syscap SystemCapability.MultimodalInput.Input.Core 621 * @since 12 622 */ 623 int32_t OH_Input_GetMouseEventAction(const struct Input_MouseEvent* mouseEvent); 624 625 /** 626 * @brief Sets the X coordinate for a mouse event. 627 * 628 * @param mouseEvent Mouse event object. 629 * @param displayX X coordinate on the display. 630 * @syscap SystemCapability.MultimodalInput.Input.Core 631 * @since 12 632 */ 633 void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX); 634 635 /** 636 * @brief Obtains the X coordinate of a mouse event. 637 * 638 * @param mouseEvent Mouse event object. 639 * @return X coordinate on the display. 640 * @syscap SystemCapability.MultimodalInput.Input.Core 641 * @since 12 642 */ 643 int32_t OH_Input_GetMouseEventDisplayX(const struct Input_MouseEvent* mouseEvent); 644 645 /** 646 * @brief Sets the Y coordinate for a mouse event. 647 * 648 * @param mouseEvent Mouse event object. 649 * @param displayY Y coordinate on the display. 650 * @syscap SystemCapability.MultimodalInput.Input.Core 651 * @since 12 652 */ 653 void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY); 654 655 /** 656 * @brief Obtains the Y coordinate of a mouse event. 657 * 658 * @param mouseEvent Mouse event object. 659 * @return Y coordinate on the display. 660 * @syscap SystemCapability.MultimodalInput.Input.Core 661 * @since 12 662 */ 663 int32_t OH_Input_GetMouseEventDisplayY(const struct Input_MouseEvent* mouseEvent); 664 665 /** 666 * @brief Sets the button for a mouse event. 667 * 668 * @param mouseEvent Mouse event object. 669 * @param button Mouse button. 670 * @syscap SystemCapability.MultimodalInput.Input.Core 671 * @since 12 672 */ 673 void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button); 674 675 /** 676 * @brief Obtains the button of a mouse event. 677 * 678 * @param mouseEvent Mouse event object. 679 * @return Mouse button. 680 * @syscap SystemCapability.MultimodalInput.Input.Core 681 * @since 12 682 */ 683 int32_t OH_Input_GetMouseEventButton(const struct Input_MouseEvent* mouseEvent); 684 685 /** 686 * @brief Sets the axis type for mouse event. 687 * 688 * @param mouseEvent Mouse event object. 689 * @param axisType Axis type, for example, X axis or Y axis. 690 * @syscap SystemCapability.MultimodalInput.Input.Core 691 * @since 12 692 */ 693 void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType); 694 695 /** 696 * @brief Obtains the axis type of a mouse event. 697 * 698 * @param mouseEvent Mouse event object. 699 * @return Axis type. 700 * @syscap SystemCapability.MultimodalInput.Input.Core 701 * @since 12 702 */ 703 int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent); 704 705 /** 706 * @brief Sets the axis value for a mouse axis event. 707 * 708 * @param mouseEvent Mouse event object. 709 * @param axisValue Axis value. A positive value means scrolling forward, 710 * and a negative number means scrolling backward. 711 * @syscap SystemCapability.MultimodalInput.Input.Core 712 * @since 12 713 */ 714 void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue); 715 716 /** 717 * @brief Obtains the axis value of a mouse event. 718 * 719 * @param mouseEvent Mouse event object. 720 * @return Axis value. 721 * @syscap SystemCapability.MultimodalInput.Input.Core 722 * @since 12 723 */ 724 float OH_Input_GetMouseEventAxisValue(const struct Input_MouseEvent* mouseEvent); 725 726 /** 727 * @brief Sets the time when a mouse event occurs. 728 * 729 * @param mouseEvent Mouse event object. 730 * @param actionTime Time when the mouse event occurs. 731 * @syscap SystemCapability.MultimodalInput.Input.Core 732 * @since 12 733 */ 734 void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime); 735 736 /** 737 * @brief Obtains the time when a mouse event occurs. 738 * 739 * @param mouseEvent Mouse event object. 740 * @return Returns the time when the mouse event occurs. 741 * @syscap SystemCapability.MultimodalInput.Input.Core 742 * @since 12 743 */ 744 int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEvent); 745 746 /** 747 * @brief Sets the windowId for a mouse event. 748 * 749 * @param mouseEvent Mouse event object. 750 * @param windowId The windowId for a mouse event. 751 * @syscap SystemCapability.MultimodalInput.Input.Core 752 * @since 15 753 */ 754 void OH_Input_SetMouseEventWindowId(struct Input_MouseEvent* mouseEvent, int32_t windowId); 755 756 /** 757 * @brief Obtains the windowId of a mouse event. 758 * 759 * @param mouseEvent Mouse event object. 760 * @return windowId. 761 * @syscap SystemCapability.MultimodalInput.Input.Core 762 * @since 15 763 */ 764 int32_t OH_Input_GetMouseEventWindowId(const struct Input_MouseEvent* mouseEvent); 765 766 /** 767 * @brief Sets the displayId for a mouse event. 768 * 769 * @param mouseEvent Mouse event object. 770 * @param displayId The displayId for a mouse event. 771 * @syscap SystemCapability.MultimodalInput.Input.Core 772 * @since 15 773 */ 774 void OH_Input_SetMouseEventDisplayId(struct Input_MouseEvent* mouseEvent, int32_t displayId); 775 776 /** 777 * @brief Obtains the displayId of a mouse event. 778 * 779 * @param mouseEvent Mouse event object. 780 * @return displayId. 781 * @syscap SystemCapability.MultimodalInput.Input.Core 782 * @since 15 783 */ 784 int32_t OH_Input_GetMouseEventDisplayId(const struct Input_MouseEvent* mouseEvent); 785 786 /** 787 * @brief Inject touch event. 788 * 789 * @param touchEvent - the touch event to be injected. 790 * @return 0 - Success. 791 * 201 - Missing permissions. 792 * 401 - Parameter error. 793 * @syscap SystemCapability.MultimodalInput.Input.Core 794 * @since 12 795 */ 796 int32_t OH_Input_InjectTouchEvent(const struct Input_TouchEvent* touchEvent); 797 798 /** 799 * @brief Creates a touch event object. 800 * 801 * @return Returns an {@link Input_TouchEvent} pointer object if the operation is successful. 802 * returns a null pointer otherwise. 803 * @syscap SystemCapability.MultimodalInput.Input.Core 804 * @since 12 805 */ 806 struct Input_TouchEvent* OH_Input_CreateTouchEvent(); 807 808 /** 809 * @brief Destroys a touch event object. 810 * 811 * @param touchEvent Touch event object. 812 * @syscap SystemCapability.MultimodalInput.Input.Core 813 * @since 12 814 */ 815 void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent); 816 817 /** 818 * @brief Sets the action for a touch event. 819 * 820 * @param touchEvent Touch event object. 821 * @param action Touch action. 822 * @syscap SystemCapability.MultimodalInput.Input.Core 823 * @since 12 824 */ 825 void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action); 826 827 /** 828 * @brief Obtains the action of a touch event. 829 * 830 * @param touchEvent Touch event object. 831 * @return Touch action. 832 * @syscap SystemCapability.MultimodalInput.Input.Core 833 * @since 12 834 */ 835 int32_t OH_Input_GetTouchEventAction(const struct Input_TouchEvent* touchEvent); 836 837 /** 838 * @brief Sets the finger ID for the touch event. 839 * 840 * @param touchEvent Touch event object. 841 * @param id Finger ID. 842 * @syscap SystemCapability.MultimodalInput.Input.Core 843 * @since 12 844 */ 845 void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id); 846 847 /** 848 * @brief Obtains the finger ID of a touch event. 849 * 850 * @param touchEvent Touch event object. 851 * @return Finger ID. 852 * @syscap SystemCapability.MultimodalInput.Input.Core 853 * @since 12 854 */ 855 int32_t OH_Input_GetTouchEventFingerId(const struct Input_TouchEvent* touchEvent); 856 857 /** 858 * @brief Sets the X coordinate for a touch event. 859 * 860 * @param touchEvent Touch event object. 861 * @param displayX X coordinate. 862 * @syscap SystemCapability.MultimodalInput.Input.Core 863 * @since 12 864 */ 865 void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX); 866 867 /** 868 * @brief Obtains the X coordinate of a touch event. 869 * 870 * @param touchEvent Touch event object. 871 * @return X coordinate. 872 * @syscap SystemCapability.MultimodalInput.Input.Core 873 * @since 12 874 */ 875 int32_t OH_Input_GetTouchEventDisplayX(const struct Input_TouchEvent* touchEvent); 876 877 /** 878 * @brief Sets the Y coordinate for a touch event. 879 * 880 * @param touchEvent Touch event object. 881 * @param displayY Y coordinate. 882 * @syscap SystemCapability.MultimodalInput.Input.Core 883 * @since 12 884 */ 885 void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY); 886 887 /** 888 * @brief Obtains the Y coordinate of a touch event. 889 * 890 * @param touchEvent Touch event object. 891 * @return Y coordinate. 892 * @syscap SystemCapability.MultimodalInput.Input.Core 893 * @since 12 894 */ 895 int32_t OH_Input_GetTouchEventDisplayY(const struct Input_TouchEvent* touchEvent); 896 897 /** 898 * @brief Sets the time when a touch event occurs. 899 * 900 * @param touchEvent Touch event object. 901 * @param actionTime Time when the touch event occurs. 902 * @syscap SystemCapability.MultimodalInput.Input.Core 903 * @since 12 904 */ 905 void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime); 906 907 /** 908 * @brief Obtains the time when a touch event occurs. 909 * 910 * @param touchEvent touch event object. 911 * @return Returns the time when the touch event occurs. 912 * @syscap SystemCapability.MultimodalInput.Input.Core 913 * @since 12 914 */ 915 int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEvent); 916 917 /** 918 * @brief Sets the windowId for a touch event. 919 * 920 * @param touchEvent Touch event object. 921 * @param windowId The windowId for a touch event. 922 * @syscap SystemCapability.MultimodalInput.Input.Core 923 * @since 15 924 */ 925 void OH_Input_SetTouchEventWindowId(struct Input_TouchEvent* touchEvent, int32_t windowId); 926 927 /** 928 * @brief Obtains the windowId of a touch event. 929 * 930 * @param touchEvent Touch event object. 931 * @return windowId. 932 * @syscap SystemCapability.MultimodalInput.Input.Core 933 * @since 15 934 */ 935 int32_t OH_Input_GetTouchEventWindowId(const struct Input_TouchEvent* touchEvent); 936 937 /** 938 * @brief Sets the displayId for a touch event. 939 * 940 * @param touchEvent Touch event object. 941 * @param displayId The displayId for a touch event. 942 * @syscap SystemCapability.MultimodalInput.Input.Core 943 * @since 15 944 */ 945 void OH_Input_SetTouchEventDisplayId(struct Input_TouchEvent* touchEvent, int32_t displayId); 946 947 /** 948 * @brief Obtains the displayId of a touch event. 949 * 950 * @param touchEvent Touch event object. 951 * @return displayId. 952 * @syscap SystemCapability.MultimodalInput.Input.Core 953 * @since 15 954 */ 955 int32_t OH_Input_GetTouchEventDisplayId(const struct Input_TouchEvent* touchEvent); 956 957 /** 958 * @brief Cancels event injection and revokes authorization. 959 * 960 * @syscap SystemCapability.MultimodalInput.Input.Core 961 * @since 12 962 */ 963 void OH_Input_CancelInjection(); 964 965 /** 966 * @brief Creates an axis event object. 967 * 968 * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. 969 * If the operation fails, null is returned. 970 * @syscap SystemCapability.MultimodalInput.Input.Core 971 * @since 12 972 */ 973 Input_AxisEvent* OH_Input_CreateAxisEvent(void); 974 975 /** 976 * @brief Destroys an axis event object. 977 * 978 * @param axisEvent Pointer to the axis event object. 979 * @return OH_Input_DestroyAxisEvent function result code. 980 * {@link INPUT_SUCCESS} Destroys axisEvent success.\n 981 * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n 982 * @syscap SystemCapability.MultimodalInput.Input.Core 983 * @since 12 984 */ 985 Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); 986 987 /** 988 * @brief Sets the axis event action. 989 * 990 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 991 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 992 * @return OH_Input_SetAxisEventAction function result code. 993 * {@link INPUT_SUCCESS} Sets the axis event action success.\n 994 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 995 * @syscap SystemCapability.MultimodalInput.Input.Core 996 * @since 12 997 */ 998 Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); 999 1000 /** 1001 * @brief Obtains the axis event action. 1002 * 1003 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1004 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 1005 * @return OH_Input_GetAxisEventAction function result code. 1006 * {@link INPUT_SUCCESS} Obtains the axis event action success.\n 1007 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n 1008 * @syscap SystemCapability.MultimodalInput.Input.Core 1009 * @since 12 1010 */ 1011 Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); 1012 1013 /** 1014 * @brief Sets the X coordinate of an axis event. 1015 * 1016 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1017 * @param displayX X coordinate of the axis event. 1018 * @return OH_Input_SetAxisEventDisplayX function result code. 1019 * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n 1020 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1021 * @syscap SystemCapability.MultimodalInput.Input.Core 1022 * @since 12 1023 */ 1024 Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); 1025 1026 /** 1027 * @brief Obtains the X coordinate of an axis event. 1028 * 1029 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1030 * @param displayX X coordinate of the axis event. 1031 * @return OH_Input_GetAxisEventDisplayX function result code. 1032 * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n 1033 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n 1034 * @syscap SystemCapability.MultimodalInput.Input.Core 1035 * @since 12 1036 */ 1037 Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); 1038 1039 /** 1040 * @brief Sets the Y coordinate of an axis event. 1041 * 1042 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1043 * @param displayY Y coordinate of the axis event. 1044 * @return OH_Input_SetAxisEventDisplayY function result code. 1045 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1046 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1047 * @syscap SystemCapability.MultimodalInput.Input.Core 1048 * @since 12 1049 */ 1050 Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); 1051 1052 /** 1053 * @brief Obtains the Y coordinate of an axis event. 1054 * 1055 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1056 * @param displayY Y coordinate of the axis event. 1057 * @return OH_Input_GetAxisEventDisplayY function result code. 1058 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1059 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1060 * @syscap SystemCapability.MultimodalInput.Input.Core 1061 * @since 12 1062 */ 1063 Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); 1064 1065 /** 1066 * @brief Sets the axis value of the axis type specified by the axis event. 1067 * 1068 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1069 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 1070 * @param axisValue Axis value. 1071 * @return OH_Input_SetAxisEventAxisValue function result code. 1072 * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n 1073 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1074 * @syscap SystemCapability.MultimodalInput.Input.Core 1075 * @since 12 1076 */ 1077 Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, 1078 InputEvent_AxisType axisType, double axisValue); 1079 1080 /** 1081 * @brief Obtains the axis value for the specified axis type of the axis event. 1082 * 1083 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1084 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 1085 * @param axisValue Axis value. 1086 * @return OH_Input_GetAxisEventAxisValue function result code. 1087 * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n 1088 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, 1089 * or the axisType not found in the axisEvent.\n 1090 * @syscap SystemCapability.MultimodalInput.Input.Core 1091 * @since 12 1092 */ 1093 Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, 1094 InputEvent_AxisType axisType, double* axisValue); 1095 1096 /** 1097 * @brief Sets the time when an axis event occurs. 1098 * 1099 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1100 * @param actionTime Time when an axis event occurs. 1101 * @return OH_Input_SetAxisEventActionTime function result code. 1102 * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n 1103 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1104 * @syscap SystemCapability.MultimodalInput.Input.Core 1105 * @since 12 1106 */ 1107 Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); 1108 1109 /** 1110 * @brief Obtains the time when an axis event occurs. 1111 * 1112 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1113 * @param actionTime Time when an axis event occurs. 1114 * @return OH_Input_GetAxisEventActionTime function result code. 1115 * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n 1116 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n 1117 * @syscap SystemCapability.MultimodalInput.Input.Core 1118 * @since 12 1119 */ 1120 Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); 1121 1122 /** 1123 * @brief Sets the axis event type. 1124 * 1125 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1126 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 1127 * @return OH_Input_SetAxisEventType function result code. 1128 * {@link INPUT_SUCCESS} Sets the axis event type success.\n 1129 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1130 * @syscap SystemCapability.MultimodalInput.Input.Core 1131 * @since 12 1132 */ 1133 Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); 1134 1135 /** 1136 * @brief Obtains the axis event type. 1137 * 1138 * @param axisEvent Axis event object. 1139 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 1140 * @return OH_Input_GetAxisEventType function result code. 1141 * {@link INPUT_SUCCESS} Obtains the axis event type success.\n 1142 * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n 1143 * @syscap SystemCapability.MultimodalInput.Input.Core 1144 * @since 12 1145 */ 1146 Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); 1147 1148 /** 1149 * @brief Sets the axis event source type. 1150 * 1151 * @param axisEvent Axis event object. 1152 * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1153 * @return OH_Input_SetAxisEventSourceType function result code. 1154 * {@link INPUT_SUCCESS} Sets the axis event source type success.\n 1155 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1156 * @syscap SystemCapability.MultimodalInput.Input.Core 1157 * @since 12 1158 */ 1159 Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); 1160 1161 /** 1162 * @brief Obtains the axis event source type. 1163 * 1164 * @param axisEvent Axis event object. 1165 * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1166 * @return OH_Input_GetAxisEventSourceType function result code. 1167 * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n 1168 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n 1169 * @syscap SystemCapability.MultimodalInput.Input.Core 1170 * @since 12 1171 */ 1172 Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); 1173 1174 /** 1175 * @brief Sets the windowId of an axis event. 1176 * 1177 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1178 * @param windowId The windowId for the axis event. 1179 * @return OH_Input_SetAxisEventDisplayY function result code. 1180 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1181 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1182 * @syscap SystemCapability.MultimodalInput.Input.Core 1183 * @since 15 1184 */ 1185 Input_Result OH_Input_SetAxisEventWindowId(Input_AxisEvent* axisEvent, int32_t windowId); 1186 1187 /** 1188 * @brief Obtains the windowId of an axis event. 1189 * 1190 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1191 * @param windowId The windowId for the axis event. 1192 * @return OH_Input_GetAxisEventDisplayY function result code. 1193 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1194 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1195 * @syscap SystemCapability.MultimodalInput.Input.Core 1196 * @since 15 1197 */ 1198 Input_Result OH_Input_GetAxisEventWindowId(const Input_AxisEvent* axisEvent, int32_t* windowId); 1199 1200 /** 1201 * @brief Sets the displayId of an axis event. 1202 * 1203 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1204 * @param displayId The displayId for the axis event. 1205 * @return OH_Input_SetAxisEventDisplayY function result code. 1206 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1207 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1208 * @syscap SystemCapability.MultimodalInput.Input.Core 1209 * @since 15 1210 */ 1211 Input_Result OH_Input_SetAxisEventDisplayId(Input_AxisEvent* axisEvent, int32_t displayId); 1212 1213 /** 1214 * @brief Obtains the displayId of an axis event. 1215 * 1216 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1217 * @param displayId The displayId for the axis event. 1218 * @return OH_Input_GetAxisEventDisplayY function result code. 1219 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1220 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1221 * @syscap SystemCapability.MultimodalInput.Input.Core 1222 * @since 15 1223 */ 1224 Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, int32_t* displayId); 1225 1226 /** 1227 * @brief Adds a listener of key events. 1228 * 1229 * @permission ohos.permission.INPUT_MONITORING 1230 * @param callback - Callback used to receive key events. 1231 * @return OH_Input_AddKeyEventMonitor function result code. 1232 * {@link INPUT_SUCCESS} Adds a listener of key events success.\n 1233 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1234 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1235 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1236 * @syscap SystemCapability.MultimodalInput.Input.Core 1237 * @since 12 1238 */ 1239 Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); 1240 1241 /** 1242 * @brief Adds a listener for mouse events, including mouse click and movement events, 1243 * but not scroll wheel events. Scroll wheel events are axis events. 1244 * 1245 * @permission ohos.permission.INPUT_MONITORING 1246 * @param callback - Callback used to receive mouse events. 1247 * @return OH_Input_AddMouseEventMonitor function result code. 1248 * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n 1249 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1250 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1251 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1252 * @syscap SystemCapability.MultimodalInput.Input.Core 1253 * @since 12 1254 */ 1255 Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); 1256 1257 /** 1258 * @brief Add a listener for touch events. 1259 * 1260 * @permission ohos.permission.INPUT_MONITORING 1261 * @param callback - Callback used to receive touch events. 1262 * @return OH_Input_AddTouchEventMonitor function result code. 1263 * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n 1264 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1265 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1266 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1267 * @syscap SystemCapability.MultimodalInput.Input.Core 1268 * @since 12 1269 */ 1270 Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); 1271 1272 /** 1273 * @brief Adds a listener for all types of axis events. 1274 * The axis event types are defined in {@Link InputEvent_AxisEventType}. 1275 * 1276 * @permission ohos.permission.INPUT_MONITORING 1277 * @param callback - Callback used to receive axis events. 1278 * @return OH_Input_AddAxisEventMonitorForAll function result code. 1279 * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n 1280 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1281 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1282 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1283 * @syscap SystemCapability.MultimodalInput.Input.Core 1284 * @since 12 1285 */ 1286 Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); 1287 1288 /** 1289 * @brief Adds a listener for the specified type of axis events. 1290 * 1291 * @permission ohos.permission.INPUT_MONITORING 1292 * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. 1293 * @param callback - Callback used to receive the specified type of axis events. 1294 * @return OH_Input_AddAxisEventMonitor function result code. 1295 * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n 1296 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1297 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1298 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1299 * @syscap SystemCapability.MultimodalInput.Input.Core 1300 * @since 12 1301 */ 1302 Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1303 1304 /** 1305 * @brief Removes a key event listener. 1306 * 1307 * @permission ohos.permission.INPUT_MONITORING 1308 * @param callback - Callback for the key event listener. 1309 * @return OH_Input_RemoveKeyEventMonitor function result code. 1310 * {@link INPUT_SUCCESS} Removes a key event listener success.\n 1311 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1312 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1313 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1314 * @syscap SystemCapability.MultimodalInput.Input.Core 1315 * @since 12 1316 */ 1317 Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); 1318 1319 /** 1320 * @brief Removes a mouse event listener. 1321 * 1322 * @permission ohos.permission.INPUT_MONITORING 1323 * @param callback - Callback for the mouse event listener. 1324 * @return OH_Input_RemoveMouseEventMonitor function result code. 1325 * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n 1326 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1327 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1328 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1329 * @syscap SystemCapability.MultimodalInput.Input.Core 1330 * @since 12 1331 */ 1332 Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); 1333 1334 /** 1335 * @brief Removes a touch event listener. 1336 * 1337 * @permission ohos.permission.INPUT_MONITORING 1338 * @param callback - Callback for the touch event listener. 1339 * @return OH_Input_RemoveTouchEventMonitor function result code. 1340 * {@link INPUT_SUCCESS} Removes a touch event listener success.\n 1341 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1342 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1343 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1344 * @syscap SystemCapability.MultimodalInput.Input.Core 1345 * @since 12 1346 */ 1347 Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); 1348 1349 /** 1350 * @brief Removes the listener for all types of axis events. 1351 * 1352 * @permission ohos.permission.INPUT_MONITORING 1353 * @param callback - Callback for the listener used to listen for all types of axis events. 1354 * @return OH_Input_RemoveAxisEventMonitorForAll function result code. 1355 * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n 1356 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1357 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1358 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1359 * @syscap SystemCapability.MultimodalInput.Input.Core 1360 * @since 12 1361 */ 1362 Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); 1363 1364 /** 1365 * @brief Removes the listener for the specified type of axis events. 1366 * 1367 * @permission ohos.permission.INPUT_MONITORING 1368 * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. 1369 * @param callback - Callback for the listener used to listen for the specified type of axis events. 1370 * @return OH_Input_RemoveAxisEventMonitor function result code. 1371 * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n 1372 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1373 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1374 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1375 * @syscap SystemCapability.MultimodalInput.Input.Core 1376 * @since 12 1377 */ 1378 Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1379 1380 /** 1381 * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. 1382 * 1383 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1384 * @param callback - Callback used to receive key events. 1385 * @param option - Options for event interception. If **null** is passed, the default value is used. 1386 * @return OH_Input_AddKeyEventInterceptor function result code. 1387 * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n 1388 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1389 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1390 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1391 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1392 * @syscap SystemCapability.MultimodalInput.Input.Core 1393 * @since 12 1394 */ 1395 Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); 1396 1397 /** 1398 * @brief Adds an interceptor for input events, including mouse, touch, and axis events. 1399 * If multiple interceptors are added, only the first one takes effect. 1400 * 1401 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1402 * @param callback - Pointer to the structure of the callback for the input event interceptor. 1403 * For details, see {@Link Input_InterceptorEventCallback}. 1404 * @param option - Options for event interception. If **null** is passed, the default value is used. 1405 * @return OH_Input_AddInputEventInterceptor function result code. 1406 * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n 1407 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1408 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1409 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1410 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1411 * @syscap SystemCapability.MultimodalInput.Input.Core 1412 * @since 12 1413 */ 1414 Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, 1415 Input_InterceptorOptions *option); 1416 1417 /** 1418 * @brief Removes a key event interceptor. 1419 * 1420 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1421 * @return OH_Input_RemoveKeyEventInterceptor function result code. 1422 * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n 1423 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1424 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1425 * @syscap SystemCapability.MultimodalInput.Input.Core 1426 * @since 12 1427 */ 1428 Input_Result OH_Input_RemoveKeyEventInterceptor(void); 1429 1430 /** 1431 * @brief Removes an interceptor for input events, including mouse, touch, and axis events. 1432 * 1433 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1434 * @return OH_Input_RemoveInputEventInterceptor function result code. 1435 * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n 1436 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1437 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1438 * @syscap SystemCapability.MultimodalInput.Input.Core 1439 * @since 12 1440 */ 1441 Input_Result OH_Input_RemoveInputEventInterceptor(void); 1442 1443 /** 1444 * @brief Obtains the interval since the last system input event. 1445 * 1446 * @param timeInterval Interval, in microseconds. 1447 * @return OH_Input_GetIntervalSinceLastInput status code, specifically, 1448 * {@Link INPUT_SUCCESS} if the Operation is successful; 1449 * {@Link INPUT_SERVICE_EXCEPTION} otherwise. 1450 * @syscap SystemCapability.MultimodalInput.Input.Core 1451 * @since 13 1452 */ 1453 int32_t OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval); 1454 1455 /** 1456 * @brief Creates a hot key object. 1457 * 1458 * @return Returns an {@Link Input_Hotkey} pointer object if the operation is successful. Otherwise, a null pointer is 1459 * returned. The possible cause is memory allocation failure. 1460 * @syscap SystemCapability.MultimodalInput.Input.Core 1461 * @since 13 1462 */ 1463 Input_Hotkey *OH_Input_CreateHotkey(void); 1464 1465 /** 1466 * @brief Destroys a hot key object. 1467 * 1468 * @param hotkey Hot key object. 1469 * @syscap SystemCapability.MultimodalInput.Input.Core 1470 * @since 13 1471 */ 1472 void OH_Input_DestroyHotkey(Input_Hotkey **hotkey); 1473 1474 /** 1475 * @brief Sets a modifier key. 1476 * 1477 * @param hotkey Hotkey key object. 1478 * @param preKeys List of modifier keys. 1479 * @param size Number of modifier keys. One or two modifier keys are supported. 1480 * @syscap SystemCapability.MultimodalInput.Input.Core 1481 * @since 13 1482 */ 1483 void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size); 1484 1485 /** 1486 * @brief Obtains a modifier key. 1487 * 1488 * @param hotkey Hotkey key object. 1489 * @param preKeys List of modifier keys. 1490 * @param preKeyCount Number of modifier keys. 1491 * @return OH_Input_GetPreKeys status code, specifically, 1492 * {@link INPUT_SUCCESS} if the operation is successful;\n 1493 * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the pressedKeys is NULL or the pressedKeyCount 1494 * is NULL.\n 1495 * @syscap SystemCapability.MultimodalInput.Input.Core 1496 * @since 13 1497 */ 1498 Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount); 1499 1500 /** 1501 * @brief Sets a modified key. 1502 * 1503 * @param hotkey Hotkey key object. 1504 * @param finalKey Modified key. Only one modified key is supported. 1505 * @syscap SystemCapability.MultimodalInput.Input.Core 1506 * @since 13 1507 */ 1508 void OH_Input_SetFinalKey(Input_Hotkey *hotkey, int32_t finalKey); 1509 1510 /** 1511 * @brief Obtains a modified key. 1512 * 1513 * @param hotkey Hotkey key object. 1514 * @param finalKeyCode Returns the key value of the decorated key. 1515 * @return OH_Input_GetfinalKey status code, specifically, 1516 * {@link INPUT_SUCCESS} if the operation is successful;\n 1517 * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the finalKeyCode is NULL.\n 1518 * @syscap SystemCapability.MultimodalInput.Input.Core 1519 * @since 13 1520 */ 1521 Input_Result OH_Input_GetFinalKey(const Input_Hotkey *hotkey, int32_t *finalKeyCode); 1522 1523 /** 1524 * @brief Creates an array of {@Link Input_Hotkey} instances. 1525 * 1526 * @param count Number of {@Link Input_Hotkey} instances to be created. The count must be the same as the number of 1527 * system shortcut keys. 1528 * @return If the operation is successful, the pointer to an array of {@Link Input_Hotkey} instances is returned. 1529 * If the operation fails, a null pointer is returned. The possible cause is memory allocation failure or count is 1530 * not equal to the number of system hotkeys. 1531 * @syscap SystemCapability.MultimodalInput.Input.Core 1532 * @since 13 1533 */ 1534 Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count); 1535 1536 /** 1537 * @brief Destroys an array of {@link Input_Hotkey} instances and reclaims memory. 1538 * 1539 * @param hotkeys Pointer to an array of {@Link Input_Hotkey } instances created by the 1540 * {@Link OH_Input_CreateAllSystemHotkeys} method. 1541 * @param count Count of the array to be destroyed, which must be the same as the number of system shortcut keys. 1542 * @syscap SystemCapability.MultimodalInput.Input.Core 1543 * @since 13 1544 */ 1545 void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count); 1546 1547 /** 1548 * @brief Obtains all hot keys supported by the system. 1549 * 1550 * @param hotkey Array of {@Link Input_Hotkey} instances. 1551 * When calling this API for the first time, you can pass NULL to obtain the array length. 1552 * @param count Number of hot keys supported by the system. 1553 * @return OH_Input_GetAllSystemHotkeys status code, specifically, 1554 * {@link INPUT_SUCCESS} if the operation is successful;\n 1555 * {@link INPUT_PARAMETER_ERROR} The hotkey or count is NULL, or the value of count does not match the number 1556 * of system shortcut keys supported by the system. 1557 * @syscap SystemCapability.MultimodalInput.Input.Core 1558 * @since 13 1559 */ 1560 Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count); 1561 1562 /** 1563 * @brief 注册设备热插拔的监听器 1564 * 1565 * @param listener 指向设备热插拔监听器{@Link Input_DeviceListener}的指针. 1566 * 1567 * @return OH_Input_RegisterDeviceListener 的返回值, 具体如下: 1568 * {@link INPUT_SUCCESS} 调用成功;\n 1569 * {@link INPUT_PARAMETER_ERROR} listener 为NULL 1570 * @syscap SystemCapability.MultimodalInput.Input.Core 1571 * @since 13 1572 */ 1573 Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener); 1574 1575 /** 1576 * @brief 取消注册设备热插拔的监听 1577 * 1578 * @param listener 指向设备热插拔监听器{@Link Input_DeviceListener}的指针. 1579 * 1580 * @return OH_Input_UnregisterDeviceListener 的返回值, 具体如下: 1581 * {@link INPUT_SUCCESS} 调用成功;\n 1582 * {@link INPUT_PARAMETER_ERROR} listener 为 NULL 或者 listener 未被注册 1583 * {@link INPUT_SERVICE_EXCEPTION} 由于服务异常调用失败 1584 * @syscap SystemCapability.MultimodalInput.Input.Core 1585 * @since 13 1586 */ 1587 Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener); 1588 1589 /** 1590 * @brief 取消注册所有的设备热插拔的监听 1591 * 1592 * @return OH_Input_UnregisterDeviceListeners 的返回值, 具体如下: 1593 * {@link INPUT_SUCCESS} 调用成功;\n 1594 * {@link INPUT_SERVICE_EXCEPTION} 由于服务异常调用失败 1595 * @syscap SystemCapability.MultimodalInput.Input.Core 1596 * @since 13 1597 */ 1598 Input_Result OH_Input_UnregisterDeviceListeners(); 1599 1600 /** 1601 * @brief Specifies whether to report repeated key events. 1602 * 1603 * @param hotkey Shortcut key object. 1604 * @param isRepeat Whether to report repeated key events. 1605 * The value <b>true</b> means to report repeated key events, and the value <b>false</b> means the opposite. 1606 * @syscap SystemCapability.MultimodalInput.Input.Core 1607 * @since 13 1608 */ 1609 void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat); 1610 1611 /** 1612 * @brief Checks whether to report repeated key events. 1613 * 1614 * @param hotkey Shortcut key object. 1615 * @param isRepeat Whether a key event is repeated. 1616 * @return OH_Input_GetIsRepeat status code, specifically, 1617 * {@link INPUT_SUCCESS} if the operation is successful;\n 1618 * {@link INPUT_PARAMETER_ERROR} otherwise.\n 1619 * @syscap SystemCapability.MultimodalInput.Input.Core 1620 * @since 13 1621 */ 1622 Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat); 1623 1624 /** 1625 * @brief Subscribes to shortcut key events. 1626 * 1627 * @param hotkey Shortcut key object. 1628 * @param callback Callback used to return shortcut key events. 1629 * @return OH_Input_AddHotkeyMonitor status code, specifically, 1630 * {@link INPUT_SUCCESS} if the operation is successful;\n 1631 * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n 1632 * {@link INPUT_HOTKEY_ALREADY_REGISTER} Subscription has been enabled;\n 1633 * {@link INPUT_REPEAT_INTERCEPTOR} The shortcut key has been occupied. 1634 * You can use {@link getAllSystemHotkeys} to query all system shortcut keys.\n 1635 * @syscap SystemCapability.MultimodalInput.Input.Core 1636 * @since 13 1637 */ 1638 Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); 1639 1640 /** 1641 * @brief Unsubscribes from shortcut key events. 1642 * 1643 * @param hotkey Shortcut key object. 1644 * @param callback Callback used to return shortcut key events. 1645 * @return OH_Input_RemoveHotkeyMonitor status code, specifically, 1646 * {@link INPUT_SUCCESS} if the operation is successful;\n 1647 * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n 1648 * @syscap SystemCapability.MultimodalInput.Input.Core 1649 * @since 13 1650 */ 1651 Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); 1652 1653 /** 1654 * @brief 获取所有输入设备的id列表。 1655 * 1656 * @param deviceIds 用于保存输入设备id的数组。 1657 * @param inSize 用于保存输入设备id数组的大小。 1658 * @param outSize 出参,输出输入设备id列表的长度,该值不会大于inSize。 1659 * @return OH_Input_GetDeviceIds 的返回值如下, 1660 * {@link INPUT_SUCCESS} 操作成功。 1661 * {@link INPUT_PARAMETER_ERROR} deviceIds或outSize为空指针或inSize小于0。 1662 * @syscap SystemCapability.MultimodalInput.Input.Core 1663 * @since 13 1664 */ 1665 Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize); 1666 1667 /** 1668 * @brief 获取输入设备信息。 1669 * 1670 * @param deviceId 设备id。 1671 * @param deviceInfo 出参,指向输入设备信息{@Link Input_DeviceInfo}的指针。 1672 * @return OH_Input_GetDevice 的返回值如下, 1673 * {@link INPUT_SUCCESS} 操作成功。 1674 * {@link INPUT_PARAMETER_ERROR} 如果deviceInfo为空指针或deviceId无效。 1675 * 可以通过{@Link OH_Input_GetDeviceIds}接口查询系统支持的设备id。 1676 * @syscap SystemCapability.MultimodalInput.Input.Core 1677 * @since 13 1678 */ 1679 Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo); 1680 1681 /** 1682 * @brief 创建输入设备信息的对象。 1683 * 1684 * @return 如果操作成功,返回设备信息{@Link Input_DeviceInfo}实例的指针。否则返回空指针,可能的原因是分配内存失败。 1685 * @syscap SystemCapability.MultimodalInput.Input.Core 1686 * @since 13 1687 */ 1688 Input_DeviceInfo* OH_Input_CreateDeviceInfo(void); 1689 1690 /** 1691 * @brief 销毁输入设备信息的对象。 1692 * 1693 * @param deviceInfo 设备信息的对象。 1694 * @syscap SystemCapability.MultimodalInput.Input.Core 1695 * @since 13 1696 */ 1697 void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo); 1698 1699 /** 1700 * @brief 获取输入设备的键盘类型。 1701 * 1702 * @param deviceId 设备id。 1703 * @param keyboardType 出参,指向键盘输入设备类型的指针。 1704 * @return OH_Input_GetKeyboardType 的返回值如下, 1705 * {@link INPUT_SUCCESS} 操作成功。 1706 * {@link INPUT_PARAMETER_ERROR} 设备id为无效值或者keyboardType是空指针。 1707 * @syscap SystemCapability.MultimodalInput.Input.Core 1708 * @since 13 1709 */ 1710 Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType); 1711 1712 /** 1713 * @brief 获取输入设备的id。 1714 * 1715 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1716 * @param id 出参,指向输入设备id的指针。 1717 * @return OH_Input_GetDeviceId 的返回值如下, 1718 * {@link INPUT_SUCCESS} 操作成功。 1719 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者id是空指针。 1720 * @syscap SystemCapability.MultimodalInput.Input.Core 1721 * @since 13 1722 */ 1723 Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id); 1724 1725 /** 1726 * @brief 获取输入设备的名称。 1727 * 1728 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1729 * @param name 出参,指向输入设备名称的指针。 1730 * @return OH_Input_GetDeviceName 的返回值如下, 1731 * {@link INPUT_SUCCESS} 操作成功。 1732 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者name是空指针。 1733 * @syscap SystemCapability.MultimodalInput.Input.Core 1734 * @since 13 1735 */ 1736 Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name); 1737 1738 /** 1739 * @brief 获取有关输入设备能力信息,比如设备是触摸屏、触控板、键盘等,详情请参考示例代码。 1740 * 1741 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1742 * @param capabilities 出参,指向输入设备能力信息的指针。 1743 * @return OH_Input_GetCapabilities 的返回值如下, 1744 * {@link INPUT_SUCCESS} 操作成功。 1745 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者capabilities是空指针。 1746 * @syscap SystemCapability.MultimodalInput.Input.Core 1747 * @since 13 1748 */ 1749 Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities); 1750 1751 /** 1752 * @brief 获取输入设备的版本信息。 1753 * 1754 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1755 * @param version 出参,指向输入设备版本信息的指针。 1756 * @return OH_Input_GetDeviceVersion 的返回值如下, 1757 * {@link INPUT_SUCCESS} 操作成功。 1758 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者version是空指针。 1759 * @syscap SystemCapability.MultimodalInput.Input.Core 1760 * @since 13 1761 */ 1762 Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version); 1763 1764 /** 1765 * @brief 获取输入设备的产品信息。 1766 * 1767 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1768 * @param product 出参,指向输入设备产品信息的指针。 1769 * @return OH_Input_GetDeviceProduct 的返回值如下, 1770 * {@link INPUT_SUCCESS} 操作成功。 1771 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者product是空指针。 1772 * @syscap SystemCapability.MultimodalInput.Input.Core 1773 * @since 13 1774 */ 1775 Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product); 1776 1777 /** 1778 * @brief 获取输入设备的厂商信息。 1779 * 1780 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1781 * @param vendor 出参,指向输入设备厂商信息的指针。 1782 * @return OH_Input_GetDeviceVendor 的返回值如下, 1783 * {@link INPUT_SUCCESS} 操作成功。 1784 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者vendor是空指针。 1785 * @syscap SystemCapability.MultimodalInput.Input.Core 1786 * @since 13 1787 */ 1788 Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor); 1789 1790 /** 1791 * @brief 获取输入设备的物理地址。 1792 * 1793 * @param deviceInfo 输入设备信息{@Link Input_DeviceInfo}。 1794 * @param address 出参,指向输入设备物理地址的指针。 1795 * @return OH_Input_GetDeviceAddress 的返回值如下, 1796 * {@link INPUT_SUCCESS} 操作成功。 1797 * {@link INPUT_PARAMETER_ERROR} deviceInfo或者address是空指针。 1798 * @syscap SystemCapability.MultimodalInput.Input.Core 1799 * @since 13 1800 */ 1801 Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address); 1802 1803 /** 1804 * @brief Obtains the function key status. 1805 * 1806 * @param keyCode Function key value. Supported function keys include capsLock, NumLock, and ScrollLock. 1807 * @param state Function key status. The value 0 indicates that the function key is disabled, 1808 * and the value 1 indicates the opposite. 1809 * @return OH_Input_GetFunctionKeyState function api result code 1810 * {@link INPUT_SUCCESS} if the operation is successful; 1811 * {@link INPUT_PARAMETER_ERROR} if keyCode is invalid or state is a null pointer. 1812 * {@link INPUT_KEYBOARD_DEVICE_NOT_EXIST} no keyboard device connected. 1813 * @syscap SystemCapability.MultimodalInput.Input.Core 1814 * @since 15 1815 */ 1816 Input_Result OH_Input_GetFunctionKeyState(int32_t keyCode, int32_t *state); 1817 #ifdef __cplusplus 1818 } 1819 #endif 1820 /** @} */ 1821 1822 #endif /* OH_INPUT_MANAGER_H */ 1823