1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Game refactor [3/X]: Move keycache to inputhandler

This commit is contained in:
Loic Blot 2018-01-13 10:40:25 +01:00 committed by Loïc Blot
parent 64fe79b53b
commit f5a006dce7
3 changed files with 106 additions and 105 deletions

View file

@ -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;