diff options
author | Laszlo Agocs <laszlo.p.agocs@nokia.com> | 2012-06-02 23:18:05 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-04 09:26:09 +0200 |
commit | b6535f65e1fa35a7088bdb577bfd828295ef4b88 (patch) | |
tree | b3eca11740ab99d15f6178421e4be5c5dde55461 /src/platformsupport/input | |
parent | d0b4c7b159a934dfd042b981f247388014d960af (diff) |
Fix touchpads with evdevmouse
evdevmouse only worked properly with real mice, the ABS event handling
was somewhat broken, it wasn't possible to properly move a mouse cursor
with a touchpad due to unwanted jumps. The button handling is also
corrected.
Change-Id: Id04ef65d867a75bcfc54240d192a78224a4481d6
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/platformsupport/input')
-rw-r--r-- | src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp | 17 | ||||
-rw-r--r-- | src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index e435f40c2d..554e70bc44 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -91,7 +91,7 @@ QEvdevMouseHandler *QEvdevMouseHandler::create(const QString &device, const QStr QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool compression, int jitterLimit) : m_device(device), m_fd(fd), m_notify(0), m_x(0), m_y(0), m_prevx(0), m_prevy(0), - m_compression(compression), m_buttons(0) + m_compression(compression), m_buttons(0), m_prevInvalid(true) { setObjectName(QLatin1String("Evdev Mouse Handler")); @@ -111,7 +111,14 @@ QEvdevMouseHandler::~QEvdevMouseHandler() void QEvdevMouseHandler::sendMouseEvent() { - emit handleMouseEvent(m_x - m_prevx, m_y - m_prevy, m_buttons); + int x = m_x - m_prevx; + int y = m_y - m_prevy; + if (m_prevInvalid) { + x = y = 0; + m_prevInvalid = false; + } + + emit handleMouseEvent(x, y, m_buttons); m_prevx = m_x; m_prevy = m_y; @@ -148,6 +155,7 @@ void QEvdevMouseHandler::readMouseData() struct ::input_event *data = &buffer[i]; //qDebug() << ">>" << hex << data->type << data->code << dec << data->value; if (data->type == EV_ABS) { + // Touchpads: store the absolute position for now, will calculate a relative one later. if (data->code == ABS_X && m_x != data->value) { m_x = data->value; posChanged = true; @@ -176,8 +184,9 @@ void QEvdevMouseHandler::readMouseData() delta, Qt::Horizontal); } } else if (data->type == EV_KEY && data->code == BTN_TOUCH) { - m_buttons = data->value ? Qt::LeftButton : Qt::NoButton; - btnChanged = true; + // We care about touchpads only, not touchscreens -> don't map to button press. + // Need to invalidate prevx/y however to get proper relative pos. + m_prevInvalid = true; } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_JOYSTICK) { Qt::MouseButton button = Qt::NoButton; // BTN_LEFT == 0x110 in kernel's input.h diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 38ee312372..4b6ec1bb94 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -77,6 +77,7 @@ private: bool m_compression; Qt::MouseButtons m_buttons; int m_jitterLimitSquared; + bool m_prevInvalid; }; QT_END_NAMESPACE |