summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp17
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h1
-rw-r--r--src/plugins/generic/evdevmouse/README5
3 files changed, 18 insertions, 5 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
diff --git a/src/plugins/generic/evdevmouse/README b/src/plugins/generic/evdevmouse/README
index b89c0a7066..76ee76bc91 100644
--- a/src/plugins/generic/evdevmouse/README
+++ b/src/plugins/generic/evdevmouse/README
@@ -1,4 +1,4 @@
-Generic plug-in for absolute & relative evdev pointer events.
+Generic plug-in for relative evdev pointer events.
To use it, launch apps with -plugin EvdevMouse
@@ -9,3 +9,6 @@ EvdevMouse:/dev/input/eventN to explicitly set the device node.
The initial cursor position is assumed to be (0, 0). Relative events
will generate Qt mouse events with screen positions relative to this
initial position.
+
+Touchpads reporting absolute events will work too, the positions will
+be turned into relative. Touchscreens are however not supported.