mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-11 05:36:12 +00:00
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.
This commit is contained in:
parent
36ae7ecd66
commit
c9824ad206
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user