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