1 /* 2 * Copyright (c) 2024-2025 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 Enumerates keyboard types. 178 * 179 * @since 13 180 */ 181 typedef enum Input_KeyboardType { 182 /** Keyboard without keys */ 183 KEYBOARD_TYPE_NONE = 0, 184 /** Keyboard with unknown keys */ 185 KEYBOARD_TYPE_UNKNOWN = 1, 186 /** Full keyboard */ 187 KEYBOARD_TYPE_ALPHABETIC = 2, 188 /** Digital keyboard */ 189 KEYBOARD_TYPE_DIGITAL = 3, 190 /** Stylus */ 191 KEYBOARD_TYPE_STYLUS = 4, 192 /** Remote control */ 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 /** No product config of specific parameter */ 251 INPUT_NO_PRODUCT_CONFIG = 3800002, 252 /** Interceptor repeatedly created for an application */ 253 INPUT_REPEAT_INTERCEPTOR = 4200001, 254 /** 255 * @error Already occupied by the system 256 * @since 13 257 */ 258 INPUT_OCCUPIED_BY_SYSTEM = 4200002, 259 /** @error Already occupied by the other */ 260 INPUT_OCCUPIED_BY_OTHER = 4200003, 261 /** @error No keyboard device connected */ 262 INPUT_KEYBOARD_DEVICE_NOT_EXIST = 3900002, 263 /** 264 * @error Authorizing 265 * @since 20 266 */ 267 INPUT_INJECTION_AUTHORIZING = 3900005, 268 /** 269 * @error Too many operations 270 * @since 20 271 */ 272 INPUT_INJECTION_OPERATION_FREQUENT = 3900006, 273 /** 274 * @error Authorized 275 * @since 20 276 */ 277 INPUT_INJECTION_AUTHORIZED = 3900007, 278 /** 279 * @error Authorized to other applications 280 * @since 20 281 */ 282 INPUT_INJECTION_AUTHORIZED_OTHERS = 3900008, 283 /** 284 * @error App is not the focused app 285 * @since 20 286 */ 287 INPUT_APP_NOT_FOCUSED = 3900009, 288 /** 289 * @error The device has no pointer 290 * @since 20 291 */ 292 INPUT_DEVICE_NO_POINTER = 3900010 293 } Input_Result; 294 295 /** 296 * @brief Enumerates the injection authorization status. 297 * 298 * @since 20 299 */ 300 typedef enum Input_InjectionStatus { 301 /** Unauthorized */ 302 UNAUTHORIZED = 0, 303 /** Authorizing */ 304 AUTHORIZING = 1, 305 /** Authorized */ 306 AUTHORIZED = 2, 307 } Input_InjectionStatus; 308 309 /** 310 * @brief Defines the hot key structure. 311 * 312 * @since 13 313 */ 314 typedef struct Input_Hotkey Input_Hotkey; 315 316 /** 317 * @brief Defines a lifecycle callback for **keyEvent**. 318 * If the callback is triggered, **keyEvent** will be destroyed. 319 * @since 12 320 */ 321 typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); 322 323 /** 324 * @brief Defines a lifecycle callback for **mouseEvent**. 325 * If the callback is triggered, **mouseEvent** will be destroyed. 326 * @since 12 327 */ 328 typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); 329 330 /** 331 * @brief Defines a lifecycle callback for **touchEvent**. 332 * If the callback is triggered, **touchEvent** will be destroyed. 333 * @since 12 334 */ 335 typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); 336 337 /** 338 * @brief Defines a lifecycle callback for **axisEvent**. 339 * If the callback is triggered, **axisEvent** will be destroyed. 340 * @since 12 341 */ 342 typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); 343 344 typedef void (*Input_HotkeyCallback)(Input_Hotkey* hotkey); 345 346 /** 347 * @brief Defines the callback for device addition events. 348 * @param deviceId Device ID. 349 * @since 13 350 */ 351 typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); 352 353 /** 354 * @brief Defines the callback for device removal events. 355 * @param deviceId Device ID. 356 * @since 13 357 */ 358 typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); 359 360 /** 361 * @brief Defines the event injection callback. 362 * @param authorizedStatus Authorization status. 363 * @since 20 364 */ 365 typedef void (*Input_InjectAuthorizeCallback)(Input_InjectionStatus authorizedStatus); 366 367 /** 368 * @brief Defines the structure for the interceptor of event callbacks, 369 * including mouseCallback, touchCallback, and axisCallback. 370 * @since 12 371 */ 372 typedef struct Input_InterceptorEventCallback { 373 /** Defines a lifecycle callback for **mouseEvent**. */ 374 Input_MouseEventCallback mouseCallback; 375 /** Defines a lifecycle callback for **touchEvent**. */ 376 Input_TouchEventCallback touchCallback; 377 /** Defines a lifecycle callback for **axisEvent**. */ 378 Input_AxisEventCallback axisCallback; 379 } Input_InterceptorEventCallback; 380 381 /** 382 * @brief Defines a listener for device insertion and removal events. 383 * @since 13 384 */ 385 typedef struct Input_DeviceListener { 386 /** Callback for device addition events */ 387 Input_DeviceAddedCallback deviceAddedCallback; 388 /** Callback for device removal events */ 389 Input_DeviceRemovedCallback deviceRemovedCallback; 390 } Input_DeviceListener; 391 392 /** 393 * @brief Defines event interceptor options. 394 * @since 12 395 */ 396 typedef struct Input_InterceptorOptions Input_InterceptorOptions; 397 398 /** 399 * @brief Represents information about the input device. 400 * 401 * @since 13 402 */ 403 typedef struct Input_DeviceInfo Input_DeviceInfo; 404 405 /** 406 * @brief Queries the key state. 407 * 408 * @param keyState Key state. 409 * @HTTP4O4 Returns {@Link Input_Result#INPUT_SUCCESS} if the operation is successful; 410 * returns an error code defined in {@Link Input_Result} otherwise. 411 * @syscap SystemCapability.MultimodalInput.Input.Core 412 * @since 12 413 */ 414 Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState); 415 416 /** 417 * @brief Creates a key status enumeration object. 418 * 419 * @return Returns an {@link Input_KeyState} pointer object if the operation is successful. 420 * returns a null pointer otherwise. 421 * @syscap SystemCapability.MultimodalInput.Input.Core 422 * @since 12 423 */ 424 struct Input_KeyState* OH_Input_CreateKeyState(); 425 426 /** 427 * @brief Destroys a key status enumeration object. 428 * 429 * @param keyState Key status enumeration object. 430 * @syscap SystemCapability.MultimodalInput.Input.Core 431 * @since 12 432 */ 433 void OH_Input_DestroyKeyState(struct Input_KeyState** keyState); 434 435 /** 436 * @brief Sets the key value of a key status enumeration object. 437 * 438 * @param keyState Key status enumeration object. 439 * @param keyCode Key value of the key status enumeration object. 440 * @syscap SystemCapability.MultimodalInput.Input.Core 441 * @since 12 442 */ 443 void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode); 444 445 /** 446 * @brief Obtains the key value of a key status enumeration object. 447 * 448 * @param keyState Key status enumeration object. 449 * @return Key value of the key status enumeration object. 450 * @syscap SystemCapability.MultimodalInput.Input.Core 451 * @since 12 452 */ 453 int32_t OH_Input_GetKeyCode(const struct Input_KeyState* keyState); 454 455 /** 456 * @brief Sets whether the key specific to a key status enumeration object is pressed. 457 * 458 * @param keyState Key status enumeration object. 459 * @param keyAction Whether the key is pressed. 460 * @syscap SystemCapability.MultimodalInput.Input.Core 461 * @since 12 462 */ 463 void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction); 464 465 /** 466 * @brief Checks whether the key specific to a key status enumeration object is pressed. 467 * 468 * @param keyState Key status enumeration object. 469 * @return Key pressing status of the key status enumeration object. 470 * @syscap SystemCapability.MultimodalInput.Input.Core 471 * @since 12 472 */ 473 int32_t OH_Input_GetKeyPressed(const struct Input_KeyState* keyState); 474 475 /** 476 * @brief Sets the key switch of the key status enumeration object. 477 * 478 * @param keyState Key status enumeration object. 479 * @param keySwitch Key switch of the key status enumeration object. 480 * @syscap SystemCapability.MultimodalInput.Input.Core 481 * @since 12 482 */ 483 void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); 484 485 /** 486 * @brief Obtains the key switch of the key status enumeration object. 487 * 488 * @param keyState Key status enumeration object. 489 * @return Key switch of the key status enumeration object. 490 * @syscap SystemCapability.MultimodalInput.Input.Core 491 * @since 12 492 */ 493 int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); 494 495 /** 496 * @brief Inject system keys. 497 * 498 * @param keyEvent - the key event to be injected. 499 * @return 0 - Success. 500 * 201 - Missing permissions. 501 * 401 - Parameter error. 502 * @syscap SystemCapability.MultimodalInput.Input.Core 503 * @since 12 504 */ 505 int32_t OH_Input_InjectKeyEvent(const struct Input_KeyEvent* keyEvent); 506 507 /** 508 * @brief Creates a key event object. 509 * 510 * @return Returns an {@link Input_KeyEvent} pointer object if the operation is successful. 511 * returns a null pointer otherwise. 512 * @syscap SystemCapability.MultimodalInput.Input.Core 513 * @since 12 514 */ 515 struct Input_KeyEvent* OH_Input_CreateKeyEvent(); 516 517 /** 518 * @brief Destroys a key event object. 519 * 520 * @param keyEvent Key event object. 521 * @syscap SystemCapability.MultimodalInput.Input.Core 522 * @since 12 523 */ 524 void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent); 525 526 /** 527 * @brief Sets the key event type. 528 * 529 * @param keyEvent Key event object. 530 * @param action Key event type. 531 * @syscap SystemCapability.MultimodalInput.Input.Core 532 * @since 12 533 */ 534 void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action); 535 536 /** 537 * @brief Obtains the key event type. 538 * 539 * @param keyEvent Key event object. 540 * @return Key event type. 541 * @syscap SystemCapability.MultimodalInput.Input.Core 542 * @since 12 543 */ 544 int32_t OH_Input_GetKeyEventAction(const struct Input_KeyEvent* keyEvent); 545 546 /** 547 * @brief Sets the key value for a key event. 548 * 549 * @param keyEvent Key event object. 550 * @param keyCode keyCode Key code. 551 * @syscap SystemCapability.MultimodalInput.Input.Core 552 * @since 12 553 */ 554 void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode); 555 556 /** 557 * @brief Obtains the key value of a key event. 558 * 559 * @param keyEvent Key event object. 560 * @return Key code. 561 * @syscap SystemCapability.MultimodalInput.Input.Core 562 * @since 12 563 */ 564 int32_t OH_Input_GetKeyEventKeyCode(const struct Input_KeyEvent* keyEvent); 565 566 /** 567 * @brief Sets the time when a key event occurs. 568 * 569 * @param keyEvent Key event object. 570 * @param actionTime Time when the key event occurs. 571 * @syscap SystemCapability.MultimodalInput.Input.Core 572 * @since 12 573 */ 574 void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime); 575 576 /** 577 * @brief Obtains the time when a key event occurs. 578 * 579 * @param keyEvent Key event object. 580 * @return Returns the time when the key event occurs. 581 * @syscap SystemCapability.MultimodalInput.Input.Core 582 * @since 12 583 */ 584 int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); 585 586 /** 587 * @brief Sets the windowId for a key event. 588 * 589 * @param keyEvent Key event object. 590 * @param windowId The windowId for a key event. 591 * @syscap SystemCapability.MultimodalInput.Input.Core 592 * @since 15 593 */ 594 void OH_Input_SetKeyEventWindowId(struct Input_KeyEvent* keyEvent, int32_t windowId); 595 596 /** 597 * @brief Obtains the windowId of a key event. 598 * 599 * @param keyEvent Key event object. 600 * @return windowId. 601 * @syscap SystemCapability.MultimodalInput.Input.Core 602 * @since 15 603 */ 604 int32_t OH_Input_GetKeyEventWindowId(const struct Input_KeyEvent* keyEvent); 605 606 /** 607 * @brief Sets the displayId for a key event. 608 * 609 * @param keyEvent Key event object. 610 * @param displayId The displayId for a key event. 611 * @syscap SystemCapability.MultimodalInput.Input.Core 612 * @since 15 613 */ 614 void OH_Input_SetKeyEventDisplayId(struct Input_KeyEvent* keyEvent, int32_t displayId); 615 616 /** 617 * @brief Obtains the displayId of a key event. 618 * 619 * @param keyEvent Key event object. 620 * @return displayId. 621 * @syscap SystemCapability.MultimodalInput.Input.Core 622 * @since 15 623 */ 624 int32_t OH_Input_GetKeyEventDisplayId(const struct Input_KeyEvent* keyEvent); 625 626 /** 627 * @brief Inject mouse event. 628 * 629 * @param mouseEvent - the mouse event to be injected. 630 * @return 0 - Success. 631 * 201 - Missing permissions. 632 * 401 - Parameter error. 633 * @syscap SystemCapability.MultimodalInput.Input.Core 634 * @since 12 635 */ 636 int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent); 637 638 /** 639 * @brief Inject mouse event using global coordinate. 640 * 641 * @param mouseEvent - the mouse event to be injected, set up effective globalX globalY. 642 * @return OH_Input_InjectMouseEventGlobal function result code. 643 * {@link INPUT_SUCCESS} inject mouseEvent success.\n 644 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 645 * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n 646 * @since 20 647 */ 648 int32_t OH_Input_InjectMouseEventGlobal(const struct Input_MouseEvent* mouseEvent); 649 650 /** 651 * @brief Creates a mouse event object. 652 * 653 * @return Returns an {@link Input_MouseEvent} pointer object if the operation is successful. 654 * returns a null pointer otherwise. 655 * @syscap SystemCapability.MultimodalInput.Input.Core 656 * @since 12 657 */ 658 struct Input_MouseEvent* OH_Input_CreateMouseEvent(); 659 660 /** 661 * @brief Destroys a mouse event object. 662 * 663 * @param mouseEvent Mouse event object. 664 * @syscap SystemCapability.MultimodalInput.Input.Core 665 * @since 12 666 */ 667 void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent); 668 669 /** 670 * @brief Sets the action for a mouse event. 671 * 672 * @param mouseEvent Mouse event object. 673 * @param action Mouse action. 674 * @syscap SystemCapability.MultimodalInput.Input.Core 675 * @since 12 676 */ 677 void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action); 678 679 /** 680 * @brief Obtains the action of a mouse event. 681 * 682 * @param mouseEvent Mouse event object. 683 * @return Mouse action. 684 * @syscap SystemCapability.MultimodalInput.Input.Core 685 * @since 12 686 */ 687 int32_t OH_Input_GetMouseEventAction(const struct Input_MouseEvent* mouseEvent); 688 689 /** 690 * @brief Sets the X coordinate for a mouse event. 691 * 692 * @param mouseEvent Mouse event object. 693 * @param displayX X coordinate on the display. 694 * @syscap SystemCapability.MultimodalInput.Input.Core 695 * @since 12 696 */ 697 void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX); 698 699 /** 700 * @brief Obtains the X coordinate of a mouse event. 701 * 702 * @param mouseEvent Mouse event object. 703 * @return X coordinate on the display. 704 * @syscap SystemCapability.MultimodalInput.Input.Core 705 * @since 12 706 */ 707 int32_t OH_Input_GetMouseEventDisplayX(const struct Input_MouseEvent* mouseEvent); 708 709 /** 710 * @brief Sets the Y coordinate for a mouse event. 711 * 712 * @param mouseEvent Mouse event object. 713 * @param displayY Y coordinate on the display. 714 * @syscap SystemCapability.MultimodalInput.Input.Core 715 * @since 12 716 */ 717 void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY); 718 719 /** 720 * @brief Obtains the Y coordinate of a mouse event. 721 * 722 * @param mouseEvent Mouse event object. 723 * @return Y coordinate on the display. 724 * @syscap SystemCapability.MultimodalInput.Input.Core 725 * @since 12 726 */ 727 int32_t OH_Input_GetMouseEventDisplayY(const struct Input_MouseEvent* mouseEvent); 728 729 /** 730 * @brief Sets the button for a mouse event. 731 * 732 * @param mouseEvent Mouse event object. 733 * @param button Mouse button. 734 * @syscap SystemCapability.MultimodalInput.Input.Core 735 * @since 12 736 */ 737 void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button); 738 739 /** 740 * @brief Obtains the button of a mouse event. 741 * 742 * @param mouseEvent Mouse event object. 743 * @return Mouse button. 744 * @syscap SystemCapability.MultimodalInput.Input.Core 745 * @since 12 746 */ 747 int32_t OH_Input_GetMouseEventButton(const struct Input_MouseEvent* mouseEvent); 748 749 /** 750 * @brief Sets the axis type for mouse event. 751 * 752 * @param mouseEvent Mouse event object. 753 * @param axisType Axis type, for example, X axis or Y axis. 754 * @syscap SystemCapability.MultimodalInput.Input.Core 755 * @since 12 756 */ 757 void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType); 758 759 /** 760 * @brief Obtains the axis type of a mouse event. 761 * 762 * @param mouseEvent Mouse event object. 763 * @return Axis type. 764 * @syscap SystemCapability.MultimodalInput.Input.Core 765 * @since 12 766 */ 767 int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent); 768 769 /** 770 * @brief Sets the axis value for a mouse axis event. 771 * 772 * @param mouseEvent Mouse event object. 773 * @param axisValue Axis value. A positive value means scrolling forward, 774 * and a negative number means scrolling backward. 775 * @syscap SystemCapability.MultimodalInput.Input.Core 776 * @since 12 777 */ 778 void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue); 779 780 /** 781 * @brief Obtains the axis value of a mouse event. 782 * 783 * @param mouseEvent Mouse event object. 784 * @return Axis value. 785 * @syscap SystemCapability.MultimodalInput.Input.Core 786 * @since 12 787 */ 788 float OH_Input_GetMouseEventAxisValue(const struct Input_MouseEvent* mouseEvent); 789 790 /** 791 * @brief Sets the time when a mouse event occurs. 792 * 793 * @param mouseEvent Mouse event object. 794 * @param actionTime Time when the mouse event occurs. 795 * @syscap SystemCapability.MultimodalInput.Input.Core 796 * @since 12 797 */ 798 void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime); 799 800 /** 801 * @brief Obtains the time when a mouse event occurs. 802 * 803 * @param mouseEvent Mouse event object. 804 * @return Returns the time when the mouse event occurs. 805 * @syscap SystemCapability.MultimodalInput.Input.Core 806 * @since 12 807 */ 808 int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEvent); 809 810 /** 811 * @brief Sets the windowId for a mouse event. 812 * 813 * @param mouseEvent Mouse event object. 814 * @param windowId The windowId for a mouse event. 815 * @syscap SystemCapability.MultimodalInput.Input.Core 816 * @since 15 817 */ 818 void OH_Input_SetMouseEventWindowId(struct Input_MouseEvent* mouseEvent, int32_t windowId); 819 820 /** 821 * @brief Obtains the windowId of a mouse event. 822 * 823 * @param mouseEvent Mouse event object. 824 * @return windowId. 825 * @syscap SystemCapability.MultimodalInput.Input.Core 826 * @since 15 827 */ 828 int32_t OH_Input_GetMouseEventWindowId(const struct Input_MouseEvent* mouseEvent); 829 830 /** 831 * @brief Sets the displayId for a mouse event. 832 * 833 * @param mouseEvent Mouse event object. 834 * @param displayId The displayId for a mouse event. 835 * @syscap SystemCapability.MultimodalInput.Input.Core 836 * @since 15 837 */ 838 void OH_Input_SetMouseEventDisplayId(struct Input_MouseEvent* mouseEvent, int32_t displayId); 839 840 /** 841 * @brief Obtains the displayId of a mouse event. 842 * 843 * @param mouseEvent Mouse event object. 844 * @return displayId. 845 * @syscap SystemCapability.MultimodalInput.Input.Core 846 * @since 15 847 */ 848 int32_t OH_Input_GetMouseEventDisplayId(const struct Input_MouseEvent* mouseEvent); 849 850 /** 851 * @brief Set the global X coordinate of the mouse event. 852 * 853 * @param mouseEvent Mouse event object. 854 * @param globalX Global X coordinate. 855 * @syscap SystemCapability.MultimodalInput.Input.Core 856 * @since 20 857 */ 858 void OH_Input_SetMouseEventGlobalX(struct Input_MouseEvent* mouseEvent, int32_t globalX); 859 860 /** 861 * @brief Queries the global X coordinate of the mouse event. 862 * 863 * @param mouseEvent Mouse event object. 864 * @return Global X coordinate. 865 * @syscap SystemCapability.MultimodalInput.Input.Core 866 * @since 20 867 */ 868 int32_t OH_Input_GetMouseEventGlobalX(const struct Input_MouseEvent* mouseEvent); 869 870 /** 871 * @brief Set the global Y coordinate of the mouse event. 872 * 873 * @param mouseEvent Mouse event object. 874 * @param globalY Global Y coordinate. 875 * @syscap SystemCapability.MultimodalInput.Input.Core 876 * @since 20 877 */ 878 void OH_Input_SetMouseEventGlobalY(struct Input_MouseEvent* mouseEvent, int32_t globalY); 879 880 /** 881 * @brief Queries the global Y coordinate of the mouse event. 882 * 883 * @param mouseEvent Mouse event object. 884 * @return Global Y coordinate. 885 * @syscap SystemCapability.MultimodalInput.Input.Core 886 * @since 20 887 */ 888 int32_t OH_Input_GetMouseEventGlobalY(const struct Input_MouseEvent* mouseEvent); 889 890 /** 891 * @brief Inject touch event. 892 * 893 * @param touchEvent - the touch event to be injected. 894 * @return 0 - Success. 895 * 201 - Missing permissions. 896 * 401 - Parameter error. 897 * @syscap SystemCapability.MultimodalInput.Input.Core 898 * @since 12 899 */ 900 int32_t OH_Input_InjectTouchEvent(const struct Input_TouchEvent* touchEvent); 901 902 /** 903 * @brief Inject touch event using global coordinate. 904 * 905 * @param touchEvent - the touch event to be injected, set up effective globalX globalY. 906 * @return OH_Input_InjectTouchEventGlobal function result code. 907 * {@link INPUT_SUCCESS} inject touchEvent success.\n 908 * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n 909 * @since 20 910 */ 911 int32_t OH_Input_InjectTouchEventGlobal(const struct Input_TouchEvent* touchEvent); 912 913 /** 914 * @brief Creates a touch event object. 915 * 916 * @return Returns an {@link Input_TouchEvent} pointer object if the operation is successful. 917 * returns a null pointer otherwise. 918 * @syscap SystemCapability.MultimodalInput.Input.Core 919 * @since 12 920 */ 921 struct Input_TouchEvent* OH_Input_CreateTouchEvent(); 922 923 /** 924 * @brief Destroys a touch event object. 925 * 926 * @param touchEvent Touch event object. 927 * @syscap SystemCapability.MultimodalInput.Input.Core 928 * @since 12 929 */ 930 void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent); 931 932 /** 933 * @brief Sets the action for a touch event. 934 * 935 * @param touchEvent Touch event object. 936 * @param action Touch action. 937 * @syscap SystemCapability.MultimodalInput.Input.Core 938 * @since 12 939 */ 940 void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action); 941 942 /** 943 * @brief Obtains the action of a touch event. 944 * 945 * @param touchEvent Touch event object. 946 * @return Touch action. 947 * @syscap SystemCapability.MultimodalInput.Input.Core 948 * @since 12 949 */ 950 int32_t OH_Input_GetTouchEventAction(const struct Input_TouchEvent* touchEvent); 951 952 /** 953 * @brief Sets the finger ID for the touch event. 954 * 955 * @param touchEvent Touch event object. 956 * @param id Finger ID. 957 * @syscap SystemCapability.MultimodalInput.Input.Core 958 * @since 12 959 */ 960 void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id); 961 962 /** 963 * @brief Obtains the finger ID of a touch event. 964 * 965 * @param touchEvent Touch event object. 966 * @return Finger ID. 967 * @syscap SystemCapability.MultimodalInput.Input.Core 968 * @since 12 969 */ 970 int32_t OH_Input_GetTouchEventFingerId(const struct Input_TouchEvent* touchEvent); 971 972 /** 973 * @brief Sets the X coordinate for a touch event. 974 * 975 * @param touchEvent Touch event object. 976 * @param displayX X coordinate. 977 * @syscap SystemCapability.MultimodalInput.Input.Core 978 * @since 12 979 */ 980 void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX); 981 982 /** 983 * @brief Obtains the X coordinate of a touch event. 984 * 985 * @param touchEvent Touch event object. 986 * @return X coordinate. 987 * @syscap SystemCapability.MultimodalInput.Input.Core 988 * @since 12 989 */ 990 int32_t OH_Input_GetTouchEventDisplayX(const struct Input_TouchEvent* touchEvent); 991 992 /** 993 * @brief Sets the Y coordinate for a touch event. 994 * 995 * @param touchEvent Touch event object. 996 * @param displayY Y coordinate. 997 * @syscap SystemCapability.MultimodalInput.Input.Core 998 * @since 12 999 */ 1000 void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY); 1001 1002 /** 1003 * @brief Obtains the Y coordinate of a touch event. 1004 * 1005 * @param touchEvent Touch event object. 1006 * @return Y coordinate. 1007 * @syscap SystemCapability.MultimodalInput.Input.Core 1008 * @since 12 1009 */ 1010 int32_t OH_Input_GetTouchEventDisplayY(const struct Input_TouchEvent* touchEvent); 1011 1012 /** 1013 * @brief Sets the time when a touch event occurs. 1014 * 1015 * @param touchEvent Touch event object. 1016 * @param actionTime Time when the touch event occurs. 1017 * @syscap SystemCapability.MultimodalInput.Input.Core 1018 * @since 12 1019 */ 1020 void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime); 1021 1022 /** 1023 * @brief Obtains the time when a touch event occurs. 1024 * 1025 * @param touchEvent touch event object. 1026 * @return Returns the time when the touch event occurs. 1027 * @syscap SystemCapability.MultimodalInput.Input.Core 1028 * @since 12 1029 */ 1030 int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEvent); 1031 1032 /** 1033 * @brief Sets the windowId for a touch event. 1034 * 1035 * @param touchEvent Touch event object. 1036 * @param windowId The windowId for a touch event. 1037 * @syscap SystemCapability.MultimodalInput.Input.Core 1038 * @since 15 1039 */ 1040 void OH_Input_SetTouchEventWindowId(struct Input_TouchEvent* touchEvent, int32_t windowId); 1041 1042 /** 1043 * @brief Obtains the windowId of a touch event. 1044 * 1045 * @param touchEvent Touch event object. 1046 * @return windowId. 1047 * @syscap SystemCapability.MultimodalInput.Input.Core 1048 * @since 15 1049 */ 1050 int32_t OH_Input_GetTouchEventWindowId(const struct Input_TouchEvent* touchEvent); 1051 1052 /** 1053 * @brief Sets the displayId for a touch event. 1054 * 1055 * @param touchEvent Touch event object. 1056 * @param displayId The displayId for a touch event. 1057 * @syscap SystemCapability.MultimodalInput.Input.Core 1058 * @since 15 1059 */ 1060 void OH_Input_SetTouchEventDisplayId(struct Input_TouchEvent* touchEvent, int32_t displayId); 1061 1062 /** 1063 * @brief Obtains the displayId of a touch event. 1064 * 1065 * @param touchEvent Touch event object. 1066 * @return displayId. 1067 * @syscap SystemCapability.MultimodalInput.Input.Core 1068 * @since 15 1069 */ 1070 int32_t OH_Input_GetTouchEventDisplayId(const struct Input_TouchEvent* touchEvent); 1071 1072 /** 1073 * @brief Set the global X coordinate of the touch event. 1074 * 1075 * @param touchEvent Touch event object. 1076 * @param globalX Global X coordinate. 1077 * @syscap SystemCapability.MultimodalInput.Input.Core 1078 * @since 20 1079 */ 1080 void OH_Input_SetTouchEventGlobalX(struct Input_TouchEvent* touchEvent, int32_t globalX); 1081 1082 /** 1083 * @brief Queries the global X coordinate of the touch event. 1084 * 1085 * @param touchEvent Touch event object. 1086 * @return Global X coordinate. 1087 * @syscap SystemCapability.MultimodalInput.Input.Core 1088 * @since 20 1089 */ 1090 int32_t OH_Input_GetTouchEventGlobalX(const struct Input_TouchEvent* touchEvent); 1091 1092 /** 1093 * @brief Set the global Y coordinate of the touch event. 1094 * 1095 * @param touchEvent Touch event object. 1096 * @param globalY Global Y coordinate. 1097 * @syscap SystemCapability.MultimodalInput.Input.Core 1098 * @since 20 1099 */ 1100 void OH_Input_SetTouchEventGlobalY(struct Input_TouchEvent* touchEvent, int32_t globalY); 1101 1102 /** 1103 * @brief Queries the global Y coordinate of the touch event. 1104 * 1105 * @param touchEvent Touch event object. 1106 * @return Global Y coordinate. 1107 * @syscap SystemCapability.MultimodalInput.Input.Core 1108 * @since 20 1109 */ 1110 int32_t OH_Input_GetTouchEventGlobalY(const struct Input_TouchEvent* touchEvent); 1111 1112 /** 1113 * @brief Cancels event injection and revokes authorization. 1114 * 1115 * @syscap SystemCapability.MultimodalInput.Input.Core 1116 * @since 12 1117 */ 1118 void OH_Input_CancelInjection(); 1119 1120 /** 1121 * @brief Creates an axis event object. 1122 * 1123 * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. 1124 * If the operation fails, null is returned. 1125 * @syscap SystemCapability.MultimodalInput.Input.Core 1126 * @since 12 1127 */ 1128 Input_AxisEvent* OH_Input_CreateAxisEvent(void); 1129 1130 /** 1131 * @brief Destroys an axis event object. 1132 * 1133 * @param axisEvent Pointer to the axis event object. 1134 * @return OH_Input_DestroyAxisEvent function result code. 1135 * {@link INPUT_SUCCESS} Destroys axisEvent success.\n 1136 * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n 1137 * @syscap SystemCapability.MultimodalInput.Input.Core 1138 * @since 12 1139 */ 1140 Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); 1141 1142 /** 1143 * @brief Sets the axis event action. 1144 * 1145 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1146 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 1147 * @return OH_Input_SetAxisEventAction function result code. 1148 * {@link INPUT_SUCCESS} Sets the axis event action success.\n 1149 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1150 * @syscap SystemCapability.MultimodalInput.Input.Core 1151 * @since 12 1152 */ 1153 Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); 1154 1155 /** 1156 * @brief Obtains the axis event action. 1157 * 1158 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1159 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 1160 * @return OH_Input_GetAxisEventAction function result code. 1161 * {@link INPUT_SUCCESS} Obtains the axis event action success.\n 1162 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n 1163 * @syscap SystemCapability.MultimodalInput.Input.Core 1164 * @since 12 1165 */ 1166 Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); 1167 1168 /** 1169 * @brief Sets the X coordinate of an axis event. 1170 * 1171 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1172 * @param displayX X coordinate of the axis event. 1173 * @return OH_Input_SetAxisEventDisplayX function result code. 1174 * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n 1175 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1176 * @syscap SystemCapability.MultimodalInput.Input.Core 1177 * @since 12 1178 */ 1179 Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); 1180 1181 /** 1182 * @brief Obtains the X coordinate of an axis event. 1183 * 1184 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1185 * @param displayX X coordinate of the axis event. 1186 * @return OH_Input_GetAxisEventDisplayX function result code. 1187 * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n 1188 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n 1189 * @syscap SystemCapability.MultimodalInput.Input.Core 1190 * @since 12 1191 */ 1192 Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); 1193 1194 /** 1195 * @brief Sets the Y coordinate of an axis event. 1196 * 1197 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1198 * @param displayY Y coordinate of the axis event. 1199 * @return OH_Input_SetAxisEventDisplayY function result code. 1200 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1201 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1202 * @syscap SystemCapability.MultimodalInput.Input.Core 1203 * @since 12 1204 */ 1205 Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); 1206 1207 /** 1208 * @brief Obtains the Y coordinate of an axis event. 1209 * 1210 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1211 * @param displayY Y coordinate of the axis event. 1212 * @return OH_Input_GetAxisEventDisplayY function result code. 1213 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1214 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1215 * @syscap SystemCapability.MultimodalInput.Input.Core 1216 * @since 12 1217 */ 1218 Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); 1219 1220 /** 1221 * @brief Sets the axis value of the axis type specified by the axis event. 1222 * 1223 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1224 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 1225 * @param axisValue Axis value. 1226 * @return OH_Input_SetAxisEventAxisValue function result code. 1227 * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n 1228 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1229 * @syscap SystemCapability.MultimodalInput.Input.Core 1230 * @since 12 1231 */ 1232 Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, 1233 InputEvent_AxisType axisType, double axisValue); 1234 1235 /** 1236 * @brief Obtains the axis value for the specified axis type of the axis event. 1237 * 1238 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1239 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 1240 * @param axisValue Axis value. 1241 * @return OH_Input_GetAxisEventAxisValue function result code. 1242 * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n 1243 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, 1244 * or the axisType not found in the axisEvent.\n 1245 * @syscap SystemCapability.MultimodalInput.Input.Core 1246 * @since 12 1247 */ 1248 Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, 1249 InputEvent_AxisType axisType, double* axisValue); 1250 1251 /** 1252 * @brief Sets the time when an axis event occurs. 1253 * 1254 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1255 * @param actionTime Time when an axis event occurs. 1256 * @return OH_Input_SetAxisEventActionTime function result code. 1257 * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n 1258 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1259 * @syscap SystemCapability.MultimodalInput.Input.Core 1260 * @since 12 1261 */ 1262 Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); 1263 1264 /** 1265 * @brief Obtains the time when an axis event occurs. 1266 * 1267 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1268 * @param actionTime Time when an axis event occurs. 1269 * @return OH_Input_GetAxisEventActionTime function result code. 1270 * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n 1271 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n 1272 * @syscap SystemCapability.MultimodalInput.Input.Core 1273 * @since 12 1274 */ 1275 Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); 1276 1277 /** 1278 * @brief Sets the axis event type. 1279 * 1280 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1281 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 1282 * @return OH_Input_SetAxisEventType function result code. 1283 * {@link INPUT_SUCCESS} Sets the axis event type success.\n 1284 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1285 * @syscap SystemCapability.MultimodalInput.Input.Core 1286 * @since 12 1287 */ 1288 Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); 1289 1290 /** 1291 * @brief Obtains the axis event type. 1292 * 1293 * @param axisEvent Axis event object. 1294 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 1295 * @return OH_Input_GetAxisEventType function result code. 1296 * {@link INPUT_SUCCESS} Obtains the axis event type success.\n 1297 * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n 1298 * @syscap SystemCapability.MultimodalInput.Input.Core 1299 * @since 12 1300 */ 1301 Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); 1302 1303 /** 1304 * @brief Sets the axis event source type. 1305 * 1306 * @param axisEvent Axis event object. 1307 * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1308 * @return OH_Input_SetAxisEventSourceType function result code. 1309 * {@link INPUT_SUCCESS} Sets the axis event source type success.\n 1310 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1311 * @syscap SystemCapability.MultimodalInput.Input.Core 1312 * @since 12 1313 */ 1314 Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); 1315 1316 /** 1317 * @brief Obtains the axis event source type. 1318 * 1319 * @param axisEvent Axis event object. 1320 * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1321 * @return OH_Input_GetAxisEventSourceType function result code. 1322 * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n 1323 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n 1324 * @syscap SystemCapability.MultimodalInput.Input.Core 1325 * @since 12 1326 */ 1327 Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); 1328 1329 /** 1330 * @brief Sets the windowId of an axis event. 1331 * 1332 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1333 * @param windowId The windowId for the axis event. 1334 * @return OH_Input_SetAxisEventDisplayY function result code. 1335 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1336 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1337 * @syscap SystemCapability.MultimodalInput.Input.Core 1338 * @since 15 1339 */ 1340 Input_Result OH_Input_SetAxisEventWindowId(Input_AxisEvent* axisEvent, int32_t windowId); 1341 1342 /** 1343 * @brief Obtains the windowId of an axis event. 1344 * 1345 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1346 * @param windowId The windowId for the axis event. 1347 * @return OH_Input_GetAxisEventDisplayY function result code. 1348 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1349 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1350 * @syscap SystemCapability.MultimodalInput.Input.Core 1351 * @since 15 1352 */ 1353 Input_Result OH_Input_GetAxisEventWindowId(const Input_AxisEvent* axisEvent, int32_t* windowId); 1354 1355 /** 1356 * @brief Sets the displayId of an axis event. 1357 * 1358 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1359 * @param displayId The displayId for the axis event. 1360 * @return OH_Input_SetAxisEventDisplayY function result code. 1361 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 1362 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1363 * @syscap SystemCapability.MultimodalInput.Input.Core 1364 * @since 15 1365 */ 1366 Input_Result OH_Input_SetAxisEventDisplayId(Input_AxisEvent* axisEvent, int32_t displayId); 1367 1368 /** 1369 * @brief Obtains the displayId of an axis event. 1370 * 1371 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1372 * @param displayId The displayId for the axis event. 1373 * @return OH_Input_GetAxisEventDisplayY function result code. 1374 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 1375 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 1376 * @syscap SystemCapability.MultimodalInput.Input.Core 1377 * @since 15 1378 */ 1379 Input_Result OH_Input_GetAxisEventDisplayId(const Input_AxisEvent* axisEvent, int32_t* displayId); 1380 1381 /** 1382 * @brief Set the global X coordinate of the axis event. 1383 * 1384 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1385 * @param globalX Global X coordinate. 1386 * @return OH_Input_SetAxisEventGlobalX function result code. 1387 * {@link INPUT_SUCCESS} Success.\n 1388 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1389 * @syscap SystemCapability.MultimodalInput.Input.Core 1390 * @since 20 1391 */ 1392 Input_Result OH_Input_SetAxisEventGlobalX(struct Input_AxisEvent* axisEvent, int32_t globalX); 1393 1394 /** 1395 * @brief Queries the global X coordinate of the axis event. 1396 * 1397 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1398 * @param globalX Global X coordinate. 1399 * @return OH_Input_GetAxisEventGlobalX function result code. 1400 * {@link INPUT_SUCCESS} Success.\n 1401 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the globalX is NULL.\n 1402 * @syscap SystemCapability.MultimodalInput.Input.Core 1403 * @since 20 1404 */ 1405 Input_Result OH_Input_GetAxisEventGlobalX(const Input_AxisEvent* axisEvent, int32_t* globalX); 1406 1407 /** 1408 * @brief Set the global Y coordinate of the axis event. 1409 * 1410 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1411 * @param globalY Global Y coordinate. 1412 * @return OH_Input_SetAxisEventGlobalY function result code. 1413 * {@link INPUT_SUCCESS} Success.\n 1414 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1415 * @syscap SystemCapability.MultimodalInput.Input.Core 1416 * @since 20 1417 */ 1418 Input_Result OH_Input_SetAxisEventGlobalY(struct Input_AxisEvent* axisEvent, int32_t globalY); 1419 1420 /** 1421 * @brief Queries the global Y coordinate of the axis event. 1422 * 1423 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 1424 * @param globalY Global Y coordinate. 1425 * @return OH_Input_GetAxisEventGlobalY function result code. 1426 * {@link INPUT_SUCCESS} Success.\n 1427 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the globalY is NULL.\n 1428 * @syscap SystemCapability.MultimodalInput.Input.Core 1429 * @since 20 1430 */ 1431 Input_Result OH_Input_GetAxisEventGlobalY(const Input_AxisEvent* axisEvent, int32_t* globalY); 1432 1433 /** 1434 * @brief Adds a listener of key events. 1435 * 1436 * @permission ohos.permission.INPUT_MONITORING 1437 * @param callback - Callback used to receive key events. 1438 * @return OH_Input_AddKeyEventMonitor function result code. 1439 * {@link INPUT_SUCCESS} Adds a listener of key events success.\n 1440 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1441 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1442 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1443 * @syscap SystemCapability.MultimodalInput.Input.Core 1444 * @since 12 1445 */ 1446 Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); 1447 1448 /** 1449 * @brief Adds a listener for mouse events, including mouse click and movement events, 1450 * but not scroll wheel events. Scroll wheel events are axis events. 1451 * 1452 * @permission ohos.permission.INPUT_MONITORING 1453 * @param callback - Callback used to receive mouse events. 1454 * @return OH_Input_AddMouseEventMonitor function result code. 1455 * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n 1456 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1457 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1458 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1459 * @syscap SystemCapability.MultimodalInput.Input.Core 1460 * @since 12 1461 */ 1462 Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); 1463 1464 /** 1465 * @brief Add a listener for touch events. 1466 * 1467 * @permission ohos.permission.INPUT_MONITORING 1468 * @param callback - Callback used to receive touch events. 1469 * @return OH_Input_AddTouchEventMonitor function result code. 1470 * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n 1471 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1472 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1473 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1474 * @syscap SystemCapability.MultimodalInput.Input.Core 1475 * @since 12 1476 */ 1477 Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); 1478 1479 /** 1480 * @brief Adds a listener for all types of axis events. 1481 * The axis event types are defined in {@Link InputEvent_AxisEventType}. 1482 * 1483 * @permission ohos.permission.INPUT_MONITORING 1484 * @param callback - Callback used to receive axis events. 1485 * @return OH_Input_AddAxisEventMonitorForAll function result code. 1486 * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n 1487 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1488 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1489 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1490 * @syscap SystemCapability.MultimodalInput.Input.Core 1491 * @since 12 1492 */ 1493 Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); 1494 1495 /** 1496 * @brief Adds a listener for the specified type of axis events. 1497 * 1498 * @permission ohos.permission.INPUT_MONITORING 1499 * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. 1500 * @param callback - Callback used to receive the specified type of axis events. 1501 * @return OH_Input_AddAxisEventMonitor function result code. 1502 * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n 1503 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1504 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1505 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1506 * @syscap SystemCapability.MultimodalInput.Input.Core 1507 * @since 12 1508 */ 1509 Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1510 1511 /** 1512 * @brief Removes a key event listener. 1513 * 1514 * @permission ohos.permission.INPUT_MONITORING 1515 * @param callback - Callback for the key event listener. 1516 * @return OH_Input_RemoveKeyEventMonitor function result code. 1517 * {@link INPUT_SUCCESS} Removes a key event listener success.\n 1518 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1519 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1520 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1521 * @syscap SystemCapability.MultimodalInput.Input.Core 1522 * @since 12 1523 */ 1524 Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); 1525 1526 /** 1527 * @brief Removes a mouse event listener. 1528 * 1529 * @permission ohos.permission.INPUT_MONITORING 1530 * @param callback - Callback for the mouse event listener. 1531 * @return OH_Input_RemoveMouseEventMonitor function result code. 1532 * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n 1533 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1534 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1535 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1536 * @syscap SystemCapability.MultimodalInput.Input.Core 1537 * @since 12 1538 */ 1539 Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); 1540 1541 /** 1542 * @brief Removes a touch event listener. 1543 * 1544 * @permission ohos.permission.INPUT_MONITORING 1545 * @param callback - Callback for the touch event listener. 1546 * @return OH_Input_RemoveTouchEventMonitor function result code. 1547 * {@link INPUT_SUCCESS} Removes a touch event listener success.\n 1548 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1549 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1550 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1551 * @syscap SystemCapability.MultimodalInput.Input.Core 1552 * @since 12 1553 */ 1554 Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); 1555 1556 /** 1557 * @brief Removes the listener for all types of axis events. 1558 * 1559 * @permission ohos.permission.INPUT_MONITORING 1560 * @param callback - Callback for the listener used to listen for all types of axis events. 1561 * @return OH_Input_RemoveAxisEventMonitorForAll function result code. 1562 * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n 1563 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1564 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1565 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1566 * @syscap SystemCapability.MultimodalInput.Input.Core 1567 * @since 12 1568 */ 1569 Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); 1570 1571 /** 1572 * @brief Removes the listener for the specified type of axis events. 1573 * 1574 * @permission ohos.permission.INPUT_MONITORING 1575 * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. 1576 * @param callback - Callback for the listener used to listen for the specified type of axis events. 1577 * @return OH_Input_RemoveAxisEventMonitor function result code. 1578 * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n 1579 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1580 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1581 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1582 * @syscap SystemCapability.MultimodalInput.Input.Core 1583 * @since 12 1584 */ 1585 Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1586 1587 /** 1588 * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. 1589 * 1590 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1591 * @param callback - Callback used to receive key events. 1592 * @param option - Options for event interception. If **null** is passed, the default value is used. 1593 * @return OH_Input_AddKeyEventInterceptor function result code. 1594 * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n 1595 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1596 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1597 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1598 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1599 * @syscap SystemCapability.MultimodalInput.Input.Core 1600 * @since 12 1601 */ 1602 Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); 1603 1604 /** 1605 * @brief Adds an interceptor for input events, including mouse, touch, and axis events. 1606 * If multiple interceptors are added, only the first one takes effect. 1607 * 1608 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1609 * @param callback - Pointer to the structure of the callback for the input event interceptor. 1610 * For details, see {@Link Input_InterceptorEventCallback}. 1611 * @param option - Options for event interception. If **null** is passed, the default value is used. 1612 * @return OH_Input_AddInputEventInterceptor function result code. 1613 * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n 1614 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1615 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1616 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1617 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1618 * @syscap SystemCapability.MultimodalInput.Input.Core 1619 * @since 12 1620 */ 1621 Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, 1622 Input_InterceptorOptions *option); 1623 1624 /** 1625 * @brief Removes a key event interceptor. 1626 * 1627 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1628 * @return OH_Input_RemoveKeyEventInterceptor function result code. 1629 * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n 1630 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1631 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1632 * @syscap SystemCapability.MultimodalInput.Input.Core 1633 * @since 12 1634 */ 1635 Input_Result OH_Input_RemoveKeyEventInterceptor(void); 1636 1637 /** 1638 * @brief Removes an interceptor for input events, including mouse, touch, and axis events. 1639 * 1640 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1641 * @return OH_Input_RemoveInputEventInterceptor function result code. 1642 * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n 1643 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1644 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1645 * @syscap SystemCapability.MultimodalInput.Input.Core 1646 * @since 12 1647 */ 1648 Input_Result OH_Input_RemoveInputEventInterceptor(void); 1649 1650 /** 1651 * @brief Obtains the interval since the last system input event. 1652 * 1653 * @param timeInterval Interval, in microseconds. 1654 * @return OH_Input_GetIntervalSinceLastInput status code, specifically, 1655 * {@Link INPUT_SUCCESS} if the Operation is successful; 1656 * {@Link INPUT_SERVICE_EXCEPTION} otherwise. 1657 * @syscap SystemCapability.MultimodalInput.Input.Core 1658 * @since 13 1659 */ 1660 int32_t OH_Input_GetIntervalSinceLastInput(int64_t *timeInterval); 1661 1662 /** 1663 * @brief Creates a hot key object. 1664 * 1665 * @return Returns an {@Link Input_Hotkey} pointer object if the operation is successful. Otherwise, a null pointer is 1666 * returned. The possible cause is memory allocation failure. 1667 * @syscap SystemCapability.MultimodalInput.Input.Core 1668 * @since 13 1669 */ 1670 Input_Hotkey *OH_Input_CreateHotkey(void); 1671 1672 /** 1673 * @brief Destroys a hot key object. 1674 * 1675 * @param hotkey Hot key object. 1676 * @syscap SystemCapability.MultimodalInput.Input.Core 1677 * @since 13 1678 */ 1679 void OH_Input_DestroyHotkey(Input_Hotkey **hotkey); 1680 1681 /** 1682 * @brief Sets a modifier key. 1683 * 1684 * @param hotkey Hotkey key object. 1685 * @param preKeys List of modifier keys. 1686 * @param size Number of modifier keys. One or two modifier keys are supported. 1687 * @syscap SystemCapability.MultimodalInput.Input.Core 1688 * @since 13 1689 */ 1690 void OH_Input_SetPreKeys(Input_Hotkey *hotkey, int32_t *preKeys, int32_t size); 1691 1692 /** 1693 * @brief Obtains a modifier key. 1694 * 1695 * @param hotkey Hotkey key object. 1696 * @param preKeys List of modifier keys. 1697 * @param preKeyCount Number of modifier keys. 1698 * @return OH_Input_GetPreKeys status code, specifically, 1699 * {@link INPUT_SUCCESS} if the operation is successful;\n 1700 * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the pressedKeys is NULL or the pressedKeyCount 1701 * is NULL.\n 1702 * @syscap SystemCapability.MultimodalInput.Input.Core 1703 * @since 13 1704 */ 1705 Input_Result OH_Input_GetPreKeys(const Input_Hotkey *hotkey, int32_t **preKeys, int32_t *preKeyCount); 1706 1707 /** 1708 * @brief Sets a modified key. 1709 * 1710 * @param hotkey Hotkey key object. 1711 * @param finalKey Modified key. Only one modified key is supported. 1712 * @syscap SystemCapability.MultimodalInput.Input.Core 1713 * @since 13 1714 */ 1715 void OH_Input_SetFinalKey(Input_Hotkey *hotkey, int32_t finalKey); 1716 1717 /** 1718 * @brief Obtains a modified key. 1719 * 1720 * @param hotkey Hotkey key object. 1721 * @param finalKeyCode Returns the key value of the decorated key. 1722 * @return OH_Input_GetfinalKey status code, specifically, 1723 * {@link INPUT_SUCCESS} if the operation is successful;\n 1724 * {@link INPUT_PARAMETER_ERROR} The hotkey is NULL or the finalKeyCode is NULL.\n 1725 * @syscap SystemCapability.MultimodalInput.Input.Core 1726 * @since 13 1727 */ 1728 Input_Result OH_Input_GetFinalKey(const Input_Hotkey *hotkey, int32_t *finalKeyCode); 1729 1730 /** 1731 * @brief Creates an array of {@Link Input_Hotkey} instances. 1732 * 1733 * @param count Number of {@Link Input_Hotkey} instances to be created. The count must be the same as the number of 1734 * system shortcut keys. 1735 * @return If the operation is successful, the pointer to an array of {@Link Input_Hotkey} instances is returned. 1736 * If the operation fails, a null pointer is returned. The possible cause is memory allocation failure or count is 1737 * not equal to the number of system hotkeys. 1738 * @syscap SystemCapability.MultimodalInput.Input.Core 1739 * @since 13 1740 */ 1741 Input_Hotkey **OH_Input_CreateAllSystemHotkeys(int32_t count); 1742 1743 /** 1744 * @brief Destroys an array of {@link Input_Hotkey} instances and reclaims memory. 1745 * 1746 * @param hotkeys Pointer to an array of {@Link Input_Hotkey } instances created by the 1747 * {@Link OH_Input_CreateAllSystemHotkeys} method. 1748 * @param count Count of the array to be destroyed, which must be the same as the number of system shortcut keys. 1749 * @syscap SystemCapability.MultimodalInput.Input.Core 1750 * @since 13 1751 */ 1752 void OH_Input_DestroyAllSystemHotkeys(Input_Hotkey **hotkeys, int32_t count); 1753 1754 /** 1755 * @brief Obtains all hot keys supported by the system. 1756 * 1757 * @param hotkey Array of {@Link Input_Hotkey} instances. 1758 * When calling this API for the first time, you can pass NULL to obtain the array length. 1759 * @param count Number of hot keys supported by the system. 1760 * @return OH_Input_GetAllSystemHotkeys status code, specifically, 1761 * {@link INPUT_SUCCESS} if the operation is successful;\n 1762 * {@link INPUT_PARAMETER_ERROR} The hotkey or count is NULL, or the value of count does not match the number 1763 * of system shortcut keys supported by the system. 1764 * @syscap SystemCapability.MultimodalInput.Input.Core 1765 * @since 13 1766 */ 1767 Input_Result OH_Input_GetAllSystemHotkeys(Input_Hotkey **hotkey, int32_t *count); 1768 1769 /** 1770 * @brief Specifies whether to report repeated key events. 1771 * 1772 * @param hotkey Shortcut key object. 1773 * @param isRepeat Whether to report repeated key events. 1774 * The value <b>true</b> means to report repeated key events, and the value <b>false</b> means the opposite. 1775 * @syscap SystemCapability.MultimodalInput.Input.Core 1776 * @since 13 1777 */ 1778 void OH_Input_SetRepeat(Input_Hotkey* hotkey, bool isRepeat); 1779 1780 /** 1781 * @brief Checks whether to report repeated key events. 1782 * 1783 * @param hotkey Shortcut key object. 1784 * @param isRepeat Whether a key event is repeated. 1785 * @return OH_Input_GetRepeat status code, specifically, 1786 * {@link INPUT_SUCCESS} if the operation is successful;\n 1787 * {@link INPUT_PARAMETER_ERROR} otherwise.\n 1788 * @syscap SystemCapability.MultimodalInput.Input.Core 1789 * @since 13 1790 */ 1791 Input_Result OH_Input_GetRepeat(const Input_Hotkey* hotkey, bool *isRepeat); 1792 1793 /** 1794 * @brief Subscribes to shortcut key events. 1795 * 1796 * @param hotkey Shortcut key object. 1797 * @param callback Callback used to return shortcut key events. 1798 * @return OH_Input_AddHotkeyMonitor status code, specifically, 1799 * {@link INPUT_SUCCESS} if the operation is successful;\n 1800 * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n 1801 * {@link INPUT_HOTKEY_ALREADY_REGISTER} Subscription has been enabled;\n 1802 * {@link INPUT_REPEAT_INTERCEPTOR} The shortcut key has been occupied. 1803 * You can use {@link getAllSystemHotkeys} to query all system shortcut keys.\n 1804 * @syscap SystemCapability.MultimodalInput.Input.Core 1805 * @since 13 1806 */ 1807 Input_Result OH_Input_AddHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); 1808 1809 /** 1810 * @brief Unsubscribes from shortcut key events. 1811 * 1812 * @param hotkey Shortcut key object. 1813 * @param callback Callback used to return shortcut key events. 1814 * @return OH_Input_RemoveHotkeyMonitor status code, specifically, 1815 * {@link INPUT_SUCCESS} if the operation is successful;\n 1816 * {@link INPUT_PARAMETER_ERROR} if hotkey or callback is NULL;\n 1817 * @syscap SystemCapability.MultimodalInput.Input.Core 1818 * @since 13 1819 */ 1820 Input_Result OH_Input_RemoveHotkeyMonitor(const Input_Hotkey* hotkey, Input_HotkeyCallback callback); 1821 1822 /** 1823 * @brief Obtains the IDs of all input devices. 1824 * 1825 * @param deviceIds Array of input device IDs. 1826 * @param inSize Size of the array of input device IDs. 1827 * @param outSize Length of the list of input device IDs. The value cannot be greater than the value of inSize. 1828 * @return OH_Input_GetDeviceIds result code, specifically, 1829 * {@link INPUT_SUCCESS} if the operation is successful; 1830 * {@link INPUT_PARAMETER_ERROR} if deviceIds or outSize is a null pointer or inSize is less than 0. 1831 * @syscap SystemCapability.MultimodalInput.Input.Core 1832 * @since 13 1833 */ 1834 Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize); 1835 1836 /** 1837 * @brief Obtains the information about an input device. 1838 * 1839 * @param deviceId Device ID. 1840 * @param deviceInfo Pointer to an {@Link Input_DeviceInfo} object. 1841 * @return OH_Input_GetDevice result code, specifically, 1842 * {@link INPUT_SUCCESS} if the operation is successful; 1843 * {@link INPUT_PARAMETER_ERROR} if the deviceInfo is a null pointer or the deviceId is invalid. 1844 * You can use the {@Link OH_Input_GetDeviceIds} interface to query the device IDs supported by the system. 1845 * @syscap SystemCapability.MultimodalInput.Input.Core 1846 * @since 13 1847 */ 1848 Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo); 1849 1850 /** 1851 * @brief Creates a deviceInfo object. 1852 * 1853 * @return Pointer to an {@Link Input_DeviceInfo} object if the operation is successful; 1854 * a null pointer otherwise (possibly because of a memory allocation failure). 1855 * @syscap SystemCapability.MultimodalInput.Input.Core 1856 * @since 13 1857 */ 1858 Input_DeviceInfo* OH_Input_CreateDeviceInfo(void); 1859 1860 /** 1861 * @brief Destroys a deviceInfo object. 1862 * 1863 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1864 * @syscap SystemCapability.MultimodalInput.Input.Core 1865 * @since 13 1866 */ 1867 void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo); 1868 1869 /** 1870 * @brief Obtains the keyboard type of an input device. 1871 * 1872 * @param deviceId Device ID. 1873 * @param keyboardType Pointer to the keyboard type of the input device. 1874 * @return OH_Input_GetKeyboardType result code, specifically, 1875 * {@link INPUT_SUCCESS} if the operation is successful; 1876 * {@link INPUT_PARAMETER_ERROR} if the device ID is invalid or keyboardType is a null pointer. 1877 * @syscap SystemCapability.MultimodalInput.Input.Core 1878 * @since 13 1879 */ 1880 Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType); 1881 1882 /** 1883 * @brief Obtains the ID of an input device. 1884 * 1885 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1886 * @param id Pointer to the ID of the input device. 1887 * @return OH_Input_GetDeviceId result code, specifically, 1888 * {@link INPUT_SUCCESS} if the operation is successful; 1889 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or id is a null pointer. 1890 * @syscap SystemCapability.MultimodalInput.Input.Core 1891 * @since 13 1892 */ 1893 Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id); 1894 1895 /** 1896 * @brief Obtains the name of an input device. 1897 * 1898 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1899 * @param name Pointer to the name of the input device. 1900 * @return OH_Input_GetDeviceName result code, specifically, 1901 * {@link INPUT_SUCCESS} if the operation is successful; 1902 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or name is a null pointer. 1903 * @syscap SystemCapability.MultimodalInput.Input.Core 1904 * @since 13 1905 */ 1906 Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name); 1907 1908 /** 1909 * @brief Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard. 1910 * 1911 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1912 * @param capabilities Pointer to the capabilities of the input device. 1913 * @return OH_Input_GetCapabilities result code, specifically, 1914 * {@link INPUT_SUCCESS} if the operation is successful; 1915 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or capabilities is a null pointer. 1916 * @syscap SystemCapability.MultimodalInput.Input.Core 1917 * @since 13 1918 */ 1919 Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities); 1920 1921 /** 1922 * @brief Obtains the version information of an input device. 1923 * 1924 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1925 * @param version Pointer to the version information of the input device. 1926 * @return OH_Input_GetDeviceVersion result code, specifically, 1927 * {@link INPUT_SUCCESS} if the operation is successful; 1928 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or version is a null pointer. 1929 * @syscap SystemCapability.MultimodalInput.Input.Core 1930 * @since 13 1931 */ 1932 Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version); 1933 1934 /** 1935 * @brief Obtains the product information of an input device. 1936 * 1937 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1938 * @param product Pointer to the product information of the input device. 1939 * @return OH_Input_GetDeviceProduct result code, specifically, 1940 * {@link INPUT_SUCCESS} if the operation is successful; 1941 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or product is a null pointer. 1942 * @syscap SystemCapability.MultimodalInput.Input.Core 1943 * @since 13 1944 */ 1945 Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product); 1946 1947 /** 1948 * @brief Obtains the vendor information of an input device. 1949 * 1950 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1951 * @param vendor Pointer to the vendor information of the input device. 1952 * @return OH_Input_GetDeviceVendor result code, specifically, 1953 * {@link INPUT_SUCCESS} if the operation is successful; 1954 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or vendor is a null pointer. 1955 * @syscap SystemCapability.MultimodalInput.Input.Core 1956 * @since 13 1957 */ 1958 Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor); 1959 1960 /** 1961 * @brief Obtains the physical address of an input device. 1962 * 1963 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1964 * @param address Pointer to the physical address of the input device. 1965 * @return OH_Input_GetDeviceAddress result code, specifically, 1966 * {@link INPUT_SUCCESS} if the operation is successful; 1967 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or address is a null pointer. 1968 * @syscap SystemCapability.MultimodalInput.Input.Core 1969 * @since 13 1970 */ 1971 Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address); 1972 1973 /** 1974 * @brief Registers a listener for device hot swap events. 1975 * 1976 * @param listener Pointer to an {@Link Input_DeviceListener} object. 1977 * 1978 * @return OH_Input_RegisterDeviceListener status code, specifically, 1979 * {@link INPUT_SUCCESS} if the operation is successful;\n 1980 * {@link INPUT_PARAMETER_ERROR} if listener is NULL; 1981 * @syscap SystemCapability.MultimodalInput.Input.Core 1982 * @since 13 1983 */ 1984 Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener); 1985 1986 /** 1987 * @brief Unregisters the listener for device hot swap events. 1988 * 1989 * @param listener Pointer to the listener for device hot swap events. For details, see {@Link Input_DeviceListener}. 1990 * 1991 * @return OH_Input_UnregisterDeviceListener status code, specifically, 1992 * {@link INPUT_SUCCESS} if the operation is successful;\n 1993 * {@link INPUT_PARAMETER_ERROR} if listener is NULL or no listener is registered; 1994 * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. 1995 * @syscap SystemCapability.MultimodalInput.Input.Core 1996 * @since 13 1997 */ 1998 Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener); 1999 2000 /** 2001 * @brief Unregisters the listener for all device hot swap events. 2002 * 2003 * @return OH_Input_UnregisterDeviceListener status code, specifically, 2004 * {@link INPUT_SUCCESS} if the operation is successful;\n 2005 * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. 2006 * @syscap SystemCapability.MultimodalInput.Input.Core 2007 * @since 13 2008 */ 2009 Input_Result OH_Input_UnregisterDeviceListeners(); 2010 2011 /** 2012 * @brief Obtains the function key status. 2013 * 2014 * @param keyCode Function key value. Supported function keys include capsLock, NumLock, and ScrollLock. 2015 * @param state Function key status. The value 0 indicates that the function key is disabled, 2016 * and the value 1 indicates the opposite. 2017 * @return OH_Input_GetFunctionKeyState function api result code 2018 * {@link INPUT_SUCCESS} if the operation is successful; 2019 * {@link INPUT_PARAMETER_ERROR} if keyCode is invalid or state is a null pointer. 2020 * {@link INPUT_KEYBOARD_DEVICE_NOT_EXIST} no keyboard device connected. 2021 * @syscap SystemCapability.MultimodalInput.Input.Core 2022 * @since 15 2023 */ 2024 Input_Result OH_Input_GetFunctionKeyState(int32_t keyCode, int32_t *state); 2025 2026 /** 2027 * @brief Queries the maximum number of touch points supported by the current device. 2028 * If -1 is returned, the number is unknown. 2029 * @param count Maximum number of touch points supported. 2030 * @return one of result code: 2031 * {@link INPUT_SUCCESS} if the operation is successful. 2032 * {@link INPUT_PARAMETER_ERROR} if count is a null pointer. 2033 * @syscap SystemCapability.MultimodalInput.Input.Core 2034 * @since 20 2035 */ 2036 Input_Result OH_Input_QueryMaxTouchPoints(int32_t *count); 2037 2038 /** 2039 * @brief Requests for injection authorization. 2040 * 2041 * @param callback - callback used to return the result. 2042 * @return OH_Input_RequestInjection function result code. 2043 * {@link INPUT_SUCCESS} Success.\n 2044 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 2045 * {@link INPUT_DEVICE_NOT_SUPPORTED} Capability not supported.\n 2046 * {@link INPUT_SERVICE_EXCEPTION} Service error.\n 2047 * {@link INPUT_INJECTION_AUTHORIZING} Authorizing.\n 2048 * {@link INPUT_INJECTION_OPERATION_FREQUENT} Too many operations.\n 2049 * {@link INPUT_INJECTION_AUTHORIZED} Authorized.\n 2050 * {@link INPUT_INJECTION_AUTHORIZED_OTHERS} Authorized to other applications.\n 2051 * @syscap SystemCapability.MultimodalInput.Input.Core 2052 * @since 20 2053 */ 2054 Input_Result OH_Input_RequestInjection(Input_InjectAuthorizeCallback callback); 2055 2056 /** 2057 * @brief Queries the injection authorization status. 2058 * 2059 * @param status Injection authorization status. For details, see {@Link Input_InjectionStatus}. 2060 * @return OH_Input_QueryAuthorizedStatus function result code. 2061 * {@link INPUT_SUCCESS} Success.\n 2062 * {@link INPUT_PARAMETER_ERROR} The status is NULL\n 2063 * {@link INPUT_SERVICE_EXCEPTION} Service error.\n 2064 * @syscap SystemCapability.MultimodalInput.Input.Core 2065 * @since 20 2066 */ 2067 Input_Result OH_Input_QueryAuthorizedStatus(Input_InjectionStatus* status); 2068 2069 /** 2070 * @brief Get pointer location. 2071 * 2072 * @param displayId The displayId for the pointer location. 2073 * @param displayX The displayX for the pointer location. 2074 * @param displayY The displayY for the pointer location. 2075 * @return OH_Input_GetPointerLocation function api result code 2076 * {@link INPUT_SUCCESS} if the operation is successful; 2077 * {@link INPUT_PARAMETER_ERROR} if parameter is a null pointer; 2078 * {@link INPUT_APP_NOT_FOCUSED} if the app is not the focused app; 2079 * {@link INPUT_DEVICE_NO_POINTER} if the device has no pointer; 2080 * {@link INPUT_SERVICE_EXCEPTION} if the service is exception. 2081 * @since 20 2082 */ 2083 Input_Result OH_Input_GetPointerLocation(int32_t *displayId, double *displayX, double *displayY); 2084 #ifdef __cplusplus 2085 } 2086 #endif 2087 /** @} */ 2088 2089 #endif /* OH_INPUT_MANAGER_H */ 2090