aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Control.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-15 20:27:53 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-15 20:50:52 +0530
commit2cb08c5e64c53eb16ea8436fb6490db72d885426 (patch)
tree332a10ba2f95fcb74bf0c80f704955f2bd1dc02d /src/Chelleport/Control.hs
parent2feff9170ade1b68d70bfd0b6ff6f2528f7a862c (diff)
downloadchelleport-2cb08c5e64c53eb16ea8436fb6490db72d885426.tar.gz
chelleport-2cb08c5e64c53eb16ea8436fb6490db72d885426.zip
Add shift to accelerate hjkl movement
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