[Scummvm-git-logs] scummvm master -> 8863b5d92f85b5d382c882497ca3801e9e4d155b

antoniou79 a.antoniou79 at gmail.com
Wed Nov 25 14:42:02 UTC 2020


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:
411407abf8 ANDROID: Restore check for Alt modifier in key events
8863b5d92f ANDROID: Get current version info from the global gScummVMVersion


Commit: 411407abf8d80c114f320f84564514514aaafa17
    https://github.com/scummvm/scummvm/commit/411407abf8d80c114f320f84564514514aaafa17
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-11-25T16:41:47+02:00

Commit Message:
ANDROID: Restore check for Alt modifier in key events

And add checks for Meta, Caps, NumLock, Scroll lock modifiers too

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 2a4972e9cb..25b646b2d8 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -88,7 +88,7 @@ enum {
 	AMETA_ALT_MASK   = AMETA_ALT_ON   | AMETA_ALT_LEFT_ON   | AMETA_ALT_RIGHT_ON
 };
 
-// map android key codes to our kbd codes
+// map android key codes to our kbd codes (common/keyboard.h)
 static const Common::KeyCode jkeymap[] = {
 	Common::KEYCODE_INVALID, // AKEYCODE_UNKNOWN
 	Common::KEYCODE_LEFTSOFT, // AKEYCODE_SOFT_LEFT
@@ -465,16 +465,56 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 			break;
 		}
 
+		// arg4 is the metastate of the key press event
+		// check for "Shift" key modifier
 		if (arg4 & AMETA_SHIFT_MASK)
 			e.kbd.flags |= Common::KBD_SHIFT;
-		// JMETA_ALT is Fn on physical keyboards!
+
+		// We revert the commit to disable the Alt modifier
+		// TODO revisit this old comment from commit https://github.com/scummvm/scummvm/commit/bfecb37501b6fdc35f2802216db5fb2b0e54b8ee
+		//      for possible issues with physical keyboards and Fn key combos.
+		//      It still seems like a bad idea to disable Alt key combos over Fn key combos
+		//      and our keymapper should be able to handle this issue anyway
+		//      (since it explicitly shows what key combination results from pressing keys, when the user edits a key mapping)
+		//      More info: Back then we were checking for JMETA_ALT (defined as 0x02) which is now NDK's AMETA_ALT_ON (0x02) (see https://developer.android.com/ndk/reference/group/input)
+		//      JMETA_ALT was defined in our own enum. (see full old file: https://github.com/scummvm/scummvm/blob/bfecb37501b6fdc35f2802216db5fb2b0e54b8ee/backends/platform/android/events.cpp#L113)
+		// Old comment:
+		// JMETA_ALT (0x02) is Fn on physical keyboards!
 		// when mapping this to ALT - as we know it from PC keyboards - all
 		// Fn combos will be broken (like Fn+q, which needs to end as 1 and
 		// not ALT+1). Do not want.
-		//if (arg4 & AMETA_ALT_MASK)
+		//if (arg4 & JMETA_ALT)
 		//	e.kbd.flags |= Common::KBD_ALT;
-		if (arg4 & (AMETA_SYM_ON | AMETA_CTRL_MASK))
+		// end of old comment --
+		// check for "Alt" key modifier
+		if (arg4 & (AMETA_ALT_MASK)) {
+			e.kbd.flags |= Common::KBD_ALT;
+		}
+
+		// check for "Ctrl" key modifier (We set Sym key to also behave as Ctrl)
+		if (arg4 & (AMETA_SYM_ON | AMETA_CTRL_MASK)) {
 			e.kbd.flags |= Common::KBD_CTRL;
+		}
+
+		// check for "Meta" key modifier
+		if (arg4 & (AMETA_META_MASK)) {
+			e.kbd.flags |= Common::KBD_META;
+		}
+
+		//  check for CAPS key modifier
+		if (arg4 & (AMETA_CAPS_LOCK_ON)) {
+			e.kbd.flags |= Common::KBD_CAPS;
+		}
+
+		//  check for NUM Lock key modifier
+		if (arg4 & (AMETA_NUM_LOCK_ON)) {
+			e.kbd.flags |= Common::KBD_NUM;
+		}
+
+		//  check for Scroll Lock key modifier
+		if (arg4 & (AMETA_SCROLL_LOCK_ON)) {
+			e.kbd.flags |= Common::KBD_SCRL;
+		}
 
 		pushEvent(e);
 
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index 34fa62c748..16e7308c3f 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -355,7 +355,7 @@ public class ScummVMEventsBase implements
 			break;
 		}
 
