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
- keyStatusM :: Key -> m (Maybe (KeyState, ModifierKeys))
- mouseButtonM :: MouseButton -> m (Maybe (MouseButtonState, ModifierKeys))
- mousePosM :: m (Double, Double)
- mouseScrollM :: m [(Double, Double)]
- windowSizeM :: m (Maybe (Double, Double))
- windowClosingM :: m Bool
- setCurrentWindowM :: Maybe Window -> m ()
- getCurrentWindowM :: m (Maybe Window)
- setBufferSizeM :: Int -> m ()
- 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) = GLFWState s Source |
class Monad m => MonadGLFW m where Source
Module low-level API
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
mouseDelta :: MonadGLFW m => GameWire m a (Double, Double) Source
Returns mouse delta moves
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
mouseScroll :: MonadGLFW m => GameWire m a (Event (Double, Double)) Source
Fires when user scrolls
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 Key :: *
Enum Key | |
Eq Key | |
Data Key | |
Ord Key | |
Read Key | |
Show Key | |
Generic Key | |
type Rep Key = D1 D1Key ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) (C1 C1_0Key U1) ((:+:) (C1 C1_1Key U1) (C1 C1_2Key U1))) ((:+:) ((:+:) (C1 C1_3Key U1) (C1 C1_4Key U1)) ((:+:) (C1 C1_5Key U1) (C1 C1_6Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_7Key U1) (C1 C1_8Key U1)) ((:+:) (C1 C1_9Key U1) (C1 C1_10Key U1))) ((:+:) ((:+:) (C1 C1_11Key U1) (C1 C1_12Key U1)) ((:+:) (C1 C1_13Key U1) (C1 C1_14Key U1))))) ((:+:) ((:+:) ((:+:) (C1 C1_15Key U1) ((:+:) (C1 C1_16Key U1) (C1 C1_17Key U1))) ((:+:) ((:+:) (C1 C1_18Key U1) (C1 C1_19Key U1)) ((:+:) (C1 C1_20Key U1) (C1 C1_21Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_22Key U1) (C1 C1_23Key U1)) ((:+:) (C1 C1_24Key U1) (C1 C1_25Key U1))) ((:+:) ((:+:) (C1 C1_26Key U1) (C1 C1_27Key U1)) ((:+:) (C1 C1_28Key U1) (C1 C1_29Key U1)))))) ((:+:) ((:+:) ((:+:) ((:+:) (C1 C1_30Key U1) ((:+:) (C1 C1_31Key U1) (C1 C1_32Key U1))) ((:+:) ((:+:) (C1 C1_33Key U1) (C1 C1_34Key U1)) ((:+:) (C1 C1_35Key U1) (C1 C1_36Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_37Key U1) (C1 C1_38Key U1)) ((:+:) (C1 C1_39Key U1) (C1 C1_40Key U1))) ((:+:) ((:+:) (C1 C1_41Key U1) (C1 C1_42Key U1)) ((:+:) (C1 C1_43Key U1) (C1 C1_44Key U1))))) ((:+:) ((:+:) ((:+:) (C1 C1_45Key U1) ((:+:) (C1 C1_46Key U1) (C1 C1_47Key U1))) ((:+:) ((:+:) (C1 C1_48Key U1) (C1 C1_49Key U1)) ((:+:) (C1 C1_50Key U1) (C1 C1_51Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_52Key U1) (C1 C1_53Key U1)) ((:+:) (C1 C1_54Key U1) (C1 C1_55Key U1))) ((:+:) ((:+:) (C1 C1_56Key U1) (C1 C1_57Key U1)) ((:+:) (C1 C1_58Key U1) (C1 C1_59Key U1))))))) ((:+:) ((:+:) ((:+:) ((:+:) ((:+:) (C1 C1_60Key U1) ((:+:) (C1 C1_61Key U1) (C1 C1_62Key U1))) ((:+:) ((:+:) (C1 C1_63Key U1) (C1 C1_64Key U1)) ((:+:) (C1 C1_65Key U1) (C1 C1_66Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_67Key U1) (C1 C1_68Key U1)) ((:+:) (C1 C1_69Key U1) (C1 C1_70Key U1))) ((:+:) ((:+:) (C1 C1_71Key U1) (C1 C1_72Key U1)) ((:+:) (C1 C1_73Key U1) (C1 C1_74Key U1))))) ((:+:) ((:+:) ((:+:) (C1 C1_75Key U1) ((:+:) (C1 C1_76Key U1) (C1 C1_77Key U1))) ((:+:) ((:+:) (C1 C1_78Key U1) (C1 C1_79Key U1)) ((:+:) (C1 C1_80Key U1) (C1 C1_81Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_82Key U1) (C1 C1_83Key U1)) ((:+:) (C1 C1_84Key U1) (C1 C1_85Key U1))) ((:+:) ((:+:) (C1 C1_86Key U1) (C1 C1_87Key U1)) ((:+:) (C1 C1_88Key U1) (C1 C1_89Key U1)))))) ((:+:) ((:+:) ((:+:) ((:+:) (C1 C1_90Key U1) ((:+:) (C1 C1_91Key U1) (C1 C1_92Key U1))) ((:+:) ((:+:) (C1 C1_93Key U1) (C1 C1_94Key U1)) ((:+:) (C1 C1_95Key U1) (C1 C1_96Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_97Key U1) (C1 C1_98Key U1)) ((:+:) (C1 C1_99Key U1) (C1 C1_100Key U1))) ((:+:) ((:+:) (C1 C1_101Key U1) (C1 C1_102Key U1)) ((:+:) (C1 C1_103Key U1) (C1 C1_104Key U1))))) ((:+:) ((:+:) ((:+:) ((:+:) (C1 C1_105Key U1) (C1 C1_106Key U1)) ((:+:) (C1 C1_107Key U1) (C1 C1_108Key U1))) ((:+:) ((:+:) (C1 C1_109Key U1) (C1 C1_110Key U1)) ((:+:) (C1 C1_111Key U1) (C1 C1_112Key U1)))) ((:+:) ((:+:) ((:+:) (C1 C1_113Key U1) (C1 C1_114Key U1)) ((:+:) (C1 C1_115Key U1) (C1 C1_116Key U1))) ((:+:) ((:+:) (C1 C1_117Key U1) (C1 C1_118Key U1)) ((:+:) (C1 C1_119Key U1) (C1 C1_120Key U1)))))))) |
data KeyState :: *
data MouseButton :: *
MouseButton'1 | |
MouseButton'2 | |
MouseButton'3 | |
MouseButton'4 | |
MouseButton'5 | |
MouseButton'6 | |
MouseButton'7 | |
MouseButton'8 |
Enum MouseButton | |
Eq MouseButton | |
Data MouseButton | |
Ord MouseButton | |
Read MouseButton | |
Show MouseButton | |
Generic MouseButton | |
type Rep MouseButton = D1 D1MouseButton ((:+:) ((:+:) ((:+:) (C1 C1_0MouseButton U1) (C1 C1_1MouseButton U1)) ((:+:) (C1 C1_2MouseButton U1) (C1 C1_3MouseButton U1))) ((:+:) ((:+:) (C1 C1_4MouseButton U1) (C1 C1_5MouseButton U1)) ((:+:) (C1 C1_6MouseButton U1) (C1 C1_7MouseButton U1)))) |
data MouseButtonState :: *
Enum MouseButtonState | |
Eq MouseButtonState | |
Data MouseButtonState | |
Ord MouseButtonState | |
Read MouseButtonState | |
Show MouseButtonState | |
Generic MouseButtonState | |
type Rep MouseButtonState = D1 D1MouseButtonState ((:+:) (C1 C1_0MouseButtonState U1) (C1 C1_1MouseButtonState U1)) |
data ModifierKeys :: *
Eq ModifierKeys | |
Data ModifierKeys | |
Ord ModifierKeys | |
Read ModifierKeys | |
Show ModifierKeys | |
Generic ModifierKeys | |
type Rep ModifierKeys = D1 D1ModifierKeys (C1 C1_0ModifierKeys ((:*:) ((:*:) (S1 S1_0_0ModifierKeys (Rec0 Bool)) (S1 S1_0_1ModifierKeys (Rec0 Bool))) ((:*:) (S1 S1_0_2ModifierKeys (Rec0 Bool)) (S1 S1_0_3ModifierKeys (Rec0 Bool))))) |