=== modified file 'src/gui/kernel/qapplication_x11.cpp' --- src/gui/kernel/qapplication_x11.cpp 2011-09-08 11:33:52 +0000 +++ src/gui/kernel/qapplication_x11.cpp 2011-09-19 10:45:47 +0000 @@ -4898,20 +4898,40 @@ fetchWacomToolId(deviceType, uid); QRect screenArea = qApp->desktop()->rect(); + const unsigned char pressureIndex = 2; + const unsigned char xTiltIndex = 3; + const unsigned char yTiltIndex = 4; + const unsigned char rotationIndex = 5; if (motion) { - xTilt = (short) motion->axis_data[3]; - yTilt = (short) motion->axis_data[4]; - rotation = ((short) motion->axis_data[5]) / 64.0; - pressure = (short) motion->axis_data[2]; + const unsigned char firstAxis = motion->first_axis; + const unsigned char axesCount = motion->axes_count; + const unsigned char maxIndex = firstAxis + axesCount; + + if (xTiltIndex < maxIndex) + xTilt = (short) motion->axis_data[xTiltIndex - firstAxis]; + if (yTiltIndex < maxIndex) + yTilt = (short) motion->axis_data[yTiltIndex - firstAxis]; + if (rotationIndex < maxIndex) + rotation = ((short) motion->axis_data[rotationIndex - firstAxis]) / 64.0; + if (pressureIndex < maxIndex) + pressure = (short) motion->axis_data[pressureIndex - firstAxis]; modifiers = X11->translateModifiers(motion->state); hiRes = tablet->scaleCoord(motion->axis_data[0], motion->axis_data[1], screenArea.x(), screenArea.width(), screenArea.y(), screenArea.height()); } else if (button) { - xTilt = (short) button->axis_data[3]; - yTilt = (short) button->axis_data[4]; - rotation = ((short) button->axis_data[5]) / 64.0; - pressure = (short) button->axis_data[2]; + const unsigned char firstAxis = button->first_axis; + const unsigned char axesCount = button->axes_count; + const unsigned char maxIndex = firstAxis + axesCount; + + if (xTiltIndex < maxIndex) + xTilt = (short) button->axis_data[xTiltIndex - firstAxis]; + if (yTiltIndex < maxIndex) + yTilt = (short) button->axis_data[yTiltIndex - firstAxis]; + if (rotationIndex < maxIndex) + rotation = ((short) button->axis_data[rotationIndex - firstAxis]) / 64.0; + if (pressureIndex < maxIndex) + pressure = (short) button->axis_data[pressureIndex - firstAxis]; modifiers = X11->translateModifiers(button->state); hiRes = tablet->scaleCoord(button->axis_data[0], button->axis_data[1], screenArea.x(), screenArea.width(),