-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Input handling abstractions for netwire
--   
--   This package contains a collection of Monad typeclasses that support
--   interaction with input devices such as keyboard and mice. Moreover,
--   these typeclasses are used to create wires from the netwire package
--   the produce mouse and keyboard input values in a reactive way. This
--   package cannot be used independently and must be used with another
--   package that provides instantiation of these typeclasses such as
--   netwire-input-glfw.
@package netwire-input
@version 0.0.6


-- | This module contains definitions for typeclasses and wires to be used
--   in FRP programs that use netwire. In order to use this module, an
--   implementation that provides an instance of one of the underlying
--   typeclasses <a>MonadMouse</a> or <a>MonadKeyboard</a> must be used. In
--   order to not require the GLFW or SDL libraries as dependencies, these
--   instances are provided in separate libraries.
module FRP.Netwire.Input

-- | Mouse button typeclass. This is used to constrain the type of Monad
--   used | to provide mouse input.
class MouseButton a

-- | The mouse cursor mode. This mode is usually dependent on whether or
--   not the mouse is in the bounds of the application window.
data CursorMode

-- | The mouse cursor is disabled
CursorMode'Disabled :: CursorMode

-- | Reset the cursor to zero between computations
CursorMode'Reset :: CursorMode

-- | The mouse cursor is hidden when over the application
CursorMode'Hidden :: CursorMode

-- | The mouse cursor is enabed and visible over the application
CursorMode'Enabled :: CursorMode

-- | This monad describes computations that involve mouse input.
class (MouseButton mb, Monad m) => MonadMouse mb m | m -> mb

-- | Sets the cursor mode for all subsequent computations. Note, that many
--   | implementations require some sort of "poll" to read the IO
setCursorMode :: MonadMouse mb m => CursorMode -> m ()

-- | Returns true if the given mouse button is pressed
mbIsPressed :: MonadMouse mb m => mb -> m (Bool)

-- | Resets the pressed state of the mouse button
releaseButton :: MonadMouse mb m => mb -> m ()

-- | Get the current cursor location
cursor :: MonadMouse mb m => m (Float, Float)

-- | Get the amount of scrolling done in the x and y directions
scroll :: MonadMouse mb m => m (Double, Double)

-- | Ignores its input and returns the current normalized mouse
--   coordinates. Regardless of window size, each of the returned
--   coordinates will be in the range <tt>[-1, 1]</tt>.
--   
--   <ul>
--   <li>Depends: now</li>
--   <li>Inhibits: never</li>
--   </ul>
mouseCursor :: MonadMouse mb m => Wire s e m a (Float, Float)

-- | Returns the change in mouse coordinates between subsequent time
--   instants
--   
--   <ul>
--   <li>Depends: before now</li>
--   <li>Inhibits: never</li>
--   </ul>
mouseDelta :: (MonadFix m, MonadMouse mb m) => Wire s e m a (Float, Float)

-- | 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 <a>CursorMode'Reset</a>
--   
--   <ul>
--   <li>Depends: now</li>
--   <li>Inhibits: never</li>
--   </ul>
mouseMickies :: MonadMouse mb m => Wire s e m a (Float, Float)

-- | Behaves like the identity wire when the mouse button is pressed and
--   inhibits otherwise
--   
--   <ul>
--   <li>Inhibits: when the mouse button is not pressed</li>
--   </ul>
mousePressed :: (Monoid e, MonadMouse mb m) => mb -> Wire s e m a a

-- | Ignores its input and returns <a>True</a> whenever the mouse button is
--   pressed, <a>False</a> otherwise.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
isMousePressed :: MonadMouse mb m => mb -> Wire s e m a Bool

-- | Behaves like the identity wire for a signle instant when the mouse
--   button is pressed and otherwise inhibits. Note that this wire causing
--   the button to be treated as released by all other wires after the
--   instant when it is pressed.
--   
--   <ul>
--   <li>Depends: the instant at which the mouse button is pressed</li>
--   <li>Inhibits: when the mouse button is not pressed or after it has
--   been pressed</li>
--   </ul>
mouseDebounced :: (Monoid e, MonadMouse mb m) => mb -> Wire s e m a a

