summaryrefslogtreecommitdiff
path: root/src/keyGet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/keyGet.cpp')
-rw-r--r--src/keyGet.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/keyGet.cpp b/src/keyGet.cpp
new file mode 100644
index 0000000..005aa51
--- /dev/null
+++ b/src/keyGet.cpp
@@ -0,0 +1,32 @@
+#include "FLD.hpp"
+
+FLD::InputState
+FLD::keyGet(SDL_Scancode sc) const
+{
+ return keystates[sc];
+}
+
+bool
+FLD::keyDown(SDL_Scancode sc) const
+{
+ const auto state = keyGet(sc);
+ return (state == InputState::Down || state == InputState::Press);
+}
+
+bool
+FLD::keyUp(SDL_Scancode sc) const
+{
+ return !keyDown(sc);
+}
+
+bool
+FLD::keyPressed(SDL_Scancode sc) const
+{
+ return (keyGet(sc) == InputState::Press);
+}
+
+bool
+FLD::keyReleased(SDL_Scancode sc) const
+{
+ return (keyGet(sc) == InputState::Release);
+}