-
-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathandroidtilt-qt5.diff
More file actions
72 lines (65 loc) · 3.54 KB
/
Copy pathandroidtilt-qt5.diff
File metadata and controls
72 lines (65 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Description: Tilt support for QTabletEvent on Android.
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -563,8 +563,20 @@
if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE) {
sendMouseEvent(event, id);
} else if (m_tabletEventSupported && pointerType != 0) {
+ int xtilt, ytilt;
+ double tilt = event.getAxisValue(MotionEvent.AXIS_TILT);
+ if (tilt == 0.0) {
+ xtilt = 0;
+ ytilt = 0;
+ } else {
+ double orientation = ((double)event.getOrientation()) - Math.PI / 2.0;
+ double tiltDegrees = Math.toDegrees(tilt);
+ xtilt = (int)Math.round(Math.cos(orientation) * tiltDegrees);
+ ytilt = (int)Math.round(-Math.sin(orientation) * tiltDegrees);
+ }
tabletEvent(id, event.getDeviceId(), event.getEventTime(), event.getAction(), pointerType,
- event.getButtonState(), event.getX(), event.getY(), event.getPressure());
+ event.getButtonState(), event.getX(), event.getY(), event.getPressure(),
+ xtilt, ytilt);
} else {
touchBegin(id);
for (int i = 0; i < event.getPointerCount(); ++i) {
@@ -1219,7 +1231,7 @@
// tablet methods
public static native boolean isTabletEventSupported();
- public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure);
+ public static native void tabletEvent(int winId, int deviceId, long time, int action, int pointerType, int buttonState, float x, float y, float pressure, int xtilt, int ytilt);
// tablet methods
// keyboard methods
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -327,7 +327,8 @@
}
static void tabletEvent(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint deviceId, jlong time, jint action,
- jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure)
+ jint pointerType, jint buttonState, jfloat x, jfloat y, jfloat pressure,
+ jint xtilt, jint ytilt)
{
#if QT_CONFIG(tabletevent)
QPointF globalPosF(x, y);
@@ -365,12 +366,13 @@
}
#ifdef QT_DEBUG_ANDROID_STYLUS
- qDebug() << action << pointerType << buttonState << '@' << x << y << "pressure" << pressure << ": buttons" << buttons;
+ qDebug() << action << pointerType << buttonState << '@' << x << y << "pressure" << pressure << "tilt" << xtilt << ytilt << ": buttons" << buttons;
#endif
QWindowSystemInterface::handleTabletEvent(tlw, ulong(time),
localPos, globalPosF, QTabletEvent::Stylus, pointerType,
- buttons, pressure, 0, 0, 0., 0., 0, deviceId, Qt::NoModifier);
+ buttons, pressure, qBound(-60, xtilt, 60), qBound(-60, ytilt, 60),
+ 0., 0., 0, deviceId, Qt::NoModifier);
#endif // QT_CONFIG(tabletevent)
}
@@ -875,7 +877,7 @@
{"mouseWheel", "(IIIFF)V", (void *)mouseWheel},
{"longPress", "(III)V", (void *)longPress},
{"isTabletEventSupported", "()Z", (void *)isTabletEventSupported},
- {"tabletEvent", "(IIJIIIFFF)V", (void *)tabletEvent},
+ {"tabletEvent", "(IIJIIIFFFII)V", (void *)tabletEvent},
{"keyDown", "(IIIZ)V", (void *)keyDown},
{"keyUp", "(IIIZ)V", (void *)keyUp},
{"keyboardVisibilityChanged", "(Z)V", (void *)keyboardVisibilityChanged},