Copyright | (c) Anton Gushcha, 2015-2016 |
---|---|
License | BSD3 |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The core module contains API for GLFW library integration. The module doesn't depends on others core modules and could be place in any place in game monad stack.
The module is NOT pure within first phase (see ModuleStack
docs), therefore currently only IO
end monad can handler the module.
Example of embedding:
-- | Application monad is monad stack build from given list of modules over base monad (IO) type AppStack = ModuleStack [GLFWT, ... other modules ... ] IO newtype AppState = AppState (ModuleState AppStack) deriving (Generic) instance NFData AppState -- | Wrapper around type family newtype AppMonad a = AppMonad (AppStack a) deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadThrow, MonadCatch, MonadGLFW, ... other modules monads ... ) instance GameModule AppMonad AppState where type ModuleState AppMonad = AppState runModule (AppMonad m) (AppState s) = do (a, s') <- runModule m s return (a, AppState s') newModuleState = AppState $ newModuleState withModule _ = withModule (Proxy :: Proxy AppStack) cleanupModule (AppState s) = cleanupModule s -- | Arrow that is build over the monad stack type AppWire a b = GameWire AppMonad a b -- | Action that makes indexed app wire type AppActor i a b = GameActor AppMonad i a b
- data GLFWState s
- data GLFWT s m a
- class Monad m => MonadGLFW m where
- keyStatus :: MonadGLFW m => Key -> GameWire m a (Event (KeyState, ModifierKeys))
- keyStatusDyn :: MonadGLFW m => GameWire m Key (Event (KeyState, ModifierKeys))
- keyPressed :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys)
- keyPressedDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys)
- keyReleased :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys)
- keyReleasedDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys)
- keyRepeating :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys)
- keyRepeatingDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys)
- keyPressing :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys)
- keyPressingDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys)
- mouseButton :: MonadGLFW m => MouseButton -> GameWire m a (Event (MouseButtonState, ModifierKeys))
- mouseButtonDyn :: MonadGLFW m => GameWire m MouseButton (Event (MouseButtonState, ModifierKeys))
- mouseButtonPressed :: MonadGLFW m => MouseButton -> GameWire m a (Event ModifierKeys)
- mouseButtonPressedDyn :: MonadGLFW m => GameWire m MouseButton (Event ModifierKeys)
- mouseButtonReleased :: MonadGLFW m => MouseButton -> GameWire m a (Event ModifierKeys)
- mouseButtonReleasedDyn :: MonadGLFW m => GameWire m MouseButton (Event ModifierKeys)
- mousePosition :: MonadGLFW m => GameWire m a (Double, Double)
- mousePositionChange :: MonadGLFW m => GameWire m a (Event (Double, Double))
- mouseXChange :: MonadGLFW m => GameWire m a (Event Double)
- mouseYChange :: MonadGLFW m => GameWire m a (Event Double)
- mouseDelta :: MonadGLFW m => GameWire m a (Double, Double)
- mouseDeltaChange :: MonadGLFW m => GameWire m a (Event (Double, Double))
- mouseDeltaXChange :: MonadGLFW m => GameWire m a (Event Double)
- mouseDeltaYChange :: MonadGLFW m => GameWire m a (Event Double)
- mouseScroll :: MonadGLFW m => GameWire m a (Event (Double, Double))
- mouseScrollX :: MonadGLFW m => GameWire m a (Event Double)
- mouseScrollY :: MonadGLFW m => GameWire m a (Event Double)
- windowSize :: MonadGLFW m => GameWire m a (Event (Double, Double))
- windowClosing :: MonadGLFW m => GameWire m a (Event ())
- data Key :: *
- = Key'Unknown
- | Key'Space
- | Key'Apostrophe
- | Key'Comma
- | Key'Minus
- | Key'Period
- | Key'Slash
- | Key'0
- | Key'1
- | Key'2
- | Key'3
- | Key'4
- | Key'5
- | Key'6
- | Key'7
- | Key'8
- | Key'9
- | Key'Semicolon
- | Key'Equal
- | Key'A
- | Key'B
- | Key'C
- | Key'D
- | Key'E
- | Key'F
- | Key'G
- | Key'H
- | Key'I
- | Key'J
- | Key'K
- | Key'L
- | Key'M
- | Key'N
- | Key'O
- | Key'P
- | Key'Q
- | Key'R
- | Key'S
- | Key'T
- | Key'U
- | Key'V
- | Key'W
- | Key'X
- | Key'Y
- | Key'Z
- | Key'LeftBracket
- | Key'Backslash
- | Key'RightBracket
- | Key'GraveAccent
- | Key'World1
- | Key'World2
- | Key'Escape
- | Key'Enter
- | Key'Tab
- | Key'Backspace
- | Key'Insert
- | Key'Delete
- | Key'Right
- | Key'Left
- | Key'Down
- | Key'Up
- | Key'PageUp
- | Key'PageDown
- | Key'Home
- | Key'End
- | Key'CapsLock
- | Key'ScrollLock
- | Key'NumLock
- | Key'PrintScreen
- | Key'Pause
- | Key'F1
- | Key'F2
- | Key'F3
- | Key'F4
- | Key'F5
- | Key'F6
- | Key'F7
- | Key'F8
- | Key'F9
- | Key'F10
- | Key'F11
- | Key'F12
- | Key'F13
- | Key'F14
- | Key'F15
- | Key'F16
- | Key'F17
- | Key'F18
- | Key'F19
- | Key'F20
- | Key'F21
- | Key'F22
- | Key'F23
- | Key'F24
- | Key'F25
- | Key'Pad0
- | Key'Pad1
- | Key'Pad2
- | Key'Pad3
- | Key'Pad4
- | Key'Pad5
- | Key'Pad6
- | Key'Pad7
- | Key'Pad8
- | Key'Pad9
- | Key'PadDecimal
- | Key'PadDivide
- | Key'PadMultiply
- | Key'PadSubtract
- | Key'PadAdd
- | Key'PadEnter
- | Key'PadEqual
- | Key'LeftShift
- | Key'LeftControl
- | Key'LeftAlt
- | Key'LeftSuper
- | Key'RightShift
- | Key'RightControl
- | Key'RightAlt
- | Key'RightSuper
- | Key'Menu
- data KeyState :: *
- data MouseButton :: *
- data MouseButtonState :: *
- data ModifierKeys :: * = ModifierKeys {}
Low-level API
Module inner state
s
- - State of next module, the states are chained via nesting.
Monad transformer that handles GLFW specific API
s
- - State of next core module in modules chain;
m
- - Next monad in modules monad stack;
a
- - Type of result value;
How to embed module:
type AppStack = ModuleStack [GLFWT, ... other modules ... ] IO newtype AppMonad a = AppMonad (AppStack a) deriving (Functor, Applicative, Monad, MonadFix, MonadIO, MonadThrow, MonadCatch, MonadSDL)
The module is NOT pure within first phase (see ModuleStack
docs), therefore currently only IO
end monad can handler the module.
MonadTrans (GLFWT s) Source # | |
Monad m => MonadState (GLFWState s) (GLFWT s m) Source # | |
Monad m => Monad (GLFWT s m) Source # | |
Functor m => Functor (GLFWT s m) Source # | |
MonadFix m => MonadFix (GLFWT s m) Source # | |
Monad m => Applicative (GLFWT s m) Source # | |
MonadIO m => MonadIO (GLFWT s m) Source # | |
MonadThrow m => MonadThrow (GLFWT s m) Source # | |
MonadMask m => MonadMask (GLFWT s m) Source # | |
MonadCatch m => MonadCatch (GLFWT s m) Source # | |
Monad m => MonadGLFW (GLFWT s m) Source # | |
type ModuleState (GLFWT s m) Source # | |
class Monad m => MonadGLFW m where Source #
Module low-level API
keyStatusM, mouseButtonM, mousePosM, mouseScrollM, windowSizeM, windowClosingM, setCurrentWindowM, getCurrentWindowM, setBufferSizeM
keyStatusM :: Key -> m (Maybe (KeyState, ModifierKeys)) Source #
Returns state of given keyboard's key
mouseButtonM :: MouseButton -> m (Maybe (MouseButtonState, ModifierKeys)) Source #
Returns state of given mouse button
mousePosM :: m (Double, Double) Source #
Returns current position of mouse cursor
mouseScrollM :: m [(Double, Double)] Source #
Returns current scroll values of mouse
windowSizeM :: m (Maybe (Double, Double)) Source #
Returns current size of window
windowClosingM :: m Bool Source #
Returns True when close button is pushed
setCurrentWindowM :: Maybe Window -> m () Source #
Setups current window for input catch
getCurrentWindowM :: m (Maybe Window) Source #
Returns current window
setBufferSizeM :: Int -> m () Source #
Setup maximum size of inner buffers for keys, mouse buttons
Arrow API
Keyboard API
keyStatus :: MonadGLFW m => Key -> GameWire m a (Event (KeyState, ModifierKeys)) Source #
Produces event when key state changes
keyStatusDyn :: MonadGLFW m => GameWire m Key (Event (KeyState, ModifierKeys)) Source #
Produces event when key state changes, get key as arrow argument
keyPressed :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys) Source #
Fires when keyboard key is pressed
keyPressedDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys) Source #
Version of keyPressed that takes key at runtime
keyReleased :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys) Source #
Fires when keyboard key is released
keyReleasedDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys) Source #
Version of keyReleased that takes key at runtime
keyRepeating :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys) Source #
Fires when keyboard key is entered into repeating mode
keyRepeatingDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys) Source #
Version of keyRepeating that takes key at runtime
keyPressing :: MonadGLFW m => Key -> GameWire m a (Event ModifierKeys) Source #
Fires event from moment of press until release of given key
keyPressingDyn :: MonadGLFW m => GameWire m Key (Event ModifierKeys) Source #
Version of keyPressing that takes key at runtime
Mouse buttons API
mouseButton :: MonadGLFW m => MouseButton -> GameWire m a (Event (MouseButtonState, ModifierKeys)) Source #
Produces event when mouse button state changes
mouseButtonDyn :: MonadGLFW m => GameWire m MouseButton (Event (MouseButtonState, ModifierKeys)) Source #
Produces event when key state changes, get key as arrow argument
mouseButtonPressed :: MonadGLFW m => MouseButton -> GameWire m a (Event ModifierKeys) Source #
Fires when mouse button is pressed
mouseButtonPressedDyn :: MonadGLFW m => GameWire m MouseButton (Event ModifierKeys) Source #
Version of mouseButtonPressed that takes button at runtime
mouseButtonReleased :: MonadGLFW m => MouseButton -> GameWire m a (Event ModifierKeys) Source #
Fires when mouse button is released
mouseButtonReleasedDyn :: MonadGLFW m => GameWire m MouseButton (Event ModifierKeys) Source #
Version of mouseButtonReleased that takes button at runtime
Cursor position
mousePosition :: MonadGLFW m => GameWire m a (Double, Double) Source #
Returns current position of mouse
mousePositionChange :: MonadGLFW m => GameWire m a (Event (Double, Double)) Source #
Fires event when mouse position changes
mouseXChange :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires event when mouse X axis changes
mouseYChange :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires event when mouse Y axis changes
mouseDeltaChange :: MonadGLFW m => GameWire m a (Event (Double, Double)) Source #
Fires when mouse moves, holds delta move
mouseDeltaXChange :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires when mouse X axis changes, holds delta move
mouseDeltaYChange :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires when mouse Y axis changes, holds delta move
Mouse scroll
mouseScrollX :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires when user scrolls X axis
mouseScrollY :: MonadGLFW m => GameWire m a (Event Double) Source #
Fires when user scrolls Y axis
Window API
windowSize :: MonadGLFW m => GameWire m a (Event (Double, Double)) Source #
Fires when windows size is changed
windowClosing :: MonadGLFW m => GameWire m a (Event ()) Source #
Fires when user hits close button of window
Reexports
data MouseButton :: * #
data MouseButtonState :: * #