Commit 543482d4 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix tablet stylus rotation on Linux

The Windows part will be fixed during the upcoming sprint.

CCBUG:331358
parent 6e252b0d
......@@ -43,7 +43,7 @@ public:
KisDynamicSensorRotation();
virtual ~KisDynamicSensorRotation() { }
virtual qreal value(const KisPaintInformation& info) {
return info.rotation() / 28 + 0.5; // it appears that rotation is between -14 and +14
return info.rotation() / 360.0;
}
};
......
......@@ -43,6 +43,8 @@ struct QTabletDeviceData
int minTanPressure;
int maxTanPressure;
int minX, maxX, minY, maxY, minZ, maxZ;
int minRotation;
int maxRotation;
inline QPointF scaleCoord(int coordX, int coordY, int outOriginX, int outExtentX,
int outOriginY, int outExtentY) const;
#endif
......@@ -142,7 +144,7 @@ struct QTabletDeviceData
}
inline int rotation() const {
return m_axis_data[Rotation] / 64;
return m_axis_data[Rotation];
}
bool updateAxesData(int firstAxis, int axesCount, const int axes[NAxes]) {
......
......@@ -235,6 +235,9 @@ static void tabletInit(const quint64 uniqueId, const UINT csr_type, HCTX hTab)
qt_tablet_tilt_support = tpOri[0].axResolution && tpOri[1].axResolution;
}
tdd.minRotation = 0;
tdd.maxRotation = int(tpOri[2].axResolution);
tdd.minX = int(lc.lcOutOrgX);
tdd.maxX = int(qAbs(lc.lcOutExtX)) + int(lc.lcOutOrgX);
......@@ -462,7 +465,12 @@ bool translateTabletEvent(const MSG &msg, PACKET *localPacketBuf,
double degY = atan(cos(radAzim) / tanAlt);
tiltX = int(degX * (180 / Q_PI));
tiltY = int(-degY * (180 / Q_PI));
rotation = ort.orTwist;
// FIXME: rotation support is not finished yet!
rotation = qreal(ort.orTwist - currentTabletPointer.minRotation) /
(currentTabletPointer.maxRotation - currentTabletPointer.minRotation) * 360.0;
//qDebug() << "Rotation" << ppVar(rotation) << ppVar(ort.orTwist) << ppVar(currentTabletPointer.minRotation) << ppVar(currentTabletPointer.maxRotation);
}
KisTabletEvent e(t, localPos, globalPos, hiResGlobal, currentTabletPointer.currentDevice,
......
......@@ -405,6 +405,8 @@ void kis_x11_init_tablet()
device_data.maxTanPressure = 0;
device_data.minZ = 0;
device_data.maxZ = 0;
device_data.minRotation = a[5].min_value;
device_data.maxRotation = a[5].max_value;
#endif
// got the max pressure no need to go further...
......@@ -611,7 +613,8 @@ bool translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet, QWidget *
pressure = tablet->savedAxesData.pressure();
xTilt = tablet->savedAxesData.xTilt();
yTilt = tablet->savedAxesData.yTilt();
rotation = tablet->savedAxesData.rotation();
rotation = qreal(tablet->savedAxesData.rotation() - tablet->minRotation) /
(tablet->maxRotation - tablet->minRotation) * 360.0;
} else if (button) {
// see the comment in 'motion' branch
......@@ -625,7 +628,8 @@ bool translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet, QWidget *
pressure = tablet->savedAxesData.pressure();
xTilt = tablet->savedAxesData.xTilt();
yTilt = tablet->savedAxesData.yTilt();
rotation = tablet->savedAxesData.rotation();
rotation = qreal(tablet->savedAxesData.rotation() - tablet->minRotation) /
(tablet->maxRotation - tablet->minRotation) * 360.0;
}
if (deviceType == QTabletEvent::Airbrush) {
tangentialPressure = rotation;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment