diff options
Diffstat (limited to 'src/client/inputhandler.h')
-rw-r--r-- | src/client/inputhandler.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/client/inputhandler.h b/src/client/inputhandler.h index c7c29510d..91c111134 100644 --- a/src/client/inputhandler.h +++ b/src/client/inputhandler.h @@ -29,6 +29,37 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gui/touchscreengui.h" #endif +class InputHandler; + +/**************************************************************************** + Fast key cache for main game loop + ****************************************************************************/ + +/* This is faster than using getKeySetting with the tradeoff that functions + * using it must make sure that it's initialised before using it and there is + * no error handling (for example bounds checking). This is really intended for + * use only in the main running loop of the client (the_game()) where the faster + * (up to 10x faster) key lookup is an asset. Other parts of the codebase + * (e.g. formspecs) should continue using getKeySetting(). + */ +struct KeyCache { + + KeyCache() + { + handler = NULL; + populate(); + populate_nonchanging(); + } + + void populate(); + + // Keys that are not settings dependent + void populate_nonchanging(); + + KeyPress key[KeyType::INTERNAL_ENUM_COUNT]; + InputHandler *handler; +}; + class KeyList : private std::list<KeyPress> { typedef std::list<KeyPress> super; |