native_interface_xcomponent.h
概述
声明用于访问Native XComponent的API。
库: libace_ndk.z.so
引用文件: <ace/xcomponent/native_interface_xcomponent.h>
起始版本: 8
相关模块:Native XComponent
汇总
结构体
| 名称 | 描述 |
|---|---|
| struct OH_NativeXComponent_TouchPoint | 触摸事件中触摸点的信息。 |
| struct OH_NativeXComponent_TouchEvent | 触摸事件。 |
| struct OH_NativeXComponent_HistoricalPoint | 历史接触点。 |
| struct OH_NativeXComponent_MouseEvent | 鼠标事件。 |
| struct OH_NativeXComponent_Callback | 注册surface生命周期和触摸事件回调。 |
| struct OH_NativeXComponent_MouseEvent_Callback | 注册鼠标事件回调。 |
| struct OH_NativeXComponent_ExpectedRateRange | 定义期望帧率范围。 |
类型定义
| 名称 | 描述 |
|---|---|
| typedef struct OH_NativeXComponent OH_NativeXComponent | 提供封装的OH_NativeXComponent实例。 |
| typedef struct OH_NativeXComponent_Callback OH_NativeXComponent_Callback | 注册surface生命周期和触摸事件回调。 |
| typedef struct OH_NativeXComponent_MouseEvent_Callback OH_NativeXComponent_MouseEvent_Callback | 注册鼠标事件的回调。 |
| typedef struct OH_NativeXComponent_KeyEvent OH_NativeXComponent_KeyEvent | 提供封装的OH_NativeXComponent_KeyEvent实例。 |
| typedef struct OH_ArkUI_SurfaceCallback OH_ArkUI_SurfaceCallback | 定义surface生命周期回调函数。 |
| typedef struct OH_ArkUI_SurfaceHolder OH_ArkUI_SurfaceHolder | 提供封装的OH_ArkUI_SurfaceHolder实例。 |
| typedef struct NativeWindow OHNativeWindow | 提供封装的NativeWindow实例。 |
枚举
| 名称 | 描述 |
|---|---|
| { OH_NATIVEXCOMPONENT_RESULT_SUCCESS = 0, OH_NATIVEXCOMPONENT_RESULT_FAILED = -1, OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER = -2 } | 枚举API访问状态。 |
| OH_NativeXComponent_TouchEventType { OH_NATIVEXCOMPONENT_DOWN = 0, OH_NATIVEXCOMPONENT_UP, OH_NATIVEXCOMPONENT_MOVE, OH_NATIVEXCOMPONENT_CANCEL, OH_NATIVEXCOMPONENT_UNKNOWN } |
触摸事件类型。 |
| OH_NativeXComponent_TouchPointToolType { OH_NATIVEXCOMPONENT_TOOL_TYPE_UNKNOWN = 0, OH_NATIVEXCOMPONENT_TOOL_TYPE_FINGER, OH_NATIVEXCOMPONENT_TOOL_TYPE_PEN, OH_NATIVEXCOMPONENT_TOOL_TYPE_RUBBER, OH_NATIVEXCOMPONENT_TOOL_TYPE_BRUSH, OH_NATIVEXCOMPONENT_TOOL_TYPE_PENCIL, OH_NATIVEXCOMPONENT_TOOL_TYPE_AIRBRUSH, OH_NATIVEXCOMPONENT_TOOL_TYPE_MOUSE, OH_NATIVEXCOMPONENT_TOOL_TYPE_LENS } |
触摸点工具类型。 |
| OH_NativeXComponent_EventSourceType { OH_NATIVEXCOMPONENT_SOURCE_TYPE_UNKNOWN = 0, OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHSCREEN, OH_NATIVEXCOMPONENT_SOURCE_TYPE_TOUCHPAD, OH_NATIVEXCOMPONENT_SOURCE_TYPE_JOYSTICK, OH_NATIVEXCOMPONENT_SOURCE_TYPE_KEYBOARD } |
触摸事件源类型。 |
| OH_NativeXComponent_TouchEvent_SourceTool { OH_NATIVEXCOMPONENT_SOURCETOOL_UNKNOWN = 0, OH_NATIVEXCOMPONENT_SOURCETOOL_FINGER, OH_NATIVEXCOMPONENT_SOURCETOOL_PEN, OH_NATIVEXCOMPONENT_SOURCETOOL_RUBBER, OH_NATIVEXCOMPONENT_SOURCETOOL_BRUSH, OH_NATIVEXCOMPONENT_SOURCETOOL_PENCIL, OH_NATIVEXCOMPONENT_SOURCETOOL_AIRBRUSH, OH_NATIVEXCOMPONENT_SOURCETOOL_MOUSE, OH_NATIVEXCOMPONENT_SOURCETOOL_LENS, OH_NATIVEXCOMPONENT_SOURCETOOL_TOUCHPAD } |
表示触摸事件的源工具类型。 |
| OH_NativeXComponent_MouseEventAction { OH_NATIVEXCOMPONENT_MOUSE_NONE = 0, OH_NATIVEXCOMPONENT_MOUSE_PRESS, OH_NATIVEXCOMPONENT_MOUSE_RELEASE, OH_NATIVEXCOMPONENT_MOUSE_MOVE, OH_NATIVEXCOMPONENT_MOUSE_CANCEL } |
鼠标事件动作。 |
| OH_NativeXComponent_MouseEventButton { OH_NATIVEXCOMPONENT_NONE_BUTTON = 0, OH_NATIVEXCOMPONENT_LEFT_BUTTON = 0x01, OH_NATIVEXCOMPONENT_RIGHT_BUTTON = 0x02, OH_NATIVEXCOMPONENT_MIDDLE_BUTTON = 0x04, OH_NATIVEXCOMPONENT_BACK_BUTTON = 0x08, OH_NATIVEXCOMPONENT_FORWARD_BUTTON = 0x10 } |
鼠标事件按键。 |
| ArkUI_XComponent_ImageAnalyzerState { ARKUI_XCOMPONENT_AI_ANALYSIS_FINISHED = 0, ARKUI_XCOMPONENT_AI_ANALYSIS_DISABLED = 110000, ARKUI_XCOMPONENT_AI_ANALYSIS_UNSUPPORTED = 110001, ARKUI_XCOMPONENT_AI_ANALYSIS_ONGOING = 110002, ARKUI_XCOMPONENT_AI_ANALYSIS_STOPPED = 110003} | XComponent图像AI分析状态码。 |
函数
| 名称 | 描述 |
|---|---|
| int32_t OH_NativeXComponent_GetXComponentId (OH_NativeXComponent *component, char *id, uint64_t *size) | 获取ArkUI XComponent的id。 |
| int32_t OH_NativeXComponent_GetXComponentSize (OH_NativeXComponent *component, const void *window, uint64_t *width, uint64_t *height) | 获取ArkUI XComponent持有的surface的大小。 |
| int32_t OH_NativeXComponent_GetXComponentOffset (OH_NativeXComponent *component, const void *window, double *x, double *y) | 获取ArkUI XComponent组件相对屏幕左上顶点的偏移量。 |
| int32_t OH_NativeXComponent_GetTouchEvent (OH_NativeXComponent *component, const void *window, OH_NativeXComponent_TouchEvent *touchEvent) | 获取ArkUI XComponent调度的触摸事件。 |
| int32_t OH_NativeXComponent_GetTouchPointToolType (OH_NativeXComponent *component, uint32_t pointIndex, OH_NativeXComponent_TouchPointToolType *toolType) | 获取ArkUI XComponent触摸点工具类型。 |
| int32_t OH_NativeXComponent_GetTouchPointTiltX (OH_NativeXComponent *component, uint32_t pointIndex, float *tiltX) | 获取ArkUI XComponent触摸点倾斜与X轴角度。 |
| int32_t OH_NativeXComponent_GetTouchPointTiltY (OH_NativeXComponent *component, uint32_t pointIndex, float *tiltY) | 获取ArkUI XComponent触摸点倾斜与Y轴角度。 |
| int32_t OH_NativeXComponent_GetTouchPointWindowX (OH_NativeXComponent *component, uint32_t pointIndex, float *windowX) | 获取ArkUI XComponent触摸点相对于应用窗口左上角的X坐标。 |
| int32_t OH_NativeXComponent_GetTouchPointWindowY (OH_NativeXComponent *component, uint32_t pointIndex, float *windowY) | 获取ArkUI XComponent触摸点相对于应用窗口左上角的Y坐标。 |
| int32_t OH_NativeXComponent_GetTouchPointDisplayX (OH_NativeXComponent *component, uint32_t pointIndex, float *displayX) | 获取ArkUI XComponent触摸点相对于应用所在屏幕左上角的X坐标。 |
| int32_t OH_NativeXComponent_GetTouchPointDisplayY (OH_NativeXComponent *component, uint32_t pointIndex, float *displayY) | 获取ArkUI XComponent触摸点相对于应用所在屏幕左上角的Y坐标。 |
| int32_t OH_NativeXComponent_GetHistoricalPoints (OH_NativeXComponent *component, const void *window, int32_t *size, OH_NativeXComponent_HistoricalPoint **historicalPoints) | 获取ArkUI XComponent的历史接触点。 |
| int32_t OH_NativeXComponent_GetMouseEvent (OH_NativeXComponent *component, const void *window, OH_NativeXComponent_MouseEvent *mouseEvent) | 获取ArkUI XComponent调度的鼠标事件。 |
| int32_t OH_NativeXComponent_RegisterCallback (OH_NativeXComponent *component, OH_NativeXComponent_Callback *callback) | 为此OH_NativeXComponent实例注册回调。 |
| int32_t OH_NativeXComponent_RegisterMouseEventCallback (OH_NativeXComponent *component, OH_NativeXComponent_MouseEvent_Callback *callback) | 为此OH_NativeXComponent实例注册鼠标事件回调。 |
| int32_t OH_NativeXComponent_RegisterFocusEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册获焦事件回调。 |
| int32_t OH_NativeXComponent_RegisterKeyEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册按键事件回调。 |
| int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult (OH_NativeXComponent *component, bool(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册有返回值的按键事件回调。 |
| int32_t OH_NativeXComponent_RegisterBlurEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册失焦事件回调。 |
| int32_t OH_NativeXComponent_GetKeyEvent (OH_NativeXComponent *component, OH_NativeXComponent_KeyEvent **keyEvent) | 获取ArkUI XComponent调度的按键事件。 |
| int32_t OH_NativeXComponent_GetKeyEventAction (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_KeyAction *action) | 获取传入按键事件的动作。 |
| int32_t OH_NativeXComponent_GetKeyEventCode (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_KeyCode *code) | 获取传入按键事件的按键码。 |
| int32_t OH_NativeXComponent_GetKeyEventSourceType (OH_NativeXComponent_KeyEvent *keyEvent, OH_NativeXComponent_EventSourceType *sourceType) | 获取传入按键事件的事件源类型。 |
| int32_t OH_NativeXComponent_GetKeyEventDeviceId (OH_NativeXComponent_KeyEvent *keyEvent, int64_t *deviceId) | 获取传入按键事件的设备id。 |
| int32_t OH_NativeXComponent_GetKeyEventTimeStamp (OH_NativeXComponent_KeyEvent *keyEvent, int64_t *timeStamp) | 获取传入按键事件的时间戳。 |
| int32_t OH_NativeXComponent_SetExpectedFrameRateRange (OH_NativeXComponent *component, OH_NativeXComponent_ExpectedRateRange *range) | 设置期望帧率范围。 |
| int32_t OH_NativeXComponent_RegisterOnFrameCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, uint64_t timestamp, uint64_t targetTimestamp)) | 为此OH_NativeXComponent实例注册显示更新回调,并使能每帧回调此函数。 |
| int32_t OH_NativeXComponent_UnregisterOnFrameCallback (OH_NativeXComponent *component) | 为此OH_NativeXComponent实例取消注册回调函数,并关闭每帧回调此函数。 |
| int32_t OH_NativeXComponent_AttachNativeRootNode (OH_NativeXComponent *component, ArkUI_NodeHandle root) | 将通过ArkUI的native接口创建出来的UI组件挂载到当前XComponent上。 |
| int32_t OH_NativeXComponent_DetachNativeRootNode (OH_NativeXComponent *component, ArkUI_NodeHandle root) | 将ArkUI的native组件从当前XComponent上卸载. |
| int32_t OH_NativeXComponent_RegisterUIInputEventCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event, ArkUI_UIInputEvent_Type type), ArkUI_UIInputEvent_Type type) | 为此OH_NativeXComponent实例注册UI输入事件回调,并使能收到UI输入事件时回调此函数。 |
| int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback (OH_NativeXComponent *component, HitTestMode(*callback)(OH_NativeXComponent *component, ArkUI_UIInputEvent *event)) | 为此OH_NativeXComponent实例注册自定义事件拦截回调,并使能在做触摸测试时回调此函数。 |
| int32_t OH_NativeXComponent_SetNeedSoftKeyboard (OH_NativeXComponent *component, bool needSoftKeyboard) | 为此OH_NativeXComponent实例设置是否需要软键盘。 |
| int32_t OH_NativeXComponent_RegisterSurfaceShowCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册surface显示回调,该回调在应用从后台返回前台时触发。 |
| int32_t OH_NativeXComponent_RegisterSurfaceHideCallback (OH_NativeXComponent *component, void(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册surface隐藏回调,该回调在应用从前台来到后台时触发。 |
| int32_t OH_NativeXComponent_GetTouchEventSourceType (OH_NativeXComponent *component, int32_t pointId, OH_NativeXComponent_EventSourceType *sourceType) | 获取ArkUI XComponent触发触摸事件的输入设备类型。 |
| OH_NativeXComponent * OH_NativeXComponent_GetNativeXComponent (ArkUI_NodeHandle node) | 基于Native接口创建的组件实例获取OH_NativeXComponent类型的指针。 |
| int32_t OH_NativeXComponent_GetNativeAccessibilityProvider (OH_NativeXComponent *component, ArkUI_AccessibilityProvider **handle) | 获取ArkUI XComponent无障碍接入句柄指针。 |
| int32_t OH_NativeXComponent_RegisterKeyEventCallbackWithResult (OH_NativeXComponent *component, bool(*callback)(OH_NativeXComponent *component, void *window)) | 为此OH_NativeXComponent实例注册有返回值的按键事件回调。 |
| int32_t OH_ArkUI_XComponent_StartImageAnalyzer (ArkUI_NodeHandle node, void *userData,void (*callback)(ArkUI_NodeHandle node, ArkUI_XComponent_ImageAnalyzerState statusCode, void *userData)) | 为此XComponent实例开始图像AI分析。 |
| int32_t OH_ArkUI_XComponent_StopImageAnalyzer(ArkUI_NodeHandle node) | 为此XComponent实例停止图像AI分析。 |
| OH_ArkUI_SurfaceCallback* OH_ArkUI_SurfaceCallback_Create() | 创建OH_ArkUI_SurfaceCallback对象。 |
| void OH_ArkUI_SurfaceCallback_Dispose(OH_ArkUI_SurfaceCallback* callback) | 销毁OH_ArkUI_SurfaceCallback对象。 |
| OH_ArkUI_SurfaceHolder* OH_ArkUI_SurfaceHolder_Create(ArkUI_NodeHandle node) | 创建XComponent组件的OH_ArkUI_SurfaceHolder对象。 |
| void OH_ArkUI_SurfaceHolder_Dispose(OH_ArkUI_SurfaceHolder* surfaceHolder) | 销毁OH_ArkUI_SurfaceHolder对象。 |
| int32_t OH_ArkUI_SurfaceHolder_SetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder,void* userData) | 向OH_ArkUI_SurfaceHolder实例存储自定义数据。 |
| void* OH_ArkUI_SurfaceHolder_GetUserData(OH_ArkUI_SurfaceHolder* surfaceHolder) | 获取OH_ArkUI_SurfaceHolder实例存储的自定义数据。 |
| void OH_ArkUI_SurfaceCallback_SetSurfaceCreatedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceCreated)(OH_ArkUI_SurfaceHolder* surfaceHolder)) | 设置surface生命周期回调中的创建回调事件。 |
| void OH_ArkUI_SurfaceCallback_SetSurfaceChangedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceChanged)(OH_ArkUI_SurfaceHolder* surfaceHolder,uint64_t width,uint64_t height)) | 设置surface生命周期回调中的大小改变回调事件。 |
| void OH_ArkUI_SurfaceCallback_SetSurfaceDestroyedEvent(OH_ArkUI_SurfaceCallback* callback,void (*onSurfaceDestroyed)(OH_ArkUI_SurfaceHolder* surfaceHolder)) | 设置surface生命周期回调中的销毁回调事件。 |
| int32_t OH_ArkUI_SurfaceHolder_AddSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback) | 添加surface生命周期回调到OH_ArkUI_SurfaceHolder实例。 |
| int32_t OH_ArkUI_SurfaceHolder_RemoveSurfaceCallback(OH_ArkUI_SurfaceHolder* surfaceHolder,OH_ArkUI_SurfaceCallback* callback) | 删除OH_ArkUI_SurfaceHolder实例的先前添加的surface生命周期回调。 |
| OHNativeWindow* OH_ArkUI_XComponent_GetNativeWindow(OH_ArkUI_SurfaceHolder* surfaceHolder) | 获取OH_ArkUI_SurfaceHolder实例关联的nativeWindow。 |
| int32_t OH_ArkUI_XComponent_SetAutoInitialize(ArkUI_NodeHandle node,bool autoInitialize) | 设置XComponent组件是否需要自动初始化的标志位。 |
| int32_t OH_ArkUI_XComponent_Initialize(ArkUI_NodeHandle node) | 初始化XComponent组件持有的surface。 |
| int32_t OH_ArkUI_XComponent_Finalize(ArkUI_NodeHandle node) | 销毁XComponent组件持有的surface。 |
| int32_t OH_ArkUI_XComponent_IsInitialized(ArkUI_NodeHandle node, bool* isInitialized) | 获取XComponent组件是否已经初始化的标志位。 |
变量
| 名称 | 描述 |
|---|---|
| const uint32_t OH_XCOMPONENT_ID_LEN_MAX = 128 | ArkUI XComponent的id的最大长度。 |
| const uint32_t OH_MAX_TOUCH_POINTS_NUMBER = 10 | 触摸事件中的可识别的触摸点个数最大值。 |