aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Control.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-15 15:39:02 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-15 15:45:37 +0530
commit1d07e554284593cdca804404d1d9f68a473ee986 (patch)
tree6f90288426699384cdb85cfdca4a036c3da1e51c /src/Chelleport/Control.hs
parent0c6b8c83e8673b394914e1f824dfb887b762b0ee (diff)
downloadchelleport-1d07e554284593cdca804404d1d9f68a473ee986.tar.gz
chelleport-1d07e554284593cdca804404d1d9f68a473ee986.zip
Refactor a bunch of stuff
Diffstat (limited to 'src/Chelleport/Control.hs')
-rw-r--r--src/Chelleport/Control.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs
index 94acf40..c915ae8 100644
--- a/src/Chelleport/Control.hs
+++ b/src/Chelleport/Control.hs
@@ -8,20 +8,18 @@ import qualified Graphics.X11.XTest as X11
import qualified SDL
triggerMouseLeftClick :: DrawContext -> IO ()
-triggerMouseLeftClick ctx = do
+triggerMouseLeftClick (DrawContext {ctxX11Display = display}) = do
threadDelay 30_000 -- Wrap with delay to prevent async window close issues. TODO: Remove maybe?
- let display = ctxX11Display ctx
X11.fakeButtonPress display X11.button1
X11.sync display False
threadDelay 30_000
moveMouse :: DrawContext -> CInt -> CInt -> IO ()
-moveMouse _ctx x y = do
+moveMouse _ x y = do
SDL.warpMouse SDL.WarpGlobal (SDL.P $ SDL.V2 x y)
isKeyPress :: SDL.KeyboardEventData -> Bool
-isKeyPress keyboardEvent =
- SDL.keyboardEventKeyMotion keyboardEvent == SDL.Pressed
+isKeyPress = (== SDL.Pressed) . SDL.keyboardEventKeyMotion
isKeyPressWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool
isKeyPressWith keyboardEvent keyCode =