1 /* 2 * Copyright (c) 2021-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 OH_NativeXComponent Native XComponent 18 * @{ 19 * 20 * @brief Describes the surface and touch event held by the ArkUI XComponent, which can be used for the EGL/OpenGL ES\n 21 * and media data input and displayed on the ArkUI XComponent. 22 * 23 * @since 8 24 * @version 1.0 25 */ 26 27 /** 28 * @file native_interface_xcomponent.h 29 * 30 * @brief Declares APIs for accessing a Native XComponent. 31 * 32 * @since 8 33 * @version 1.0 34 */ 35 36 #ifndef _NATIVE_INTERFACE_XCOMPONENT_H_ 37 #define _NATIVE_INTERFACE_XCOMPONENT_H_ 38 39 #include <stdbool.h> 40 #include <stdint.h> 41 42 #include "native_type.h" 43 #include "native_xcomponent_key_event.h" 44 #include "ui_input_event.h" 45 #include "native_interface_accessibility.h" 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 #define OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") 52 53 const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128; 54 const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; 55 56 /** 57 * @brief Enumerates the API access states. 58 * 59 * @since 8 60 * @version 1.0 61 */ 62 enum { 63 /** Successful. */ 64 OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, 65 /** Failed. */ 66 OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, 67 /** Invalid parameters. */ 68 OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2, 69 }; 70 71 typedef enum { 72 /** Trigger a touch event when a finger is pressed. */ 73 OH_NATIVEXCOMPONENT_DOWN = 0, 74 /** Trigger a touch event when a finger is lifted. */ 75 OH_NATIVEXCOMPONENT_UP, 76 /** Trigger a touch event when a finger moves on the screen in pressed state. */ 77 OH_NATIVEXCOMPONENT_MOVE, 78 /** Trigger an event when a touch event is canceled. */ 79 OH_NATIVEXCOMPONENT_CANCEL, 80 /** Invalid touch type. */ 81 OH_NATIVEXCOMPONENT_UNKNOWN, 82 } OH_NativeXComponent_TouchEventType; 83 84 /** 85 * @brief Represents the touch point tool type. 86 * 87 * @since 9 88 * @version 1.0 89 */ 90 typedef enum { 91 /** Indicates invalid tool type. */ 92 OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, 93 /** Indicates a finger. */ 94 OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, 95 /** Indicates a stylus. */ 96 OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, 97 /** Indicates a eraser. */ 98 OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER, 99 /** Indicates a brush. */ 100 OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, 101 /** Indicates a pencil. */ 102 OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, 103 /** Indicates a brush. */ 104 OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, 105 /** Indicates a mouse. */ 106 OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE, 107 /** Indicates a lens. */ 108 OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS, 109 } OH_NativeXComponent_TouchPointToolType; 110 111 /** 112 * @brief Represents the touch event source type. 113 * 114 * @since 9 115 * @version 1.0 116 */ 117 typedef enum { 118 /** Indicates an unknown input source type. */ 119 OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, 120 /** Indicates that the input source generates a mouse multi-touch event. */ 121 OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, 122 /** Indicates that the input source generates a touchscreen multi-touch event. */ 123 OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, 124 /** Indicates that the input source generates a touchpad multi-touch event. */ 125 OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD, 126 /** Indicates that the input source generates a joystick multi-touch event. */ 127 OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, 128 /** 129 * @brief Indicates that the input source generates a keyboard event. 130 * 131 * @since 10 132 * @version 1.0 133 */ 134 OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD, 135 } OH_NativeXComponent_EventSourceType; 136 137 /** 138 * @brief Represents the mouse event action. 139 * 140 * @since 9 141 * @version 1.0 142 */ 143 typedef enum { 144 OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, 145 OH_NATIVEXCOMPONENT_MOUSE_PRESS, 146 OH_NATIVEXCOMPONENT_MOUSE_RELEASE, 147 OH_NATIVEXCOMPONENT_MOUSE_MOVE, 148 } OH_NativeXComponent_MouseEventAction; 149 150 /** 151 * @brief Represents the mouse event button. 152 * 153 * @since 9 154 * @version 1.0 155 */ 156 typedef enum { 157 OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, 158 OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, 159 OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, 160 OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04, 161 OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, 162 OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10, 163 } OH_NativeXComponent_MouseEventButton; 164 165 /** 166 * @brief Represents the source tool type of TouchEvent 167 * 168 * @since 10 169 * @version 1.0 170 */ 171 typedef enum { 172 OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0, 173 OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER = 1, 174 OH_NATIVEXCOMPONENT_SOURCETOOL_PEN = 2, 175 OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER = 3, 176 OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH = 4, 177 OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL = 5, 178 OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH = 6, 179 OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE = 7, 180 OH_NATIVEXCOMPONENT_SOURCETOOL_LENS = 8, 181 OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD = 9, 182 } OH_NativeXComponent_TouchEvent_SourceTool; 183 184 typedef struct { 185 /** Unique identifier of a finger. */ 186 int32_t id; 187 /** X coordinate of the touch point relative to the left edge of the screen. */ 188 float screenX; 189 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 190 float screenY; 191 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 192 float x; 193 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 194 float y; 195 /** Touch type of the touch event. */ 196 OH_NativeXComponent_TouchEventType type; 197 /** Contact area between the finger pad and the screen. */ 198 double size; 199 /** Pressure of the current touch event. */ 200 float force; 201 /** Timestamp of the current touch event. */ 202 int64_t timeStamp; 203 /** The angle betweenprojection on plane-X-Y and axis-Z of the current touch event. */ 204 float titlX; 205 /** The angle betweenprojection on plane-Y-Z and axis-Z of the current touch event. */ 206 float titlY; 207 /** The sourceTool of the current touch event. */ 208 OH_NativeXComponent_TouchEvent_SourceTool sourceTool; 209 } OH_NativeXComponent_HistoricalPoint; 210 211 typedef struct { 212 /** Unique identifier of a finger. */ 213 int32_t id; 214 /** X coordinate of the touch point relative to the left edge of the screen. */ 215 float screenX; 216 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 217 float screenY; 218 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 219 float x; 220 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 221 float y; 222 /** Touch type of the touch event. */ 223 OH_NativeXComponent_TouchEventType type; 224 /** Contact area between the finger pad and the screen. */ 225 double size; 226 /** Pressure of the current touch event. */ 227 float force; 228 /** Timestamp of the current touch event. */ 229 int64_t timeStamp; 230 /** Whether the current point is pressed. */ 231 bool isPressed; 232 } OH_NativeXComponent_TouchPoint; 233 234 // Represents the touch point information. 235 typedef struct { 236 /** Unique identifier of a finger. */ 237 int32_t id; 238 /** X coordinate of the touch point relative to the left edge of the screen. */ 239 float screenX; 240 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 241 float screenY; 242 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 243 float x; 244 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 245 float y; 246 /** Touch type of the touch event. */ 247 OH_NativeXComponent_TouchEventType type; 248 /** Contact area between the finger pad and the screen. */ 249 double size; 250 /** Pressure of the current touch event. */ 251 float force; 252 /** ID of the device where the current touch event is generated. */ 253 int64_t deviceId; 254 /** Timestamp of the current touch event. */ 255 int64_t timeStamp; 256 /** Array of the current touch points. */ 257 OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; 258 /** Number of current touch points. */ 259 uint32_t numPoints; 260 } OH_NativeXComponent_TouchEvent; 261 262 /** 263 * @brief Represents the mouse event information. 264 * 265 * @since 9 266 * @version 1.0 267 */ 268 typedef struct { 269 /** X coordinate of the mouse point relative to the left edge of the element to mouse. */ 270 float x; 271 /** Y coordinate of the mouse point relative to the upper edge of the element to mouse. */ 272 float y; 273 /** X coordinate of the mouse point relative to the left edge of the screen. */ 274 float screenX; 275 /** Y coordinate of the mouse point relative to the upper edge of the screen. */ 276 float screenY; 277 /** Timestamp of the current mouse event. */ 278 int64_t timestamp; 279 /** Mouse event action. */ 280 OH_NativeXComponent_MouseEventAction action; 281 /** Mouse event button. */ 282 OH_NativeXComponent_MouseEventButton button; 283 } OH_NativeXComponent_MouseEvent; 284 285 /** 286 * @brief Provides an encapsulated <b>OH_NativeXComponent</b> instance. 287 * 288 * @since 8 289 * @version 1.0 290 */ 291 typedef struct OH_NativeXComponent OH_NativeXComponent; 292 293 /** 294 * @brief Registers the surface lifecycle and touch event callbacks. 295 * 296 * @since 8 297 * @version 1.0 298 */ 299 typedef struct OH_NativeXComponent_Callback { 300 /** Called when the surface is created. */ 301 void (*OnSurfaceCreated)(OH_NativeXComponent* component, void* window); 302 /** Called when the surface is changed. */ 303 void (*OnSurfaceChanged)(OH_NativeXComponent* component, void* window); 304 /** Called when the surface is destroyed. */ 305 void (*OnSurfaceDestroyed)(OH_NativeXComponent* component, void* window); 306 /** Called when a touch event is triggered. */ 307 void (*DispatchTouchEvent)(OH_NativeXComponent* component, void* window); 308 } OH_NativeXComponent_Callback; 309 310 /** 311 * @brief Registers the mouse event callbacks. 312 * 313 * @since 9 314 * @version 1.0 315 */ 316 typedef struct OH_NativeXComponent_MouseEvent_Callback { 317 /** Called when a mouse event is triggered. */ 318 void (*DispatchMouseEvent)(OH_NativeXComponent* component, void* window); 319 /** Called when a hover event is triggered. */ 320 void (*DispatchHoverEvent)(OH_NativeXComponent* component, bool isHover); 321 } OH_NativeXComponent_MouseEvent_Callback; 322 323 struct OH_NativeXComponent_KeyEvent; 324 /** 325 * @brief Provides an encapsulated <b>OH_NativeXComponent_KeyEvent</b> instance. 326 * 327 * @since 10 328 * @version 1.0 329 */ 330 typedef struct OH_NativeXComponent_KeyEvent OH_NativeXComponent_KeyEvent; 331 332 /** 333 * @brief Defines the expected frame rate range struct. 334 * 335 * @since 11 336 * @version 1.0 337 */ 338 typedef struct { 339 /** The minimum frame rate of dynamical callback rate range. */ 340 int32_t min; 341 /** The maximum frame rate of dynamical callback rate range. */ 342 int32_t max; 343 /** The expected frame rate of dynamical callback rate range. */ 344 int32_t expected; 345 } OH_NativeXComponent_ExpectedRateRange; 346 347 /** 348 * @brief Obtains the ID of the ArkUI XComponent. 349 * 350 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 351 * @param id Indicates the char buffer to keep the ID of this <b>OH_NativeXComponent</b> instance.\n 352 * Notice that a null-terminator will be appended to the char buffer, so the size of the\n 353 * char buffer should be at least as large as the size of the real id length plus 1.\n 354 * It is recommended that the size of the char buffer be [OH_XCOMPONENT_ID_LEN_MAX + 1]. 355 * @param size Indicates the pointer to the length of <b>id</b>, which you can set and receive. 356 * @return Returns the status code of the execution. 357 * @since 8 358 * @version 1.0 359 */ 360 int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size); 361 362 /** 363 * @brief Obtains the size of the surface held by the ArkUI XComponent. 364 * 365 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 366 * @param window Indicates the native window handler. 367 * @param width Indicates the pointer to the width of the current surface. 368 * @param height Indicates the pointer to the height of the current surface. 369 * @return Returns the status code of the execution. 370 * @since 8 371 * @version 1.0 372 */ 373 int32_t OH_NativeXComponent_GetXComponentSize( 374 OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height); 375 376 /** 377 * @brief Obtains the offset of the surface held by the ArkUI XComponent. 378 * 379 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 380 * @param window Indicates the native window handler. 381 * @param x Indicates the pointer to the x coordinate of the current surface. 382 * @param y Indicates the pointer to the y coordinate of the current surface. 383 * @return Returns the status code of the execution. 384 * @since 8 385 * @version 1.0 386 */ 387 int32_t OH_NativeXComponent_GetXComponentOffset( 388 OH_NativeXComponent* component, const void* window, double* x, double* y); 389 390 /** 391 * @brief Obtains the touch event dispatched by the ArkUI XComponent. 392 * 393 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 394 * @param window Indicates the native window handler. 395 * @param touchEvent Indicates the pointer to the current touch event. 396 * @return Returns the status code of the execution. 397 * @since 8 398 * @version 1.0 399 */ 400 int32_t OH_NativeXComponent_GetTouchEvent( 401 OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent); 402 403 /** 404 * @brief Obtains the touch pointer tool type by the ArkUI XComponent. 405 * 406 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 407 * @param pointIndex Indicates the pointer index in the touchPoints. 408 * @param toolType Indicates the tool Type of the pointer. 409 * @return Returns the status code of the execution. 410 * @since 9 411 * @version 1.0 412 */ 413 int32_t OH_NativeXComponent_GetTouchPointToolType( 414 OH_NativeXComponent* component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType* toolType); 415 416 /** 417 * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. 418 * 419 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 420 * @param pointIndex Indicates the pointer index in the touchPoints. 421 * @param tiltX Indicates the x tilt of the pointer. 422 * @return Returns the status code of the execution. 423 * @since 9 424 * @version 1.0 425 */ 426 int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX); 427 428 /** 429 * @brief Obtains the touch pointer tiltY by the ArkUI XComponent. 430 * 431 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 432 * @param pointIndex Indicates the pointer index in the touchPoints. 433 * @param tiltY Indicates the y tilt of the pointer. 434 * @return Returns the status code of the execution. 435 * @since 9 436 * @version 1.0 437 */ 438 int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY); 439 440 /** 441 * @brief Obtains the x coordinate of a specific touch point relative to the upper left corner of\n 442 * the current application window from the ArkUI XComponent. 443 * 444 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 445 * @param pointIndex Indicates the pointer index in the touchPoints. 446 * @param windowX Indicates the x coordinate relative to the upper left corner of the current\n 447 application window. 448 * @return Returns the status code of the execution. 449 * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} get windowX success. 450 * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is NULL, windowX is NULL\n 451 * or native XComponent is NULL. 452 * @since 12 453 * @version 1.0 454 */ 455 int32_t OH_NativeXComponent_GetTouchPointWindowX(OH_NativeXComponent* component, uint32_t pointIndex, float* windowX); 456 457 /** 458 * @brief Obtains the y coordinate of a specific touch point relative to the upper left corner of\n 459 * the current application window from the ArkUI XComponent. 460 * 461 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 462 * @param pointIndex Indicates the pointer index in the touchPoints. 463 * @param windowY Indicates the y coordinate relative to the upper left corner of the current\n 464 application window. 465 * @return Returns the status code of the execution. 466 * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} get windowY success. 467 * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is NULL, windowY is NULL\n 468 * or native XComponent is NULL. 469 * @since 12 470 * @version 1.0 471 */ 472 int32_t OH_NativeXComponent_GetTouchPointWindowY(OH_NativeXComponent* component, uint32_t pointIndex, float* windowY); 473 474 /** 475 * @brief Obtains the x coordinate of a specific touch point relative to the upper left corner of\n 476 * the current screen from the ArkUI XComponent. 477 * 478 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 479 * @param pointIndex Indicates the pointer index in the touchPoints. 480 * @param displayX Indicates the x coordinate relative to the upper left corner of the current\n 481 screen. 482 * @return Returns the status code of the execution. 483 * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} get displayX success. 484 * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is NULL, displayX is NULL\n 485 * or native XComponent is NULL. 486 * @since 12 487 * @version 1.0 488 */ 489 int32_t OH_NativeXComponent_GetTouchPointDisplayX(OH_NativeXComponent* component, uint32_t pointIndex, float* displayX); 490 491 /** 492 * @brief Obtains the y coordinate of a specific touch point relative to the upper left corner of\n 493 * the current screen from the ArkUI XComponent. 494 * 495 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 496 * @param pointIndex Indicates the pointer index in the touchPoints. 497 * @param displayY Indicates the y coordinate relative to the upper left corner of the current\n 498 screen. 499 * @return Returns the status code of the execution. 500 * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} get displayY success. 501 * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is NULL, displayY is NULL\n 502 * or native XComponent is NULL. 503 * @since 12 504 * @version 1.0 505 */ 506 int32_t OH_NativeXComponent_GetTouchPointDisplayY(OH_NativeXComponent* component, uint32_t pointIndex, float* displayY); 507 508 /** 509 * @brief Obtains the touch event dispatched by the ArkUI XComponent. 510 * 511 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 512 * @param window Indicates the native window handler. 513 * @param historicalPoints Indicates the pointer to the current historicalPoints. 514 * @return Returns the status code of the execution. 515 * @since 10 516 * @version 1.0 517 */ 518 int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window, 519 int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints); 520 521 /** 522 * @brief Obtains the mouse event dispatched by the ArkUI XComponent. 523 * 524 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 525 * @param window Indicates the native window handler. 526 * @param mouseEvent Indicates the pointer to the current mouse event. 527 * @return Returns the status code of the execution. 528 * @since 9 529 * @version 1.0 530 */ 531 int32_t OH_NativeXComponent_GetMouseEvent( 532 OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent); 533 534 /** 535 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 536 * 537 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 538 * @param callback Indicates the pointer to a surface lifecycle and touch event callback. 539 * @return Returns the status code of the execution. 540 * @since 8 541 * @version 1.0 542 */ 543 int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback); 544 545 /** 546 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 547 * 548 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 549 * @param callback Indicates the pointer to a mouse event callback. 550 * @return Returns the status code of the execution. 551 * @since 9 552 * @version 1.0 553 */ 554 int32_t OH_NativeXComponent_RegisterMouseEventCallback( 555 OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback); 556 557 /** 558 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 559 * 560 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 561 * @param callback Indicates the pointer to a focus event callback. 562 * @return Returns the status code of the execution. 563 * @since 10 564 * @version 1.0 565 */ 566 int32_t OH_NativeXComponent_RegisterFocusEventCallback( 567 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 568 569 /** 570 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 571 * 572 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 573 * @param callback Indicates the pointer to a key event callback. 574 * @return Returns the status code of the execution. 575 * @since 10 576 * @version 1.0 577 */ 578 int32_t OH_NativeXComponent_RegisterKeyEventCallback( 579 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 580 581 /** 582 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 583 * 584 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 585 * @param callback Indicates the pointer to a blur event callback. 586 * @return Returns the status code of the execution. 587 * @since 10 588 * @version 1.0 589 */ 590 int32_t OH_NativeXComponent_RegisterBlurEventCallback( 591 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 592 593 /** 594 * @brief Obtains the key event dispatched by the ArkUI XComponent. 595 * 596 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 597 * @param keyEvent Indicates the pointer to pointer of <b>OH_NativeXComponent_KeyEvent</b> instance. 598 * @return Returns the status code of the execution. 599 * @since 10 600 * @version 1.0 601 */ 602 int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent); 603 604 /** 605 * @brief Obtains the action of the key event. 606 * 607 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 608 * @param action Indicates the action of the <b>OH_NativeXComponent_KeyEvent</b> instance. 609 * @return Returns the status code of the execution. 610 * @since 10 611 * @version 1.0 612 */ 613 int32_t OH_NativeXComponent_GetKeyEventAction( 614 OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action); 615 616 /** 617 * @brief Obtains the keyCode of the key event. 618 * 619 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 620 * @param code Indicates the keyCode of the <b>OH_NativeXComponent_KeyEvent</b> instance. 621 * @return Returns the status code of the execution. 622 * @since 10 623 * @version 1.0 624 */ 625 int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code); 626 627 /** 628 * @brief Obtains the sourceType of the key event. 629 * 630 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 631 * @param sourceType Indicates the sourceType of the <b>OH_NativeXComponent_KeyEvent</b> instance. 632 * @return Returns the status code of the execution. 633 * @since 10 634 * @version 1.0 635 */ 636 int32_t OH_NativeXComponent_GetKeyEventSourceType( 637 OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType); 638 639 /** 640 * @brief Obtains the deviceId of the key event. 641 * 642 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 643 * @param deviceId Indicates the deviceId of the <b>OH_NativeXComponent_KeyEvent</b> instance. 644 * @return Returns the status code of the execution. 645 * @since 10 646 * @version 1.0 647 */ 648 int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId); 649 650 /** 651 * @brief Obtains the timestamp of the key event. 652 * 653 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 654 * @param timestamp Indicates the timestamp of the <b>OH_NativeXComponent_KeyEvent</b> instance. 655 * @return Returns the status code of the execution. 656 * @since 10 657 * @version 1.0 658 */ 659 int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp); 660 661 /** 662 * @brief Set the Expected FrameRateRange. 663 * 664 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 665 * @param callback Indicates the pointer to a expected rate range. 666 * @return Returns the status code of the execution. 667 * @since 11 668 * @version 1.0 669 */ 670 int32_t OH_NativeXComponent_SetExpectedFrameRateRange( 671 OH_NativeXComponent* component, OH_NativeXComponent_ExpectedRateRange* range); 672 673 /** 674 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 675 * 676 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 677 * @param callback Indicates the pointer to a onFrame callback. 678 * @return Returns the status code of the execution. 679 * @since 11 680 * @version 1.0 681 */ 682 int32_t OH_NativeXComponent_RegisterOnFrameCallback(OH_NativeXComponent* component, 683 void (*callback)(OH_NativeXComponent* component, uint64_t timestamp, uint64_t targetTimestamp)); 684 685 /** 686 * @brief Unregister a callback for this <b>OH_NativeXComponent</b> instance. 687 * 688 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 689 * @return Returns the status code of the execution. 690 * @since 11 691 * @version 1.0 692 */ 693 int32_t OH_NativeXComponent_UnregisterOnFrameCallback(OH_NativeXComponent* component); 694 695 /** 696 * @brief Attaches the UI component created through the native API of ArkUI to this <b>OH_NativeXComponent</b> instance. 697 * 698 * @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance. 699 * @param root Indicates the pointer to the component instance created by the native API. 700 * @return Returns 0 if success. 701 * Returns 401 if a parameter exception occurs. 702 * 703 * @since 12 704 */ 705 int32_t OH_NativeXComponent_AttachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root); 706 707 /** 708 * @brief Detaches the native component of ArkUI from this <b>OH_NativeXComponent</b> instance. 709 * 710 * @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance. 711 * @param root Indicates the pointer to the component instance created by the native API. 712 * @return Returns 0 if success. 713 * Returns 401 if a parameter exception occurs. 714 * 715 * @since 12 716 */ 717 int32_t OH_NativeXComponent_DetachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root); 718 719 /** 720 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 721 * 722 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 723 * @param callback Indicates the pointer to a surface show event callback. 724 * @return Returns the status code of the execution. 725 * @since 12 726 * @version 1.0 727 */ 728 int32_t OH_NativeXComponent_RegisterSurfaceShowCallback( 729 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 730 731 /** 732 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 733 * 734 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 735 * @param callback Indicates the pointer to a surface hide event callback. 736 * @return Returns the status code of the execution. 737 * @since 12 738 * @version 1.0 739 */ 740 int32_t OH_NativeXComponent_RegisterSurfaceHideCallback( 741 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 742 743 /** 744 * @brief Registers a UI input event callback for this <b>OH_NativeXComponent</b> instance and enables the callback to 745 * be invoked when a UI input event is received. 746 * 747 * @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance. 748 * @param callback Indicates the pointer to the UI input event callback. 749 * @param type Indicates the type of the current UI input event. 750 * @return Returns 0 if success. 751 * Returns 401 if a parameter exception occurs. 752 * @since 12 753 */ 754 int32_t OH_NativeXComponent_RegisterUIInputEventCallback(OH_NativeXComponent* component, 755 void (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event, ArkUI_UIInputEvent_Type type), 756 ArkUI_UIInputEvent_Type type); 757 758 /** 759 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 760 * 761 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 762 * @param callback Indicates the pointer to a key event callback. 763 * @return Returns the status code of the execution. 764 * @since 10 765 * @version 1.0 766 */ 767 int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback( 768 OH_NativeXComponent* component, HitTestMode (*callback)(OH_NativeXComponent* component, ArkUI_UIInputEvent* event)); 769 770 /** 771 * @brief Set whether the <b>OH_NativeXComponent</b> instance needs soft keyboard. 772 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 773 * @param needSoftKeyboard Indicates whether the <b>OH_NativeXComponent</b> instance needs soft keyboard or not. 774 * Default value is false. 775 * @return Returns the status code of the execution. 776 * @since 12 777 * @version 1.0 778 */ 779 int32_t OH_NativeXComponent_SetNeedSoftKeyboard(OH_NativeXComponent* component, bool needSoftKeyboard); 780 781 /** 782 * @brief Obtains the touch event's source type dispatched by the ArkUI XComponent. 783 * 784 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 785 * @param pointId Indicates the id of the touch point which triggers this touch event. 786 * @param sourceType Indicates the source type of this touch event. 787 * @return Returns OH_NATIVEXCOMPONENT_RESULT_SUCCESS if success. 788 * Returns OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER if a parameter exception occurs. 789 * Returns OH_NATIVEXCOMPONENT_RESULT_FAILED if other exceptions occur. 790 * @since 12 791 * @version 1.0 792 */ 793 int32_t OH_NativeXComponent_GetTouchEventSourceType( 794 OH_NativeXComponent* component, int32_t pointId, OH_NativeXComponent_EventSourceType* sourceType); 795 796 /** 797 * @brief Obtains the pointer to an <b>OH_NativeXComponent</b> instance based on the specified component 798 * instance created by the native API. 799 * 800 * @param node Indicates the pointer to the component instance created by the native API. 801 * @return Returns the pointer to the <b>OH_NativeXComponent</b> instance. 802 * @since 12 803 * @version 1.0 804 */ 805 OH_NativeXComponent* OH_NativeXComponent_GetNativeXComponent(ArkUI_NodeHandle node); 806 807 /** 808 * @brief Obtains the pointer to the <b> ArkUI_AccessibilityProvider</b> 809 * instance of this <b>OH_NativeXComponent</b> instance. 810 * 811 * @param component Indicates the pointer to the <b>OH_NativeXComponent</b> instance. 812 * @param handle Indicates the pointer to the <b>ArkUI_AccessibilityProvider</b> instance. 813 * @return Returns <b>OH_NATIVEXCOMPONENT_RESULT_SUCCESS</b> if the operation is successful. 814 * Returns <b>OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER</b> if a parameter error occurs. 815 * @since 13 816 */ 817 int32_t OH_NativeXComponent_GetNativeAccessibilityProvider( 818 OH_NativeXComponent* component, ArkUI_AccessibilityProvider** handle); 819 820 /** 821 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 822 * 823 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 824 * @param callback Indicates the pointer to a key event callback with result. 825 * @return Returns the status code of the execution. 826 * {@link OH_NATIVEXCOMPONENT_RESULT_SUCCESS} the callback function is successfully registered.\n 827 * {@link OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER} component is nullptr or callback is nullptr.\n 828 * @since 14 829 * @version 1.0 830 */ 831 int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult( 832 OH_NativeXComponent* component, bool (*callback)(OH_NativeXComponent* component, void* window)); 833 834 #ifdef __cplusplus 835 }; 836 #endif 837 #endif // _NATIVE_INTERFACE_XCOMPONENT_H_ 838