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