mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
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
This commit is contained in:
parent
ef100f12a1
commit
fa6b21a15b
4 changed files with 57 additions and 11 deletions
23
src/game.cpp
23
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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue