diff --git a/service/libinput_adapter/include/libinput_adapter.h b/service/libinput_adapter/include/libinput_adapter.cpp similarity index 94% rename from service/libinput_adapter/include/libinput_adapter.h rename to service/libinput_adapter/include/libinput_adapter.cpp index c3e926c2891d6537740e17832282cf1a094993af..3c4513ac75597d3b65e6853406e56390d23c95ec 100644 --- a/service/libinput_adapter/include/libinput_adapter.h +++ b/service/libinput_adapter/include/libinput_adapter.cpp @@ -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 a06d2507ffb6b35e24c17d8af1aba4f76cc6d51f..735e03a04b62da586428a5ecec1e5aa915212296 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,129 @@ 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; + 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; + 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; + 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) {