[Scummvm-git-logs] scummvm master -> 36418c7ebdcb970186c475bd8f17eacee59a5968

lephilousophe noreply at scummvm.org
Thu Jul 6 18:55:14 UTC 2023


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

Summary:
c2ee0fb250 ANDROID: Notify user when a touch will trigger a right or middle click
36418c7ebd ANDROID: Increase timeout to trigger middle click to 1.5s


Commit: c2ee0fb25028562094c810bf3cd2e8e0932aa6fe
    https://github.com/scummvm/scummvm/commit/c2ee0fb25028562094c810bf3cd2e8e0932aa6fe
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-07-06T20:54:29+02:00

Commit Message:
ANDROID: Notify user when a touch will trigger a right or middle click

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index ab5ffe2e751..cbf7242c916 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -12,6 +12,7 @@ import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewConfiguration;
 import android.view.GestureDetector;
+import android.view.HapticFeedbackConstants;
 import android.view.InputDevice;
 //import android.view.inputmethod.InputMethodManager;
 
@@ -73,6 +74,7 @@ public class ScummVMEventsBase implements
 	final protected MouseHelper _mouseHelper;
 	final protected MultitouchHelper _multitouchHelper;
 
+	protected View _currentView;
 	protected int _touchMode;
 
 	// Custom handler code (to avoid mem leaks, see warning "This Handler Class Should Be Static Or Leaks Might Occur”) based on:
@@ -99,7 +101,7 @@ public class ScummVMEventsBase implements
 		}
 	}
 
-	final private ScummVMEventHandler _skeyHandler = new ScummVMEventHandler(this);
+	final private ScummVMEventHandler _handler = new ScummVMEventHandler(this);
 
 //	/**
 //	 * An example getter to provide it to some external class
@@ -126,6 +128,10 @@ public class ScummVMEventsBase implements
 		_longPressTimeout = ViewConfiguration.getLongPressTimeout();
 	}
 
+	final static int MSG_SMENU_LONG_PRESS = 1;
+	final static int MSG_SBACK_LONG_PRESS = 2;
+	final static int MSG_LONG_TOUCH_EVENT = 3;
+
 	private void handleEVHMessage(final Message msg) {
 		if (msg.what == MSG_SMENU_LONG_PRESS) {
 			// this toggles the android keyboard (see showVirtualKeyboard() in ScummVMActivity.java)
@@ -151,6 +157,8 @@ public class ScummVMEventsBase implements
 			                   0,
 			                   0,
 			                   0);
+		} else if (msg.what == MSG_LONG_TOUCH_EVENT) {
+			_currentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
 		}
 	}
 
@@ -187,7 +195,7 @@ public class ScummVMEventsBase implements
 	}
 
 	public void clearEventHandler() {
-		_skeyHandler.clear();
+		_handler.clear();
 		_multitouchHelper.clearEventHandler();
 	}
 
@@ -209,9 +217,6 @@ public class ScummVMEventsBase implements
 		return false;
 	}
 
-	final static int MSG_SMENU_LONG_PRESS = 1;
-	final static int MSG_SBACK_LONG_PRESS = 2;
-
 	// OnKeyListener
 	@Override
 	final public boolean onKey(View v, int keyCode, KeyEvent e) {
@@ -233,6 +238,7 @@ public class ScummVMEventsBase implements
 //		}
 //		Log.d(ScummVM.LOG_TAG, "SCUMMV-EVENTS-BASE - onKEY:::" + keyCode + " Action::" + actionStr); // Called
 
+		_currentView = v;
 		final int action = e.getAction();
 
 		int eventUnicodeChar = e.getUnicodeChar();
@@ -305,12 +311,12 @@ public class ScummVMEventsBase implements
 					typeOfLongPressMessage = MSG_SBACK_LONG_PRESS;
 				}
 
-				final boolean fired = !_skeyHandler.hasMessages(typeOfLongPressMessage);
+				final boolean fired = !_handler.hasMessages(typeOfLongPressMessage);
 
