diff options
author | Cameron Cawley | 2019-10-18 18:16:41 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-10-23 07:41:31 +0300 |
commit | 38beac8d9598be3f6ff8abde58d02eef0ac81560 (patch) | |
tree | 6a2454ea7006446a00999c28d9c85ddd967928e7 /backends/platform/android | |
parent | 94a53ccb0f1dc2d67124b382f26d51582aa4f394 (diff) | |
download | scummvm-rg350-38beac8d9598be3f6ff8abde58d02eef0ac81560.tar.gz scummvm-rg350-38beac8d9598be3f6ff8abde58d02eef0ac81560.tar.bz2 scummvm-rg350-38beac8d9598be3f6ff8abde58d02eef0ac81560.zip |
ANDROID: Simplify handling of menu/back button events
Diffstat (limited to 'backends/platform/android')
-rw-r--r-- | backends/platform/android/android.h | 1 | ||||
-rw-r--r-- | backends/platform/android/events.cpp | 25 |
2 files changed, 12 insertions, 14 deletions
diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index b13b42e5bf..bd6f015a7f 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -119,6 +119,7 @@ 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 84a95ffa3c..da35fb0dd4 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -105,13 +105,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, } else { e.kbd.keycode = Common::KEYCODE_ESCAPE; e.kbd.ascii = Common::ASCII_ESCAPE; - - lockMutex(_event_queue_lock); - e.type = Common::EVENT_KEYDOWN; - _event_queue.push(e); - e.type = Common::EVENT_KEYUP; - _event_queue.push(e); - unlockMutex(_event_queue_lock); + pushKeyPressEvent(e); } return; @@ -120,13 +114,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, if (_swap_menu_and_back) { e.kbd.keycode = Common::KEYCODE_ESCAPE; e.kbd.ascii = Common::ASCII_ESCAPE; - - lockMutex(_event_queue_lock); - e.type = Common::EVENT_KEYDOWN; - _event_queue.push(e); - e.type = Common::EVENT_KEYUP; - _event_queue.push(e); - unlockMutex(_event_queue_lock); + pushKeyPressEvent(e); } else { e.type = Common::EVENT_MAINMENU; pushEvent(e); @@ -746,4 +734,13 @@ 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 |