From 46a03b56a09775e44ba31001745938db9090f96b Mon Sep 17 00:00:00 2001 From: hemenghao Date: Wed, 30 Apr 2025 10:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E5=8F=8A?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hemenghao --- .../event_handler/src/client_msg_handler.cpp | 1 - .../src/input_device_consumer.cpp | 1 - .../event_handler/src/input_manager_impl.cpp | 2 -- .../src/multimodal_input_connect_proxy.cpp | 2 -- .../include/event_normalize_handler.h | 2 ++ .../src/event_normalize_handler.cpp | 32 +++++++++++-------- service/module_loader/src/mmi_service.cpp | 2 -- .../src/input_device_consumer_handler.cpp | 10 +++--- 8 files changed, 25 insertions(+), 27 deletions(-) diff --git a/frameworks/proxy/event_handler/src/client_msg_handler.cpp b/frameworks/proxy/event_handler/src/client_msg_handler.cpp index fd5f473b6..c9e97ee5c 100644 --- a/frameworks/proxy/event_handler/src/client_msg_handler.cpp +++ b/frameworks/proxy/event_handler/src/client_msg_handler.cpp @@ -545,7 +545,6 @@ int32_t ClientMsgHandler::OnSubscribeInputActiveCallback(const UDSClient& client int32_t ClientMsgHandler::ReportDeviceConsumer(const UDSClient& client, NetPacket& pkt) { - MMI_HILOGD("start"); if (pkt.ChkRWError()) { MMI_HILOGE("Packet read Pointer data failed"); return RET_ERR; diff --git a/frameworks/proxy/event_handler/src/input_device_consumer.cpp b/frameworks/proxy/event_handler/src/input_device_consumer.cpp index 62acd1855..87cf2ae09 100644 --- a/frameworks/proxy/event_handler/src/input_device_consumer.cpp +++ b/frameworks/proxy/event_handler/src/input_device_consumer.cpp @@ -29,7 +29,6 @@ InputDeviceConsumer::~InputDeviceConsumer() {} int32_t InputDeviceConsumer::SetInputDeviceConsumer(const std::vector& deviceNames, std::shared_ptr consumer) { - MMI_HILOGD("start"); CALL_DEBUG_ENTER; if (consumer == nullptr) { MULTIMODAL_INPUT_CONNECT_MGR->ClearInputDeviceConsumer(deviceNames); diff --git a/frameworks/proxy/event_handler/src/input_manager_impl.cpp b/frameworks/proxy/event_handler/src/input_manager_impl.cpp index 32334214b..9072daeb9 100644 --- a/frameworks/proxy/event_handler/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handler/src/input_manager_impl.cpp @@ -2794,9 +2794,7 @@ void InputManagerImpl::UnsubscribeInputActive(int32_t subscribeId) int32_t InputManagerImpl::SetInputDeviceConsumer(const std::vector& deviceNames, std::shared_ptr consumer) { - MMI_HILOGD("start"); CALL_DEBUG_ENTER; - CHKPR(consumer, INVALID_HANDLER_ID); if (!MMIEventHdl.InitClient()) { MMI_HILOGE("Client init failed"); return RET_ERR; diff --git a/service/connect_manager/src/multimodal_input_connect_proxy.cpp b/service/connect_manager/src/multimodal_input_connect_proxy.cpp index f5a87ef12..31d4f099a 100644 --- a/service/connect_manager/src/multimodal_input_connect_proxy.cpp +++ b/service/connect_manager/src/multimodal_input_connect_proxy.cpp @@ -1048,7 +1048,6 @@ int32_t MultimodalInputConnectProxy::AddInputHandler(InputHandlerType handlerTyp int32_t MultimodalInputConnectProxy::SetInputDeviceConsumer(const std::vector& deviceNames) { - MMI_HILOGD("start"); CALL_DEBUG_ENTER; MessageParcel data; if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) { @@ -1073,7 +1072,6 @@ int32_t MultimodalInputConnectProxy::SetInputDeviceConsumer(const std::vector& deviceNames) { - MMI_HILOGD("start"); CALL_DEBUG_ENTER; MessageParcel data; if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) { diff --git a/service/event_handler/include/event_normalize_handler.h b/service/event_handler/include/event_normalize_handler.h index d49e01930..c9178c65c 100644 --- a/service/event_handler/include/event_normalize_handler.h +++ b/service/event_handler/include/event_normalize_handler.h @@ -80,6 +80,8 @@ private: void PointerEventSetPressedKeys(std::shared_ptr pointerEvent); bool TouchPadKnuckleDoubleClickHandle(libinput_event* event); int32_t GetToolType(libinput_event* event); + void HandleDeviceConsumerEvent(int32_t toolType, libinput_event* event, PointerEvent::PointerItem &item, + std::shared_ptr pointerEvent); private: int32_t timerId_ { -1 }; diff --git a/service/event_handler/src/event_normalize_handler.cpp b/service/event_handler/src/event_normalize_handler.cpp index c50748bc7..96dee711f 100644 --- a/service/event_handler/src/event_normalize_handler.cpp +++ b/service/event_handler/src/event_normalize_handler.cpp @@ -730,20 +730,10 @@ int32_t EventNormalizeHandler::HandleTouchEvent(libinput_event* event, int64_t f } else { auto toolType = GetToolType(event); if (toolType == PointerEvent::TOOL_TYPE_THP_FEATURE) { - auto touch = libinput_event_get_touch_event(event); - CHKPR(touch, ERROR_NULL_POINTER); - auto orientation = libinput_event_touch_get_orientation(touch); - item.SetOrientation(orientation); - item.SetToolType(toolType); - pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item); - CHKPF(event); - auto device = libinput_event_get_device(event); - CHKPF(device); - std::string name = libinput_device_get_name(device); - DEVICEHANDLER->HandleDeviceConsumerEvent(name, pointerEvent); - return RET_OK; + HandleDeviceConsumerEvent(toolType, event, item, pointerEvent); + } else { + nextHandler_->HandleTouchEvent(pointerEvent); } - nextHandler_->HandleTouchEvent(pointerEvent); } } #ifdef OHOS_BUILD_ENABLE_VKEYBOARD @@ -1183,5 +1173,21 @@ int32_t EventNormalizeHandler::GetToolType(libinput_event* event) } return libinput_event_touch_get_tool_type(touch); } + +void EventNormalizeHandler::HandleDeviceConsumerEvent(int32_t toolType, libinput_event* event, + PointerEvent::PointerItem &item, std::shared_ptr pointerEvent) +{ + auto touch = libinput_event_get_touch_event(event); + CHKPV(touch); + auto orientation = libinput_event_touch_get_orientation(touch); + item.SetOrientation(orientation); + item.SetToolType(toolType); + pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item); + CHKPV(event); + auto device = libinput_event_get_device(event); + CHKPV(device); + std::string name = libinput_device_get_name(device); + DEVICEHANDLER->HandleDeviceConsumerEvent(name, pointerEvent); +} } // namespace MMI } // namespace OHOS diff --git a/service/module_loader/src/mmi_service.cpp b/service/module_loader/src/mmi_service.cpp index ca3408568..31fd239d9 100644 --- a/service/module_loader/src/mmi_service.cpp +++ b/service/module_loader/src/mmi_service.cpp @@ -3803,7 +3803,6 @@ int32_t MMIService::UnsubscribeInputActive(int32_t subscribeId) int32_t MMIService::SetInputDeviceConsumer(const std::vector& deviceNames) { - MMI_HILOGD("start"); CALL_INFO_TRACE; int32_t pid = GetCallingPid(); auto sess = GetSessionByPid(pid); @@ -3822,7 +3821,6 @@ int32_t MMIService::SetInputDeviceConsumer(const std::vector& devic int32_t MMIService::ClearInputDeviceConsumer(const std::vector& deviceNames) { - MMI_HILOGD("start"); CALL_INFO_TRACE; int32_t pid = GetCallingPid(); auto sess = GetSessionByPid(pid); diff --git a/service/touch_event_normalize/src/input_device_consumer_handler.cpp b/service/touch_event_normalize/src/input_device_consumer_handler.cpp index b9337b1fa..1d5e4e5d4 100644 --- a/service/touch_event_normalize/src/input_device_consumer_handler.cpp +++ b/service/touch_event_normalize/src/input_device_consumer_handler.cpp @@ -31,7 +31,6 @@ namespace MMI { int32_t InputDeviceConsumerHandler::SetDeviceConsumerHandler(const std::vector& deviceNames, SessionPtr sess) { - MMI_HILOGD("start"); CALL_INFO_TRACE; CHKPR(sess, ERROR_NULL_POINTER); for (auto& name : deviceNames) { @@ -55,7 +54,6 @@ int32_t InputDeviceConsumerHandler::ClearDeviceConsumerHandler(const std::vector void InputDeviceConsumerHandler::DeviceHandler::HandleEvent(std::string name, std::shared_ptr pointerEvent) { - MMI_HILOGD("start"); CHKPV(pointerEvent); auto it = deviceHandler_.find(name); if (it == deviceHandler_.end()) { @@ -81,9 +79,10 @@ void InputDeviceConsumerHandler::DeviceHandler::HandleEvent(std::string name, return; } for (const auto& [deviceName, handlers] : deviceHandler_) { - MMI_HILOGD("HandleEvent, deviceName:%{public}s", deviceName.c_str()); - for (const auto& handler : handlers) { - handler.SendToClient(pointerEvent, pkt); + if (deviceName == name) { + for (const auto& handler : handlers) { + handler.SendToClient(pointerEvent, pkt); + } } } } @@ -91,7 +90,6 @@ void InputDeviceConsumerHandler::DeviceHandler::HandleEvent(std::string name, int32_t InputDeviceConsumerHandler::DeviceHandler::RemoveDeviceHandler(const std::vector& deviceNames, SessionPtr sess) { - MMI_HILOGD("start"); for (const auto& name : deviceNames) { auto it = deviceHandler_.find(name); if (it != deviceHandler_.end()) { -- Gitee