Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains a minimum yet convenient API needed to get started writing reflex apps with sdl2.
For an example see app/Main.hs
- host :: r -> ConcreteReflexSDL2 r () -> IO void
- type ReflexSDL2 r t m = (Reflex t, MonadHold t m, MonadSample t m, MonadAdjust t m, PostBuild t m, PerformEvent t m, MonadFix m, MonadIO m, MonadIO (Performable m), MonadReader (SystemEvents r t) m)
- data ReflexSDL2T r t m a
- type ConcreteReflexSDL2 r = ReflexSDL2T r Spider (PostBuildT Spider (PerformEventT Spider (SpiderHost Global)))
- holdView :: ReflexSDL2 r t m => m a -> Event t (m a) -> m (Dynamic t a)
- dynView :: ReflexSDL2 r t m => Dynamic t (m a) -> m (Event t a)
- getDeltaTickEvent :: ReflexSDL2 r t m => m (Event t Word32)
- performEventDelta :: ReflexSDL2 r t m => Event t a -> m (Event t Word32)
- getRecurringTimerEventWithEventCode :: ReflexSDL2 r t m => Int32 -> Int -> m (Event t ())
- getAsyncEventWithEventCode :: (ReflexSDL2 r t m, Storable a) => Int32 -> IO a -> m (Event t a)
- delayEventWithEventCode :: (ReflexSDL2 r t m, Storable a) => Int32 -> Int -> Event t a -> m (Event t a)
- userLocal :: MonadReader (SystemEvents r t) m => (r -> r) -> m a -> m a
- putDebugLnE :: (PerformEvent t m, Reflex t, MonadIO (Performable m)) => Event t a -> (a -> String) -> m ()
- getTicksEvent :: ReflexSDL2 r t m => m (Event t Word32)
- getAnySDLEvent :: ReflexSDL2 r t m => m (Event t EventPayload)
- getWindowShownEvent :: ReflexSDL2 r t m => m (Event t WindowShownEventData)
- getWindowHiddenEvent :: ReflexSDL2 r t m => m (Event t WindowHiddenEventData)
- getWindowExposedEvent :: ReflexSDL2 r t m => m (Event t WindowExposedEventData)
- getWindowMovedEvent :: ReflexSDL2 r t m => m (Event t WindowMovedEventData)
- getWindowResizedEvent :: ReflexSDL2 r t m => m (Event t WindowResizedEventData)
- getWindowSizeChangedEvent :: ReflexSDL2 r t m => m (Event t WindowSizeChangedEventData)
- getWindowMinimizedEvent :: ReflexSDL2 r t m => m (Event t WindowMinimizedEventData)
- getWindowMaximizedEvent :: ReflexSDL2 r t m => m (Event t WindowMaximizedEventData)
- getWindowRestoredEvent :: ReflexSDL2 r t m => m (Event t WindowRestoredEventData)
- getWindowGainedMouseFocusEvent :: ReflexSDL2 r t m => m (Event t WindowGainedMouseFocusEventData)
- getWindowLostMouseFocusEvent :: ReflexSDL2 r t m => m (Event t WindowLostMouseFocusEventData)
- getWindowGainedKeyboardFocusEvent :: ReflexSDL2 r t m => m (Event t WindowGainedKeyboardFocusEventData)
- getWindowLostKeyboardFocusEvent :: ReflexSDL2 r t m => m (Event t WindowLostKeyboardFocusEventData)
- getWindowClosedEvent :: ReflexSDL2 r t m => m (Event t WindowClosedEventData)
- getKeyboardEvent :: ReflexSDL2 r t m => m (Event t KeyboardEventData)
- getTextEditingEvent :: ReflexSDL2 r t m => m (Event t TextEditingEventData)
- getTextInputEvent :: ReflexSDL2 r t m => m (Event t TextInputEventData)
- getKeymapChangedEvent :: ReflexSDL2 r t m => m (Event t ())
- getMouseMotionEvent :: ReflexSDL2 r t m => m (Event t MouseMotionEventData)
- getMouseButtonEvent :: ReflexSDL2 r t m => m (Event t MouseButtonEventData)
- getMouseWheelEvent :: ReflexSDL2 r t m => m (Event t MouseWheelEventData)
- getJoyAxisEvent :: ReflexSDL2 r t m => m (Event t JoyAxisEventData)
- getJoyBallEvent :: ReflexSDL2 r t m => m (Event t JoyBallEventData)
- getJoyHatEvent :: ReflexSDL2 r t m => m (Event t JoyHatEventData)
- getJoyButtonEvent :: ReflexSDL2 r t m => m (Event t JoyButtonEventData)
- getJoyDeviceEvent :: ReflexSDL2 r t m => m (Event t JoyDeviceEventData)
- getControllerAxisEvent :: ReflexSDL2 r t m => m (Event t ControllerAxisEventData)
- getControllerButtonEvent :: ReflexSDL2 r t m => m (Event t ControllerButtonEventData)
- getControllerDeviceEvent :: ReflexSDL2 r t m => m (Event t ControllerDeviceEventData)
- getAudioDeviceEvent :: ReflexSDL2 r t m => m (Event t AudioDeviceEventData)
- getQuitEvent :: ReflexSDL2 r t m => m (Event t ())
- getUserEvent :: ReflexSDL2 r t m => m (Event t UserEventData)
- getSysWMEvent :: ReflexSDL2 r t m => m (Event t SysWMEventData)
- getTouchFingerEvent :: ReflexSDL2 r t m => m (Event t TouchFingerEventData)
- getMultiGestureEvent :: ReflexSDL2 r t m => m (Event t MultiGestureEventData)
- getDollarGestureEvent :: ReflexSDL2 r t m => m (Event t DollarGestureEventData)
- getDropEvent :: ReflexSDL2 r t m => m (Event t DropEventData)
- getClipboardUpdateEvent :: ReflexSDL2 r t m => m (Event t ())
- getUnknownEvent :: ReflexSDL2 r t m => m (Event t UnknownEventData)
- getUserData :: ReflexSDL2 r t m => m r
- module Reflex
- module SDL
- class Monad m => MonadIO m where
- liftIO :: MonadIO m => forall a. IO a -> m a
Running an app
:: r | A user data value of type |
-> ConcreteReflexSDL2 r () | A concrete reflex-sdl2 network to run. |
-> IO void |
Host a reflex-sdl2 app. This function is your application's main loop and will not terminate.
The reflex-sdl2 base type and constraints
type ReflexSDL2 r t m = (Reflex t, MonadHold t m, MonadSample t m, MonadAdjust t m, PostBuild t m, PerformEvent t m, MonadFix m, MonadIO m, MonadIO (Performable m), MonadReader (SystemEvents r t) m) Source #
A collection of constraints that represent the default reflex-sdl2 network.
data ReflexSDL2T r t m a Source #
Provides a basic implementation of ReflexSDL2
constraints.
type ConcreteReflexSDL2 r = ReflexSDL2T r Spider (PostBuildT Spider (PerformEventT Spider (SpiderHost Global))) Source #
The concrete/specialized type used to run reflex-sdl2 apps.
Higher order switching
Time delta events
getDeltaTickEvent :: ReflexSDL2 r t m => m (Event t Word32) Source #
Returns an event that fires each frame with the number of milliseconds
since the last frame.
Be aware that subscribing to this Event
(by using it in a monadic action)
will result in your app running sdl2's event loop every frame.
performEventDelta :: ReflexSDL2 r t m => Event t a -> m (Event t Word32) Source #
Populate the event value with the time in milliseconds since the last time the event fired.
*WithEventCode events
The *WithEventCode flavor of events use sdl2's user events system. Each
function evaluates on the current thread, returning an Event
that will fire
on the main thread and can be used to drive GL updates. It uses sdl2's
user event machinery, requiring a special single use event code to identify
the event on the other side of sdl2's FFI. This is a great use case for a
Fresh
effect in your app.
getRecurringTimerEventWithEventCode Source #
:: ReflexSDL2 r t m | |
=> Int32 | Single use event code. |
-> Int | Number of milliseconds. |
-> m (Event t ()) |
Retrieves an event that fires every n
milliseconds.
getAsyncEventWithEventCode :: (ReflexSDL2 r t m, Storable a) => Int32 -> IO a -> m (Event t a) Source #
Executes the given IO action in a separate thread asynchronously and
returns an Event
that fires on the main thread with the result value
of that action. This uses sdl2's user events system, which requires that
the action result have an instance of Storable
.
Your a
type gets marshalled to C FFI and back, hence the
Storable
requirement.
delayEventWithEventCode :: (ReflexSDL2 r t m, Storable a) => Int32 -> Int -> Event t a -> m (Event t a) Source #
Delays the given event by the given number of milliseconds.
User data
userLocal :: MonadReader (SystemEvents r t) m => (r -> r) -> m a -> m a Source #
Run a (
computation with a modified
Reader
SystemEvents
r t)sysUserData
r
.
Debugging
:: (PerformEvent t m, Reflex t, MonadIO (Performable m)) | |
=> Event t a | The |
-> (a -> String) | A function to show the |
-> m () |
SDL2 events
getTicksEvent :: ReflexSDL2 r t m => m (Event t Word32) Source #
getAnySDLEvent :: ReflexSDL2 r t m => m (Event t EventPayload) Source #
getWindowShownEvent :: ReflexSDL2 r t m => m (Event t WindowShownEventData) Source #
getWindowHiddenEvent :: ReflexSDL2 r t m => m (Event t WindowHiddenEventData) Source #
getWindowExposedEvent :: ReflexSDL2 r t m => m (Event t WindowExposedEventData) Source #
getWindowMovedEvent :: ReflexSDL2 r t m => m (Event t WindowMovedEventData) Source #
getWindowResizedEvent :: ReflexSDL2 r t m => m (Event t WindowResizedEventData) Source #
getWindowSizeChangedEvent :: ReflexSDL2 r t m => m (Event t WindowSizeChangedEventData) Source #
getWindowMinimizedEvent :: ReflexSDL2 r t m => m (Event t WindowMinimizedEventData) Source #
getWindowMaximizedEvent :: ReflexSDL2 r t m => m (Event t WindowMaximizedEventData) Source #
getWindowRestoredEvent :: ReflexSDL2 r t m => m (Event t WindowRestoredEventData) Source #
getWindowGainedMouseFocusEvent :: ReflexSDL2 r t m => m (Event t WindowGainedMouseFocusEventData) Source #
getWindowLostMouseFocusEvent :: ReflexSDL2 r t m => m (Event t WindowLostMouseFocusEventData) Source #
getWindowGainedKeyboardFocusEvent :: ReflexSDL2 r t m => m (Event t WindowGainedKeyboardFocusEventData) Source #
getWindowLostKeyboardFocusEvent :: ReflexSDL2 r t m => m (Event t WindowLostKeyboardFocusEventData) Source #
getWindowClosedEvent :: ReflexSDL2 r t m => m (Event t WindowClosedEventData) Source #
getKeyboardEvent :: ReflexSDL2 r t m => m (Event t KeyboardEventData) Source #
getTextEditingEvent :: ReflexSDL2 r t m => m (Event t TextEditingEventData) Source #
getTextInputEvent :: ReflexSDL2 r t m => m (Event t TextInputEventData) Source #
getKeymapChangedEvent :: ReflexSDL2 r t m => m (Event t ()) Source #
getMouseMotionEvent :: ReflexSDL2 r t m => m (Event t MouseMotionEventData) Source #
getMouseButtonEvent :: ReflexSDL2 r t m => m (Event t MouseButtonEventData) Source #
getMouseWheelEvent :: ReflexSDL2 r t m => m (Event t MouseWheelEventData) Source #
getJoyAxisEvent :: ReflexSDL2 r t m => m (Event t JoyAxisEventData) Source #
getJoyBallEvent :: ReflexSDL2 r t m => m (Event t JoyBallEventData) Source #
getJoyHatEvent :: ReflexSDL2 r t m => m (Event t JoyHatEventData) Source #
getJoyButtonEvent :: ReflexSDL2 r t m => m (Event t JoyButtonEventData) Source #
getJoyDeviceEvent :: ReflexSDL2 r t m => m (Event t JoyDeviceEventData) Source #
getControllerAxisEvent :: ReflexSDL2 r t m => m (Event t ControllerAxisEventData) Source #
getControllerButtonEvent :: ReflexSDL2 r t m => m (Event t ControllerButtonEventData) Source #
getControllerDeviceEvent :: ReflexSDL2 r t m => m (Event t ControllerDeviceEventData) Source #
getAudioDeviceEvent :: ReflexSDL2 r t m => m (Event t AudioDeviceEventData) Source #
getQuitEvent :: ReflexSDL2 r t m => m (Event t ()) Source #
getUserEvent :: ReflexSDL2 r t m => m (Event t UserEventData) Source #
getSysWMEvent :: ReflexSDL2 r t m => m (Event t SysWMEventData) Source #
getTouchFingerEvent :: ReflexSDL2 r t m => m (Event t TouchFingerEventData) Source #
getMultiGestureEvent :: ReflexSDL2 r t m => m (Event t MultiGestureEventData) Source #
getDollarGestureEvent :: ReflexSDL2 r t m => m (Event t DollarGestureEventData) Source #
getDropEvent :: ReflexSDL2 r t m => m (Event t DropEventData) Source #
getClipboardUpdateEvent :: ReflexSDL2 r t m => m (Event t ()) Source #
getUnknownEvent :: ReflexSDL2 r t m => m (Event t UnknownEventData) Source #
getUserData :: ReflexSDL2 r t m => m r Source #
Re-exports
module Reflex
module SDL
class Monad m => MonadIO m where #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads: