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:
Cameron Cawley 2020-01-20 21:33:36 +00:00
parent 36ae7ecd66
commit c9824ad206
3 changed files with 25 additions and 45 deletions

View file

@ -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