From 480195e831fd1314a07e6f927a200db4509d0bd1 Mon Sep 17 00:00:00 2001 From: duanaoqi Date: Wed, 18 Sep 2024 14:22:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8D=95=E7=8B=AC=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E4=BA=A7=E7=94=9F=E7=9A=84touch=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E4=BC=A0=E9=80=92=E7=BB=99PlatformView?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3webview=E6=97=A0=E6=B3=95=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: duanaoqi --- shell/platform/ohos/ohos_touch_processor.cpp | 26 +++++++++++++++++++ shell/platform/ohos/ohos_touch_processor.h | 3 +++ .../platform/ohos/ohos_xcomponent_adapter.cpp | 1 + 3 files changed, 30 insertions(+) diff --git a/shell/platform/ohos/ohos_touch_processor.cpp b/shell/platform/ohos/ohos_touch_processor.cpp index 4849075ba0..1c04f38f03 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 94012bf1a8..1f59bd16a9 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 d1b62dcd70..562e17f44b 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_), -- Gitee From 4c2c1aea8a585402c202b8db3ccdd05e2e272612 Mon Sep 17 00:00:00 2001 From: duanaoqi Date: Wed, 18 Sep 2024 15:17:00 +0800 Subject: [PATCH 2/3] codecheck fix Signed-off-by: duanaoqi --- shell/platform/ohos/ohos_touch_processor.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/ohos_touch_processor.h b/shell/platform/ohos/ohos_touch_processor.h index 1f59bd16a9..551a5fc5c6 100644 --- a/shell/platform/ohos/ohos_touch_processor.h +++ b/shell/platform/ohos/ohos_touch_processor.h @@ -40,9 +40,10 @@ class OhosTouchProcessor { OH_NativeXComponent* component, OH_NativeXComponent_MouseEvent mouseEvent, double offsetY); - void HandleVirtualTouchEvent(int64_t shell_holderID, - OH_NativeXComponent* component, - OH_NativeXComponent_TouchEvent* touchEvent); + 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); -- Gitee From c0348cad6f4c60dc879a14befebc4542445d6587 Mon Sep 17 00:00:00 2001 From: duanaoqi Date: Wed, 18 Sep 2024 15:41:07 +0800 Subject: [PATCH 3/3] fix codecheck Signed-off-by: duanaoqi --- shell/platform/ohos/ohos_touch_processor.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_touch_processor.h b/shell/platform/ohos/ohos_touch_processor.h index 551a5fc5c6..1f59bd16a9 100644 --- a/shell/platform/ohos/ohos_touch_processor.h +++ b/shell/platform/ohos/ohos_touch_processor.h @@ -40,10 +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); + 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); -- Gitee