-				_skeyHandler.removeMessages(typeOfLongPressMessage);
+				_handler.removeMessages(typeOfLongPressMessage);
 
 				if (action == KeyEvent.ACTION_DOWN) {
-					_skeyHandler.sendMessageDelayed(_skeyHandler.obtainMessage(typeOfLongPressMessage), _longPressTimeout);
+					_handler.sendMessageDelayed(_handler.obtainMessage(typeOfLongPressMessage), _longPressTimeout);
 					return true;
 				} else if (action != KeyEvent.ACTION_UP) {
 					return true;
@@ -495,6 +501,7 @@ public class ScummVMEventsBase implements
 		//         as noted here:
 		//         https://stackoverflow.com/a/11709964
 
+		_currentView = v;
 		final int action = event.getAction();
 
 		// Get the index of the pointer associated with the action.
@@ -560,6 +567,7 @@ public class ScummVMEventsBase implements
 			// Deal with LINT warning "ScummVMEvents#onTouch should call View#performClick when a click is detected"
 			switch (action) {
 				case MotionEvent.ACTION_UP:
+					_handler.removeMessages(MSG_LONG_TOUCH_EVENT);
 					v.performClick();
 					break;
 				case MotionEvent.ACTION_DOWN:
@@ -594,6 +602,7 @@ public class ScummVMEventsBase implements
 		//										e1.toString(), e2.toString(),
 		//										velocityX, velocityY));
 
+		_handler.removeMessages(MSG_LONG_TOUCH_EVENT);
 		return true;
 	}
 
@@ -605,6 +614,7 @@ public class ScummVMEventsBase implements
 	@Override
 	final public boolean onScroll(MotionEvent e1, MotionEvent e2,
 									float distanceX, float distanceY) {
+		_handler.removeMessages(MSG_LONG_TOUCH_EVENT);
 //		Log.d(ScummVM.LOG_TAG, "onScroll");
 		if (_touchMode != TOUCH_MODE_GAMEPAD) {
 			// typical use:
@@ -618,6 +628,11 @@ public class ScummVMEventsBase implements
 
 	@Override
 	final public void onShowPress(MotionEvent e) {
+		_handler.removeMessages(MSG_LONG_TOUCH_EVENT);
+		// Schedule a Right click notification
+		_handler.sendMessageAtTime(_handler.obtainMessage(MSG_LONG_TOUCH_EVENT, 0, 0), e.getDownTime() + 500);
+		// Middle click
+		_handler.sendMessageAtTime(_handler.obtainMessage(MSG_LONG_TOUCH_EVENT, 1, 0), e.getDownTime() + 1000);
 	}
 
 	@Override


Commit: 36418c7ebdcb970186c475bd8f17eacee59a5968
    https://github.com/scummvm/scummvm/commit/36418c7ebdcb970186c475bd8f17eacee59a5968
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2023-07-06T20:54:39+02:00

Commit Message:
ANDROID: Increase timeout to trigger middle click to 1.5s

Changed paths:
    backends/platform/android/events.cpp
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java


diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 5e1268b26dd..12d738d8a02 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -742,7 +742,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 			//       This is the reason we use "double tap and move" to emulate that specific behavior.
 			// TODO This might be unwanted "alternate" behavior (better to have it as optional?)
 			// TODO put these time (in milliseconds) values in some option dlg?
-			if (arg3 > 1000) {
+			if (arg3 > 1500) {
 //				LOGD("JE_TAP - arg3 %d --> Middle Mouse Button", arg3);
 				down = Common::EVENT_MBUTTONDOWN;
 				up = Common::EVENT_MBUTTONUP;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index cbf7242c916..25cc46c0393 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -632,7 +632,7 @@ public class ScummVMEventsBase implements
 		// Schedule a Right click notification
 		_handler.sendMessageAtTime(_handler.obtainMessage(MSG_LONG_TOUCH_EVENT, 0, 0), e.getDownTime() + 500);
 		// Middle click
-		_handler.sendMessageAtTime(_handler.obtainMessage(MSG_LONG_TOUCH_EVENT, 1, 0), e.getDownTime() + 1000);
+		_handler.sendMessageAtTime(_handler.obtainMessage(MSG_LONG_TOUCH_EVENT, 1, 0), e.getDownTime() + 1500);
 	}
 
 	@Override




More information about the Scummvm-git-logs mailing list