-- | Fires an event the instant the given mouse button is pressed after not
--   being pressed.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
mousePressedEvent :: MonadMouse mb m => mb -> Wire s e m a (Event a)

-- | Fires an event the instant the given mouse button is released after
--   being pressed.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
mouseReleasedEvent :: MonadMouse mb m => mb -> Wire s e m a (Event a)

-- | The mouse scroll is the offset from zero at each time instant.
--   
--   <ul>
--   <li>Depends: now</li>
--   <li>Inhibits: never</li>
--   </ul>
mouseScroll :: (Monoid e, MonadMouse mb m) => Wire s e m a (Double, Double)

-- | The amount that the mouse has scrolled over the course of the entire
--   wire.
--   
--   <ul>
--   <li>Depends: now</li>
--   <li>Inhibits: never</li>
--   </ul>
mouseScrolled :: (Monoid e, MonadMouse mb m) => Wire s e m a (Double, Double)

-- | Behaves like the identity wire, and inhibits immediately after setting
--   the cursor mode. Common uses of this wire are to switch it to the
--   identity wire: <tt> cursorMode CursorMode'Disabled --&gt; mkId </tt>
--   
--   <ul>
--   <li>Inhibits: after now</li>
--   </ul>
cursorMode :: (MonadMouse mb m, Monoid e) => CursorMode -> Wire s e m a a

-- | Key typeclass. This is used to constrain the type of Monad used | to
--   provide keyboard input.
class Key a

-- | This monad describes computations that involve keyboard input.
class (Key k, Monad m) => MonadKeyboard k m | m -> k

-- | Returns true if the given key is currently pressed
keyIsPressed :: MonadKeyboard k m => k -> m (Bool)

-- | Resets the pressed state of the given key.
releaseKey :: MonadKeyboard k m => k -> m ()

-- | Behaves like the identity wire when the key is pressed and inhibits
--   otherwise
--   
--   <ul>
--   <li>Inhibits: when the key is not pressed</li>
--   </ul>
keyPressed :: (Monoid e, MonadKeyboard k m) => k -> Wire s e m a a

-- | Behaves like the identity wire when the key is not pressed and
--   inhibits otherwise
--   
--   <ul>
--   <li>Inhibits: when the key is pressed</li>
--   </ul>
keyNotPressed :: (Monoid e, MonadKeyboard k m) => k -> Wire s e m a a

-- | Ignores its input and returns <a>True</a> whenever the key is pressed,
--   <a>False</a> otherwise.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
isKeyPressed :: MonadKeyboard k m => k -> Wire s e m a Bool

-- | Behaves like the identity wire for a single instant when the key is
--   pressed and otherwise inhibits. Note that this wire causes the key to
--   be treated as released by all other wires after the instant when it is
--   pressed.
--   
--   <ul>
--   <li>Inhibits: when the key is not pressed or after it has been
--   pressed</li>
--   </ul>
keyDebounced :: (Monoid e, MonadKeyboard k m) => k -> Wire s e m a a

-- | Fires an event the instant the given key is pressed after not being
--   pressed.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
keyPressedEvent :: MonadKeyboard k m => k -> Wire s e m a (Event a)

-- | Fires an event the instant the given key is released after being
--   pressed.
--   
--   <ul>
--   <li>Inhibits: never</li>
--   </ul>
keyReleasedEvent :: MonadKeyboard k m => k -> Wire s e m a (Event a)
instance GHC.Read.Read FRP.Netwire.Input.CursorMode
instance GHC.Show.Show FRP.Netwire.Input.CursorMode
instance GHC.Classes.Eq FRP.Netwire.Input.CursorMode
instance GHC.Enum.Enum FRP.Netwire.Input.CursorMode
instance GHC.Classes.Ord FRP.Netwire.Input.CursorMode
