[Scummvm-git-logs] scummvm branch-2-2 -> 9fae3f27dedbfc301991b8cb112e5969f0a44031
antoniou79
a.antoniou79 at gmail.com
Sat Oct 17 19:03:50 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:
055919af67 ANDROID: Fix crash when connecting or disconnecting physical keyboard
9fae3f27de ANDROID: Do not use or show virtual keyboard when physical is connected
Commit: 055919af671937ea13947b2f4fd3cc845c89888a
https://github.com/scummvm/scummvm/commit/055919af671937ea13947b2f4fd3cc845c89888a
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-10-17T22:03:31+03:00
Commit Message:
ANDROID: Fix crash when connecting or disconnecting physical keyboard
And also add some code to load and use the keyCharacterMap of the source device for the event
It is unclear if getUnicodeChar() already does this (loads the keyCharacterMap of the source device.
If it does, then the extra code is redundant.
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
dists/android/AndroidManifest.xml
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index c9905c45ff..70bacadc9c 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -113,8 +113,20 @@ public class ScummVMEventsBase implements
// imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
((ScummVMActivity) _context).toggleScreenKeyboard();
} else if (msg.what == MSG_SBACK_LONG_PRESS) {
- _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
- _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MENU, 0, 0, 0, 0);
+ _scummvm.pushEvent(JE_SYS_KEY,
+ KeyEvent.ACTION_DOWN,
+ KeyEvent.KEYCODE_MENU,
+ 0,
+ 0,
+ 0,
+ 0);
+ _scummvm.pushEvent(JE_SYS_KEY,
+ KeyEvent.ACTION_UP,
+ KeyEvent.KEYCODE_MENU,
+ 0,
+ 0,
+ 0,
+ 0);
}
}
@@ -147,7 +159,16 @@ public class ScummVMEventsBase implements
// Log.d(ScummVM.LOG_TAG, "SCUMMV-EVENTS-BASE - onKEY:::" + keyCode); // Called
final int action = e.getAction();
- if (e.getUnicodeChar() == (int)EditableAccommodatingLatinIMETypeNullIssues.ONE_UNPROCESSED_CHARACTER.charAt(0)) {
+ int eventUnicodeChar = e.getUnicodeChar();
+ if (e.getDeviceId() != 0) {
+ // getDeviceId: Gets the id for the device that this event came from.
+ // An id of zero indicates that the event didn't come from a physical device and maps to the default keymap.
+ // The other numbers are arbitrary and you shouldn't depend on the values.
+ final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
+ eventUnicodeChar = m.get(e.getKeyCode(), e.getMetaState());
+ }
+
+ if (eventUnicodeChar == (int)EditableAccommodatingLatinIMETypeNullIssues.ONE_UNPROCESSED_CHARACTER.charAt(0)) {
//We are ignoring this character, and we want everyone else to ignore it, too, so
// we return true indicating that we have handled it (by ignoring it).
return true;
@@ -221,26 +242,34 @@ public class ScummVMEventsBase implements
}
// It's still necessary to send a key down event to the backend.
- _scummvm.pushEvent(JE_SYS_KEY, KeyEvent.ACTION_DOWN, keyCode,
- e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
- e.getMetaState(), e.getRepeatCount(),
- (int)(e.getEventTime() - e.getDownTime()));
+ _scummvm.pushEvent(JE_SYS_KEY,
+ KeyEvent.ACTION_DOWN,
+ keyCode,
+ eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
+ e.getMetaState(),
+ e.getRepeatCount(),
+ (int)(e.getEventTime() - e.getDownTime()));
}
}
// sequence of characters
- if (action == KeyEvent.ACTION_MULTIPLE &&
- keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+ if (action == KeyEvent.ACTION_MULTIPLE
+ && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId());
final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray());
- if (es == null)
+ if (es == null) {
return true;
+ }
for (KeyEvent s : es) {
- _scummvm.pushEvent(JE_KEY, s.getAction(), s.getKeyCode(),
- s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
- s.getMetaState(), s.getRepeatCount(), 0);
+ _scummvm.pushEvent(JE_KEY,
+ s.getAction(),
+ s.getKeyCode(),
+ eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
+ s.getMetaState(),
+ s.getRepeatCount(),
+ 0);
}
return true;
@@ -289,11 +318,16 @@ public class ScummVMEventsBase implements
break;
}
+// _scummvm.displayMessageOnOSD("GetKey: " + keyCode + " unic=" + eventUnicodeChar+ " arg3= " + (eventUnicodeChar& KeyCharacterMap.COMBINING_ACCENT_MASK));
+
// look in events.cpp for how this is handled
- _scummvm.pushEvent(type, action, keyCode,
- e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK,
- e.getMetaState(), e.getRepeatCount(),
- (int)(e.getEventTime() - e.getDownTime()));
+ _scummvm.pushEvent(type,
+ action,
+ keyCode,
+ eventUnicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK,
+ e.getMetaState(),
+ e.getRepeatCount(),
+ (int)(e.getEventTime() - e.getDownTime()));
return true;
}
@@ -304,8 +338,8 @@ public class ScummVMEventsBase implements
//Log.d(ScummVM.LOG_TAG, "SCUMMV-EVENTS-BASE - onTOUCH");
if (ScummVMActivity.keyboardWithoutTextInputShown
- && ((ScummVMActivity) _context).isScreenKeyboardShown()
- && ((ScummVMActivity) _context).getScreenKeyboard().getY() <= event.getY() ) {
+ && ((ScummVMActivity) _context).isScreenKeyboardShown()
+ && ((ScummVMActivity) _context).getScreenKeyboard().getY() <= event.getY() ) {
event.offsetLocation(-((ScummVMActivity) _context).getScreenKeyboard().getX(), -((ScummVMActivity) _context).getScreenKeyboard().getY());
// TODO maybe call the onTouchEvent of something else here?
((ScummVMActivity) _context).getScreenKeyboard().onTouchEvent(event);
diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml
index 40f734fd18..d1decbf6e1 100644
--- a/dists/android/AndroidManifest.xml
+++ b/dists/android/AndroidManifest.xml
@@ -40,7 +40,7 @@
<activity
android:name=".SplashActivity"
android:banner="@drawable/leanback_icon"
- android:configChanges="orientation|keyboardHidden|screenSize"
+ android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:screenOrientation="landscape"
android:theme="@style/SplashTheme"
android:windowSoftInputMode="adjustResize">
@@ -55,7 +55,7 @@
<activity
android:name=".ScummVMActivity"
android:banner="@drawable/leanback_icon"
- android:configChanges="orientation|keyboardHidden|screenSize"
+ android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:screenOrientation="landscape"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustResize">
Commit: 9fae3f27dedbfc301991b8cb112e5969f0a44031
https://github.com/scummvm/scummvm/commit/9fae3f27dedbfc301991b8cb112e5969f0a44031
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-10-17T22:03:40+03:00
Commit Message:
ANDROID: Do not use or show virtual keyboard when physical is connected
The toggle button will still be shown, but it won't show the in-app keyboard when pressed, unless the physical keyboard is disconnected
Changed paths:
backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 52486c7804..3f1e090791 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -10,6 +10,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
+import android.content.res.Configuration;
import android.graphics.Rect;
//import android.inputmethodservice.Keyboard;
//import android.inputmethodservice.KeyboardView;
@@ -58,6 +59,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeSet;
+import static android.content.res.Configuration.KEYBOARD_QWERTY;
+
//import android.os.Environment;
//import java.util.List;
@@ -124,6 +127,18 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
{ 0, R.xml.qwerty_alt_shift }
};
+ @Override
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (isHWKeyboardConnected()) {
+ hideScreenKeyboard();
+ }
+ }
+
+ private boolean isHWKeyboardConnected() {
+ return getResources().getConfiguration().keyboard == KEYBOARD_QWERTY;
+ }
+
public void showScreenKeyboardWithoutTextInputField(final int keyboard) {
if (_main_surface != null) {
_inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -431,6 +446,11 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
public void showScreenKeyboard() {
final boolean bGlobalsCompatibilityHacksTextInputEmulatesHwKeyboard = true;
final int dGlobalsTextInputKeyboard = 1;
+
+ if (isHWKeyboardConnected()) {
+ return;
+ }
+
if (_main_surface != null) {
if (bGlobalsCompatibilityHacksTextInputEmulatesHwKeyboard) {
More information about the Scummvm-git-logs
mailing list