1 /* 2 * Copyright (c) 2021-2023 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 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 #define OH_NATIVE_XCOMPONENT_OBJ ("__NATIVE_XCOMPONENT_OBJ__") 50 51 const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128; 52 const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10; 53 54 /** 55 * @brief Enumerates the API access states. 56 * 57 * @since 8 58 * @version 1.0 59 */ 60 enum { 61 /** Successful. */ 62 OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, 63 /** Failed. */ 64 OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, 65 /** Invalid parameters. */ 66 OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2, 67 }; 68 69 typedef enum { 70 /** Trigger a touch event when a finger is pressed. */ 71 OH_NATIVEXCOMPONENT_DOWN = 0, 72 /** Trigger a touch event when a finger is lifted. */ 73 OH_NATIVEXCOMPONENT_UP, 74 /** Trigger a touch event when a finger moves on the screen in pressed state. */ 75 OH_NATIVEXCOMPONENT_MOVE, 76 /** Trigger an event when a touch event is canceled. */ 77 OH_NATIVEXCOMPONENT_CANCEL, 78 /** Invalid touch type. */ 79 OH_NATIVEXCOMPONENT_UNKNOWN, 80 } OH_NativeXComponent_TouchEventType; 81 82 /** 83 * @brief Represents the touch point tool type. 84 * 85 * @since 9 86 * @version 1.0 87 */ 88 typedef enum { 89 /** Indicates invalid tool type. */ 90 OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, 91 /** Indicates a finger. */ 92 OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, 93 /** Indicates a stylus. */ 94 OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, 95 /** Indicates a eraser. */ 96 OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER, 97 /** Indicates a brush. */ 98 OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, 99 /** Indicates a pencil. */ 100 OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, 101 /** Indicates a brush. */ 102 OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, 103 /** Indicates a mouse. */ 104 OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE, 105 /** Indicates a lens. */ 106 OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS, 107 } OH_NativeXComponent_TouchPointToolType; 108 109 /** 110 * @brief Represents the touch event source type. 111 * 112 * @since 9 113 * @version 1.0 114 */ 115 typedef enum { 116 /** Indicates an unknown input source type. */ 117 OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, 118 /** Indicates that the input source generates a mouse multi-touch event. */ 119 OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, 120 /** Indicates that the input source generates a touchscreen multi-touch event. */ 121 OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, 122 /** Indicates that the input source generates a touchpad multi-touch event. */ 123 OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD, 124 /** Indicates that the input source generates a joystick multi-touch event. */ 125 OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, 126 /** 127 * @brief Indicates that the input source generates a keyboard event. 128 * 129 * @since 10 130 * @version 1.0 131 */ 132 OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD, 133 } OH_NativeXComponent_EventSourceType; 134 135 /** 136 * @brief Represents the mouse event action. 137 * 138 * @since 9 139 * @version 1.0 140 */ 141 typedef enum { 142 OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, 143 OH_NATIVEXCOMPONENT_MOUSE_PRESS, 144 OH_NATIVEXCOMPONENT_MOUSE_RELEASE, 145 OH_NATIVEXCOMPONENT_MOUSE_MOVE, 146 } OH_NativeXComponent_MouseEventAction; 147 148 /** 149 * @brief Represents the mouse event button. 150 * 151 * @since 9 152 * @version 1.0 153 */ 154 typedef enum { 155 OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, 156 OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, 157 OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, 158 OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04, 159 OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, 160 OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10, 161 } OH_NativeXComponent_MouseEventButton; 162 163 /** 164 * @brief Represents the source tool type of TouchEvent 165 * 166 * @since 10 167 * @version 1.0 168 */ 169 typedef enum { 170 OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0, 171 OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER = 1, 172 OH_NATIVEXCOMPONENT_SOURCETOOL_PEN = 2, 173 OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER = 3, 174 OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH = 4, 175 OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL = 5, 176 OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH = 6, 177 OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE = 7, 178 OH_NATIVEXCOMPONENT_SOURCETOOL_LENS = 8, 179 OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD = 9, 180 } OH_NativeXComponent_TouchEvent_SourceTool; 181 182 typedef struct { 183 /** Unique identifier of a finger. */ 184 int32_t id; 185 /** X coordinate of the touch point relative to the left edge of the screen. */ 186 float screenX; 187 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 188 float screenY; 189 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 190 float x; 191 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 192 float y; 193 /** Touch type of the touch event. */ 194 OH_NativeXComponent_TouchEventType type; 195 /** Contact area between the finger pad and the screen. */ 196 double size; 197 /** Pressure of the current touch event. */ 198 float force; 199 /** Timestamp of the current touch event. */ 200 int64_t timeStamp; 201 /** The angle betweenprojection on plane-X-Y and axis-Z of the current touch event. */ 202 float titlX; 203 /** The angle betweenprojection on plane-Y-Z and axis-Z of the current touch event. */ 204 float titlY; 205 /** The sourceTool of the current touch event. */ 206 OH_NativeXComponent_TouchEvent_SourceTool sourceTool; 207 } OH_NativeXComponent_HistoricalPoint; 208 209 typedef struct { 210 /** Unique identifier of a finger. */ 211 int32_t id; 212 /** X coordinate of the touch point relative to the left edge of the screen. */ 213 float screenX; 214 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 215 float screenY; 216 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 217 float x; 218 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 219 float y; 220 /** Touch type of the touch event. */ 221 OH_NativeXComponent_TouchEventType type; 222 /** Contact area between the finger pad and the screen. */ 223 double size; 224 /** Pressure of the current touch event. */ 225 float force; 226 /** Timestamp of the current touch event. */ 227 int64_t timeStamp; 228 /** Whether the current point is pressed. */ 229 bool isPressed; 230 } OH_NativeXComponent_TouchPoint; 231 232 // Represents the touch point information. 233 typedef struct { 234 /** Unique identifier of a finger. */ 235 int32_t id; 236 /** X coordinate of the touch point relative to the left edge of the screen. */ 237 float screenX; 238 /** Y coordinate of the touch point relative to the upper edge of the screen. */ 239 float screenY; 240 /** X coordinate of the touch point relative to the left edge of the element to touch. */ 241 float x; 242 /** Y coordinate of the touch point relative to the upper edge of the element to touch. */ 243 float y; 244 /** Touch type of the touch event. */ 245 OH_NativeXComponent_TouchEventType type; 246 /** Contact area between the finger pad and the screen. */ 247 double size; 248 /** Pressure of the current touch event. */ 249 float force; 250 /** ID of the device where the current touch event is generated. */ 251 int64_t deviceId; 252 /** Timestamp of the current touch event. */ 253 int64_t timeStamp; 254 /** Array of the current touch points. */ 255 OH_NativeXComponent_TouchPoint touchPoints[OH_MAX_TOUCH_POINTS_NUMBER]; 256 /** Number of current touch points. */ 257 uint32_t numPoints; 258 } OH_NativeXComponent_TouchEvent; 259 260 /** 261 * @brief Represents the mouse event information. 262 * 263 * @since 9 264 * @version 1.0 265 */ 266 typedef struct { 267 /** X coordinate of the mouse point relative to the left edge of the element to mouse. */ 268 float x; 269 /** Y coordinate of the mouse point relative to the upper edge of the element to mouse. */ 270 float y; 271 /** X coordinate of the mouse point relative to the left edge of the screen. */ 272 float screenX; 273 /** Y coordinate of the mouse point relative to the upper edge of the screen. */ 274 float screenY; 275 /** Timestamp of the current mouse event. */ 276 int64_t timestamp; 277 /** Mouse event action. */ 278 OH_NativeXComponent_MouseEventAction action; 279 /** Mouse event button. */ 280 OH_NativeXComponent_MouseEventButton button; 281 } OH_NativeXComponent_MouseEvent; 282 283 /** 284 * @brief Provides an encapsulated <b>OH_NativeXComponent</b> instance. 285 * 286 * @since 8 287 * @version 1.0 288 */ 289 typedef struct OH_NativeXComponent OH_NativeXComponent; 290 291 /** 292 * @brief Registers the surface lifecycle and touch event callbacks. 293 * 294 * @since 8 295 * @version 1.0 296 */ 297 typedef struct OH_NativeXComponent_Callback { 298 /** Called when the surface is created. */ 299 void (*OnSurfaceCreated)(OH_NativeXComponent* component, void* window); 300 /** Called when the surface is changed. */ 301 void (*OnSurfaceChanged)(OH_NativeXComponent* component, void* window); 302 /** Called when the surface is destroyed. */ 303 void (*OnSurfaceDestroyed)(OH_NativeXComponent* component, void* window); 304 /** Called when a touch event is triggered. */ 305 void (*DispatchTouchEvent)(OH_NativeXComponent* component, void* window); 306 } OH_NativeXComponent_Callback; 307 308 /** 309 * @brief Registers the mouse event callbacks. 310 * 311 * @since 9 312 * @version 1.0 313 */ 314 typedef struct OH_NativeXComponent_MouseEvent_Callback { 315 /** Called when a mouse event is triggered. */ 316 void (*DispatchMouseEvent)(OH_NativeXComponent* component, void* window); 317 /** Called when a hover event is triggered. */ 318 void (*DispatchHoverEvent)(OH_NativeXComponent* component, bool isHover); 319 } OH_NativeXComponent_MouseEvent_Callback; 320 321 struct OH_NativeXComponent_KeyEvent; 322 /** 323 * @brief Provides an encapsulated <b>OH_NativeXComponent_KeyEvent</b> instance. 324 * 325 * @since 10 326 * @version 1.0 327 */ 328 typedef struct OH_NativeXComponent_KeyEvent OH_NativeXComponent_KeyEvent; 329 330 /** 331 * @brief Defines the expected frame rate range struct. 332 * 333 * @since 11 334 * @version 1.0 335 */ 336 typedef struct { 337 /** The minimum frame rate of dynamical callback rate range. */ 338 int32_t min; 339 /** The maximum frame rate of dynamical callback rate range. */ 340 int32_t max; 341 /** The expected frame rate of dynamical callback rate range. */ 342 int32_t expected; 343 } OH_NativeXComponent_ExpectedRateRange; 344 345 /** 346 * @brief Obtains the ID of the ArkUI XComponent. 347 * 348 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 349 * @param id Indicates the char buffer to keep the ID of this <b>OH_NativeXComponent</b> instance.\n 350 * Notice that a null-terminator will be appended to the char buffer, so the size of the\n 351 * char buffer should be at least as large as the size of the real id length plus 1.\n 352 * It is recommended that the size of the char buffer be [OH_XCOMPONENT_ID_LEN_MAX + 1]. 353 * @param size Indicates the pointer to the length of <b>id</b>, which you can set and receive. 354 * @return Returns the status code of the execution. 355 * @since 8 356 * @version 1.0 357 */ 358 int32_t OH_NativeXComponent_GetXComponentId(OH_NativeXComponent* component, char* id, uint64_t* size); 359 360 /** 361 * @brief Obtains the size of the surface held by the ArkUI XComponent. 362 * 363 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 364 * @param window Indicates the native window handler. 365 * @param width Indicates the pointer to the width of the current surface. 366 * @param height Indicates the pointer to the height of the current surface. 367 * @return Returns the status code of the execution. 368 * @since 8 369 * @version 1.0 370 */ 371 int32_t OH_NativeXComponent_GetXComponentSize( 372 OH_NativeXComponent* component, const void* window, uint64_t* width, uint64_t* height); 373 374 /** 375 * @brief Obtains the offset of the surface held by the ArkUI XComponent. 376 * 377 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 378 * @param window Indicates the native window handler. 379 * @param x Indicates the pointer to the x coordinate of the current surface. 380 * @param y Indicates the pointer to the y coordinate of the current surface. 381 * @return Returns the status code of the execution. 382 * @since 8 383 * @version 1.0 384 */ 385 int32_t OH_NativeXComponent_GetXComponentOffset( 386 OH_NativeXComponent* component, const void* window, double* x, double* y); 387 388 /** 389 * @brief Obtains the touch event dispatched by the ArkUI XComponent. 390 * 391 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 392 * @param window Indicates the native window handler. 393 * @param touchEvent Indicates the pointer to the current touch event. 394 * @return Returns the status code of the execution. 395 * @since 8 396 * @version 1.0 397 */ 398 int32_t OH_NativeXComponent_GetTouchEvent( 399 OH_NativeXComponent* component, const void* window, OH_NativeXComponent_TouchEvent* touchEvent); 400 401 /** 402 * @brief Obtains the touch pointer tool type by the ArkUI XComponent. 403 * 404 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 405 * @param pointIndex Indicates the pointer index in the touchPoints. 406 * @param toolType Indicates the tool Type of the pointer. 407 * @return Returns the status code of the execution. 408 * @since 9 409 * @version 1.0 410 */ 411 int32_t OH_NativeXComponent_GetTouchPointToolType( 412 OH_NativeXComponent* component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType* toolType); 413 414 /** 415 * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. 416 * 417 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 418 * @param pointIndex Indicates the pointer index in the touchPoints. 419 * @param tiltX Indicates the x tilt of the pointer. 420 * @return Returns the status code of the execution. 421 * @since 9 422 * @version 1.0 423 */ 424 int32_t OH_NativeXComponent_GetTouchPointTiltX(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltX); 425 426 /** 427 * @brief Obtains the touch pointer tiltX by the ArkUI XComponent. 428 * 429 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 430 * @param pointIndex Indicates the pointer index in the touchPoints. 431 * @param tiltY Indicates the y tilt of the pointer. 432 * @return Returns the status code of the execution. 433 * @since 9 434 * @version 1.0 435 */ 436 int32_t OH_NativeXComponent_GetTouchPointTiltY(OH_NativeXComponent* component, uint32_t pointIndex, float* tiltY); 437 438 /** 439 * @brief Obtains the touch event dispatched by the ArkUI XComponent. 440 * 441 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 442 * @param window Indicates the native window handler. 443 * @param historicalPoints Indicates the pointer to the current historicalPoints. 444 * @return Returns the status code of the execution. 445 * @since 10 446 * @version 1.0 447 */ 448 int32_t OH_NativeXComponent_GetHistoricalPoints(OH_NativeXComponent* component, const void* window, 449 int32_t* size, OH_NativeXComponent_HistoricalPoint** historicalPoints); 450 451 /** 452 * @brief Obtains the mouse event dispatched by the ArkUI XComponent. 453 * 454 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 455 * @param window Indicates the native window handler. 456 * @param mouseEvent Indicates the pointer to the current mouse event. 457 * @return Returns the status code of the execution. 458 * @since 9 459 * @version 1.0 460 */ 461 int32_t OH_NativeXComponent_GetMouseEvent( 462 OH_NativeXComponent* component, const void* window, OH_NativeXComponent_MouseEvent* mouseEvent); 463 464 /** 465 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 466 * 467 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 468 * @param callback Indicates the pointer to a surface lifecycle and touch event callback. 469 * @return Returns the status code of the execution. 470 * @since 8 471 * @version 1.0 472 */ 473 int32_t OH_NativeXComponent_RegisterCallback(OH_NativeXComponent* component, OH_NativeXComponent_Callback* callback); 474 475 /** 476 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 477 * 478 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 479 * @param callback Indicates the pointer to a mouse event callback. 480 * @return Returns the status code of the execution. 481 * @since 9 482 * @version 1.0 483 */ 484 int32_t OH_NativeXComponent_RegisterMouseEventCallback( 485 OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent_Callback* callback); 486 487 /** 488 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 489 * 490 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 491 * @param callback Indicates the pointer to a focus event callback. 492 * @return Returns the status code of the execution. 493 * @since 10 494 * @version 1.0 495 */ 496 int32_t OH_NativeXComponent_RegisterFocusEventCallback( 497 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 498 499 /** 500 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 501 * 502 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 503 * @param callback Indicates the pointer to a key event callback. 504 * @return Returns the status code of the execution. 505 * @since 10 506 * @version 1.0 507 */ 508 int32_t OH_NativeXComponent_RegisterKeyEventCallback( 509 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 510 511 /** 512 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 513 * 514 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 515 * @param callback Indicates the pointer to a blur event callback. 516 * @return Returns the status code of the execution. 517 * @since 10 518 * @version 1.0 519 */ 520 int32_t OH_NativeXComponent_RegisterBlurEventCallback( 521 OH_NativeXComponent* component, void (*callback)(OH_NativeXComponent* component, void* window)); 522 523 /** 524 * @brief Obtains the key event dispatched by the ArkUI XComponent. 525 * 526 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 527 * @param keyEvent Indicates the pointer to pointer of <b>OH_NativeXComponent_KeyEvent</b> instance. 528 * @return Returns the status code of the execution. 529 * @since 10 530 * @version 1.0 531 */ 532 int32_t OH_NativeXComponent_GetKeyEvent(OH_NativeXComponent* component, OH_NativeXComponent_KeyEvent** keyEvent); 533 534 /** 535 * @brief Obtains the action of the key event. 536 * 537 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 538 * @param action Indicates the action of the <b>OH_NativeXComponent_KeyEvent</b> instance. 539 * @return Returns the status code of the execution. 540 * @since 10 541 * @version 1.0 542 */ 543 int32_t OH_NativeXComponent_GetKeyEventAction( 544 OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyAction* action); 545 546 /** 547 * @brief Obtains the keyCode of the key event. 548 * 549 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 550 * @param code Indicates the keyCode of the <b>OH_NativeXComponent_KeyEvent</b> instance. 551 * @return Returns the status code of the execution. 552 * @since 10 553 * @version 1.0 554 */ 555 int32_t OH_NativeXComponent_GetKeyEventCode(OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_KeyCode* code); 556 557 /** 558 * @brief Obtains the sourceType of the key event. 559 * 560 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 561 * @param sourceType Indicates the sourceType of the <b>OH_NativeXComponent_KeyEvent</b> instance. 562 * @return Returns the status code of the execution. 563 * @since 10 564 * @version 1.0 565 */ 566 int32_t OH_NativeXComponent_GetKeyEventSourceType( 567 OH_NativeXComponent_KeyEvent* keyEvent, OH_NativeXComponent_EventSourceType* sourceType); 568 569 /** 570 * @brief Obtains the deviceId of the key event. 571 * 572 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 573 * @param deviceId Indicates the deviceId of the <b>OH_NativeXComponent_KeyEvent</b> instance. 574 * @return Returns the status code of the execution. 575 * @since 10 576 * @version 1.0 577 */ 578 int32_t OH_NativeXComponent_GetKeyEventDeviceId(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* deviceId); 579 580 /** 581 * @brief Obtains the timestamp of the key event. 582 * 583 * @param keyEvent Indicates the pointer to this <b>OH_NativeXComponent_KeyEvent</b> instance. 584 * @param timestamp Indicates the timestamp of the <b>OH_NativeXComponent_KeyEvent</b> instance. 585 * @return Returns the status code of the execution. 586 * @since 10 587 * @version 1.0 588 */ 589 int32_t OH_NativeXComponent_GetKeyEventTimestamp(OH_NativeXComponent_KeyEvent* keyEvent, int64_t* timestamp); 590 591 /** 592 * @brief Set the Expected FrameRateRange. 593 * 594 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 595 * @param callback Indicates the pointer to a expected rate range. 596 * @return Returns the status code of the execution. 597 * @since 11 598 * @version 1.0 599 */ 600 int32_t OH_NativeXComponent_SetExpectedFrameRateRange( 601 OH_NativeXComponent* component, OH_NativeXComponent_ExpectedRateRange* range); 602 603 /** 604 * @brief Registers a callback for this <b>OH_NativeXComponent</b> instance. 605 * 606 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 607 * @param callback Indicates the pointer to a onFrame callback. 608 * @return Returns the status code of the execution. 609 * @since 11 610 * @version 1.0 611 */ 612 int32_t OH_NativeXComponent_RegisterOnFrameCallback(OH_NativeXComponent* component, 613 void (*callback)(OH_NativeXComponent* component, uint64_t timestamp, uint64_t targetTimestamp)); 614 615 /** 616 * @brief Unregister a callback for this <b>OH_NativeXComponent</b> instance. 617 * 618 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 619 * @return Returns the status code of the execution. 620 * @since 11 621 * @version 1.0 622 */ 623 int32_t OH_NativeXComponent_UnregisterOnFrameCallback(OH_NativeXComponent* component); 624 625 /** 626 * @brief Attach the root <b>ArkUI_NodeHandle</b> to xcomponent's <b>OH_NativeXComponent</b>. 627 * 628 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 629 * @param root Indicates the pointer to the root <b>ArkUI_NodeHandle</b>. 630 * @return Returns the status code of the execution. 631 * @since 11 632 * @version 1.0 633 */ 634 int32_t OH_NativeXComponent_AttachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root); 635 636 /** 637 * @brief detach the root <b>ArkUI_NodeHandle</b> to xcomponent's <b>OH_NativeXComponent</b>. 638 * 639 * @param component Indicates the pointer to this <b>OH_NativeXComponent</b> instance. 640 * @param root Indicates the pointer to the root <b>ArkUI_NodeHandle</b>. 641 * @return Returns the status code of the execution. 642 * @since 11 643 * @version 1.0 644 */ 645 int32_t OH_NativeXComponent_DetachNativeRootNode(OH_NativeXComponent* component, ArkUI_NodeHandle root); 646 647 #ifdef __cplusplus 648 }; 649 #endif 650 #endif // _NATIVE_INTERFACE_XCOMPONENT_H_ 651