summaryrefslogtreecommitdiff
path: root/axis.hs
diff options
context:
space:
mode:
Diffstat (limited to 'axis.hs')
-rw-r--r--axis.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/axis.hs b/axis.hs
index b59a6f6..7513163 100644
--- a/axis.hs
+++ b/axis.hs
@@ -5,6 +5,8 @@ import Control.Wire hiding (when)
5import Control.Wire.Session 5import Control.Wire.Session
6import Control.Monad 6import Control.Monad
7import qualified Graphics.UI.SDL as SDL 7import qualified Graphics.UI.SDL as SDL
8import AlsaSeq
9import qualified Data.Set as Set
8 10
9netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String 11netwireIsCool :: (Monad m) => Wire (Timed NominalDiffTime ()) () m a String
10netwireIsCool = 12netwireIsCool =
@@ -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 () 24main = 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."
25main = 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)