From 0921c83c08d4d9fd49901cfc5bd6295c710f0553 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Wed, 15 Jan 2014 18:40:15 -0500 Subject: grabInput True; showCursor False; display mouse buttons --- axis.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'axis.hs') diff --git a/axis.hs b/axis.hs index 9116991..3e9917e 100644 --- a/axis.hs +++ b/axis.hs @@ -31,6 +31,9 @@ main = info <- SDL.getVideoInfo let width = SDL.videoInfoWidth info height = SDL.videoInfoHeight info + warpMouse = do + _ <- SDL.warpMouse (fromIntegral (width `div` 2)) (fromIntegral (height `div` 2)) + return () --screen <- SDL.setVideoMode width height 32 [SDL.SWSurface, SDL.Fullscreen] screen <- SDL.setVideoMode width height 32 [SDL.SWSurface] @@ -39,6 +42,8 @@ main = videoSurface <- SDL.getVideoSurface videoClipRect <- SDL.getClipRect videoSurface _ <- SDL.showCursor False + _ <- SDL.grabInput True + warpMouse -- _ <- SDL.setRelativeMouseMode True -- SDL2. Should I use it? putStrLn "Initialized." @@ -64,10 +69,8 @@ main = mouse <- SDL.getRelativeMouseState let (x, y, button) = mouse - textBand videoSurface videoClipRect (SDL.Rect 0 140 0 70) font ((show x) ++ " " ++ (show y)) - Control.Monad.when (x /= 0 || y /= 0) $ do - _ <- SDL.warpMouse (fromIntegral (width `div` 2)) (fromIntegral (height `div` 2)) - return () + textBand videoSurface videoClipRect (SDL.Rect 0 140 0 70) font ((show x) ++ " " ++ (show y) ++ " " ++ (show button)) + Control.Monad.when (x /= 0 || y /= 0) warpMouse _ <- SDL.updateRect videoSurface videoClipRect let framerate = 30 -- cgit v1.2.3