diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-14 20:07:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-14 20:45:54 +0530 |
| commit | 34907bc25dba055dfbfe91d9a91803cc75283bfa (patch) | |
| tree | 310ed24c944b073f558ce6c67e3352fe0ad19d1d /src/Chelleport/Control.hs | |
| parent | 73564537897f7573690955596097085b711c92e5 (diff) | |
| download | chelleport-34907bc25dba055dfbfe91d9a91803cc75283bfa.tar.gz chelleport-34907bc25dba055dfbfe91d9a91803cc75283bfa.zip | |
Refactor view + add better highlighting of regions
Diffstat (limited to '')
| -rw-r--r-- | src/Chelleport/Control.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs index 2fb4f6c..94acf40 100644 --- a/src/Chelleport/Control.hs +++ b/src/Chelleport/Control.hs @@ -1,6 +1,6 @@ module Chelleport.Control where -import Chelleport.Context (DrawContext (ctxX11Display)) +import Chelleport.Types import Control.Concurrent (threadDelay) import Foreign.C (CInt) import qualified Graphics.X11 as X11 @@ -18,3 +18,11 @@ triggerMouseLeftClick ctx = do moveMouse :: DrawContext -> CInt -> CInt -> IO () moveMouse _ctx x y = do SDL.warpMouse SDL.WarpGlobal (SDL.P $ SDL.V2 x y) + +isKeyPress :: SDL.KeyboardEventData -> Bool +isKeyPress keyboardEvent = + SDL.keyboardEventKeyMotion keyboardEvent == SDL.Pressed + +isKeyPressWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool +isKeyPressWith keyboardEvent keyCode = + isKeyPress keyboardEvent && SDL.keysymKeycode (SDL.keyboardEventKeysym keyboardEvent) == keyCode |