-		//_scummvm.displayMessageOnOSD("GetKey: " + keyCode + " unic=" + eventUnicodeChar+ " arg3= " + (eventUnicodeChar& KeyCharacterMap.COMBINING_ACCENT_MASK));
+		//_scummvm.displayMessageOnOSD("GetKey: " + keyCode + " unic=" + eventUnicodeChar+ " arg3= " + (eventUnicodeChar& KeyCharacterMap.COMBINING_ACCENT_MASK) + " meta: " + e.getMetaState());
 
 		// look in events.cpp for how this is handled
 		_scummvm.pushEvent(type,


Commit: 8863b5d92f85b5d382c882497ca3801e9e4d155b
    https://github.com/scummvm/scummvm/commit/8863b5d92f85b5d382c882497ca3801e9e4d155b
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-11-25T16:41:47+02:00

Commit Message:
ANDROID: Get current version info from the global gScummVMVersion

...instead of the versionName in build.gradle

Also check for "dirty" version name and in that case do not skip re-copying the asset files

Changed paths:
    backends/platform/android/jni-android.cpp
    backends/platform/android/jni-android.h
    backends/platform/android/org/scummvm/scummvm/ScummVM.java
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
    backends/platform/android/org/scummvm/scummvm/SplashActivity.java
    backends/platform/android/org/scummvm/scummvm/Version.java


diff --git a/backends/platform/android/jni-android.cpp b/backends/platform/android/jni-android.cpp
index 50c0e67ed5..7cbbf5e633 100644
--- a/backends/platform/android/jni-android.cpp
+++ b/backends/platform/android/jni-android.cpp
@@ -117,7 +117,9 @@ const JNINativeMethod JNI::_natives[] = {
 	{ "pushEvent", "(IIIIIII)V",
 		(void *)JNI::pushEvent },
 	{ "setPause", "(Z)V",
-		(void *)JNI::setPause }
+		(void *)JNI::setPause },
+	{ "getNativeVersionInfo", "()Ljava/lang/String;",
+		(void *)JNI::getNativeVersionInfo }
 };
 
 JNI::JNI() {
@@ -719,6 +721,11 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
 	}
 }
 
+
+jstring JNI::getNativeVersionInfo(JNIEnv *env, jobject self) {
+	return convertToJString(env, Common::U32String(gScummVMVersion));
+}
+
 jstring JNI::convertToJString(JNIEnv *env, const Common::U32String &str) {
 	uint len = 0;
 	uint16 *u16str = str.encodeUTF16Native(&len);
@@ -738,6 +745,7 @@ Common::U32String JNI::convertFromJString(JNIEnv *env, const jstring &jstr) {
 	return str;
 }
 
+// TODO should this be a U32String array?
 Common::Array<Common::String> JNI::getAllStorageLocations() {
 	Common::Array<Common::String> *res = new Common::Array<Common::String>();
 
@@ -828,5 +836,4 @@ void JNI::closeFileWithSAF(const Common::String &hackyFilename) {
 
 }
 
-
 #endif
diff --git a/backends/platform/android/jni-android.h b/backends/platform/android/jni-android.h
index 6b2c49d45d..17a62aefa1 100644
--- a/backends/platform/android/jni-android.h
+++ b/backends/platform/android/jni-android.h
@@ -147,6 +147,7 @@ private:
 							int arg2, int arg3, int arg4, int arg5, int arg6);
 	static void setPause(JNIEnv *env, jobject self, jboolean value);
 
+	static jstring getNativeVersionInfo(JNIEnv *env, jobject self);
 	static jstring convertToJString(JNIEnv *env, const Common::U32String &str);
 	static Common::U32String convertFromJString(JNIEnv *env, const jstring &jstr);
 
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 46d72cef69..1a5fb455ca 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -55,6 +55,8 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 	final public native void pushEvent(int type, int arg1, int arg2, int arg3,
 										int arg4, int arg5, int arg6);
 
+	final public native String getNativeVersionInfo();
+
 	// Callbacks from C++ peer instance
 	abstract protected void getDPI(float[] values);
 	abstract protected void displayMessageOnOSD(String msg);
@@ -80,6 +82,10 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 		holder.addCallback(this);
 	}
 
+	final public String getInstallingScummVMVersionInfo() {
+		return getNativeVersionInfo();
+	}
+
 	// SurfaceHolder callback
 	final public void surfaceCreated(SurfaceHolder holder) {
 		Log.d(LOG_TAG, "surfaceCreated");
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index cdf6224086..3b218a2ab1 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -439,7 +439,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 										key -= 100000;
 										compiledMetaState |= KeyEvent.META_SHIFT_LEFT_ON;
 									}
