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