packages feed

netwire-input 0.0.2 → 0.0.3

raw patch · 3 files changed

+23/−4 lines, 3 files

Files

README.md view
@@ -1,4 +1,4 @@-netwire-input+netwire-input [![Build Status](https://travis-ci.org/Mokosha/netwire-input.svg)](https://travis-ci.org/Mokosha/netwire-input) ============  A library of wires that provide keyboard, mouse, and joystick input.
lib/FRP/Netwire/Input.hs view
@@ -19,6 +19,7 @@  -------------------------------------------------------------------------------- -- Requried modules+import Control.Monad (liftM) import Control.Monad.Fix import Control.Wire hiding ((.)) import Data.Monoid@@ -65,7 +66,7 @@ -- * Depends: now -- * Inhibits: never mouseCursor :: MonadMouse mb m => Wire s e m a (Float, Float)-mouseCursor = mkGen_ $ \_ -> cursor >>= (return . Right)+mouseCursor = mkGen_ $ \_ -> liftM Right cursor  -- | Returns the change in mouse coordinates between subsequent time instants -- @@ -77,7 +78,7 @@   in    (mouseCursor >>>) $ loop $ second (delay (0, 0)) >>>    (arr $ \(cur, last) -> (delta cur last, cur))-     + -- | The mouse mickies are the offset from zero at each time instant. If this -- wire is being used, then it is assuming that the cursor mode is set to -- 'CursorMode'Reset'@@ -111,6 +112,24 @@   if pressed     then releaseButton mouse >> return (Right x)     else return (Left mempty)++-- | The mouse scroll is the offset from zero at each time instant.+-- +-- * Depends: now+-- * Inhibits: never+mouseScroll :: (Monoid e, MonadMouse mb m) => Wire s e m a (Double, Double)+mouseScroll = mkGen_ $ \_ -> liftM Right scroll++-- | The amount that the mouse has scrolled over the course of the entire wire.+-- +-- * Depends: now+-- * Inhibits: never+mouseScrolled :: (Monoid e, MonadMouse mb m) => Wire s e m a (Double, Double)+mouseScrolled = mouseScroll >>> fn (0, 0)+  where+    fn (x, y) = mkSFN $ \(dx, dy) ->+      let result = (x + dx, y + dy)+      in (result, fn result)  -- | Behaves like the identity wire, and inhibits immediately after -- setting the cursor mode. Common uses of this wire are to switch it
netwire-input.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                netwire-input-version:             0.0.2+version:             0.0.3 synopsis:            Input handling abstractions for netwire description:         This package contains a collection of Monad typeclasses that support                      interaction with input devices such as keyboard and mice. Moreover, these