summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_s60.cpp
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-05-20 09:25:47 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2010-05-21 08:28:30 (GMT)
commit24b811e53b30546279346ab7b16799be119ab8c4 (patch)
treee0741ca6d71c9c01d343c51ed2896aa674841393 /src/gui/kernel/qapplication_s60.cpp
parent1f1ff85bb9841d1b040b25af9a5c99a5c1f87e58 (diff)
downloadQt-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
Diffstat (limited to 'src/gui/kernel/qapplication_s60.cpp')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp53
1 files changed, 42 insertions, 11 deletions
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
}