From d505886dd696d0f01bb64cbc7a1191d960d4d060 Mon Sep 17 00:00:00 2001 From: Rick Stockton Date: Wed, 29 Feb 2012 23:56:34 -0800 Subject: [PATCH] Support 16+4 mouse buttons within the generic/evdevmouse plugin. The Kernel's evdev module is capable of presenting up to 16 mouse buttons, plus wheel events (UP, DOWN, LEFT, and RIGHT). This patch updates our Plugin, so that it tranlates all of those button numbers into corresponding MouseEvent Qt::MouseButton values. Task-number: QTBUG-24590 Change-Id: Ib8cbb9500280c76f06a51ce95095e22ae84de1c6 Reviewed-by: Laszlo Agocs --- .../generic/evdevmouse/qevdevmouse.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/plugins/generic/evdevmouse/qevdevmouse.cpp b/src/plugins/generic/evdevmouse/qevdevmouse.cpp index 0b72123c02..be779c68a5 100644 --- a/src/plugins/generic/evdevmouse/qevdevmouse.cpp +++ b/src/plugins/generic/evdevmouse/qevdevmouse.cpp @@ -176,12 +176,27 @@ void QEvdevMouseHandler::readMouseData() sendMouseEvent(); pendingMouseEvent = false; - } else if (data->type == EV_KEY && data->code >= BTN_LEFT && data->code <= BTN_MIDDLE) { + } 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 + // The range of possible mouse buttons ends just before BTN_JOYSTICK, value 0x120. switch (data->code) { - case BTN_LEFT: button = Qt::LeftButton; break; - case BTN_MIDDLE: button = Qt::MidButton; break; - case BTN_RIGHT: button = Qt::RightButton; break; + case 0x110: button = Qt::LeftButton; break; // BTN_LEFT + case 0x111: button = Qt::RightButton; break; + case 0x112: button = Qt::MiddleButton; break; + case 0x113: button = Qt::ExtraButton1; break; // AKA Qt::BackButton + case 0x114: button = Qt::ExtraButton2; break; // AKA Qt::ForwardButton + case 0x115: button = Qt::ExtraButton3; break; // AKA Qt::TaskButton + case 0x116: button = Qt::ExtraButton4; break; + case 0x117: button = Qt::ExtraButton5; break; + case 0x118: button = Qt::ExtraButton6; break; + case 0x119: button = Qt::ExtraButton7; break; + case 0x11a: button = Qt::ExtraButton8; break; + case 0x11b: button = Qt::ExtraButton9; break; + case 0x11c: button = Qt::ExtraButton10; break; + case 0x11d: button = Qt::ExtraButton11; break; + case 0x11e: button = Qt::ExtraButton12; break; + case 0x11f: button = Qt::ExtraButton13; break; } if (data->value) m_buttons |= button;