From 496c7d048df6a9a3650c0a0b996888decb4ea9d1 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 20 Dec 2024 19:51:08 +0530 Subject: Add shift+click to chain clicks in sequence --- src/Chelleport/Control.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Chelleport/Control.hs') diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs index 2ad2a34..38b6c53 100644 --- a/src/Chelleport/Control.hs +++ b/src/Chelleport/Control.hs @@ -36,8 +36,8 @@ instance (MonadIO m) => MonadControl (AppM m) where (SDL.P (SDL.V2 x y)) <- SDL.getAbsoluteMouseLocation pure (x, y) -isKeyPress :: SDL.KeyboardEventData -> Bool -isKeyPress = (== SDL.Pressed) . SDL.keyboardEventKeyMotion +isKeyPressed :: SDL.KeyboardEventData -> Bool +isKeyPressed = (== SDL.Pressed) . SDL.keyboardEventKeyMotion isKeyRelease :: SDL.KeyboardEventData -> Bool isKeyRelease = (== SDL.Released) . SDL.keyboardEventKeyMotion @@ -47,12 +47,17 @@ eventToKeycode = SDL.keysymKeycode . SDL.keyboardEventKeysym isKeyPressWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool isKeyPressWith keyboardEvent keyCode = - isKeyPress keyboardEvent && eventToKeycode keyboardEvent == keyCode + isKeyPressed keyboardEvent && eventToKeycode keyboardEvent == keyCode isKeyReleaseWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool isKeyReleaseWith keyboardEvent keyCode = isKeyRelease keyboardEvent && eventToKeycode keyboardEvent == keyCode +withShift :: SDL.KeyboardEventData -> Bool +withShift event = SDL.keyModifierLeftShift modifier || SDL.keyModifierRightShift modifier + where + modifier = SDL.keysymModifier . SDL.keyboardEventKeysym $ event + directionalIncrement :: (CInt, CInt) -> Char -> (Int, Int) directionalIncrement (incX, incY) = \case 'H' -> (-cIntToInt incX, 0) -- cgit v1.3.1