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