aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Control.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Chelleport/Control.hs')
-rw-r--r--src/Chelleport/Control.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs
index 7b58fdf..0fd01cc 100644
--- a/src/Chelleport/Control.hs
+++ b/src/Chelleport/Control.hs
@@ -26,6 +26,16 @@ currentMousePosition _ctx = do
isKeyPress :: SDL.KeyboardEventData -> Bool
isKeyPress = (== SDL.Pressed) . SDL.keyboardEventKeyMotion
+isKeyRelease :: SDL.KeyboardEventData -> Bool
+isKeyRelease = (== SDL.Released) . SDL.keyboardEventKeyMotion
+
+eventToKeycode :: SDL.KeyboardEventData -> SDL.Keycode
+eventToKeycode = SDL.keysymKeycode . SDL.keyboardEventKeysym
+
isKeyPressWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool
isKeyPressWith keyboardEvent keyCode =
- isKeyPress keyboardEvent && SDL.keysymKeycode (SDL.keyboardEventKeysym keyboardEvent) == keyCode
+ isKeyPress keyboardEvent && eventToKeycode keyboardEvent == keyCode
+
+isKeyReleaseWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool
+isKeyReleaseWith keyboardEvent keyCode =
+ isKeyRelease keyboardEvent && eventToKeycode keyboardEvent == keyCode