module FRP.Helm.Mouse (
Mouse(..),
isDown,
position, x, y
) where
import Control.Applicative
import FRP.Elerea.Simple
import qualified Graphics.UI.SDL as SDL
data Mouse = LeftMouse | MiddleMouse | RightMouse
position :: SignalGen (Signal (Int, Int))
position = effectful $ (\(x_, y_, _) -> (x_, y_)) <$> SDL.getMouseState
x :: SignalGen (Signal Int)
x = effectful $ (\(x_, _, _) -> x_) <$> SDL.getMouseState
y :: SignalGen (Signal Int)
y = effectful $ (\(_, y_, _) -> y_) <$> SDL.getMouseState
mapMouse :: Mouse -> SDL.MouseButton
mapMouse m =
case m of
LeftMouse -> SDL.ButtonLeft
MiddleMouse -> SDL.ButtonMiddle
RightMouse -> SDL.ButtonRight
isDown :: Mouse -> SignalGen (Signal Bool)
isDown m = effectful $ (\(_, _, b_) -> elem (mapMouse m) b_) <$> SDL.getMouseState