summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp23
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();