From 5e907919d77fec0a92905d29764a56ee282cfcee Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 6 Mar 2013 18:01:37 +0100 Subject: Android: Allow more than three touch points Now that we do not support Android versions below API level 9, we can use the modern multi-touch functions. Change-Id: I5887b4c35f9e02089a334526cebecf0cf767bd6c Reviewed-by: BogDan Vatra Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../src/org/qtproject/qt5/android/QtNative.java | 48 ++++------------------ 1 file changed, 7 insertions(+), 41 deletions(-) (limited to 'src/android/jar') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 346bc1221a..7cb3fdff45 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -279,10 +279,10 @@ public class QtNative }); } - //@ANDROID-5 + //@ANDROID-9 static private int getAction(int index, MotionEvent event) { - int action = event.getAction(); + int action = event.getActionMasked(); if (action == MotionEvent.ACTION_MOVE) { int hsz = event.getHistorySize(); if (hsz > 0) { @@ -295,48 +295,14 @@ public class QtNative } return 1; } - - switch (index) { - case 0: - if (action == MotionEvent.ACTION_DOWN - || action == MotionEvent.ACTION_POINTER_1_DOWN) { - return 0; - } - - if (action == MotionEvent.ACTION_UP - || action == MotionEvent.ACTION_POINTER_1_UP) { - return 3; - } - break; - - case 1: - if (action == MotionEvent.ACTION_POINTER_2_DOWN - || action == MotionEvent.ACTION_POINTER_DOWN) { - return 0; - } - - if (action == MotionEvent.ACTION_POINTER_2_UP - || action == MotionEvent.ACTION_POINTER_UP) { - return 3; - } - break; - - case 2: - if (action == MotionEvent.ACTION_POINTER_3_DOWN - || action == MotionEvent.ACTION_POINTER_DOWN) { - return 0; - } - - if (action == MotionEvent.ACTION_POINTER_3_UP - || action == MotionEvent.ACTION_POINTER_UP) { - return 3; - } - - break; + if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN && index == event.getActionIndex()) { + return 0; + } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP && index == event.getActionIndex()) { + return 3; } return 2; } - //@ANDROID-5 + //@ANDROID-9 static public void sendTouchEvent(MotionEvent event, int id) { -- cgit v1.2.3