diff options
author | est31 <MTest31@outlook.com> | 2016-05-14 16:25:57 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2016-05-26 20:33:33 +0200 |
commit | fa6b21a15b415cd82dce6896b94a5341b7dd76f0 (patch) | |
tree | 1fc68b1ebb2ce52c81b33e816b0f8f8f827d47a7 /src/game.cpp | |
parent | ef100f12a1346f7bfd2a05dc606cb22e97179c02 (diff) | |
download | minetest-fa6b21a15b415cd82dce6896b94a5341b7dd76f0.tar.gz minetest-fa6b21a15b415cd82dce6896b94a5341b7dd76f0.tar.bz2 minetest-fa6b21a15b415cd82dce6896b94a5341b7dd76f0.zip |
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
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
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(); |