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