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