[Scummvm-cvs-logs] scummvm master -> 4763b2c51b4c73dae4340993fc9b71200bcdbe28

fuzzie fuzzie at fuzzie.org
Fri Feb 3 12:39:14 CET 2012


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:
4763b2c51b ANDROID: Add faked input delay.


Commit: 4763b2c51b4c73dae4340993fc9b71200bcdbe28
    https://github.com/scummvm/scummvm/commit/4763b2c51b4c73dae4340993fc9b71200bcdbe28
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2012-02-03T03:36:03-08:00

Commit Message:
ANDROID: Add faked input delay.

This adds an artificial delay for mouse up events to make engines
like Gob work, similar to the iPhone fix in b3062b5e.

Changed paths:
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/events.cpp



diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index aba3132..902599d 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -134,6 +134,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) :
 	_enable_zoning(false),
 	_mixer(0),
 	_shake_offset(0),
+	_queuedEventTime(0),
 	_event_queue_lock(createMutex()),
 	_touch_pt_down(),
 	_touch_pt_scroll(),
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index f39a8f1..47a6515 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -220,6 +220,8 @@ public:
 
 private:
 	Common::Queue<Common::Event> _event_queue;
+	Common::Event _queuedEvent;
+	uint32 _queuedEventTime;
 	MutexRef _event_queue_lock;
 
 	Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt;
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index e73e689..b46c144 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -216,6 +216,8 @@ static inline T scalef(T in, float numerator, float denominator) {
 	return static_cast<float>(in) * numerator / denominator;
 }
 
+static const int kQueuedInputEventDelay = 50;
+
 void OSystem_Android::setupKeymapper() {
 #ifdef ENABLE_KEYMAPPER
 	using namespace Common;
@@ -601,13 +603,18 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 
 			lockMutex(_event_queue_lock);
 
+			if (_queuedEventTime)
+				_event_queue.push(_queuedEvent);
+
 			if (!_touchpad_mode)
 				_event_queue.push(e);
 
 			e.type = down;
 			_event_queue.push(e);
+
 			e.type = up;
-			_event_queue.push(e);
+			_queuedEvent = e;
+			_queuedEventTime = getMillis() + kQueuedInputEventDelay;
 
 			unlockMutex(_event_queue_lock);
 		}
@@ -702,9 +709,14 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 
 				lockMutex(_event_queue_lock);
 
+				if (_queuedEventTime)
+					_event_queue.push(_queuedEvent);
+
 				_event_queue.push(e);
+
 				e.type = up;
-				_event_queue.push(e);
+				_queuedEvent = e;
+				_queuedEventTime = getMillis() + kQueuedInputEventDelay;
 
 				unlockMutex(_event_queue_lock);
 				return;
@@ -800,6 +812,13 @@ bool OSystem_Android::pollEvent(Common::Event &event) {
 
 	lockMutex(_event_queue_lock);
 
+	if (_queuedEventTime && (getMillis() > _queuedEventTime)) {
+		event = _queuedEvent;
+		_queuedEventTime = 0;
+		unlockMutex(_event_queue_lock);
+		return true;
+	}
+
 	if (_event_queue.empty()) {
 		unlockMutex(_event_queue_lock);
 		return false;






More information about the Scummvm-git-logs mailing list