summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorMikko Harju <mikko.harju@jolla.com>2013-06-03 15:26:27 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-06 10:11:32 +0200
commitfdde071b06cd19f41de01f4ffdb9fdeef3c20914 (patch)
tree5f866dd5829afc534fae305e7517e5ca02480ca3 /src/platformsupport
parentc9398312fefcbb8d519c73346fa9876c8c05a3d9 (diff)
Added rotation parameter to qevdevtouch
In some cases the event coordinates reported by evdev are in different orientation compared to the primary orientation of the platform window. This commit adds plugin parameter rotate=[90, 180, 270] to rotate the normalized coordinate system before reporting the touch event. Change-Id: Ic830a2d259f9d3c5fb63b80afb795d8b400c2ece Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouch.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
index b05ea0de59..5e493ac68c 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp
@@ -125,6 +125,7 @@ public:
bool m_forceToActiveWindow;
QTouchDevice *m_device;
bool m_typeB;
+ QTransform m_rotate;
};
QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args)
@@ -177,10 +178,24 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
QStringList args = spec.split(QLatin1Char(':'));
+ int rotationAngle = 0;
for (int i = 0; i < args.count(); ++i) {
- if (args.at(i).startsWith(QLatin1String("/dev/"))) {
+ if (args.at(i).startsWith(QLatin1String("/dev/")) && dev.isEmpty()) {
dev = args.at(i);
- break;
+ } else if (args.at(i).startsWith(QLatin1String("rotate"))) {
+ QString rotateArg = args.at(i).section(QLatin1Char('='), 1, 1);
+ bool ok;
+ uint argValue = rotateArg.toUInt(&ok);
+ if (ok) {
+ switch (argValue) {
+ case 90:
+ case 180:
+ case 270:
+ rotationAngle = argValue;
+ default:
+ break;
+ }
+ }
}
}
@@ -265,6 +280,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification,
#endif
qDebug("Protocol type %c %s", d->m_typeB ? 'B' : 'A', mtdevStr);
+ if (rotationAngle)
+ d->m_rotate = QTransform::fromTranslate(0.5, 0.5).rotate(rotationAngle).translate(-0.5, -0.5);
+
d->registerDevice();
}
@@ -421,6 +439,9 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
tp.normalPosition = QPointF((contact.x - hw_range_x_min) / qreal(hw_range_x_max - hw_range_x_min),
(contact.y - hw_range_y_min) / qreal(hw_range_y_max - hw_range_y_min));
+ if (!m_rotate.isIdentity())
+ tp.normalPosition = m_rotate.map(tp.normalPosition);
+
tp.rawPositions.append(QPointF(contact.x, contact.y));
m_touchPoints.append(tp);