aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Control.hs
blob: 2fb4f6c8bb4dc88c03a578f6687b36e239730878 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Chelleport.Control where

import Chelleport.Context (DrawContext (ctxX11Display))
import Control.Concurrent (threadDelay)
import Foreign.C (CInt)
import qualified Graphics.X11 as X11
import qualified Graphics.X11.XTest as X11
import qualified SDL

triggerMouseLeftClick :: DrawContext -> IO ()
triggerMouseLeftClick ctx = 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
  SDL.warpMouse SDL.WarpGlobal (SDL.P $ SDL.V2 x y)