From 27e3de478c84a19fe3e5fda79290e24906c51938 Mon Sep 17 00:00:00 2001 From: z84394594 Date: Wed, 16 Apr 2025 03:03:48 -0400 Subject: [PATCH 1/3] add new gesture Signed-off-by: z84394594 --- .../include/libinput_adapter.h | 12 ++ .../libinput_adapter/src/libinput_adapter.cpp | 129 ++++++++++++++++++ 2 files changed, 141 insertions(+) diff --git a/service/libinput_adapter/include/libinput_adapter.h b/service/libinput_adapter/include/libinput_adapter.h index c3e926c289..3c4513ac75 100644 --- a/service/libinput_adapter/include/libinput_adapter.h +++ b/service/libinput_adapter/include/libinput_adapter.h @@ -69,6 +69,10 @@ enum class VTPStateMachineMessageType : int32_t { LEFT_TOUCH_DOWN = 18, LEFT_TOUCH_UP = 19, TWO_FINGER_TAP = 20, + LEFT_TOUCH_UP_CANCEL = 21, + SWIPE_BEGIN = 22, + SWIPE_UPDATE = 23, + SWIPE_END = 24, }; enum class VKeyboardActivation : int32_t { @@ -129,6 +133,8 @@ private: VTPStateMachineMessageType msgType, const std::vector& msgItem); void OnVKeyTrackPadGestureTwoMessage(libinput_event_touch* touch, VTPStateMachineMessageType msgType, const std::vector& msgItem); + void OnVKeyTrackPadGestureThreeMessage(libinput_event_touch* touch, + VTPStateMachineMessageType msgType, const std::vector& msgItem); bool HandleVKeyTrackPadPointerMove(libinput_event_touch* touch, const std::vector& msgItem); bool HandleVKeyTrackPadLeftBtnDown(libinput_event_touch* touch, @@ -164,6 +170,12 @@ private: const std::vector& msgItem); bool HandleVKeyTrackPadPanEnd(libinput_event_touch* touch, const std::vector& msgItem); + bool HandleVKeyTrackPadSwipeBegin(libinput_event_touch* touch, + const std::vector& msgItem); + bool HandleVKeyTrackPadSwipeUpdate(libinput_event_touch* touch, + const std::vector& msgItem); + bool HandleVKeyTrackPadSwipeEnd(libinput_event_touch* touch, + const std::vector& msgItem); bool HandleVKeyTrackPadRotateBegin(libinput_event_touch* touch, const std::vector& msgItem); bool HandleVKeyTrackPadRotateUpdate(libinput_event_touch* touch, diff --git a/service/libinput_adapter/src/libinput_adapter.cpp b/service/libinput_adapter/src/libinput_adapter.cpp index a06d2507ff..82ee209bb4 100644 --- a/service/libinput_adapter/src/libinput_adapter.cpp +++ b/service/libinput_adapter/src/libinput_adapter.cpp @@ -55,6 +55,7 @@ constexpr int32_t VKEY_TP_SM_MSG_POS_Y_IDX { 3 }; constexpr int32_t VKEY_TP_SM_MSG_SCALE_IDX { 4 }; constexpr int32_t VKEY_TP_SM_MSG_ANGLE_IDX { 5 }; constexpr int32_t VKEY_TP_GSE_TWO_FINGERS { 2 }; +constexpr int32_t VKEY_TP_GSE_THREE_FINGERS { 3 }; constexpr uint32_t VKEY_TP_LB_ID { 272 }; constexpr uint32_t VKEY_TP_RB_ID { 273 }; constexpr uint32_t VKEY_TP_SEAT_BTN_COUNT_NONE { 0 }; @@ -619,10 +620,138 @@ void LibinputAdapter::OnVKeyTrackPadGestureTwoMessage(libinput_event_touch* touc } break; default: + OnVKeyTrackPadGestureThreeMessage(touch, msgType, msgItem); break; } } +void LibinputAdapter::OnVKeyTrackPadGestureThreeMessage(libinput_event_touch* touch, + VTPStateMachineMessageType msgType, const std::vector& msgItem) +{ + switch (msgType) { + case VTPStateMachineMessageType::SWIPE_BEGIN: + if (!HandleVKeyTrackPadSwipeBegin(touch, msgItem)) { + MMI_HILOGE("Virtual TrackPad swipe begin event cannot be handled"); + } + break; + case VTPStateMachineMessageType::SWIPE_UPDATE: + if (!HandleVKeyTrackPadSwipeUpdate(touch, msgItem)) { + MMI_HILOGE("Virtual TrackPad swipe update event cannot be handled"); + } + break; + case VTPStateMachineMessageType::SWIPE_END: + if (!HandleVKeyTrackPadSwipeEnd(touch, msgItem)) { + MMI_HILOGE("Virtual TrackPad swipe end event cannot be handled"); + } + break; + } +} + +bool LibinputAdapter::HandleVKeyTrackPadSwipeBegin(libinput_event_touch* touch, + const std::vector& msgItem) +{ + if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { + MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", + static_cast(msgItem.size())); + return false; + } + int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; + int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; + int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; + event_gesture gEvent; + gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN; + gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; + sloted_coords_info slotInfo = {}; + slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; + slotInfo.coords[0].is_active = true; + slotInfo.coords[0].x = static_cast(msgPPosX); + slotInfo.coords[0].y = static_cast(msgPPosY); + slotInfo.coords[0].is_active = true; + slotInfo.coords[1].x = static_cast(msgPPosX); + slotInfo.coords[1].y = static_cast(msgPPosY); + slotInfo.coords[1].is_active = true; + slotInfo.coords[2].x = static_cast(msgPPosX); + slotInfo.coords[2].y = static_cast(msgPPosY); + slotInfo.coords[2].is_active = true; + gEvent.solt_touches = slotInfo; + libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); + funInputEvent_((libinput_event*)lgEvent, frameTime); + free(lgEvent); + return true; +} + +bool LibinputAdapter::HandleVKeyTrackPadSwipeUpdate(libinput_event_touch* touch, + const std::vector& msgItem) +{ + if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { + MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", + static_cast(msgItem.size())); + return false; + } + int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; + int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; + int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; + int32_t msgPSwipe = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; + event_gesture gEvent; + gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE; + gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; + gEvent.delta_x = 0; + gEvent.delta_y = msgPSwipe; + gEvent.delta_unaccel_x = 0; + gEvent.delta_unaccel_y = msgPSwipe; + sloted_coords_info slotInfo = {}; + slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; + slotInfo.coords[0].is_active = true; + slotInfo.coords[0].x = static_cast(msgPPosX); + slotInfo.coords[0].y = static_cast(msgPPosY); + slotInfo.coords[0].is_active = true; + slotInfo.coords[1].x = static_cast(msgPPosX); + slotInfo.coords[1].y = static_cast(msgPPosY); + slotInfo.coords[1].is_active = true; + slotInfo.coords[2].x = static_cast(msgPPosX); + slotInfo.coords[2].y = static_cast(msgPPosY); + slotInfo.coords[2].is_active = true; + gEvent.solt_touches = slotInfo; + libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); + funInputEvent_((libinput_event*)lgEvent, frameTime); + free(lgEvent); + return true; +} + +bool LibinputAdapter::HandleVKeyTrackPadSwipeEnd(libinput_event_touch* touch, + const std::vector& msgItem) +{ + if (msgItem.size() < VKEY_TP_SM_MSG_SIZE) { + MMI_HILOGE("Virtual TrackPad state machine message size:%{public}d is not correct", + static_cast(msgItem.size())); + return false; + } + int32_t msgPId = msgItem[VKEY_TP_SM_MSG_POINTER_ID_IDX]; + int32_t msgPPosX = msgItem[VKEY_TP_SM_MSG_POS_X_IDX]; + int32_t msgPPosY = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; + int32_t msgPSwipe = msgItem[VKEY_TP_SM_MSG_POS_Y_IDX]; + event_gesture gEvent; + gEvent.event_type = libinput_event_type::LIBINPUT_EVENT_GESTURE_SWIPE_END; + gEvent.finger_count = VKEY_TP_GSE_THREE_FINGERS; + sloted_coords_info slotInfo = {}; + slotInfo.active_count = VKEY_TP_GSE_THREE_FINGERS; + slotInfo.coords[0].is_active = true; + slotInfo.coords[0].x = static_cast(msgPPosX); + slotInfo.coords[0].y = static_cast(msgPPosY); + slotInfo.coords[0].is_active = true; + slotInfo.coords[1].x = static_cast(msgPPosX); + slotInfo.coords[1].y = static_cast(msgPPosY); + slotInfo.coords[1].is_active = true; + slotInfo.coords[2].x = static_cast(msgPPosX); + slotInfo.coords[2].y = static_cast(msgPPosY); + slotInfo.coords[2].is_active = true; + gEvent.solt_touches = slotInfo; + libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); + funInputEvent_((libinput_event*)lgEvent, frameTime); + free(lgEvent); + return true; +} + bool LibinputAdapter::HandleVKeyTrackPadPointerMove(libinput_event_touch* touch, const std::vector& msgItem) { -- Gitee From 1b53d64787ccf37163c6b7b84b7f8d71572ddc3b Mon Sep 17 00:00:00 2001 From: zehaozhang_9a74 Date: Wed, 16 Apr 2025 07:51:20 +0000 Subject: [PATCH 2/3] update service/libinput_adapter/include/libinput_adapter.h. Signed-off-by: zehaozhang_9a74 --- .../include/{libinput_adapter.h => libinput_adapter.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename service/libinput_adapter/include/{libinput_adapter.h => libinput_adapter.cpp} (100%) diff --git a/service/libinput_adapter/include/libinput_adapter.h b/service/libinput_adapter/include/libinput_adapter.cpp similarity index 100% rename from service/libinput_adapter/include/libinput_adapter.h rename to service/libinput_adapter/include/libinput_adapter.cpp -- Gitee From a1fca9d7ee55d61b4edd03bff4eacb0fbaf5ac4a Mon Sep 17 00:00:00 2001 From: zehaozhang_9a74 Date: Wed, 16 Apr 2025 07:52:54 +0000 Subject: [PATCH 3/3] update service/libinput_adapter/src/libinput_adapter.cpp. Signed-off-by: zehaozhang_9a74 --- service/libinput_adapter/src/libinput_adapter.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/service/libinput_adapter/src/libinput_adapter.cpp b/service/libinput_adapter/src/libinput_adapter.cpp index 82ee209bb4..735e03a04b 100644 --- a/service/libinput_adapter/src/libinput_adapter.cpp +++ b/service/libinput_adapter/src/libinput_adapter.cpp @@ -670,9 +670,6 @@ bool LibinputAdapter::HandleVKeyTrackPadSwipeBegin(libinput_event_touch* touch, slotInfo.coords[1].x = static_cast(msgPPosX); slotInfo.coords[1].y = static_cast(msgPPosY); slotInfo.coords[1].is_active = true; - slotInfo.coords[2].x = static_cast(msgPPosX); - slotInfo.coords[2].y = static_cast(msgPPosY); - slotInfo.coords[2].is_active = true; gEvent.solt_touches = slotInfo; libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); funInputEvent_((libinput_event*)lgEvent, frameTime); @@ -708,9 +705,6 @@ bool LibinputAdapter::HandleVKeyTrackPadSwipeUpdate(libinput_event_touch* touch, slotInfo.coords[1].x = static_cast(msgPPosX); slotInfo.coords[1].y = static_cast(msgPPosY); slotInfo.coords[1].is_active = true; - slotInfo.coords[2].x = static_cast(msgPPosX); - slotInfo.coords[2].y = static_cast(msgPPosY); - slotInfo.coords[2].is_active = true; gEvent.solt_touches = slotInfo; libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); funInputEvent_((libinput_event*)lgEvent, frameTime); @@ -742,9 +736,6 @@ bool LibinputAdapter::HandleVKeyTrackPadSwipeEnd(libinput_event_touch* touch, slotInfo.coords[1].x = static_cast(msgPPosX); slotInfo.coords[1].y = static_cast(msgPPosY); slotInfo.coords[1].is_active = true; - slotInfo.coords[2].x = static_cast(msgPPosX); - slotInfo.coords[2].y = static_cast(msgPPosY); - slotInfo.coords[2].is_active = true; gEvent.solt_touches = slotInfo; libinput_event_gesture* lgEvent = libinput_create_gesture_event(touch, gEvent); funInputEvent_((libinput_event*)lgEvent, frameTime); -- Gitee