aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Control.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-21 20:03:25 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-21 20:03:25 +0530
commit70ac685a5043a7b8ea9b72537dca8258198640c7 (patch)
treeb0e67fd2868cd17354f4b0861caca716d6b9d7ee /src/Chelleport/Control.hs
parent87815edbab70302793fb83259fedc1ae9004d172 (diff)
downloadchelleport-70ac685a5043a7b8ea9b72537dca8258198640c7.tar.gz
chelleport-70ac685a5043a7b8ea9b72537dca8258198640c7.zip
Minor refactor
Diffstat (limited to 'src/Chelleport/Control.hs')
-rw-r--r--src/Chelleport/Control.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs
index fa25681..80be6f8 100644
--- a/src/Chelleport/Control.hs
+++ b/src/Chelleport/Control.hs
@@ -80,15 +80,14 @@ isKeyReleaseWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool
isKeyReleaseWith keyboardEvent keyCode =
isKeyRelease keyboardEvent && eventToKeycode keyboardEvent == keyCode
+keyModifier :: SDL.KeyboardEventData -> SDL.KeyModifier
+keyModifier = SDL.keysymModifier . SDL.keyboardEventKeysym
+
withShift :: SDL.KeyboardEventData -> Bool
-withShift event = SDL.keyModifierLeftShift modifier || SDL.keyModifierRightShift modifier
- where
- modifier = SDL.keysymModifier . SDL.keyboardEventKeysym $ event
+withShift ev = SDL.keyModifierLeftShift (keyModifier ev) || SDL.keyModifierRightShift (keyModifier ev)
withCtrl :: SDL.KeyboardEventData -> Bool
-withCtrl event = SDL.keyModifierLeftCtrl modifier || SDL.keyModifierRightCtrl modifier
- where
- modifier = SDL.keysymModifier . SDL.keyboardEventKeysym $ event
+withCtrl ev = SDL.keyModifierLeftCtrl (keyModifier ev) || SDL.keyModifierRightCtrl (keyModifier ev)
directionalIncrement :: (CInt, CInt) -> Char -> (Int, Int)
directionalIncrement (incX, incY) = \case