aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordhewg2011-04-06 18:08:38 +0200
committerdhewg2011-04-06 18:27:15 +0200
commita565e63c48b2bb55b9e1197addddd3c03cf85c48 (patch)
treeee64fe4f2e466d40b2e0d885dd7ed08a7b781d03
parentb45640c47b97c36442d01c35e73b4cae9ad5648e (diff)
downloadscummvm-rg350-a565e63c48b2bb55b9e1197addddd3c03cf85c48.tar.gz
scummvm-rg350-a565e63c48b2bb55b9e1197addddd3c03cf85c48.tar.bz2
scummvm-rg350-a565e63c48b2bb55b9e1197addddd3c03cf85c48.zip
ANDROID: Add multitouch support
-rw-r--r--backends/platform/android/android.cpp1
-rw-r--r--backends/platform/android/android.h1
-rw-r--r--backends/platform/android/events.cpp60
-rw-r--r--backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java15
-rw-r--r--dists/android/README.Android5
5 files changed, 79 insertions, 3 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index ab3f1908c4..bbfdb06b8d 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -132,6 +132,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
_touchpad_mode(true),
_touchpad_scale(66),
_dpad_scale(4),
+ _fingersDown(0),
_trackball_scale(2) {
Common::String mf = getSystemProperty("ro.product.manufacturer");
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index f3d989c3f8..6eebdb97d9 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -234,6 +234,7 @@ private:
int _touchpad_scale;
int _trackball_scale;
int _dpad_scale;
+ int _fingersDown;
void clipMouse(Common::Point &p);
void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true);
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index ed825dbc9c..09466b4d2f 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -43,7 +43,8 @@ enum {
JE_SCROLL = 4,
JE_TAP = 5,
JE_DOUBLE_TAP = 6,
- JE_BALL = 7,
+ JE_MULTI = 7,
+ JE_BALL = 8,
JE_QUIT = 0x1000
};
@@ -51,7 +52,9 @@ enum {
enum {
JACTION_DOWN = 0,
JACTION_UP = 1,
- JACTION_MULTIPLE = 2
+ JACTION_MULTIPLE = 2,
+ JACTION_POINTER_DOWN = 5,
+ JACTION_POINTER_UP = 6
};
// system keys
@@ -549,6 +552,11 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
case JE_TAP:
+ if (_fingersDown > 0) {
+ _fingersDown = 0;
+ return;
+ }
+
e.type = Common::EVENT_MOUSEMOVE;
if (_touchpad_mode) {
@@ -643,6 +651,54 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
+ case JE_MULTI:
+ switch (arg2) {
+ case JACTION_POINTER_DOWN:
+ if (arg1 > _fingersDown)
+ _fingersDown = arg1;
+
+ return;
+
+ case JACTION_POINTER_UP:
+ if (arg1 != _fingersDown)
+ return;
+
+ {
+ Common::EventType up;
+
+ switch (_fingersDown) {
+ case 1:
+ e.type = Common::EVENT_RBUTTONDOWN;
+ up = Common::EVENT_RBUTTONUP;
+ break;
+ case 2:
+ e.type = Common::EVENT_MBUTTONDOWN;
+ up = Common::EVENT_MBUTTONUP;
+ break;
+ default:
+ LOGD("unmapped multi tap: %d", _fingersDown);
+ return;
+ }
+
+ e.mouse = getEventManager()->getMousePos();
+
+ lockMutex(_event_queue_lock);
+
+ _event_queue.push(e);
+ e.type = up;
+ _event_queue.push(e);
+
+ unlockMutex(_event_queue_lock);
+ return;
+
+ default:
+ LOGE("unhandled jaction on multi tap: %d", arg2);
+ return;
+ }
+ }
+
+ return;
+
case JE_BALL:
e.mouse = getEventManager()->getMousePos();
diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
index 8182f194a8..2d5c100a1c 100644
--- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
@@ -25,7 +25,8 @@ public class ScummVMEvents implements
public static final int JE_SCROLL = 4;
public static final int JE_TAP = 5;
public static final int JE_DOUBLE_TAP = 6;
- public static final int JE_BALL = 7;
+ public static final int JE_MULTI = 7;
+ public static final int JE_BALL = 8;
public static final int JE_QUIT = 0x1000;
final protected Context _context;
@@ -160,6 +161,18 @@ public class ScummVMEvents implements
// OnTouchListener
final public boolean onTouch(View v, MotionEvent e) {
+ final int action = e.getAction();
+
+ // constants from APIv5:
+ // (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT
+ final int pointer = (action & 0xff00) >> 8;
+
+ if (pointer > 0) {
+ _scummvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK
+ (int)e.getX(), (int)e.getY(), 0);
+ return true;
+ }
+
return _gd.onTouchEvent(e);
}
diff --git a/dists/android/README.Android b/dists/android/README.Android
index 7bc8b2ef88..550b73bdfa 100644
--- a/dists/android/README.Android
+++ b/dists/android/README.Android
@@ -42,6 +42,11 @@ CONTROLS
Tap held for >1s without movement: Middle mouse button click
Double Tap + movement: Drag and drop
+ On devices supporting multitouch:
+
+ Two finger tap: Right mouse button click
+ Three finger tap: Middle mouse button click
+
System keys
Back button: Escape