diff options
-rw-r--r-- | axis.hs | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -31,6 +31,9 @@ main = | |||
31 | info <- SDL.getVideoInfo | 31 | info <- SDL.getVideoInfo |
32 | let width = SDL.videoInfoWidth info | 32 | let width = SDL.videoInfoWidth info |
33 | height = SDL.videoInfoHeight info | 33 | height = SDL.videoInfoHeight info |
34 | warpMouse = do | ||
35 | _ <- SDL.warpMouse (fromIntegral (width `div` 2)) (fromIntegral (height `div` 2)) | ||
36 | return () | ||
34 | --screen <- SDL.setVideoMode width height 32 [SDL.SWSurface, SDL.Fullscreen] | 37 | --screen <- SDL.setVideoMode width height 32 [SDL.SWSurface, SDL.Fullscreen] |
35 | screen <- SDL.setVideoMode width height 32 [SDL.SWSurface] | 38 | screen <- SDL.setVideoMode width height 32 [SDL.SWSurface] |
36 | 39 | ||
@@ -39,6 +42,8 @@ main = | |||
39 | videoSurface <- SDL.getVideoSurface | 42 | videoSurface <- SDL.getVideoSurface |
40 | videoClipRect <- SDL.getClipRect videoSurface | 43 | videoClipRect <- SDL.getClipRect videoSurface |
41 | _ <- SDL.showCursor False | 44 | _ <- SDL.showCursor False |
45 | _ <- SDL.grabInput True | ||
46 | warpMouse | ||
42 | -- _ <- SDL.setRelativeMouseMode True -- SDL2. Should I use it? | 47 | -- _ <- SDL.setRelativeMouseMode True -- SDL2. Should I use it? |
43 | 48 | ||
44 | putStrLn "Initialized." | 49 | putStrLn "Initialized." |
@@ -64,10 +69,8 @@ main = | |||
64 | 69 | ||
65 | mouse <- SDL.getRelativeMouseState | 70 | mouse <- SDL.getRelativeMouseState |
66 | let (x, y, button) = mouse | 71 | let (x, y, button) = mouse |
67 | textBand videoSurface videoClipRect (SDL.Rect 0 140 0 70) font ((show x) ++ " " ++ (show y)) | 72 | textBand videoSurface videoClipRect (SDL.Rect 0 140 0 70) font ((show x) ++ " " ++ (show y) ++ " " ++ (show button)) |
68 | Control.Monad.when (x /= 0 || y /= 0) $ do | 73 | Control.Monad.when (x /= 0 || y /= 0) warpMouse |
69 | _ <- SDL.warpMouse (fromIntegral (width `div` 2)) (fromIntegral (height `div` 2)) | ||
70 | return () | ||
71 | _ <- SDL.updateRect videoSurface videoClipRect | 74 | _ <- SDL.updateRect videoSurface videoClipRect |
72 | 75 | ||
73 | let framerate = 30 | 76 | let framerate = 30 |