summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-24 14:27:10 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-24 14:27:10 +0200
commitccf859fe805afe8db3aa694df5d26da7778dfc68 (patch)
tree14de9b0e16dde360de4790d440eca89757156152 /src
parent657f3ea479ec9a1e7703140d0655fd7283a784e0 (diff)
downloadrpgedit-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.hpp16
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) {