module FRP.Reactive.GLUT.UI
( UI(..)
, KeyState(..), Key(..), G.SpecialKey(..)
, keyPressed
, uiIntegral
) where
import Control.Applicative (liftA2)
import qualified Graphics.UI.GLUT as G
import Data.VectorSpace
import FRP.Reactive
data UI = UI {
mousePosition :: Behavior (Double,Double),
leftButtonPressed :: Event (),
rightButtonPressed :: Event (),
keyAction :: Event (KeyState, Key),
framePass :: Event ()
}
data Key = Char Char | SpecialKey G.SpecialKey
deriving (Eq, Ord, Show)
data KeyState = Down | Up
deriving (Eq, Ord, Show)
keyPressed :: UI -> Event Key
keyPressed = fmap snd . filterE ((==Down) . fst) . keyAction
uiIntegral :: (VectorSpace v, Scalar v ~ TimeT) =>
(UI -> Behavior v) -> (UI -> Behavior v)
uiIntegral = liftA2 integral framePass