diff --git a/shell/platform/ohos/ohos_touch_processor.cpp b/shell/platform/ohos/ohos_touch_processor.cpp index 4849075ba095c396720b2a04fbf3d9a7e644978d..1c04f38f03e71cae08e93d35e0015faa4100869b 100644 --- a/shell/platform/ohos/ohos_touch_processor.cpp +++ b/shell/platform/ohos/ohos_touch_processor.cpp @@ -260,4 +260,30 @@ void OhosTouchProcessor::HandleMouseEvent( ohos_shell_holder->GetPlatformView()->DispatchPointerDataPacket(std::move(packet)); return; } + +void OhosTouchProcessor::HandleVirtualTouchEvent( + int64_t shell_holderID, + OH_NativeXComponent* component, + OH_NativeXComponent_TouchEvent* touchEvent) +{ + int numPoints = touchEvent->numPoints; + float tiltX = 0.0; + float tiltY = 0.0; + auto ohos_shell_holder = reinterpret_cast(shell_holderID); + OH_NativeXComponent_TouchPointToolType toolType; + OH_NativeXComponent_GetTouchPointToolType(component, 0, &toolType); + OH_NativeXComponent_GetTouchPointTiltX(component, 0, &tiltX); + OH_NativeXComponent_GetTouchPointTiltY(component, 0, &tiltY); + std::unique_ptr touchPacket = + std::make_unique(); + touchPacket->touchEventInput = touchEvent; + touchPacket->toolTypeInput = toolType; + touchPacket->tiltX = tiltX; + touchPacket->tiltX = tiltY; + + std::shared_ptr touchPacketString = packagePacketData(std::move(touchPacket)); + int size = CHANGES_POINTER_MEMBER + PER_POINTER_MEMBER * numPoints + TOUCH_EVENT_ADDITIONAL_ATTRIBUTES; + ohos_shell_holder->GetPlatformView()->OnTouchEvent(touchPacketString, size); + return; +} } // namespace flutter \ No newline at end of file diff --git a/shell/platform/ohos/ohos_touch_processor.h b/shell/platform/ohos/ohos_touch_processor.h index 94012bf1a8a2f37aef726e958fc739aca6218651..1f59bd16a98b0f171a2ef36c62d774cbc7315e92 100644 --- a/shell/platform/ohos/ohos_touch_processor.h +++ b/shell/platform/ohos/ohos_touch_processor.h @@ -40,6 +40,9 @@ class OhosTouchProcessor { OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent mouseEvent, double offsetY); + void HandleVirtualTouchEvent(int64_t shell_holderID, + OH_NativeXComponent* component, + OH_NativeXComponent_TouchEvent* touchEvent); flutter::PointerData::Change getPointerChangeForAction(int maskedAction); flutter::PointerData::DeviceKind getPointerDeviceTypeForToolType( int toolType); diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index d1b62dcd70290cd31a49024b51ec846a1bed569d..562e17f44b8a24286b035dbc9e8d2f0f3f6e9895 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -378,6 +378,7 @@ void XComponentBase::OnDispatchTouchEvent(OH_NativeXComponent* component, int32_t ret2 = OH_NativeXComponent_GetTouchEventSourceType(component, touchEvent_.id, &sourceType); if (ret2 == OH_NATIVEXCOMPONENT_RESULT_SUCCESS && sourceType == OH_NATIVEXCOMPONENT_SOURCE_TYPE_MOUSE) { + ohosTouchProcessor_.HandleVirtualTouchEvent(std::stoll(shellholderId_), component, &touchEvent_); return; } ohosTouchProcessor_.HandleTouchEvent(std::stoll(shellholderId_),