diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-05-20 09:25:47 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-05-21 08:28:30 (GMT) |
commit | 24b811e53b30546279346ab7b16799be119ab8c4 (patch) | |
tree | e0741ca6d71c9c01d343c51ed2896aa674841393 | |
parent | 1f1ff85bb9841d1b040b25af9a5c99a5c1f87e58 (diff) | |
download | Qt-24b811e53b30546279346ab7b16799be119ab8c4.zip Qt-24b811e53b30546279346ab7b16799be119ab8c4.tar.gz Qt-24b811e53b30546279346ab7b16799be119ab8c4.tar.bz2 |
Enable QTouchEvent for S60 5.0
Symbian OS doesn't support advanced pointer events before Symbian^3
Advanced pointer events are required for multitouch, and are used to
generate QTouchEvents.
This change enables sending of a single touch point QTouchEvent on
touchscreen phones based on earlier Symbian OS versions.
i.e. S60 5th edition
On devices without advanced pointers, or where the hardware does not
support pressure detection, the pressure is set to 1.0 in the touch
event. This is consistent with the Mac port.
Task-number: QTBUG-5668
Reviewed-by: Bradley T. Hughes
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 53 | ||||
-rw-r--r-- | src/gui/kernel/qt_s60_p.h | 1 |
3 files changed, 45 insertions, 12 deletions
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 01abe54..e30b6be 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -581,7 +581,8 @@ public: void _q_readRX71MultiTouchEvents(); #endif -#if defined(Q_WS_S60) +#if defined(Q_OS_SYMBIAN) + int pressureSupported; int maxTouchPressure; QList<QTouchEvent::TouchPoint> appAllTouchPoints; #endif diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 803241e..7e270aa 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -416,25 +416,44 @@ void QSymbianControl::HandleLongTapEventL( const TPoint& aPenEventLocation, cons void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent *event) { QApplicationPrivate *d = QApplicationPrivate::instance(); + QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); + qreal pressure; + if(d->pressureSupported + && event->Pressure() > 0) //workaround for misconfigured HAL + pressure = event->Pressure() / qreal(d->maxTouchPressure); + else + pressure = qreal(1.0); + processTouchEvent(event->PointerNumber(), event->iType, screenPos, pressure); +} +#endif +void QSymbianControl::processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure) +{ QRect screenGeometry = qApp->desktop()->screenGeometry(qwidget); - while (d->appAllTouchPoints.count() <= event->PointerNumber()) - d->appAllTouchPoints.append(QTouchEvent::TouchPoint(d->appAllTouchPoints.count())); + QApplicationPrivate *d = QApplicationPrivate::instance(); + + QList<QTouchEvent::TouchPoint> points = d->appAllTouchPoints; + while (points.count() <= pointerNumber) + points.append(QTouchEvent::TouchPoint(points.count())); Qt::TouchPointStates allStates = 0; - for (int i = 0; i < d->appAllTouchPoints.count(); ++i) { - QTouchEvent::TouchPoint &touchPoint = d->appAllTouchPoints[i]; + for (int i = 0; i < points.count(); ++i) { + QTouchEvent::TouchPoint &touchPoint = points[i]; - if (touchPoint.id() == event->PointerNumber()) { + if (touchPoint.id() == pointerNumber) { Qt::TouchPointStates state; - switch (event->iType) { + switch (type) { case TPointerEvent::EButton1Down: +#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER case TPointerEvent::EEnterHighPressure: +#endif state = Qt::TouchPointPressed; break; case TPointerEvent::EButton1Up: +#ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER case TPointerEvent::EExitCloseProximity: +#endif state = Qt::TouchPointReleased; break; case TPointerEvent::EDrag: @@ -445,16 +464,15 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent state = Qt::TouchPointStationary; break; } - if (event->PointerNumber() == 0) + if (pointerNumber == 0) state |= Qt::TouchPointPrimary; touchPoint.setState(state); - QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); touchPoint.setScreenPos(screenPos); touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), screenPos.y() / screenGeometry.height())); - touchPoint.setPressure(event->Pressure() / qreal(d->maxTouchPressure)); + touchPoint.setPressure(pressure); } else if (touchPoint.state() != Qt::TouchPointReleased) { // all other active touch points should be marked as stationary touchPoint.setState(Qt::TouchPointStationary); @@ -466,13 +484,14 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased) { // all touch points released d->appAllTouchPoints.clear(); + } else { + d->appAllTouchPoints = points; } QApplicationPrivate::translateRawTouchEvent(qwidget, QTouchEvent::TouchScreen, - d->appAllTouchPoints); + points); } -#endif void QSymbianControl::HandlePointerEventL(const TPointerEvent& pEvent) { @@ -546,6 +565,13 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) qt_symbian_move_cursor_sprite(); #endif +//Generate single touch event for S60 5.0 (has touchscreen, does not have advanced pointers) +#ifndef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER + if (S60->hasTouchscreen) { + processTouchEvent(0, pEvent.iType, QPointF(globalPos), 1.0); + } +#endif + sendMouseEvent(receiver, type, globalPos, button, modifiers); } @@ -2047,8 +2073,13 @@ TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym) void QApplicationPrivate::initializeMultitouch_sys() { #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER + if (HAL::Get(HALData::EPointer3DPressureSupported, pressureSupported) != KErrNone) + pressureSupported = 0; if (HAL::Get(HALData::EPointer3DMaxPressure, maxTouchPressure) != KErrNone) maxTouchPressure = KMaxTInt; +#else + pressureSupported = 0; + maxTouchPressure = KMaxTInt; #endif } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 232e9b3..fe3fa57 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -217,6 +217,7 @@ private: const QPoint &globalPos, Qt::MouseButton button, Qt::KeyboardModifiers modifiers); + void processTouchEvent(int pointerNumber, TPointerEvent::TType type, QPointF screenPos, qreal pressure); void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); |