From 091ca0ede21b62a55893307018722b384052c642 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Sep 2013 16:37:59 +0200 Subject: [PATCH] evdevtouch: Fix ABS limit queries Add the missing parentheses around the conditional expression. EVIOCGABS and similar macros do not have guarding parentheses in older kernel headers. Change-Id: I5f464351e9407d90643d4e73d4afdbb2ad88b02b Reviewed-by: Gunnar Sletta --- .../input/evdevtouch/qevdevtouch.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp index a7502fbcc0..176373e9f9 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp @@ -254,16 +254,25 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, input_absinfo absInfo; memset(&absInfo, 0, sizeof(input_absinfo)); - if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X), &absInfo) >= 0) { + bool has_x_range = false, has_y_range = false; + + if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_X : ABS_MT_POSITION_X)), &absInfo) >= 0) { qDebug("min X: %d max X: %d", absInfo.minimum, absInfo.maximum); d->hw_range_x_min = absInfo.minimum; d->hw_range_x_max = absInfo.maximum; + has_x_range = true; } - if (ioctl(m_fd, EVIOCGABS(d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y), &absInfo) >= 0) { + + if (ioctl(m_fd, EVIOCGABS((d->m_singleTouch ? ABS_Y : ABS_MT_POSITION_Y)), &absInfo) >= 0) { qDebug("min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum); d->hw_range_y_min = absInfo.minimum; d->hw_range_y_max = absInfo.maximum; + has_y_range = true; } + + if (!has_x_range || !has_y_range) + qWarning("evdevtouch: Invalid ABS limits, behavior unspecified"); + if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) { qDebug("min pressure: %d max pressure: %d", absInfo.minimum, absInfo.maximum); if (absInfo.maximum > absInfo.minimum) {