1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OH_INPUT_MANAGER_H 17 #define OH_INPUT_MANAGER_H 18 19 /** 20 * @addtogroup input 21 * @{ 22 * 23 * @brief Provides the C interface in the multi-modal input domain. 24 * 25 * @since 12 26 */ 27 28 /** 29 * @file oh_input_manager.h 30 * 31 * @brief Provides capabilities such as event injection and key status query. 32 * @kit InputKit 33 * @syscap SystemCapability.MultimodalInput.Input.Core 34 * @library liboh_input.so 35 * @since 12 36 */ 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 event source types. 171 * 172 * @since 12 173 */ 174 typedef enum InputEvent_SourceType { 175 /** 176 * Indicates that the input source generates events similar to mouse cursor movement, 177 * button press and release, and wheel scrolling. 178 * 179 * @since 12 180 */ 181 SOURCE_TYPE_MOUSE = 1, 182 /** 183 * Indicates that the input source generates a touchscreen multi-touch event. 184 * 185 * @since 12 186 */ 187 SOURCE_TYPE_TOUCHSCREEN = 2, 188 /** 189 * Indicates that the input source generates a touchpad multi-touch event. 190 * 191 * @since 12 192 */ 193 SOURCE_TYPE_TOUCHPAD = 3 194 } InputEvent_SourceType; 195 196 /** 197 * @brief Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type. 198 * 199 * @since 12 200 */ 201 typedef struct Input_KeyState Input_KeyState; 202 203 /** 204 * @brief The key event to be injected. 205 * 206 * @since 12 207 */ 208 typedef struct Input_KeyEvent Input_KeyEvent; 209 210 /** 211 * @brief The mouse event to be injected. 212 * 213 * @since 12 214 */ 215 typedef struct Input_MouseEvent Input_MouseEvent; 216 217 /** 218 * @brief The touch event to be injected. 219 * 220 * @since 12 221 */ 222 typedef struct Input_TouchEvent Input_TouchEvent; 223 224 /** 225 * @brief Enumerates axis events. 226 * 227 * @since 12 228 */ 229 typedef struct Input_AxisEvent Input_AxisEvent; 230 231 /** 232 * @brief Enumerates error codes. 233 * 234 * @since 12 235 */ 236 typedef enum Input_Result { 237 /** @error Success return code on success*/ 238 INPUT_SUCCESS = 0, 239 /** @error Permission verification failed */ 240 INPUT_PERMISSION_DENIED = 201, 241 /** @error Non-system application */ 242 INPUT_NOT_SYSTEM_APPLICATION = 202, 243 /** @error Parameter check failed */ 244 INPUT_PARAMETER_ERROR = 401, 245 /** @error Service error */ 246 INPUT_SERVICE_EXCEPTION = 3800001, 247 /** @error Interceptor repeatedly created for an application */ 248 INPUT_REPEAT_INTERCEPTOR = 4200001 249 } Input_Result; 250 251 /** 252 * @brief Represents information about the input device. 253 * 254 * @since 13 255 */ 256 typedef struct Input_DeviceInfo Input_DeviceInfo; 257 258 /** 259 * @brief Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. 260 * 261 * @param keyEvent Key event object. 262 * @since 12 263 */ 264 typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); 265 266 /** 267 * @brief Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. 268 * 269 * @param mouseEvent Mouse event object. 270 * @since 12 271 */ 272 typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); 273 274 /** 275 * @brief Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. 276 * 277 * @param touchEvent Touch event object. 278 * @since 12 279 */ 280 typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); 281 282 /** 283 * @brief Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. 284 * 285 * @param axisEvent Axis event object. 286 * @since 12 287 */ 288 typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); 289 290 /** 291 * @brief Defines the callback for device addition events. 292 * @param deviceId Device ID. 293 * @since 13 294 */ 295 typedef void (*Input_DeviceAddedCallback)(int32_t deviceId); 296 297 /** 298 * @brief Defines the callback for device removal events. 299 * @param deviceId Device ID. 300 * @since 13 301 */ 302 typedef void (*Input_DeviceRemovedCallback)(int32_t deviceId); 303 304 /** 305 * @brief Defines the structure for the interceptor of event callbacks, 306 * including mouseCallback, touchCallback, and axisCallback. 307 * @since 12 308 */ 309 typedef struct Input_InterceptorEventCallback { 310 /** Defines a lifecycle callback for **mouseEvent**. */ 311 Input_MouseEventCallback mouseCallback; 312 /** Defines a lifecycle callback for **touchEvent**. */ 313 Input_TouchEventCallback touchCallback; 314 /** Defines a lifecycle callback for **axisEvent**. */ 315 Input_AxisEventCallback axisCallback; 316 } Input_InterceptorEventCallback; 317 318 /** 319 * @brief Defines a listener for device insertion and removal events. 320 * @since 13 321 */ 322 typedef struct Input_DeviceListener { 323 /** Callback for device addition events */ 324 Input_DeviceAddedCallback deviceAddedCallback; 325 /** Callback for device removal events */ 326 Input_DeviceRemovedCallback deviceRemovedCallback; 327 } Input_DeviceListener; 328 329 /** 330 * @brief Defines event interceptor options. 331 * @since 12 332 */ 333 typedef struct Input_InterceptorOptions Input_InterceptorOptions; 334 335 /** 336 * @brief Queries the key state. 337 * 338 * @param keyState Key state. 339 * @return OH_Input_GetKeyState function result code. 340 * {@link INPUT_SUCCESS} get KeyState success.\n 341 * {@link INPUT_PARAMETER_ERROR} keyCode is invalid.\n 342 * @syscap SystemCapability.MultimodalInput.Input.Core 343 * @since 12 344 */ 345 Input_Result OH_Input_GetKeyState(struct Input_KeyState* keyState); 346 347 /** 348 * @brief Creates a key status enumeration object. 349 * 350 * @return Returns an {@Input_KeyState} pointer object if the operation is successful. 351 * Otherwise, a null pointer is returned. The possible cause is memory allocation failure. 352 * @syscap SystemCapability.MultimodalInput.Input.Core 353 * @since 12 354 */ 355 struct Input_KeyState* OH_Input_CreateKeyState(); 356 357 /** 358 * @brief Destroys a key status enumeration object. 359 * 360 * @param keyState Key status enumeration object. 361 * @syscap SystemCapability.MultimodalInput.Input.Core 362 * @since 12 363 */ 364 void OH_Input_DestroyKeyState(struct Input_KeyState** keyState); 365 366 /** 367 * @brief Sets the key value of a key status enumeration object. 368 * 369 * @param keyState Key status enumeration object. 370 * @param keyCode Key value of the key status enumeration object. 371 * @syscap SystemCapability.MultimodalInput.Input.Core 372 * @since 12 373 */ 374 void OH_Input_SetKeyCode(struct Input_KeyState* keyState, int32_t keyCode); 375 376 /** 377 * @brief Obtains the key value of a key status enumeration object. 378 * 379 * @param keyState Key status enumeration object. 380 * @return Key value of the key status enumeration object. 381 * @syscap SystemCapability.MultimodalInput.Input.Core 382 * @since 12 383 */ 384 int32_t OH_Input_GetKeyCode(const struct Input_KeyState* keyState); 385 386 /** 387 * @brief Sets whether the key specific to a key status enumeration object is pressed. 388 * 389 * @param keyState Key status enumeration object. 390 * @param keyAction Whether the key is pressed. 391 * @syscap SystemCapability.MultimodalInput.Input.Core 392 * @since 12 393 */ 394 void OH_Input_SetKeyPressed(struct Input_KeyState* keyState, int32_t keyAction); 395 396 /** 397 * @brief Checks whether the key specific to a key status enumeration object is pressed. 398 * 399 * @param keyState Key status enumeration object. 400 * @return Key pressing status of the key status enumeration object. 401 * @syscap SystemCapability.MultimodalInput.Input.Core 402 * @since 12 403 */ 404 int32_t OH_Input_GetKeyPressed(const struct Input_KeyState* keyState); 405 406 /** 407 * @brief Sets the key switch of the key status enumeration object. 408 * 409 * @param keyState Key status enumeration object. 410 * @param keySwitch Key switch of the key status enumeration object. 411 * @syscap SystemCapability.MultimodalInput.Input.Core 412 * @since 12 413 */ 414 void OH_Input_SetKeySwitch(struct Input_KeyState* keyState, int32_t keySwitch); 415 416 /** 417 * @brief Obtains the key switch of the key status enumeration object. 418 * 419 * @param keyState Key status enumeration object. 420 * @return Key switch of the key status enumeration object. 421 * @syscap SystemCapability.MultimodalInput.Input.Core 422 * @since 12 423 */ 424 int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); 425 426 /** 427 * @brief Inject system keys. 428 * 429 * @param keyEvent - the key event to be injected. 430 * @return OH_Input_InjectKeyEvent function result code. 431 * {@link INPUT_SUCCESS} inject keyEvent success.\n 432 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 433 * {@link INPUT_PARAMETER_ERROR} keyCode is less 0, can not process.\n 434 * @syscap SystemCapability.MultimodalInput.Input.Core 435 * @since 12 436 */ 437 int32_t OH_Input_InjectKeyEvent(const struct Input_KeyEvent* keyEvent); 438 439 /** 440 * @brief Creates a key event object. 441 * 442 * @return Returns an {@link Input_KeyEvent} pointer object if the operation is successful. 443 * Otherwise, a null pointer is returned. The possible cause is memory allocation failure. 444 * @syscap SystemCapability.MultimodalInput.Input.Core 445 * @since 12 446 */ 447 struct Input_KeyEvent* OH_Input_CreateKeyEvent(); 448 449 /** 450 * @brief Destroys a key event object. 451 * 452 * @param keyEvent Key event object. 453 * @syscap SystemCapability.MultimodalInput.Input.Core 454 * @since 12 455 */ 456 void OH_Input_DestroyKeyEvent(struct Input_KeyEvent** keyEvent); 457 458 /** 459 * @brief Sets the key event type. 460 * 461 * @param keyEvent Key event object. 462 * @param action Key event type. 463 * @syscap SystemCapability.MultimodalInput.Input.Core 464 * @since 12 465 */ 466 void OH_Input_SetKeyEventAction(struct Input_KeyEvent* keyEvent, int32_t action); 467 468 /** 469 * @brief Obtains the key event type. 470 * 471 * @param keyEvent Key event object. 472 * @return Key event type. 473 * @syscap SystemCapability.MultimodalInput.Input.Core 474 * @since 12 475 */ 476 int32_t OH_Input_GetKeyEventAction(const struct Input_KeyEvent* keyEvent); 477 478 /** 479 * @brief Sets the key value for a key event. 480 * 481 * @param keyEvent Key event object. 482 * @param keyCode keyCode Key code. 483 * @syscap SystemCapability.MultimodalInput.Input.Core 484 * @since 12 485 */ 486 void OH_Input_SetKeyEventKeyCode(struct Input_KeyEvent* keyEvent, int32_t keyCode); 487 488 /** 489 * @brief Obtains the key value of a key event. 490 * 491 * @param keyEvent Key event object. 492 * @return Key code. 493 * @syscap SystemCapability.MultimodalInput.Input.Core 494 * @since 12 495 */ 496 int32_t OH_Input_GetKeyEventKeyCode(const struct Input_KeyEvent* keyEvent); 497 498 /** 499 * @brief Sets the time when a key event occurs. 500 * 501 * @param keyEvent Key event object. 502 * @param actionTime Time when the key event occurs. 503 * @syscap SystemCapability.MultimodalInput.Input.Core 504 * @since 12 505 */ 506 void OH_Input_SetKeyEventActionTime(struct Input_KeyEvent* keyEvent, int64_t actionTime); 507 508 /** 509 * @brief Obtains the time when a key event occurs. 510 * 511 * @param keyEvent Key event object. 512 * @return Returns the time when the key event occurs. 513 * @syscap SystemCapability.MultimodalInput.Input.Core 514 * @since 12 515 */ 516 int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); 517 518 /** 519 * @brief Inject mouse event. 520 * 521 * @param mouseEvent - the mouse event to be injected. 522 * @return OH_Input_InjectMouseEvent function result code. 523 * {@link INPUT_SUCCESS} inject mouseEvent success.\n 524 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 525 * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n 526 * @syscap SystemCapability.MultimodalInput.Input.Core 527 * @since 12 528 */ 529 int32_t OH_Input_InjectMouseEvent(const struct Input_MouseEvent* mouseEvent); 530 531 /** 532 * @brief Creates a mouse event object. 533 * 534 * @return Returns an {@link Input_MouseEvent} pointer object if the operation is successful. 535 * Otherwise, a null pointer is returned. The possible cause is memory allocation failure. 536 * @syscap SystemCapability.MultimodalInput.Input.Core 537 * @since 12 538 */ 539 struct Input_MouseEvent* OH_Input_CreateMouseEvent(); 540 541 /** 542 * @brief Destroys a mouse event object. 543 * 544 * @param mouseEvent Mouse event object. 545 * @syscap SystemCapability.MultimodalInput.Input.Core 546 * @since 12 547 */ 548 void OH_Input_DestroyMouseEvent(struct Input_MouseEvent** mouseEvent); 549 550 /** 551 * @brief Sets the action for a mouse event. 552 * 553 * @param mouseEvent Mouse event object. 554 * @param action Mouse action. 555 * @syscap SystemCapability.MultimodalInput.Input.Core 556 * @since 12 557 */ 558 void OH_Input_SetMouseEventAction(struct Input_MouseEvent* mouseEvent, int32_t action); 559 560 /** 561 * @brief Obtains the action of a mouse event. 562 * 563 * @param mouseEvent Mouse event object. 564 * @return Mouse action. 565 * @syscap SystemCapability.MultimodalInput.Input.Core 566 * @since 12 567 */ 568 int32_t OH_Input_GetMouseEventAction(const struct Input_MouseEvent* mouseEvent); 569 570 /** 571 * @brief Sets the X coordinate for a mouse event. 572 * 573 * @param mouseEvent Mouse event object. 574 * @param displayX X coordinate on the display. 575 * @syscap SystemCapability.MultimodalInput.Input.Core 576 * @since 12 577 */ 578 void OH_Input_SetMouseEventDisplayX(struct Input_MouseEvent* mouseEvent, int32_t displayX); 579 580 /** 581 * @brief Obtains the X coordinate of a mouse event. 582 * 583 * @param mouseEvent Mouse event object. 584 * @return X coordinate on the display. 585 * @syscap SystemCapability.MultimodalInput.Input.Core 586 * @since 12 587 */ 588 int32_t OH_Input_GetMouseEventDisplayX(const struct Input_MouseEvent* mouseEvent); 589 590 /** 591 * @brief Sets the Y coordinate for a mouse event. 592 * 593 * @param mouseEvent Mouse event object. 594 * @param displayY Y coordinate on the display. 595 * @syscap SystemCapability.MultimodalInput.Input.Core 596 * @since 12 597 */ 598 void OH_Input_SetMouseEventDisplayY(struct Input_MouseEvent* mouseEvent, int32_t displayY); 599 600 /** 601 * @brief Obtains the Y coordinate of a mouse event. 602 * 603 * @param mouseEvent Mouse event object. 604 * @return Y coordinate on the display. 605 * @syscap SystemCapability.MultimodalInput.Input.Core 606 * @since 12 607 */ 608 int32_t OH_Input_GetMouseEventDisplayY(const struct Input_MouseEvent* mouseEvent); 609 610 /** 611 * @brief Sets the button for a mouse event. 612 * 613 * @param mouseEvent Mouse event object. 614 * @param button Mouse button. 615 * @syscap SystemCapability.MultimodalInput.Input.Core 616 * @since 12 617 */ 618 void OH_Input_SetMouseEventButton(struct Input_MouseEvent* mouseEvent, int32_t button); 619 620 /** 621 * @brief Obtains the button of a mouse event. 622 * 623 * @param mouseEvent Mouse event object. 624 * @return Mouse button. 625 * @syscap SystemCapability.MultimodalInput.Input.Core 626 * @since 12 627 */ 628 int32_t OH_Input_GetMouseEventButton(const struct Input_MouseEvent* mouseEvent); 629 630 /** 631 * @brief Sets the axis type for mouse event. 632 * 633 * @param mouseEvent Mouse event object. 634 * @param axisType Axis type, for example, X axis or Y axis. 635 * @syscap SystemCapability.MultimodalInput.Input.Core 636 * @since 12 637 */ 638 void OH_Input_SetMouseEventAxisType(struct Input_MouseEvent* mouseEvent, int32_t axisType); 639 640 /** 641 * @brief Obtains the axis type of a mouse event. 642 * 643 * @param mouseEvent Mouse event object. 644 * @return Axis type. 645 * @syscap SystemCapability.MultimodalInput.Input.Core 646 * @since 12 647 */ 648 int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent); 649 650 /** 651 * @brief Sets the axis value for a mouse axis event. 652 * 653 * @param mouseEvent Mouse event object. 654 * @param axisType Axis value. A positive value means scrolling forward, 655 * and a negative number means scrolling backward. 656 * @syscap SystemCapability.MultimodalInput.Input.Core 657 * @since 12 658 */ 659 void OH_Input_SetMouseEventAxisValue(struct Input_MouseEvent* mouseEvent, float axisValue); 660 661 /** 662 * @brief Obtains the axis value of a mouse event. 663 * 664 * @param mouseEvent Mouse event object. 665 * @return Axis value. 666 * @syscap SystemCapability.MultimodalInput.Input.Core 667 * @since 12 668 */ 669 float OH_Input_GetMouseEventAxisValue(const struct Input_MouseEvent* mouseEvent); 670 671 /** 672 * @brief Sets the time when a mouse event occurs. 673 * 674 * @param mouseEvent Mouse event object. 675 * @param actionTime Time when the mouse event occurs. 676 * @syscap SystemCapability.MultimodalInput.Input.Core 677 * @since 12 678 */ 679 void OH_Input_SetMouseEventActionTime(struct Input_MouseEvent* mouseEvent, int64_t actionTime); 680 681 /** 682 * @brief Obtains the time when a mouse event occurs. 683 * 684 * @param keyEvent Mouse event object. 685 * @return Returns the time when the mouse event occurs. 686 * @syscap SystemCapability.MultimodalInput.Input.Core 687 * @since 12 688 */ 689 int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEvent); 690 691 /** 692 * @brief Inject touch event. 693 * 694 * @param touchEvent - the touch event to be injected. 695 * @return OH_Input_InjectTouchEvent function result code. 696 * {@link INPUT_SUCCESS} inject touchEvent success.\n 697 * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n 698 * @syscap SystemCapability.MultimodalInput.Input.Core 699 * @since 12 700 */ 701 int32_t OH_Input_InjectTouchEvent(const struct Input_TouchEvent* touchEvent); 702 703 /** 704 * @brief Creates a touch event object. 705 * 706 * @return Returns an {@link Input_TouchEvent} pointer object if the operation is successful. 707 * Otherwise, a null pointer is returned. The possible cause is memory allocation failure. 708 * @syscap SystemCapability.MultimodalInput.Input.Core 709 * @since 12 710 */ 711 struct Input_TouchEvent* OH_Input_CreateTouchEvent(); 712 713 /** 714 * @brief Destroys a touch event object. 715 * 716 * @param touchEvent Touch event object. 717 * @syscap SystemCapability.MultimodalInput.Input.Core 718 * @since 12 719 */ 720 void OH_Input_DestroyTouchEvent(struct Input_TouchEvent** touchEvent); 721 722 /** 723 * @brief Sets the action for a touch event. 724 * 725 * @param touchEvent Touch event object. 726 * @param action Touch action. 727 * @syscap SystemCapability.MultimodalInput.Input.Core 728 * @since 12 729 */ 730 void OH_Input_SetTouchEventAction(struct Input_TouchEvent* touchEvent, int32_t action); 731 732 /** 733 * @brief Obtains the action of a touch event. 734 * 735 * @param touchEvent Touch event object. 736 * @return Touch action. 737 * @syscap SystemCapability.MultimodalInput.Input.Core 738 * @since 12 739 */ 740 int32_t OH_Input_GetTouchEventAction(const struct Input_TouchEvent* touchEvent); 741 742 /** 743 * @brief Sets the finger ID for the touch event. 744 * 745 * @param touchEvent Touch event object. 746 * @param id Finger ID. 747 * @syscap SystemCapability.MultimodalInput.Input.Core 748 * @since 12 749 */ 750 void OH_Input_SetTouchEventFingerId(struct Input_TouchEvent* touchEvent, int32_t id); 751 752 /** 753 * @brief Obtains the finger ID of a touch event. 754 * 755 * @param touchEvent Touch event object. 756 * @return Finger ID. 757 * @syscap SystemCapability.MultimodalInput.Input.Core 758 * @since 12 759 */ 760 int32_t OH_Input_GetTouchEventFingerId(const struct Input_TouchEvent* touchEvent); 761 762 /** 763 * @brief Sets the X coordinate for a touch event. 764 * 765 * @param touchEvent Touch event object. 766 * @param displayX X coordinate. 767 * @syscap SystemCapability.MultimodalInput.Input.Core 768 * @since 12 769 */ 770 void OH_Input_SetTouchEventDisplayX(struct Input_TouchEvent* touchEvent, int32_t displayX); 771 772 /** 773 * @brief Obtains the X coordinate of a touch event. 774 * 775 * @param touchEvent Touch event object. 776 * @return X coordinate. 777 * @syscap SystemCapability.MultimodalInput.Input.Core 778 * @since 12 779 */ 780 int32_t OH_Input_GetTouchEventDisplayX(const struct Input_TouchEvent* touchEvent); 781 782 /** 783 * @brief Sets the Y coordinate for a touch event. 784 * 785 * @param touchEvent Touch event object. 786 * @param displayY Y coordinate. 787 * @syscap SystemCapability.MultimodalInput.Input.Core 788 * @since 12 789 */ 790 void OH_Input_SetTouchEventDisplayY(struct Input_TouchEvent* touchEvent, int32_t displayY); 791 792 /** 793 * @brief Obtains the Y coordinate of a touch event. 794 * 795 * @param touchEvent Touch event object. 796 * @return Y coordinate. 797 * @syscap SystemCapability.MultimodalInput.Input.Core 798 * @since 12 799 */ 800 int32_t OH_Input_GetTouchEventDisplayY(const struct Input_TouchEvent* touchEvent); 801 802 /** 803 * @brief Sets the time when a touch event occurs. 804 * 805 * @param keyEvent Touch event object. 806 * @param actionTime Time when the touch event occurs. 807 * @syscap SystemCapability.MultimodalInput.Input.Core 808 * @since 12 809 */ 810 void OH_Input_SetTouchEventActionTime(struct Input_TouchEvent* touchEvent, int64_t actionTime); 811 812 /** 813 * @brief Obtains the time when a touch event occurs. 814 * 815 * @param keyEvent touch event object. 816 * @return Returns the time when the touch event occurs. 817 * @syscap SystemCapability.MultimodalInput.Input.Core 818 * @since 12 819 */ 820 int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEvent); 821 822 /** 823 * @brief Cancels event injection and revokes authorization. 824 * 825 * @syscap SystemCapability.MultimodalInput.Input.Core 826 * @since 12 827 */ 828 void OH_Input_CancelInjection(); 829 830 /** 831 * @brief Creates an axis event object. 832 * 833 * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. 834 * If the operation fails, null is returned. 835 * @syscap SystemCapability.MultimodalInput.Input.Core 836 * @since 12 837 */ 838 Input_AxisEvent* OH_Input_CreateAxisEvent(void); 839 840 /** 841 * @brief Destroys an axis event object. 842 * 843 * @param axisEvent Pointer to the axis event object. 844 * @return OH_Input_DestroyAxisEvent function result code. 845 * {@link INPUT_SUCCESS} Destroys axisEvent success.\n 846 * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n 847 * @syscap SystemCapability.MultimodalInput.Input.Core 848 * @since 12 849 */ 850 Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); 851 852 /** 853 * @brief Sets the axis event action. 854 * 855 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 856 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 857 * @return OH_Input_SetAxisEventAction function result code. 858 * {@link INPUT_SUCCESS} Sets the axis event action success.\n 859 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 860 * @syscap SystemCapability.MultimodalInput.Input.Core 861 * @since 12 862 */ 863 Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); 864 865 /** 866 * @brief Obtains the axis event action. 867 * 868 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 869 * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. 870 * @return OH_Input_GetAxisEventAction function result code. 871 * {@link INPUT_SUCCESS} Obtains the axis event action success.\n 872 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n 873 * @syscap SystemCapability.MultimodalInput.Input.Core 874 * @since 12 875 */ 876 Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); 877 878 /** 879 * @brief Sets the X coordinate of an axis event. 880 * 881 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 882 * @param displayX X coordinate of the axis event. 883 * @return OH_Input_SetAxisEventDisplayX function result code. 884 * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n 885 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 886 * @syscap SystemCapability.MultimodalInput.Input.Core 887 * @since 12 888 */ 889 Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); 890 891 /** 892 * @brief Obtains the X coordinate of an axis event. 893 * 894 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 895 * @param displayX X coordinate of the axis event. 896 * @return OH_Input_GetAxisEventDisplayX function result code. 897 * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n 898 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n 899 * @syscap SystemCapability.MultimodalInput.Input.Core 900 * @since 12 901 */ 902 Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); 903 904 /** 905 * @brief Sets the Y coordinate of an axis event. 906 * 907 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 908 * @param displayY Y coordinate of the axis event. 909 * @return OH_Input_SetAxisEventDisplayY function result code. 910 * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n 911 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 912 * @syscap SystemCapability.MultimodalInput.Input.Core 913 * @since 12 914 */ 915 Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); 916 917 /** 918 * @brief Obtains the Y coordinate of an axis event. 919 * 920 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 921 * @param displayY Y coordinate of the axis event. 922 * @return OH_Input_GetAxisEventDisplayY function result code. 923 * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n 924 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n 925 * @syscap SystemCapability.MultimodalInput.Input.Core 926 * @since 12 927 */ 928 Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); 929 930 /** 931 * @brief Sets the axis value of the axis type specified by the axis event. 932 * 933 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 934 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 935 * @param axisValue Axis value. 936 * @return OH_Input_SetAxisEventAxisValue function result code. 937 * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n 938 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 939 * @syscap SystemCapability.MultimodalInput.Input.Core 940 * @since 12 941 */ 942 Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, 943 InputEvent_AxisType axisType, double axisValue); 944 945 /** 946 * @brief Obtains the axis value for the specified axis type of the axis event. 947 * 948 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 949 * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. 950 * @param axisValue Axis value. 951 * @return OH_Input_GetAxisEventAxisValue function result code. 952 * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n 953 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, 954 * or the axisType not found in the axisEvent.\n 955 * @syscap SystemCapability.MultimodalInput.Input.Core 956 * @since 12 957 */ 958 Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, 959 InputEvent_AxisType axisType, double* axisValue); 960 961 /** 962 * @brief Sets the time when an axis event occurs. 963 * 964 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 965 * @param actionTime Time when an axis event occurs. 966 * @return OH_Input_SetAxisEventActionTime function result code. 967 * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n 968 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 969 * @syscap SystemCapability.MultimodalInput.Input.Core 970 * @since 12 971 */ 972 Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); 973 974 /** 975 * @brief Obtains the time when an axis event occurs. 976 * 977 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 978 * @param actionTime Time when an axis event occurs. 979 * @return OH_Input_GetAxisEventActionTime function result code. 980 * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n 981 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n 982 * @syscap SystemCapability.MultimodalInput.Input.Core 983 * @since 12 984 */ 985 Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); 986 987 /** 988 * @brief Sets the axis event type. 989 * 990 * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. 991 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 992 * @return OH_Input_SetAxisEventType function result code. 993 * {@link INPUT_SUCCESS} Sets the axis event type success.\n 994 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 995 * @syscap SystemCapability.MultimodalInput.Input.Core 996 * @since 12 997 */ 998 Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); 999 1000 /** 1001 * @brief Obtains the axis event type. 1002 * 1003 * @param axisEvent Axis event object. 1004 * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. 1005 * @return OH_Input_GetAxisEventType function result code. 1006 * {@link INPUT_SUCCESS} Obtains the axis event type success.\n 1007 * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n 1008 * @syscap SystemCapability.MultimodalInput.Input.Core 1009 * @since 12 1010 */ 1011 Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); 1012 1013 /** 1014 * @brief Sets the axis event source type. 1015 * 1016 * @param axisEvent Axis event object. 1017 * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1018 * @return OH_Input_SetAxisEventSourceType function result code. 1019 * {@link INPUT_SUCCESS} Sets the axis event source type success.\n 1020 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n 1021 * @syscap SystemCapability.MultimodalInput.Input.Core 1022 * @since 12 1023 */ 1024 Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); 1025 1026 /** 1027 * @brief Obtains the axis event source type. 1028 * 1029 * @param axisEvent Axis event object. 1030 * @param axisEventType Axis event source type. The values are defined in {@link InputEvent_SourceType}. 1031 * @return OH_Input_GetAxisEventSourceType function result code. 1032 * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n 1033 * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n 1034 * @syscap SystemCapability.MultimodalInput.Input.Core 1035 * @since 12 1036 */ 1037 Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); 1038 1039 /** 1040 * @brief Adds a listener of key events. 1041 * 1042 * @permission ohos.permission.INPUT_MONITORING 1043 * @param callback - Callback used to receive key events. 1044 * @return OH_Input_AddKeyEventMonitor function result code. 1045 * {@link INPUT_SUCCESS} Adds a listener of key events success.\n 1046 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1047 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1048 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1049 * @syscap SystemCapability.MultimodalInput.Input.Core 1050 * @since 12 1051 */ 1052 Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); 1053 1054 /** 1055 * @brief Adds a listener for mouse events, including mouse click and movement events, 1056 * but not scroll wheel events. Scroll wheel events are axis events. 1057 * 1058 * @permission ohos.permission.INPUT_MONITORING 1059 * @param callback - Callback used to receive mouse events. 1060 * @return OH_Input_AddMouseEventMonitor function result code. 1061 * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n 1062 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1063 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1064 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1065 * @syscap SystemCapability.MultimodalInput.Input.Core 1066 * @since 12 1067 */ 1068 Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); 1069 1070 /** 1071 * @brief Add a listener for touch events. 1072 * 1073 * @permission ohos.permission.INPUT_MONITORING 1074 * @param callback - Callback used to receive touch events. 1075 * @return OH_Input_AddTouchEventMonitor function result code. 1076 * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n 1077 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1078 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1079 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1080 * @syscap SystemCapability.MultimodalInput.Input.Core 1081 * @since 12 1082 */ 1083 Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); 1084 1085 /** 1086 * @brief Adds a listener for all types of axis events. 1087 * The axis event types are defined in {@Link InputEvent_AxisEventType}. 1088 * 1089 * @permission ohos.permission.INPUT_MONITORING 1090 * @param callback - Callback used to receive axis events. 1091 * @return OH_Input_AddAxisEventMonitorForAll function result code. 1092 * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n 1093 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1094 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1095 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1096 * @syscap SystemCapability.MultimodalInput.Input.Core 1097 * @since 12 1098 */ 1099 Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); 1100 1101 /** 1102 * @brief Adds a listener for the specified type of axis events. 1103 * 1104 * @permission ohos.permission.INPUT_MONITORING 1105 * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. 1106 * @param callback - Callback used to receive the specified type of axis events. 1107 * @return OH_Input_AddAxisEventMonitor function result code. 1108 * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n 1109 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1110 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1111 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n 1112 * @syscap SystemCapability.MultimodalInput.Input.Core 1113 * @since 12 1114 */ 1115 Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1116 1117 /** 1118 * @brief Removes a key event listener. 1119 * 1120 * @permission ohos.permission.INPUT_MONITORING 1121 * @param callback - Callback for the key event listener. 1122 * @return OH_Input_RemoveKeyEventMonitor function result code. 1123 * {@link INPUT_SUCCESS} Removes a key event listener success.\n 1124 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1125 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1126 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1127 * @syscap SystemCapability.MultimodalInput.Input.Core 1128 * @since 12 1129 */ 1130 Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); 1131 1132 /** 1133 * @brief Removes a mouse event listener. 1134 * 1135 * @permission ohos.permission.INPUT_MONITORING 1136 * @param callback - Callback for the mouse event listener. 1137 * @return OH_Input_RemoveMouseEventMonitor function result code. 1138 * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n 1139 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1140 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1141 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1142 * @syscap SystemCapability.MultimodalInput.Input.Core 1143 * @since 12 1144 */ 1145 Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); 1146 1147 /** 1148 * @brief Removes a touch event listener. 1149 * 1150 * @permission ohos.permission.INPUT_MONITORING 1151 * @param callback - Callback for the touch event listener. 1152 * @return OH_Input_RemoveTouchEventMonitor function result code. 1153 * {@link INPUT_SUCCESS} Removes a touch event listener success.\n 1154 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1155 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1156 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1157 * @syscap SystemCapability.MultimodalInput.Input.Core 1158 * @since 12 1159 */ 1160 Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); 1161 1162 /** 1163 * @brief Removes the listener for all types of axis events. 1164 * 1165 * @permission ohos.permission.INPUT_MONITORING 1166 * @param callback - Callback for the listener used to listen for all types of axis events. 1167 * @return OH_Input_RemoveAxisEventMonitorForAll function result code. 1168 * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n 1169 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1170 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1171 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1172 * @syscap SystemCapability.MultimodalInput.Input.Core 1173 * @since 12 1174 */ 1175 Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); 1176 1177 /** 1178 * @brief Removes the listener for the specified type of axis events. 1179 * 1180 * @permission ohos.permission.INPUT_MONITORING 1181 * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. 1182 * @param callback - Callback for the listener used to listen for the specified type of axis events. 1183 * @return OH_Input_RemoveAxisEventMonitor function result code. 1184 * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n 1185 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1186 * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n 1187 * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n 1188 * @syscap SystemCapability.MultimodalInput.Input.Core 1189 * @since 12 1190 */ 1191 Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); 1192 1193 /** 1194 * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. 1195 * 1196 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1197 * @param callback - Callback used to receive key events. 1198 * @param option - Options for event interception. If **null** is passed, the default value is used. 1199 * @return OH_Input_AddKeyEventInterceptor function result code. 1200 * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n 1201 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1202 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1203 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1204 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1205 * @syscap SystemCapability.MultimodalInput.Input.Core 1206 * @since 12 1207 */ 1208 Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); 1209 1210 /** 1211 * @brief Adds an interceptor for input events, including mouse, touch, and axis events. 1212 * If multiple interceptors are added, only the first one takes effect. 1213 * 1214 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1215 * @param callback - Pointer to the structure of the callback for the input event interceptor. 1216 * For details, see {@Link Input_InterceptorEventCallback}. 1217 * @param option - Options for event interception. If **null** is passed, the default value is used. 1218 * @return OH_Input_AddInputEventInterceptor function result code. 1219 * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n 1220 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1221 * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n 1222 * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n 1223 * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n 1224 * @syscap SystemCapability.MultimodalInput.Input.Core 1225 * @since 12 1226 */ 1227 Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, 1228 Input_InterceptorOptions *option); 1229 1230 /** 1231 * @brief Removes a key event interceptor. 1232 * 1233 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1234 * @return OH_Input_RemoveKeyEventInterceptor function result code. 1235 * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n 1236 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1237 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1238 * @syscap SystemCapability.MultimodalInput.Input.Core 1239 * @since 12 1240 */ 1241 Input_Result OH_Input_RemoveKeyEventInterceptor(void); 1242 1243 /** 1244 * @brief Removes an interceptor for input events, including mouse, touch, and axis events. 1245 * 1246 * @permission ohos.permission.INTERCEPT_INPUT_EVENT 1247 * @return OH_Input_RemoveInputEventInterceptor function result code. 1248 * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n 1249 * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n 1250 * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n 1251 * @syscap SystemCapability.MultimodalInput.Input.Core 1252 * @since 12 1253 */ 1254 Input_Result OH_Input_RemoveInputEventInterceptor(void); 1255 1256 /** 1257 * @brief Obtains the IDs of all input devices. 1258 * 1259 * @param deviceIds Array of input device IDs. 1260 * @param inSize Size of the array of input device IDs. 1261 * @param outSize Length of the list of input device IDs. The value cannot be greater than the value of inSize. 1262 * @return OH_Input_GetDeviceIds result code, specifically, 1263 * {@link INPUT_SUCCESS} if the operation is successful; 1264 * {@link INPUT_PARAMETER_ERROR} if deviceIds or outSize is a null pointer or inSize is less than 0. 1265 * @syscap SystemCapability.MultimodalInput.Input.Core 1266 * @since 13 1267 */ 1268 Input_Result OH_Input_GetDeviceIds(int32_t *deviceIds, int32_t inSize, int32_t *outSize); 1269 1270 /** 1271 * @brief Obtains the information about an input device. 1272 * 1273 * @param deviceId Device ID. 1274 * @param deviceInfo Pointer to an {@Link Input_DeviceInfo} object. 1275 * @return OH_Input_GetDevice result code, specifically, 1276 * {@link INPUT_SUCCESS} if the operation is successful; 1277 * {@link INPUT_PARAMETER_ERROR} if the deviceInfo is a null pointer or the deviceId is invalid. 1278 * You can use the {@Link OH_Input_GetDeviceIds} interface to query the device IDs supported by the system. 1279 * @syscap SystemCapability.MultimodalInput.Input.Core 1280 * @since 13 1281 */ 1282 Input_Result OH_Input_GetDevice(int32_t deviceId, Input_DeviceInfo **deviceInfo); 1283 1284 /** 1285 * @brief Creates a deviceInfo object. 1286 * 1287 * @return Pointer to an {@Link Input_DeviceInfo} object if the operation is successful; 1288 * a null pointer otherwise (possibly because of a memory allocation failure). 1289 * @syscap SystemCapability.MultimodalInput.Input.Core 1290 * @since 13 1291 */ 1292 Input_DeviceInfo* OH_Input_CreateDeviceInfo(void); 1293 1294 /** 1295 * @brief Destroys a deviceInfo object. 1296 * 1297 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1298 * @syscap SystemCapability.MultimodalInput.Input.Core 1299 * @since 13 1300 */ 1301 void OH_Input_DestroyDeviceInfo(Input_DeviceInfo **deviceInfo); 1302 1303 /** 1304 * @brief Obtains the keyboard type of an input device. 1305 * 1306 * @param deviceId Device ID. 1307 * @param keyboardType Pointer to the keyboard type of the input device. 1308 * @return OH_Input_GetKeyboardType result code, specifically, 1309 * {@link INPUT_SUCCESS} if the operation is successful; 1310 * {@link INPUT_PARAMETER_ERROR} if the device ID is invalid or keyboardType is a null pointer. 1311 * @syscap SystemCapability.MultimodalInput.Input.Core 1312 * @since 13 1313 */ 1314 Input_Result OH_Input_GetKeyboardType(int32_t deviceId, int32_t *keyboardType); 1315 1316 /** 1317 * @brief Obtains the ID of an input device. 1318 * 1319 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1320 * @param id Pointer to the ID of the input device. 1321 * @return OH_Input_GetDeviceId result code, specifically, 1322 * {@link INPUT_SUCCESS} if the operation is successful; 1323 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or id is a null pointer. 1324 * @syscap SystemCapability.MultimodalInput.Input.Core 1325 * @since 13 1326 */ 1327 Input_Result OH_Input_GetDeviceId(Input_DeviceInfo *deviceInfo, int32_t *id); 1328 1329 /** 1330 * @brief Obtains the name of an input device. 1331 * 1332 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1333 * @param name Pointer to the name of the input device. 1334 * @return OH_Input_GetDeviceName result code, specifically, 1335 * {@link INPUT_SUCCESS} if the operation is successful; 1336 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or name is a null pointer. 1337 * @syscap SystemCapability.MultimodalInput.Input.Core 1338 * @since 13 1339 */ 1340 Input_Result OH_Input_GetDeviceName(Input_DeviceInfo *deviceInfo, char **name); 1341 1342 /** 1343 * @brief Obtains the capabilities of an input device, for example, a touchscreen, touchpad, or keyboard. 1344 * 1345 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1346 * @param capabilities Pointer to the capabilities of the input device. 1347 * @return OH_Input_GetCapabilities result code, specifically, 1348 * {@link INPUT_SUCCESS} if the operation is successful; 1349 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or capabilities is a null pointer. 1350 * @syscap SystemCapability.MultimodalInput.Input.Core 1351 * @since 13 1352 */ 1353 Input_Result OH_Input_GetCapabilities(Input_DeviceInfo *deviceInfo, int32_t *capabilities); 1354 1355 /** 1356 * @brief Obtains the version information of an input device. 1357 * 1358 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1359 * @param version Pointer to the version information of the input device. 1360 * @return OH_Input_GetDeviceVersion result code, specifically, 1361 * {@link INPUT_SUCCESS} if the operation is successful; 1362 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or version is a null pointer. 1363 * @syscap SystemCapability.MultimodalInput.Input.Core 1364 * @since 13 1365 */ 1366 Input_Result OH_Input_GetDeviceVersion(Input_DeviceInfo *deviceInfo, int32_t *version); 1367 1368 /** 1369 * @brief Obtains the product information of an input device. 1370 * 1371 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1372 * @param product Pointer to the product information of the input device. 1373 * @return OH_Input_GetDeviceProduct result code, specifically, 1374 * {@link INPUT_SUCCESS} if the operation is successful; 1375 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or product is a null pointer. 1376 * @syscap SystemCapability.MultimodalInput.Input.Core 1377 * @since 13 1378 */ 1379 Input_Result OH_Input_GetDeviceProduct(Input_DeviceInfo *deviceInfo, int32_t *product); 1380 1381 /** 1382 * @brief Obtains the vendor information of an input device. 1383 * 1384 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1385 * @param vendor Pointer to the vendor information of the input device. 1386 * @return OH_Input_GetDeviceVendor result code, specifically, 1387 * {@link INPUT_SUCCESS} if the operation is successful; 1388 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or vendor is a null pointer. 1389 * @syscap SystemCapability.MultimodalInput.Input.Core 1390 * @since 13 1391 */ 1392 Input_Result OH_Input_GetDeviceVendor(Input_DeviceInfo *deviceInfo, int32_t *vendor); 1393 1394 /** 1395 * @brief Obtains the physical address of an input device. 1396 * 1397 * @param deviceInfo information object. For details, see {@Link Input_DeviceInfo}. 1398 * @param address Pointer to the physical address of the input device. 1399 * @return OH_Input_GetDeviceAddress result code, specifically, 1400 * {@link INPUT_SUCCESS} if the operation is successful; 1401 * {@link INPUT_PARAMETER_ERROR} if deviceInfo or address is a null pointer. 1402 * @syscap SystemCapability.MultimodalInput.Input.Core 1403 * @since 13 1404 */ 1405 Input_Result OH_Input_GetDeviceAddress(Input_DeviceInfo *deviceInfo, char **address); 1406 1407 /** 1408 * @brief Registers a listener for device hot swap events. 1409 * 1410 * @param listener Pointer to an {@Link Input_DeviceListener} object. 1411 * 1412 * @return OH_Input_RegisterDeviceListener status code, specifically, 1413 * {@link INPUT_SUCCESS} if the operation is successful;\n 1414 * {@link INPUT_PARAMETER_ERROR} if listener is NULL; 1415 * @syscap SystemCapability.MultimodalInput.Input.Core 1416 * @since 13 1417 */ 1418 Input_Result OH_Input_RegisterDeviceListener(Input_DeviceListener* listener); 1419 1420 /** 1421 * @brief Unregisters the listener for device hot swap events. 1422 * 1423 * @param listener Pointer to the listener for device hot swap events. For details, see {@Link Input_DeviceListener}. 1424 * 1425 * @return OH_Input_UnregisterDeviceListener status code, specifically, 1426 * {@link INPUT_SUCCESS} if the operation is successful;\n 1427 * {@link INPUT_PARAMETER_ERROR} if listener is NULL or no listener is registered; 1428 * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. 1429 * @syscap SystemCapability.MultimodalInput.Input.Core 1430 * @since 13 1431 */ 1432 Input_Result OH_Input_UnregisterDeviceListener(Input_DeviceListener* listener); 1433 1434 /** 1435 * @brief Unregisters the listener for all device hot swap events. 1436 * 1437 * @return OH_Input_UnregisterDeviceListener status code, specifically, 1438 * {@link INPUT_SUCCESS} if the operation is successful;\n 1439 * {@link INPUT_SERVICE_EXCEPTION} if the service is abnormal. 1440 * @syscap SystemCapability.MultimodalInput.Input.Core 1441 * @since 13 1442 */ 1443 Input_Result OH_Input_UnregisterDeviceListeners(); 1444 #ifdef __cplusplus 1445 } 1446 #endif 1447 /** @} */ 1448 1449 #endif /* OH_INPUT_MANAGER_H */ 1450