diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-24 14:27:10 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-24 14:27:10 +0200 |
commit | ccf859fe805afe8db3aa694df5d26da7778dfc68 (patch) | |
tree | 14de9b0e16dde360de4790d440eca89757156152 /src | |
parent | 657f3ea479ec9a1e7703140d0655fd7283a784e0 (diff) | |
download | rpgedit-ccf859fe805afe8db3aa694df5d26da7778dfc68.tar rpgedit-ccf859fe805afe8db3aa694df5d26da7778dfc68.zip |
InputHandler: only call listeners when the key's state has changed
Diffstat (limited to 'src')
-rw-r--r-- | src/control/InputHandler.hpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/control/InputHandler.hpp b/src/control/InputHandler.hpp index 1a34982..7eb98a9 100644 --- a/src/control/InputHandler.hpp +++ b/src/control/InputHandler.hpp @@ -51,17 +51,17 @@ public: } void keyPressed(uint16_t key, uint64_t time) { - pressedKeys.insert(key); - - for (auto &listener : listeners) - listener(key, true, time); + if (pressedKeys.insert(key).second) { + for (auto &listener : listeners) + listener(key, true, time); + } } void keyReleased(uint16_t key, uint64_t time) { - pressedKeys.erase(key); - - for (auto &listener : listeners) - listener(key, false, time); + if (pressedKeys.erase(key)) { + for (auto &listener : listeners) + listener(key, false, time); + } } bool isKeyPressed(uint16_t key) { |