[Scummvm-cvs-logs] scummvm master -> a565e63c48b2bb55b9e1197addddd3c03cf85c48

dhewg dhewg at wiibrew.org
Wed Apr 6 18:28:51 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a565e63c48 ANDROID: Add multitouch support


Commit: a565e63c48b2bb55b9e1197addddd3c03cf85c48
    https://github.com/scummvm/scummvm/commit/a565e63c48b2bb55b9e1197addddd3c03cf85c48
Author: dhewg (dhewg at wiibrew.org)
Date: 2011-04-06T09:27:15-07:00

Commit Message:
ANDROID: Add multitouch support

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/events.cpp
    backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
    dists/android/README.Android



diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index ab3f190..bbfdb06 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 f3d989c..6eebdb9 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 ed825db..09466b4 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 8182f19..2d5c100 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 7bc8b2e..550b73b 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






More information about the Scummvm-git-logs mailing list