[Scummvm-git-logs] scummvm master -> c9824ad2062d630ce9aa3b8c6ac3c74d56ea3136
ccawley2011
ccawley2011 at gmail.com
Mon Jan 20 21:36:21 UTC 2020
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:
c9824ad206 ANDROID: Improve handling of system keys
Commit: c9824ad2062d630ce9aa3b8c6ac3c74d56ea3136
https://github.com/scummvm/scummvm/commit/c9824ad2062d630ce9aa3b8c6ac3c74d56ea3136
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-01-20T21:36:05Z
Commit Message:
ANDROID: Improve handling of system keys
- Unrecognised system keys are treated as regular keys.
- Key down events are always sent when pressing the Menu or Back buttons.
Changed paths:
backends/platform/android/android.h
backends/platform/android/events.cpp
backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h
index 356a551..62825de 100644
--- a/backends/platform/android/android.h
+++ b/backends/platform/android/android.h
@@ -118,7 +118,6 @@ private:
public:
virtual void pushEvent(const Common::Event &event);
- virtual void pushKeyPressEvent(Common::Event &event);
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis(bool skipRecord = false);
virtual void delayMillis(uint msecs);
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 9025d44..6a07b09 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -71,28 +71,29 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
}
switch (arg2) {
-
- // special case. we'll only get its key-up event
case JKEYCODE_BACK:
if (_swap_menu_and_back) {
- e.type = Common::EVENT_MAINMENU;
- pushEvent(e);
+ if (arg1 == JACTION_DOWN) {
+ e.type = Common::EVENT_MAINMENU;
+ pushEvent(e);
+ }
} else {
e.kbd.keycode = Common::KEYCODE_ESCAPE;
e.kbd.ascii = Common::ASCII_ESCAPE;
- pushKeyPressEvent(e);
+ pushEvent(e);
}
return;
- // special case. we'll only get its key-up event
case JKEYCODE_MENU:
if (_swap_menu_and_back) {
e.kbd.keycode = Common::KEYCODE_ESCAPE;
e.kbd.ascii = Common::ASCII_ESCAPE;
- pushKeyPressEvent(e);
- } else {
- e.type = Common::EVENT_MAINMENU;
pushEvent(e);
+ } else {
+ if (arg1 == JACTION_DOWN) {
+ e.type = Common::EVENT_MAINMENU;
+ pushEvent(e);
+ }
}
return;
@@ -122,11 +123,10 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
default:
- LOGW("unmapped system key: %d", arg2);
- return;
+ break;
}
- break;
+ // fall through
case JE_KEY:
switch (arg1) {
@@ -709,13 +709,4 @@ void OSystem_Android::pushEvent(const Common::Event &event) {
unlockMutex(_event_queue_lock);
}
-void OSystem_Android::pushKeyPressEvent(Common::Event &event) {
- lockMutex(_event_queue_lock);
- event.type = Common::EVENT_KEYDOWN;
- _event_queue.push(event);
- event.type = Common::EVENT_KEYUP;
- _event_queue.push(event);
- unlockMutex(_event_queue_lock);
-}
-
#endif
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
index 9d76bc2..acf6df8 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
@@ -87,6 +87,7 @@ public class ScummVMEvents implements
if (imm != null)
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
} 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);
}
}
@@ -112,20 +113,6 @@ public class ScummVMEvents implements
}
if (e.isSystem()) {
- // filter what we handle
- switch (keyCode) {
- case KeyEvent.KEYCODE_BACK:
- case KeyEvent.KEYCODE_MENU:
- case KeyEvent.KEYCODE_CAMERA:
- case KeyEvent.KEYCODE_SEARCH:
- case KeyEvent.KEYCODE_MEDIA_PLAY:
- case KeyEvent.KEYCODE_MEDIA_PAUSE:
- break;
-
- default:
- return false;
- }
-
// no repeats for system keys
if (e.getRepeatCount() > 0)
return false;
@@ -161,21 +148,20 @@ public class ScummVMEvents implements
keyHandler.sendMessageDelayed(keyHandler.obtainMessage(
typeOfLongPressMessage), _longPress);
return true;
+ } else if (action != KeyEvent.ACTION_UP) {
+ return true;
}
if (fired) {
return true;
}
- // only send up events of the menu or back button to the native side
- if (action != KeyEvent.ACTION_UP) {
- return true;
- }
+ // 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, action, keyCode, 0, 0, 0, 0);
-
- return true;
}
// sequence of characters
@@ -227,7 +213,11 @@ public class ScummVMEvents implements
type = JE_GAMEPAD;
break;
default:
- type = JE_KEY;
+ if (e.isSystem()) {
+ type = JE_SYS_KEY;
+ } else {
+ type = JE_KEY;
+ }
break;
}
More information about the Scummvm-git-logs
mailing list