-
 									// update the eventTime after the above check for first time "hit"
 									KeyEvent compiledKeyEvent = new KeyEvent(builtinKeyboard.mEventPressTime,
 										SystemClock.uptimeMillis(),
@@ -893,8 +892,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		takeKeyEvents(true);
 
 		_clipboardManager = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
-		_currentScummVMVersion = new Version(BuildConfig.VERSION_NAME);
-		Log.d(ScummVM.LOG_TAG, "Current ScummVM version running is: " + _currentScummVMVersion.getDescription() + " (" + _currentScummVMVersion.get() + ")");
 
 		// REMOVED: Since getFilesDir() is guaranteed to exist, getFilesDir().mkdirs() might be related to crashes in Android version 9+ (Pie or above, API 28+)!
 
@@ -918,6 +915,10 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		                                                        }
 		                                                    });
 
+		// Currently in release builds version string does not contain the revision info
+		// but in debug builds (daily builds) this should be there (see base/internal_version_h)
+		_currentScummVMVersion = new Version(_scummvm.getInstallingScummVMVersionInfo());
+		Log.d(ScummVM.LOG_TAG, "Current ScummVM version launching is: " + _currentScummVMVersion.getDescription() + " (" + _currentScummVMVersion.get() + ")");
 		//
 		// seekAndInitScummvmConfiguration() returns false if something went wrong
 		// when initializing configuration (or when seeking and trying to use an existing ini file) for ScummVM
@@ -1679,7 +1680,19 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
 		//      A more efficient way would be to compare hash (when we deem that an upgrade is happening, so we will also still have to compare versions)
 		// Note that isSideUpgrading is also true each time we re-launch the app
 		// Also even during a side-upgrade we cleanup any redundant files (no longer part of our assets)
-		boolean isSideUpgrading = (maxOldVersionFound.compareTo(_currentScummVMVersion) == 0);
+
+		// By first checking for isDirty() and then comparing the Version objects,
+		// we don't need to also compare the Version descriptions (full version text) for a match too,
+		// since, if the full versions text do not match, it's because at least one of them is dirty.
+		// TODO: This does mean that "pre" (or similar) versions (eg. 2.2.1pre) will always be considered non-side-upgrades
+		//        and will re-copy the assets upon each launch
+		//       This should have a slight performance impact (for launch time) for those intermediate version releases,
+		//       but it's better than the alternative (comparing MD5 hashes for all files), and it should go away with the next proper release.
+		//       This solution should cover "git" versions properly
+		//       (ie. developer builds, built with release configuration (eg 2.3.0git) or debug configuration (eg. 2.3.0git9272-gc71ac4748b))
+		boolean isSideUpgrading = (!_currentScummVMVersion.isDirty()
+		                           && !maxOldVersionFound.isDirty()
+		                           && maxOldVersionFound.compareTo(_currentScummVMVersion) == 0);
 		copyAssetsToInternalMemory(isSideUpgrading);
 
 		//
diff --git a/backends/platform/android/org/scummvm/scummvm/SplashActivity.java b/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
index cce03c9db4..44fdadba37 100644
--- a/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/SplashActivity.java
@@ -34,9 +34,6 @@ public class SplashActivity extends Activity {
 		super.onCreate(savedInstanceState);
 		hideSystemUI();
 
-		Version _currentScummVMVersion = new Version(BuildConfig.VERSION_NAME);
-		Log.d(ScummVM.LOG_TAG, "Splash: Current ScummVM version running is: " + _currentScummVMVersion.getDescription() + " (" + _currentScummVMVersion.get() + ")");
-
 		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
 		    && (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
 		        || checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
diff --git a/backends/platform/android/org/scummvm/scummvm/Version.java b/backends/platform/android/org/scummvm/scummvm/Version.java
index 69b5b1be42..3bd320883f 100644
--- a/backends/platform/android/org/scummvm/scummvm/Version.java
+++ b/backends/platform/android/org/scummvm/scummvm/Version.java
@@ -21,7 +21,7 @@ public class Version implements Comparable<Version> {
 		} else {
 			this.versionDescription = version;
 			// cleanup from any non-digit characters in the version string
-			String strippedVersion = version.replaceAll("[^\\d.]", "");
+			final String strippedVersion = version.replaceAll("[^\\d.]", "");
 			if (!strippedVersion.matches("[0-9]+(\\.[0-9]+)*")) {
 				this.versionOnlyDigits = "0";
 			} else {
@@ -30,6 +30,14 @@ public class Version implements Comparable<Version> {
 		}
 	}
 
+	// Here a version is considered "dirty" if it contains other characters in the description string than the expected digits (and dots) of a "clean" proper version
+	// eg. 2.3.0pre or 2.3.0git or 2.3.0git9272-gc71ac4748b are dirty
+	//     2.3.0 is NOT dirty
+	public boolean isDirty() {
+		return (versionOnlyDigits.compareTo(versionDescription) != 0);
+	}
+
+
 	@Override public int compareTo(Version that) {
 		if(that == null)
 			return 1;




More information about the Scummvm-git-logs mailing list