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