--- src/gui/kernel/qapplication_x11.cpp 2011-09-22 22:19:49.000000000 +0200 +++ src/gui/kernel/qapplication_x11.cpp 2011-09-22 22:20:24.298626927 +0200 @@ -4737,6 +4737,13 @@ return false; } +static int previousXLoc = 0; +static int previousYLoc = 0; +static int previousXTilt = 0; +static int previousYTilt = 0; +static qreal previousPressure = 0; +static qreal previousRotation = 0; + bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet) { #if defined (Q_OS_IRIX) @@ -4755,12 +4762,14 @@ QPoint global, curr; QPointF hiRes; - qreal pressure = 0; - int xTilt = 0, - yTilt = 0, + qreal pressure = previousPressure; + int xTilt = previousXTilt, + yTilt = previousYTilt, + xLoc = previousXLoc, + yLoc = previousYLoc, z = 0; qreal tangentialPressure = 0; - qreal rotation = 0; + qreal rotation = previousRotation; int deviceType = QTabletEvent::NoDevice; int pointerType = QTabletEvent::UnknownPointer; const XDeviceMotionEvent *motion = 0; @@ -4898,22 +4907,56 @@ fetchWacomToolId(deviceType, uid); QRect screenArea = qApp->desktop()->rect(); + const unsigned char xIndex = 0; + const unsigned char yIndex = 1; + 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 (xIndex >= firstAxis && xIndex < maxIndex) + xLoc = motion->axis_data[xIndex]; + if (yIndex >= firstAxis && yIndex < maxIndex) + yLoc = motion->axis_data[yIndex - firstAxis]; + if (xTiltIndex >= firstAxis && xTiltIndex < maxIndex) + xTilt = (short) motion->axis_data[xTiltIndex - firstAxis]; + if (yTiltIndex >= firstAxis && yTiltIndex < maxIndex) + yTilt = (short) motion->axis_data[yTiltIndex - firstAxis]; + if (rotationIndex >= firstAxis && rotationIndex < maxIndex) + rotation = ((short) motion->axis_data[rotationIndex - firstAxis]) / 64.0; + if (pressureIndex >= firstAxis && 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], + hiRes = tablet->scaleCoord(xLoc, yLoc, 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 (xIndex >= firstAxis && xIndex < maxIndex) + xLoc = button->axis_data[xIndex]; + if (yIndex >= firstAxis && yIndex < maxIndex) + yLoc = button->axis_data[yIndex - firstAxis]; + if (xTiltIndex >= firstAxis && xTiltIndex < maxIndex) + xTilt = (short) button->axis_data[xTiltIndex - firstAxis]; + if (yTiltIndex >= firstAxis && yTiltIndex < maxIndex) + yTilt = (short) button->axis_data[yTiltIndex - firstAxis]; + if (rotationIndex >= firstAxis && rotationIndex < maxIndex) + rotation = ((short) button->axis_data[rotationIndex - firstAxis]) / 64.0; + if (pressureIndex >= firstAxis && 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], + hiRes = tablet->scaleCoord(xLoc, yLoc, screenArea.x(), screenArea.width(), screenArea.y(), screenArea.height()); } else if (proximity) { @@ -4947,6 +4990,12 @@ deviceType, pointerType, qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)), xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid); + previousXLoc = xLoc; + previousYLoc = yLoc; + previousXTilt = xTilt; + previousYTilt = yTilt; + previousPressure = pressure; + previousRotation = rotation; if (proximity) { QApplication::sendSpontaneousEvent(qApp, &e); } else {