From fa6b21a15b415cd82dce6896b94a5341b7dd76f0 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 14 May 2016 16:25:57 +0200 Subject: Tell irrlicht if we handle a key or not. We can remove the function in MtNativeActivity now as it serves precisely that purpose: to tell irrlicht that we handled the esc key. TODO for later: * Perhaps try to find a more performant container than KeyList --- src/game.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 23f261cfd..c5211a042 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1297,7 +1297,11 @@ static void updateChat(Client &client, f32 dtime, bool show_debug, */ struct KeyCache { - KeyCache() { populate(); } + KeyCache() + { + handler = NULL; + populate(); + } enum { // Player movement @@ -1349,6 +1353,7 @@ struct KeyCache { void populate(); KeyPress key[KEYMAP_INTERNAL_ENUM_COUNT]; + InputHandler *handler; }; void KeyCache::populate() @@ -1399,6 +1404,19 @@ void KeyCache::populate() key[KEYMAP_ID_QUICKTUNE_DEC] = getKeySetting("keymap_quicktune_dec"); key[KEYMAP_ID_DEBUG_STACKS] = getKeySetting("keymap_print_debug_stacks"); + + if (handler) { + // First clear all keys, then re-add the ones we listen for + handler->dontListenForKeys(); + for (size_t i = 0; i < KEYMAP_INTERNAL_ENUM_COUNT; i++) { + handler->listenForKey(key[i]); + } + handler->listenForKey(EscapeKey); + handler->listenForKey(CancelKey); + for (size_t i = 0; i < 10; i++) { + handler->listenForKey(NumberKey[i]); + } + } } @@ -1829,6 +1847,9 @@ bool Game::startup(bool *kill, this->chat_backend = chat_backend; this->simple_singleplayer_mode = simple_singleplayer_mode; + keycache.handler = input; + keycache.populate(); + driver = device->getVideoDriver(); smgr = device->getSceneManager(); -- cgit v1.2.3