diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-15 20:27:53 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-15 20:50:52 +0530 |
| commit | 2cb08c5e64c53eb16ea8436fb6490db72d885426 (patch) | |
| tree | 332a10ba2f95fcb74bf0c80f704955f2bd1dc02d /src/Chelleport/Control.hs | |
| parent | 2feff9170ade1b68d70bfd0b6ff6f2528f7a862c (diff) | |
| download | chelleport-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.hs | 12 |
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 |
