From: GiWoong Kim Date: Sat, 9 May 2015 03:20:37 +0000 (+0900) Subject: touch: supports up to 2 touch points only on MT_SYMM mode X-Git-Tag: TizenStudio_2.0_p3.0~234 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f41327f3f5cca6ccfad091353964b389c3750d7;p=sdk%2Femulator%2Fqemu.git touch: supports up to 2 touch points only on MT_SYMM mode Change-Id: Ib00a8de81d82019aa23244bb27df9d386d397968 Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/input/keyboardhelper.cpp b/tizen/src/ui/input/keyboardhelper.cpp index 420dc2f..8696592 100644 --- a/tizen/src/ui/input/keyboardhelper.cpp +++ b/tizen/src/ui/input/keyboardhelper.cpp @@ -291,6 +291,8 @@ void KeyboardHelper::pressFilterMtChecking(QKeyEvent *event) if (event->modifiers() == (Qt::ControlModifier | Qt::AltModifier)) { qDebug() << "enable multi-touch mode : SYMM"; set_multi_touch_enable(MultiTouchTracker::MT_SYMM); + + mtTracker->leaveTouchPoint(MT_SYMM_MAX_POINT); } break; diff --git a/tizen/src/ui/input/multitouchtracker.cpp b/tizen/src/ui/input/multitouchtracker.cpp index f9db5a3..7bb6b49 100644 --- a/tizen/src/ui/input/multitouchtracker.cpp +++ b/tizen/src/ui/input/multitouchtracker.cpp @@ -142,6 +142,31 @@ TouchPoint *MultiTouchTracker::searchTouchPoint(int targetID) return NULL; } +int MultiTouchTracker::leaveTouchPoint(int remainCnt) +{ + releaseGrabTouchPoint(); + + const int beforeCnt = touchPointList.count(); + TouchPoint *point = NULL; + + while (touchPointList.count() > remainCnt) { + point = touchPointList.last(); + if (point != NULL) { + qDebug() << "ID" << point->getID() << "point releasing"; + + virtio_touchscreen_event( + point->getGuestPos().x(), point->getGuestPos().y(), + point->getID() - 1, 0); + + delete point; + } + + touchPointList.removeLast(); + } + + return beforeCnt - touchPointList.count(); +} + void MultiTouchTracker::mtProcessing(int mode, QPoint hostPos, QPoint guestPos) { if (mode >= MT_OFF && mode < MT_MAX) { @@ -316,7 +341,7 @@ void MultiTouchTracker::processingSymm(QPoint hostPos, QPoint guestPos) } else if ((point = searchTouchPoint(hostPos)) != NULL) { /* grab a touch */ qDebug() << "ID" << point->getID() << "point is taken"; grabTouchPoint = point; - } else if (touchCnt >= 2) { /* last touch */ + } else if (touchCnt >= MT_SYMM_MAX_POINT) { /* last touch */ /* supports up to 2 touch points */ point = touchPointList.last(); if (point != NULL) { @@ -343,7 +368,7 @@ void MultiTouchTracker::processingSymm(QPoint hostPos, QPoint guestPos) } } -void MultiTouchTracker::touchReleasing() +void MultiTouchTracker::releaseGrabTouchPoint() { if (grabTouchPoint != NULL) { qDebug() << "ID" << grabTouchPoint->getID() << "point let go"; @@ -353,7 +378,7 @@ void MultiTouchTracker::touchReleasing() void MultiTouchTracker::finishTracking() { - touchReleasing(); + releaseGrabTouchPoint(); TouchPoint *point = NULL; for (int i = 0; i < touchPointList.count(); i++) { diff --git a/tizen/src/ui/input/multitouchtracker.h b/tizen/src/ui/input/multitouchtracker.h index 1d102c4..9437107 100644 --- a/tizen/src/ui/input/multitouchtracker.h +++ b/tizen/src/ui/input/multitouchtracker.h @@ -32,6 +32,8 @@ class TouchScreenHelper; +#define MT_SYMM_MAX_POINT (2) + class TouchPoint { public: @@ -61,7 +63,8 @@ public: int addTouchPoint(QPoint hostPos, QPoint guestPos); TouchPoint *searchTouchPoint(QPoint targetPos); TouchPoint *searchTouchPoint(int targetID); - void touchReleasing(); + int leaveTouchPoint(int remainCnt); + void releaseGrabTouchPoint(); void finishTracking(); void mtProcessing(int mode, QPoint, QPoint); diff --git a/tizen/src/ui/input/touchscreenhelper.cpp b/tizen/src/ui/input/touchscreenhelper.cpp index 2415d8e..ab1b9a7 100644 --- a/tizen/src/ui/input/touchscreenhelper.cpp +++ b/tizen/src/ui/input/touchscreenhelper.cpp @@ -70,7 +70,7 @@ void TouchScreenHelper::mousePressed(QMouseEvent *event, QPoint guestPos) void TouchScreenHelper::mouseReleased(QMouseEvent *event, QPoint guestPos) { if (get_multi_touch_enable() != MultiTouchTracker::MT_OFF) { - mtTracker->touchReleasing(); + mtTracker->releaseGrabTouchPoint(); return; }