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