diff options
Diffstat (limited to 'axis.hs')
-rw-r--r-- | axis.hs | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -5,6 +5,8 @@ import Control.Wire hiding (when) | |||
5 | import Control.Wire.Session | 5 | import Control.Wire.Session |
6 | import Control.Monad | 6 | import Control.Monad |
7 | import qualified Graphics.UI.SDL as SDL | 7 | import qualified Graphics.UI.SDL as SDL |
8 | import AlsaSeq | ||
9 | import qualified Data.Set as Set | ||
8 | 10 | ||
9 | netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String | 11 | netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String |
10 | netwireIsCool = | 12 | netwireIsCool = |
@@ -19,17 +21,16 @@ netwireIsCool = | |||
19 | holdFor 0.5 . periodic 1 . pure "Hoo..." <|> | 21 | holdFor 0.5 . periodic 1 . pure "Hoo..." <|> |
20 | pure "...ray!" | 22 | pure "...ray!" |
21 | 23 | ||
22 | --main :: IO () | 24 | main = SDL.withInit [SDL.InitVideo, SDL.InitTimer, SDL.InitJoystick] $ |
23 | --main = testWire clockSession_ netwireIsCool | 25 | withAlsaInit $ \h public private q publicAddr privateAddr -> do |
24 | 26 | putStrLn "Initialized." | |
25 | main = SDL.withInit [SDL.InitVideo, SDL.InitTimer, SDL.InitJoystick] $ do | ||
26 | loop clockSession_ netwireIsCool "" | 27 | loop clockSession_ netwireIsCool "" |
27 | where | 28 | where |
28 | loop s w x = do | 29 | loop s w x = do |
29 | (ds, s') <- stepSession s | 30 | (ds, s') <- stepSession s |
30 | (ex, w') <- stepWire w ds (Right x) | 31 | (ex, w') <- stepWire w ds (Right x) |
31 | let x' = either (const "") id ex | 32 | let x' = either (const "") id ex |
32 | Control.Monad.when (x /= x' && x /= "") $ putStrLn x | 33 | Control.Monad.when (x /= x' && x' /= "") $ putStrLn x' |
33 | let framerate = 30 | 34 | let framerate = 30 |
34 | let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds) | 35 | let delay = 1000 `div` framerate - 1000 * (floor $ dtime ds) |
35 | SDL.delay (delay) | 36 | SDL.delay (delay) |