Detect wrongly labelled wheel buttons

A mouse device with both missing labels and a wrongly placed label
on the mouse wheel buttons have been spotted.

This patch makes the XInput2 code even more lenient to better match
legacy systems that always assumed button 4 and 5 are mapped that way.

Task-number: QTBUG-40806
Change-Id: I7cc52f3d9c54e15e6f3ddcc2bdeb1bb8e0ac9eca
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
Allan Sandfeld Jensen 2014-08-19 14:45:45 +02:00 committed by Shawn Rutledge
parent 1bae226076
commit 29787ec29c

View File

@ -164,7 +164,10 @@ void QXcbConnection::xi2SetupDevices()
if (bci->num_buttons >= 5) {
Atom label4 = bci->labels[3];
Atom label5 = bci->labels[4];
if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp) && (!label5 || qatom(label5) == QXcbAtom::ButtonWheelDown))
// Some drivers have no labels on the wheel buttons, some have no label on just one and some have no label on
// button 4 and the wrong one on button 5. So we just check that they are not labelled with unrelated buttons.
if ((!label4 || qatom(label4) == QXcbAtom::ButtonWheelUp || qatom(label4) == QXcbAtom::ButtonWheelDown) &&
(!label5 || qatom(label5) == QXcbAtom::ButtonWheelUp || qatom(label5) == QXcbAtom::ButtonWheelDown))
scrollingDevice.legacyOrientations |= Qt::Vertical;
}
if (bci->num_buttons >= 7) {